libmsg/lib/libmsg.h

119 lines
3.5 KiB
C
Raw Permalink Normal View History

2000-07-28 17:34:22 +02:00
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <ver.h>
#include <node.h>
#include <datastr.h>
#include <msg.h>
extern char * strdup (const char *);
int MSG_Signal_Received;
/* Tous les heaps cr<63><72>s via la librairie LIBMSG seront pr<70>fix<69>s par le nom suivant */
#define MSG_PREFIX "MSG"
/* Nom du fichier <20> charger pour acc<63>der aux fonctions manager d'une data structure cr<63><72>e par la LIBMSG */
#define MSG_FILE_MANAGER "libmsg.so"
/*
Heap dans lequel sera stock<EFBFBD>e la base de la librairie LIBMSG :
Ce heap ne contient que la structure MSGT_Base qui permet de r<EFBFBD>f<EFBFBD>rencer
la liste des ports de messages.
Ce heap ne sera constitu<EFBFBD> que d'une unique segment tr<EFBFBD>s petit.
*/
#define MSG_BASE_HEAP_NAME "BASE"
#define MSG_BASE_HEAP_SEGMENT_SIZE 100
/*
Heap dans lequel sera stock<EFBFBD>e la liste des ports de messages :
Ce heap ne contient que la structure MSGT_Base qui permet de r<EFBFBD>f<EFBFBD>rencer
la liste des ports de messages.
Ce heap n'a pas besoin besoin d'<EFBFBD>tre tr<EFBFBD>s grand.
*/
#define MSG_PORT_LIST_NAME "PORT_REF"
#define MSG_PORT_LIST_SEGMENT_SIZE 10240
/*
Heap sous-jacent <EFBFBD> un port de messages :
Un port de messages est une data structure qui ne contient que sa racine, les
noeuds <EFBFBD>tant stock<EFBFBD>s par ailleurs. On peut donc se contenter d'un petit segment.
*/
#define MSG_PORT_SEGMENT_SIZE 1024
/*
Heap dans lequel seront allou<EFBFBD>s les messages :
Ce heap <EFBFBD>tant amen<EFBFBD> <EFBFBD> grandir rapidemment, il vaut mieux choisir
une taille importante par segment afin de limiter le nombre de segments.
*/
#define MSG_MESSAGE_HEAP_NAME "MSG_REF"
#define MSG_MESSAGE_HEAP_SEGMENT_SIZE 1024000
/* Utilisation des s<>maphores pour l'<27>coute des ports de messages ou des liste de ports */
struct sembuf MSG_SemOp_Listen [2] = { {0, -1, 0}, {0, 1, 0} }; /* Op<4F>ration d'<27>coute */
struct sembuf MSG_SemOp_Receive [1] = { {0, -1, IPC_NOWAIT} }; /* Op<4F>ration de retrait de message */
struct sembuf MSG_SemOp_Add [1] = { {0, 1, IPC_NOWAIT} }; /* Op<4F>ration d'ajout de message */
/* Utilisation des s<>maphores pour verrouiller les ports de messages */
struct sembuf MSG_SemOp_SSL [2] = { {0, -1, SEM_UNDO}, {0, 2, SEM_UNDO} };
struct sembuf MSG_SemOp_RSL [2] = { {0, -2, SEM_UNDO|IPC_NOWAIT}, {0, 1, SEM_UNDO|IPC_NOWAIT} };
struct sembuf MSG_SemOp_SEL [2] = { {0, -1, SEM_UNDO}, {0, 0, SEM_UNDO} };
struct sembuf MSG_SemOp_REL [2] = { {0, 0, SEM_UNDO|IPC_NOWAIT}, {0, 1, SEM_UNDO|IPC_NOWAIT} };
/* Compteur d'ouverture de la librairie */
unsigned int MSG_Open_Counter = 0;
/* Flux de sortie des messages d'erreur g<>n<EFBFBD>r<EFBFBD>s par la librairie */
FILE * MSG_stderr;
typedef union semun {
int val;
struct semid_ds * buf;
unsigned short int * array;
} semun;
NDT_Status MSG_Base_Port_List_Manager (va_list);
NDT_Status MSG_Semaphore_List_Manager (va_list args_ptr);
NDT_Status MSG_PortList_Manager (va_list args_ptr);
NDT_Status MSG_MessageQueue_Manager (va_list);
MSGT_Status MSG_ShareLock_Set (int);
MSGT_Status MSG_ShareLock_Release (int);
MSGT_Status MSG_ExclusiveLock_Set (int);
MSGT_Status MSG_ExclusiveLock_Release (int);
MSGT_Status MSG_Semaphore_Operate (int, struct sembuf *, unsigned int);
void MSG_Error_Print ( void );
static char * MSG_Name_Prefix (const char * Name);
char * MSG_LockStatus_Get (int SemID);