1 /*****************************************************************************
4 * Set of definition for service routines
8 * $Id: Gapil.h,v 1.1 2002/12/03 11:06:05 piccardi Exp $
10 *****************************************************************************/
11 #include <sys/sem.h> /* IPC semaphore declarations */
12 #include <sys/shm.h> /* IPC shared memory declarations */
13 #include <sys/types.h>
15 #include <unistd.h> /* unix standard functions */
16 #include <fcntl.h> /* file control (lock) functions */
17 #include <signal.h> /* signal handling declarations */
19 * Definition of semun struct; used to implement a MutexXXXX API To
20 * create a Mutex use an underlaying semaphore and init it; we put
21 * here all the needed data structures
23 /* use this definition, get from the man pages */
24 #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
25 /* union semun is defined by including <sys/sem.h> */
27 /* according to X/OPEN we have to define it ourselves */
29 int val; /* value for SETVAL */
30 struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
31 unsigned short int *array; /* array for GETALL, SETALL */
32 struct seminfo *__buf; /* buffer for IPC_INFO */
36 * Mutex handling Functions
38 /* Function MutexCreate: create a mutex. See Mutex.c */
39 inline int MutexCreate(key_t ipc_key);
40 /* Function MutexFind: get the mutex ID given fomr IPC key. See Mutex.c */
41 inline int MutexFind(key_t ipc_key);
42 /* Function MutexRead: read the current value of the mutex. See Mutex.c */
43 inline int MutexRead(int sem_id);
44 /* Function MutexLock: to lock a mutex/semaphore. See Mutex.c */
45 inline int MutexLock(int sem_id);
46 /* Function MutexUnlock: to unlock a mutex/semaphore. See Mutex.c */
47 inline int MutexUnlock(int sem_id);
49 /* Function LockFile: create a lock file. See FileLock.c*/
50 inline int LockFile(const char* path_name);
51 /* Function UnLockFile: remove a lock file. See FileLock.c*/
52 inline int UnlockFile(const char* path_name);
54 * Signal Handling Functions
56 typedef void SigFunc(int);
57 /* Function Signal: Initialize a signal handler. See SigHand.c */
58 SigFunc * Signal(int signo, SigFunc *func);
59 /* Function HandSigCHLD: to handle SIGCHILD. See SigHand.c */
60 void HandSigCHLD(int sig);
62 * Socket service functions
64 /* Function SockRead: to read from a socket. See SockRead.c */
65 ssize_t SockRead(int fd, void *buf, size_t count);
66 /* Function SockWrite: to read from a socket. See SockWrite.c */
67 ssize_t SockWrite(int fd, const void *buf, size_t count);