/* OpenIDA - Outil d'analyse de fichiers binaires * configuration.h - prototypes pour les éléments de configuration du programme * * Copyright (C) 2009 Cyrille Bagard * * This file is part of OpenIDA. * * OpenIDA is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * OpenIDA 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Foobar. If not, see . */ #ifndef _CONFIGURATION_H #define _CONFIGURATION_H #include /* Tyoes de valeur pour élement de configuration */ typedef enum _ConfigValueType { CVT_BOOLEAN, /* Valeur booléenne */ CVT_INTEGER, /* Valeur entière */ CVT_STRING, /* Chaîne de caractère */ CVT_COUNT } ConfigValueType; /* Valeurs supportées par les configurations */ typedef union _config_value { bool boolean; /* Valeur booléenne */ int integer; /* Valeur entière */ char *string; /* Chaîne de caractère */ } config_value; /* Eléments des configurations */ typedef struct _config_param { const char *path; /* Chemin d'accès XML */ ConfigValueType type; /* Type de valeur */ bool defined; /* Présence de valeur courante */ config_value def; /* Valeur par défaut */ config_value cur; /* Valeur courante */ } config_param; /* Paramètres de configuration */ typedef struct _configuration configuration; /* Charge la configuration principale. */ configuration *load_configuration(const char *, config_param *, unsigned int); /* Décharge la configuration principale. */ void unload_configuration(configuration *); /* Définit une valeur booléenne dans la configuration. */ bool set_boolean_config_value(configuration *, unsigned int, bool); /* Fournit une valeur booléenne issue de la configuration. */ bool get_boolean_config_value(configuration *, unsigned int); /* Définit une valeur entière dans la configuration. */ bool set_integer_config_value(configuration *, unsigned int, int); /* Fournit une valeur entière issue de la configuration. */ int get_integer_config_value(configuration *, unsigned int); /* Définit une chaîne de caractères dans la configuration. */ bool set_string_config_value(configuration *, unsigned int, const char *); /* Fournit une chaîne de caractères issue de la configuration. */ const char *get_string_config_value(configuration *, unsigned int); #endif /* _CONFIGURATION_H */