src/xpath/xpath.c
/*
 * Returns the length of the content for a file and set buffer with the file
 * content. Note that malloc is used to allocate memory for the buffer.
 *
 * In case of an error -1 is returned and buffer will be set to NULL.
 */
Returns the length of the content for a file and set buffer with the file
content. Note that malloc is used to allocate memory for the buffer.

In case of an error -1 is returned and buffer will be set to NULL.
Returns the length of the content for a file and set buffer with the file content . Note that malloc is used to allocate memory for the buffer . In case of an error - 1 is returned and buffer will be set to NULL .
ssize_t xpath_get_content(char ** buffer, const char * fn)
{
    ssize_t size = 0;
    *buffer = NULL;
    FILE * fp = fopen(fn, "r");
    if (fp == NULL)
    {
        log_critical("Cannot open file: '%s'", fn);
        return -1;
    }
    if (fseeko(fp, 0, SEEK_END) == 0 &&
        (size = ftello(fp)) != -1 &&
        fseeko(fp, 0, SEEK_SET) == 0)
    {
        *buffer = (char *) malloc(size);
        if (*buffer != NULL)
        {
            if (fread(*buffer, size, 1, fp) != 1)
            {
                log_critical("Could not get full content from '%s'", fn);
                free(*buffer);
                *buffer = NULL;
            }
        }
    }
    fclose(fp);
    return (*buffer == NULL) ? -1 : size;
}
ssize_t xpath_get_content ( char * * buffer , const char * fn ) { ssize_t size = 0 ; * buffer = NULL ; FILE * fp = fopen ( fn , " " ) ; if ( fp == NULL ) { log_critical ( " " , fn ) ; return -1 ; } if ( fseeko ( fp , 0 , SEEK_END ) == 0 && ( size = ftello ( fp ) ) != -1 && fseeko ( fp , 0 , SEEK_SET ) == 0 ) { * buffer = ( char * ) malloc ( size ) ; if ( * buffer != NULL ) { if ( fread ( * buffer , size , 1 , fp ) != 1 ) { log_critical ( " " , fn ) ; free ( * buffer ) ; * buffer = NULL ; } } } fclose ( fp ) ; return ( * buffer == NULL ) ? -1 : size ; }
Returns the length of the content for a file and set buffer with the file
 content.
Returns the length of the content for a file and set buffer with the file content .