confuse-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Confuse-devel] search path


From: J.J. Green
Subject: [Confuse-devel] search path
Date: Wed, 21 Apr 2010 11:01:08 +0100

Hi all

I've been using libconfuse for a while, but 
have only just tried the "include" facility.  
To my disappointment, I find that included 
files are not found if they are not in the 
current directory, or a full path is given.  
I think this makes file inclusion barely useful.

A quick look at the code tells me that this would
be fairly easy to implement without disturbing
the API: For a null-terminated array of string

const char* path[] = { "/usr/local/share/myapp",
                       "/usr/share/myapp",
                       NULL };

int cfg_parse_path(cfg_t *cfg, 
                   const char *filename,
                   const char** path)

assigns path to global const char** cfg_path
then checks for the existence of the files
at path/filename (with stat() or access())
and if found calls cfg_parse() with the found
file.

cfg_lexer_include() is modified to check the
global cfg_path and if not-null searches in 
the same way.

Thoughts?

Would there be any interest in me adding this to
the main code branch rather than just making my 
own fork?

Cheers

Jim
-- 
J.J. Green,  Seaview Sensing Ltd., 
http://seaviewsensing.com/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]