diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/xml.c | 80 | ||||
| -rw-r--r-- | src/common/xml.h | 6 | 
2 files changed, 86 insertions, 0 deletions
| diff --git a/src/common/xml.c b/src/common/xml.c index 90c86cd..d3c1998 100644 --- a/src/common/xml.c +++ b/src/common/xml.c @@ -409,6 +409,86 @@ char *get_node_text_value(xmlXPathContextPtr xpathCtx, const char *path)  /******************************************************************************  *                                                                             * +*  Paramètres  : xpathCtx = contexte à utiliser pour les recherches.          * +*                path     = chemin d'accès au noeud visé.                     * +*                out      = valeur booléenne associée à un noeud. [OUT]       * +*                                                                             * +*  Description : Obtient une valeur booléenne placée entre <...> et </...>.   * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool get_node_boolean_value(xmlXPathContextPtr xpathCtx, const char *path, bool *out) +{ +    bool result;                            /* Bilan à retourner           */ +    char *value;                            /* Valeur brute lue            */ + +    result = false; + +    value = get_node_text_value(xpathCtx, path); + +    if (value != NULL) +    { +        if (strlen(value) > 0) +        { +            result = true; +            *out = (strcasecmp(value, "true") == 0 || strcmp(value, "1") == 0); +        } + +        free(value); + +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : xpathCtx = contexte à utiliser pour les recherches.          * +*                path     = chemin d'accès au noeud visé.                     * +*                out      = valeur entière associée à un noeud. [OUT]         * +*                                                                             * +*  Description : Obtient une valeur entière placée entre <...> et </...>.     * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool get_node_long_value(xmlXPathContextPtr xpathCtx, const char *path, long *out) +{ +    bool result;                            /* Bilan à retourner           */ +    char *value;                            /* Valeur brute lue            */ + +    result = false; + +    value = get_node_text_value(xpathCtx, path); + +    if (value != NULL) +    { +        if (strlen(value) > 0) +        { +            result = true; +            *out = strtol(value, NULL, 10); +        } + +        free(value); + +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : node = noeud dont une propriété est à lire.                  *  *                name = nom de la propriété à lire.                           *  *                                                                             * diff --git a/src/common/xml.h b/src/common/xml.h index fe99b91..91f0552 100644 --- a/src/common/xml.h +++ b/src/common/xml.h @@ -74,6 +74,12 @@ char *qck_get_node_text_value(xmlNodePtr);  /* Obtient une valeur placée entre <...> et </...>. */  char *get_node_text_value(xmlXPathContextPtr, const char *); +/* Obtient une valeur booléenne placée entre <...> et </...>. */ +bool get_node_boolean_value(xmlXPathContextPtr, const char *, bool *); + +/* Obtient une valeur entière placée entre <...> et </...>. */ +bool get_node_long_value(xmlXPathContextPtr, const char *, long *); +  /* Obtient la valeur d'une propriété d'un élément. */  char *qck_get_node_prop_value(xmlNodePtr, const char *); | 
