X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FGapil.h;fp=sources%2FGapil.h;h=00dc3a67f6d62523b23351ca27e6eba807cc82c5;hp=0000000000000000000000000000000000000000;hb=6483a787322c614bc6282a0bf0ee001f1bf54b44;hpb=78a82bdb333ca71e395ba39a5c03745761341150 diff --git a/sources/Gapil.h b/sources/Gapil.h new file mode 100644 index 0000000..00dc3a6 --- /dev/null +++ b/sources/Gapil.h @@ -0,0 +1,67 @@ +/***************************************************************************** + * + * File Gapil.h: + * Set of definition for service routines + * + * Author: S. Piccardi + * + * $Id: Gapil.h,v 1.1 2002/12/03 11:06:05 piccardi Exp $ + * + *****************************************************************************/ +#include /* IPC semaphore declarations */ +#include /* IPC shared memory declarations */ +#include +#include +#include /* unix standard functions */ +#include /* file control (lock) functions */ +#include /* signal handling declarations */ +/* + * Definition of semun struct; used to implement a MutexXXXX API To + * create a Mutex use an underlaying semaphore and init it; we put + * here all the needed data structures + */ +/* use this definition, get from the man pages */ +#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) +/* union semun is defined by including */ +#else +/* according to X/OPEN we have to define it ourselves */ +union semun { + int val; /* value for SETVAL */ + struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ + unsigned short int *array; /* array for GETALL, SETALL */ + struct seminfo *__buf; /* buffer for IPC_INFO */ +}; +#endif +/* + * Mutex handling Functions + */ +/* Function MutexCreate: create a mutex. See Mutex.c */ +inline int MutexCreate(key_t ipc_key); +/* Function MutexFind: get the mutex ID given fomr IPC key. See Mutex.c */ +inline int MutexFind(key_t ipc_key); +/* Function MutexRead: read the current value of the mutex. See Mutex.c */ +inline int MutexRead(int sem_id); +/* Function MutexLock: to lock a mutex/semaphore. See Mutex.c */ +inline int MutexLock(int sem_id); +/* Function MutexUnlock: to unlock a mutex/semaphore. See Mutex.c */ +inline int MutexUnlock(int sem_id); + +/* Function LockFile: create a lock file. See FileLock.c*/ +inline int LockFile(const char* path_name); +/* Function UnLockFile: remove a lock file. See FileLock.c*/ +inline int UnlockFile(const char* path_name); +/* + * Signal Handling Functions + */ +typedef void SigFunc(int); +/* Function Signal: Initialize a signal handler. See SigHand.c */ +SigFunc * Signal(int signo, SigFunc *func); +/* Function HandSigCHLD: to handle SIGCHILD. See SigHand.c */ +void HandSigCHLD(int sig); +/* + * Socket service functions + */ +/* Function SockRead: to read from a socket. See SockRead.c */ +ssize_t SockRead(int fd, void *buf, size_t count); +/* Function SockWrite: to read from a socket. See SockWrite.c */ +ssize_t SockWrite(int fd, const void *buf, size_t count);