Thanks for a very useful, efficient library.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Thanks for a very useful, efficient library.

Sean Burke
Hi All,

I just integrated libconfuse with my project, and I am very pleased with it.
It has a very nice balance of features and simplicity, and was very ease to use.

I did find it useful to change cfg_include, so that paths are constructed
relative to the file containing the include directive, see below.

-Sean

DLLIMPORT int cfg_include(cfg_t *cfg, cfg_opt_t *opt, int argc,
                          const char **argv)
{
    opt = NULL;
    if (argc == 1)
    {
        const char * arg = argv[0];
        int          res = 0;
#ifndef WIN32
        // If the argument does not begin with / or ~ (not an absolute path),                                                                                                                                                              
        // construct a path relative to the current filename.                                                                                                                                                                              
        if (!strspn(arg, "~/") && strchr(cfg->filename, '/'))
        {
         char * tmp = malloc(strlen(cfg->filename) + strlen(arg));
            strcpy(tmp, cfg->filename);
            strcpy(strrchr(tmp, '/') + 1, arg);
            arg = tmp;
        }
#endif
        res = cfg_lexer_include(cfg, arg);
        if (arg != argv[0]) free(arg);
        return res;
    }
    else
    {
        cfg_error(cfg, _("wrong number of arguments to cfg_include()"));
        return 1;
    }
}


_______________________________________________
Confuse-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/confuse-devel