#ifndef _LIBVER #define _LIBVER #ifdef __cplusplus extern "C" { #endif typedef int VERT_Info; #define VERD_VERSION 1 #define VERD_TAG 2 #define VERD_SRCFILE 3 #define VERD_AUTHOR 4 typedef int VERT_Print_Mode; #define VERD_VERBOSE 1 #define VERD_MINIMAL 2 typedef int VERT_Status; #define VER_ERROR(s) (s < 0) /* Tous les codes retour négatifs correspondent à des erreurs */ #define VERS_OK 1 #define VERS_KO 0 #define VERS_ERRMEM -1 /* Problème d'allocation mémoire */ #define VERS_ERRAPI -2 /* Utilisation incorrecte des API */ typedef struct { char * name; char * version; char * tag; char * srcfile; char * author; } VERT_Info_Container; typedef VERT_Info_Container * VERT_Fcn (void); typedef struct _link_map VERT_Object; typedef unsigned int VERT_Index; #define VER_FCN_NAME "VER_Info_Export" #define INIT(x) VERT_Info_Container * Container; VER_Info_Init (&Container, x); #define VERSION(x) if (Container) VER_Info_Set(Container,VERD_VERSION, x); #define TAG(x) if (Container) VER_Info_Set(Container,VERD_TAG, x); #define SRCFILE(x) if (Container) VER_Info_Set(Container,VERD_SRCFILE, x); #define AUTHOR(x) if (Container) VER_Info_Set(Container,VERD_AUTHOR, x); #define VER_INFO_EXPORT(obj,ver,tag,file,author) \ VERT_Info_Container * VER_Info_Export_##obj (void); \ VERT_Info_Container * VER_Info_Export_##obj (void) \ { \ INIT(#obj) \ VERSION(ver) \ TAG(tag) \ SRCFILE(file) \ AUTHOR(author) \ return (Container); \ } /*------------------------------------------------------------------------------*/ /* Affichage des informations exportées par l'objet courant */ /*------------------------------------------------------------------------------*/ /* (I) Stream : pointeur sur le flux de sortie */ /* (I) Mode : mode d'affichage */ /*------------------------------------------------------------------------------*/ VERT_Status VER_Object_Print (FILE * Stream, VERT_Print_Mode Mode); /*------------------------------------------------------------------------------*/ /* Récupération d'un conteneur d'informations */ /*------------------------------------------------------------------------------*/ /* (O) Container : adresse d'un pointeur sur le conteneur d'informations */ /* (I) Object : objet dans lequel on effectue la recherche */ /* (I) Index : pointeur d'index à partir duquel on effectue la recherche */ /*------------------------------------------------------------------------------*/ VERT_Status VER_Info_Next_Get (VERT_Info_Container ** Container, VERT_Object * Object, VERT_Index * Index); /*------------------------------------------------------------------------------*/ /* Affichage des informations d'un conteneur */ /*------------------------------------------------------------------------------*/ /* (I) Stream : pointeur sur le flux de sortie */ /* (I) Container : pointeur sur le conteneur d'informations */ /* (I) Mode : mode d'affichage */ /*------------------------------------------------------------------------------*/ VERT_Status VER_Info_Print (FILE * Stream, VERT_Info_Container * Container, VERT_Print_Mode Mode); /*------------------------------------------------------------------------------*/ /* Création d'un conteneur d'informations */ /*------------------------------------------------------------------------------*/ /* (O) Contanier : adresse d'un pointeur sur le container à créer */ /* (I) Object_Name : nom de l'objet */ /*------------------------------------------------------------------------------*/ VERT_Status VER_Info_Init (VERT_Info_Container ** Container, const char * Object_Name); /*------------------------------------------------------------------------------*/ /* Mise à jour d'une information */ /*------------------------------------------------------------------------------*/ /* (I) Container : pointeur sur le conteneur d'informations */ /* (I) Info_Type : type d'information à mettre à jour */ /* (I) Value : valeur de l'information */ /*------------------------------------------------------------------------------*/ VERT_Status VER_Info_Set (VERT_Info_Container * Container, VERT_Info Info_Type, const char * Value); /*------------------------------------------------------------------------------*/ /* Effacement d'une information */ /*------------------------------------------------------------------------------*/ /* (I) Container : pointeur sur le conteneur d'informations */ /* (I) Info_Type : type d'information à effacer */ /*------------------------------------------------------------------------------*/ VERT_Status VER_Info_Clean (VERT_Info_Container * Container, VERT_Info Info_Type); /*------------------------------------------------------------------------------*/ /* Destruction d'un container d'informations */ /*------------------------------------------------------------------------------*/ /* (I) Container : pointeur sur le conteneur d'informations */ /*------------------------------------------------------------------------------*/ VERT_Status VER_Info_End (VERT_Info_Container * Container); /*------------------------------------------------------------------------------*/ # ifdef __cplusplus } # endif #endif