Revisione completa (e relativa razionalizzazione) dei sorgenti degli esempi.
[gapil.git] / sources / Gapil.h
diff --git a/sources/Gapil.h b/sources/Gapil.h
new file mode 100644 (file)
index 0000000..00dc3a6
--- /dev/null
@@ -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 <sys/sem.h>                           /* IPC semaphore declarations */
+#include <sys/shm.h>                       /* IPC shared memory declarations */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>                               /* unix standard functions */
+#include <fcntl.h>                          /* file control (lock) functions */
+#include <signal.h>                          /* 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 <sys/sem.h> */
+#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);