libdatastr/lib/libdatastr.h

152 lines
6.2 KiB
C
Raw Normal View History

/*----------------------------------------------------------------------------*/
/* libdatastr.h */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* This file is part of LibDataStr. */
/* */
/* LibDataStr is free software: you can redistribute it and/or modify it */
/* under the terms of the GNU Lesser General Public License as published */
/* by the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* LibDataStr is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Lesser General Public License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public */
/* License along with LibDataStr. If not, see */
/* <https://www.gnu.org/licenses/>. */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include <stdarg.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/sem.h>
#include <sys/ipc.h>
//#include <ver.h>
2000-07-28 17:30:55 +02:00
#include <node.h>
#include <datastr.h>
/*----------------------------------------------------------------------------*/
/* Definitions */
/*----------------------------------------------------------------------------*/
#define LGD_MODULE_NAME "ds"
2000-07-28 17:30:55 +02:00
extern char * strdup ( const char * );
/* Compteur d'ouverture de la librairie */
unsigned int DS_Open_Counter = 0;
/* Tous les heaps cr<63><72>s via la librairie LIBDATASTR seront pr<70>fix<69>s par le nom suivant */
#define DS_PREFIX "DATASTR"
/* Flux de sortie des messages d'erreur */
FILE * DS_stderr;
/*
Pour g<EFBFBD>rer les ouvertures, fermetures ou destructions d'une data structure, on
op<EFBFBD>re sur un s<EFBFBD>maphore (OpenSemID) rattach<EFBFBD> <EFBFBD> la description de la structure
qui comptabilise les processus ayant ouvert la data structure.
*/
struct sembuf DS_SemOp_Open [1] = { {0, 1, SEM_UNDO|IPC_NOWAIT} };
struct sembuf DS_SemOp_Close [1] = { {0, -1, SEM_UNDO|IPC_NOWAIT} };
struct sembuf DS_SemOp_Destroy [2] = { {0, -1, SEM_UNDO|IPC_NOWAIT}, {0, 0, SEM_UNDO|IPC_NOWAIT} };
typedef union semun {
int val;
struct semid_ds * buf;
unsigned short int * array;
} semun;
/* Liste des data structure ouvertes par le processus courant */
NDT_Root * OpenedDS_List;
typedef struct {
NDT_Root * Root;
char * Name;
} DST_DataStruct;
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Fonctions priv<69>es de la librairie */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
/*----------------------------------------------------------------------------*/
/* Cr<43>ation d'un s<>maphore pour g<>rer l'ouverture d'une data structure */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
DST_Status DS_Semaphore_Create (NDT_Root * Root);
/*----------------------------------------------------------------------------*/
/* Op<4F>ration sur un s<>maphore */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
DST_Status DS_Semaphore_Operate (int, struct sembuf *, unsigned int);
2024-04-23 17:10:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fonction d'allocation attach<63>e <20> une structure de donn<6E>es : */
/*----------------------------------------------------------------------------*/
2024-04-23 17:10:37 +02:00
DST_Status DS_DataStruct_Alloc ( void **Ptr, size_t Size, void *Data );
2000-07-28 17:30:55 +02:00
/*----------------------------------------------------------------------------*/
/* Fonction de d<>sallocation attach<63>e <20> une structure de donn<6E>es : */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Free ( void * Ptr, void * Data );
/*----------------------------------------------------------------------------*/
/* Routine d'affichage d'un message d'erreur */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
void DS_Error_Print ( void );
2024-04-23 17:10:37 +02:00
/*----------------------------------------------------------------------------*/
/* Pour pr<70>fixer les noms de heap avec l'identifiant de la librairie */
/*----------------------------------------------------------------------------*/
2024-04-23 17:10:37 +02:00
static char *DS_Name_Prefix (const char *Name);
2000-07-28 17:30:55 +02:00
/*----------------------------------------------------------------------------*/
/* Teste si une data structure a d<>j<EFBFBD> <20>t<EFBFBD> ouverte par le processus courant */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_IsOpen (const char * DS_Name, NDT_Root ** Root);
/*----------------------------------------------------------------------------*/
/* Fonction manager de la liste des DS ouvertes */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
NDT_Status DS_OpenedDS_List_Manager (va_list Args);