2024-04-22 00:24:37 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* 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>
|
2024-04-22 00:24:37 +02:00
|
|
|
|
|
|
|
|
|
//#include <ver.h>
|
|
|
|
|
|
2000-07-28 17:30:55 +02:00
|
|
|
|
#include <node.h>
|
|
|
|
|
#include <datastr.h>
|
|
|
|
|
|
2024-04-22 18:37:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* 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;
|
|
|
|
|
|
2024-04-24 20:27:46 +02:00
|
|
|
|
|
|
|
|
|
|
2000-07-28 17:30:55 +02:00
|
|
|
|
/* Liste des data structure ouvertes par le processus courant */
|
|
|
|
|
|
2024-04-24 20:27:46 +02:00
|
|
|
|
NDT_Root *OpenedDS_List;
|
2000-07-28 17:30:55 +02:00
|
|
|
|
|
2024-04-24 20:27:46 +02:00
|
|
|
|
typedef struct DST_DataStruct
|
|
|
|
|
{
|
2024-04-30 19:03:08 +02:00
|
|
|
|
char Name[ DSD_NAME_SIZE];
|
2024-05-03 00:32:08 +02:00
|
|
|
|
DST_Root *Root_Ptr;
|
2000-07-28 17:30:55 +02:00
|
|
|
|
} DST_DataStruct;
|
|
|
|
|
|
2024-04-24 20:27:46 +02:00
|
|
|
|
|
|
|
|
|
|
2024-04-22 00:24:37 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Fonctions priv<69>es de la librairie */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2000-07-28 17:30:55 +02:00
|
|
|
|
|
2024-04-22 00:24:37 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Cr<43>ation d'un s<>maphore pour g<>rer l'ouverture d'une data structure */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2024-04-27 20:00:00 +02:00
|
|
|
|
|
2024-05-03 00:32:08 +02:00
|
|
|
|
DST_Status DS_Semaphore_Create( DST_Root *);
|
2024-04-27 20:00:00 +02:00
|
|
|
|
|
|
|
|
|
|
2000-07-28 17:30:55 +02:00
|
|
|
|
|
2024-04-22 00:24:37 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Op<4F>ration sur un s<>maphore */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2024-04-27 20:00:00 +02:00
|
|
|
|
|
2024-05-03 00:32:08 +02:00
|
|
|
|
DST_Status DS_Semaphore_Operate (int, struct sembuf *, unsigned int);
|
2000-07-28 17:30:55 +02:00
|
|
|
|
|
2024-04-23 17:10:37 +02:00
|
|
|
|
|
|
|
|
|
|
2024-04-22 00:24:37 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Fonction d'allocation attach<63>e <20> une structure de donn<6E>es : */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2024-04-23 17:10:37 +02:00
|
|
|
|
|
2024-05-03 00:32:08 +02:00
|
|
|
|
DST_Status DS_DataStruct_Alloc ( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_t Size, void *User_Ptr);
|
2024-04-23 17:10:37 +02:00
|
|
|
|
|
|
|
|
|
|
2000-07-28 17:30:55 +02:00
|
|
|
|
|
2024-04-22 00:24:37 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Fonction de d<>sallocation attach<63>e <20> une structure de donn<6E>es : */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2024-04-28 19:59:38 +02:00
|
|
|
|
|
2024-05-03 00:32:08 +02:00
|
|
|
|
DST_Status DS_DataStruct_Free ( void *Ptr, NDT_Root *ND_Root_Ptr, void *User_Ptr );
|
2024-04-28 19:59:38 +02:00
|
|
|
|
|
|
|
|
|
|
2000-07-28 17:30:55 +02:00
|
|
|
|
|
2024-04-22 00:24:37 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Routine d'affichage d'un message d'erreur */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2024-05-03 00:32:08 +02:00
|
|
|
|
void DS_Error_Print ( void );
|
2000-07-28 17:30:55 +02:00
|
|
|
|
|
2024-04-23 17:10:37 +02:00
|
|
|
|
|
|
|
|
|
|
2024-04-22 00:24:37 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Pour pr<70>fixer les noms de heap avec l'identifiant de la librairie */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2024-04-28 19:59:38 +02:00
|
|
|
|
|
|
|
|
|
DST_Status DS_Name_Prefix( char *Prefixed, const char *Unprefixed);
|
2024-04-23 17:10:37 +02:00
|
|
|
|
|
|
|
|
|
|
2000-07-28 17:30:55 +02:00
|
|
|
|
|
2024-04-22 00:24:37 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Teste si une data structure a d<>j<EFBFBD> <20>t<EFBFBD> ouverte par le processus courant */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2024-04-24 20:27:46 +02:00
|
|
|
|
|
2024-05-03 00:32:08 +02:00
|
|
|
|
DST_Status DS_DataStruct_IsOpen( DST_Root **Root_Ptr_Ptr, char *DS_Name);
|
2024-04-24 20:27:46 +02:00
|
|
|
|
|
|
|
|
|
|
2000-07-28 17:30:55 +02:00
|
|
|
|
|
2024-04-22 00:24:37 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Fonction manager de la liste des DS ouvertes */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2024-04-24 20:27:46 +02:00
|
|
|
|
|
2024-05-03 00:32:08 +02:00
|
|
|
|
NDT_Status DS_OpenedDS_List_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr);
|
2024-04-24 20:27:46 +02:00
|
|
|
|
|