Problème pour modifier une fonction
Bonjour,
Avant tout je veux vous dire que je n'ai jamais utilisé la Glib.
En fait, j'ai une fonction dont la définition est la suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| gboolean get_param_positive_double(struct call *c, GData *param, GQuark name, gdouble *value, GError **error) {
gchar *data, *endptr;
if (!(data = g_datalist_id_get_data(¶m, name))) {
goto missing;
}
if (!strcmp(data, "random")) {
*value = g_rand_double(get_rand());
} else {
*value = g_ascii_strtod(data, &endptr);
if (data == endptr) {
goto baddata;
}
if (*value < 0) {
set_config_error(error, c, name, CONFIG_ERROR_BADDATA, "positive double value (%lf) is negative", *value);
goto error;
}
}
return TRUE;
missing:
set_config_error(error, c, name, CONFIG_ERROR_MISSING, NULL);
goto error;
baddata:
set_config_error(error, c, name, CONFIG_ERROR_BADDATA, NULL);
goto error;
error:
return FALSE;
} |
D'près ce que j'ai compris, cette fonction prend la valeur (double) d'un type spécifié dans un fichier XML.
Ce que je veux faire c'est de programmer une fonction qui prend une chaine de caractère spécifique.
voila ce que j'ai écrit, mais ça ne marche pas ::(
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| gboolean get_param_string(struct call *c, GData *param, GQuark name, gchar *value, GError **error) {
if (!(value = g_datalist_id_get_data(¶m, name))) {
goto missing;
}
return TRUE;
missing:
set_config_error(error, c, name, CONFIG_ERROR_MISSING, NULL);
goto error;
error:
return FALSE;
} |
Pourriez vous m'aider SVP