--- libaitsess/inc/aitsess.h 2008/08/28 13:18:30 1.1 +++ libaitsess/inc/aitsess.h 2011/04/30 21:35:21 1.2 @@ -1,3 +1,11 @@ +/************************************************************************* +* (C) 2008 AITNET ltd - Sofia/Bulgaria - +* by Michael Pounov +* +* $Author: misho $ +* $Id: aitsess.h,v 1.2 2011/04/30 21:35:21 misho Exp $ +* +*************************************************************************/ #ifndef __AITSESS_H #define __AITSESS_H @@ -118,6 +126,14 @@ inline void *ipc_attachSession(tagSess * __restrict s, inline void ipc_detachSession(tagSess * __restrict s); /* + * isAttached() Check for mapped/(attached) shared memory + * @s = Session item + * return: -1 null session item, 0 not attached, 1 attached memory +*/ +inline int isAttached(tagSess * __restrict s); + + +/* * map_notSemaphore() MMAP negative block if semaphore isn`t signaled * @s = Session item */ @@ -165,13 +181,14 @@ inline int ipc_addSemaphore(tagSess * __restrict s); */ inline int ipc_decSemaphore(tagSess * __restrict s); + // --------------------------------------------------------- // // Lazy macros for lazy programmers :-) by Michael Pounov; Optimizing work with sessions! // #define DESTROY_SESSION(fname, s) do { \ - switch ((s)->type) { \ + switch (((*s))->type) { \ case SHARED_IPC: \ ipc_destroySession((fname), (s)); \ break; \ @@ -181,13 +198,13 @@ inline int ipc_decSemaphore(tagSess * __restrict s); } \ } while(0) -#define ATTACH_MEMORY(s, shared) do { \ +#define ATTACH_MEMORY(s) do { \ switch ((s)->type) { \ case SHARED_IPC: \ - (shared) = ipc_attachSession((s), 0); \ + ipc_attachSession((s), 0); \ break; \ case SHARED_MAP: \ - (shared) = map_attachSession((s), 0); \ + map_attachSession((s), 0); \ break; \ } \ } while(0) @@ -255,6 +272,19 @@ inline int ipc_decSemaphore(tagSess * __restrict s); // --------------------------------------------------------- +/* + * sess_FreeValues() Free all values from value array allocated from sess_GetValues() + * @ppsVals = Array strings + * return: none +*/ +inline void sess_FreeValues(char *** __restrict ppsVals); +/* + * sess_GetValues() Get all values from session shared memory + * @s = Session item + * @ppsVals = Return array strings + * return: -1 error: in parameter, !=-1 count of returned strings in ppsVals (must be free after use!) +*/ +int sess_GetValues(tagSess * __restrict s, char ***ppsVals); /* * sess_GetValue() Get value from session shared memory from attribute * @s = Session item