diff options
Diffstat (limited to 'src/glibext/configuration.c')
-rw-r--r-- | src/glibext/configuration.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/glibext/configuration.c b/src/glibext/configuration.c index b1a16f0..718f7c0 100644 --- a/src/glibext/configuration.c +++ b/src/glibext/configuration.c @@ -50,6 +50,7 @@ typedef union _param_value { bool boolean; /* Valeur booléenne */ int integer; /* Valeur entière */ + unsigned long ulong; /* Valeur entière positive */ char *string; /* Chaîne de caractères */ } param_value; @@ -332,6 +333,10 @@ GCfgParam *g_config_param_new(const char *path, ConfigParamType type, ...) result->def.integer = va_arg(ap, int); break; + case CPT_ULONG: + result->def.ulong = va_arg(ap, unsigned long); + break; + case CPT_STRING: result->def.string = va_arg(ap, char *); if (result->def.string != NULL) @@ -406,6 +411,7 @@ static bool g_config_param_read(GCfgParam *param, xmlXPathContextPtr context) { char *access; /* Chemin d'accès XML */ char *value; /* Valeur en chaîne de carac. */ + unsigned long ulval; /* Valeur transformée */ access = strdup(param->path); access = strrpl(access, ".", "/"); @@ -428,6 +434,11 @@ static bool g_config_param_read(GCfgParam *param, xmlXPathContextPtr context) g_config_param_set_value(param, atoi(value)); break; + case CPT_ULONG: + ulval = strtoul(value, NULL, 10); + g_config_param_set_value(param, ulval); + break; + case CPT_STRING: g_config_param_set_value(param, value); break; @@ -469,6 +480,7 @@ static bool g_config_param_write(GCfgParam *param, xmlDocPtr xdoc, xmlXPathConte ConfigParamState state; /* Etat du paramètre */ char *access; /* Chemin d'accès XML */ char int_val[sizeof(XSTR(INT_MIN)) + 1];/* Valeur en chaîne de carac. */ + char ul_val[sizeof(XSTR(ULONG_MAX)) + 1];/* Valeur en chaîne de carac. */ state = g_config_param_get_state(param); @@ -497,6 +509,11 @@ static bool g_config_param_write(GCfgParam *param, xmlDocPtr xdoc, xmlXPathConte result = add_content_to_node(xdoc, context, access, int_val); break; + case CPT_ULONG: + snprintf(ul_val, sizeof(ul_val), "%lu", param->cur.ulong); + result = add_content_to_node(xdoc, context, access, ul_val); + break; + case CPT_STRING: if (param->def.string != NULL && param->def.string != NULL @@ -620,6 +637,10 @@ ConfigParamState g_config_param_get_state(GCfgParam *param) param->cached_state = (param->def.integer == param->cur.integer ? CPS_DEFAULT : CPS_CHANGED); break; + case CPT_ULONG: + param->cached_state = (param->def.ulong == param->cur.ulong ? CPS_DEFAULT : CPS_CHANGED); + break; + case CPT_STRING: if (param->def.string == NULL && param->cur.string == NULL) param->cached_state = CPS_DEFAULT; @@ -667,6 +688,10 @@ void g_config_param_make_empty(GCfgParam *param) param->cur.integer = INT_MIN; break; + case CPT_ULONG: + param->cur.ulong = 0; + break; + case CPT_STRING: if (param->cur.string != NULL) { @@ -722,6 +747,10 @@ void g_config_param_reset(GCfgParam *param) param->cur.integer = param->def.integer; break; + case CPT_ULONG: + param->cur.ulong = param->def.ulong; + break; + case CPT_STRING: if (param->def.string != NULL) param->cur.string = strdup(param->def.string); @@ -767,6 +796,7 @@ void g_config_param_set_value(GCfgParam *param, ...) va_list ap; /* Liste d'arguments */ bool old_boolean; /* Valeur booléenne */ int old_integer; /* Valeur entière */ + unsigned long old_ulong; /* Valeur entière positive */ char *old_string; /* Chaîne de caractères */ bool modified; /* Détermine une modification */ @@ -786,6 +816,12 @@ void g_config_param_set_value(GCfgParam *param, ...) modified = (old_integer != param->cur.integer); break; + case CPT_ULONG: + old_ulong = param->cur.ulong; + param->cur.ulong = va_arg(ap, unsigned long); + modified = (old_ulong != param->cur.ulong); + break; + case CPT_STRING: old_string = param->cur.string; param->cur.string = va_arg(ap, char *); @@ -856,6 +892,10 @@ void g_config_param_get_value(GCfgParam *param, ...) *(va_arg(ap, int *)) = param->cur.integer; break; + case CPT_ULONG: + *(va_arg(ap, unsigned long *)) = param->cur.ulong; + break; + case CPT_STRING: *(va_arg(ap, char **)) = param->cur.string; break; |