diff options
author | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2004-01-11 09:26:15 +0000 |
---|---|---|
committer | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2004-01-11 09:26:15 +0000 |
commit | e2854bdb20aa686e18df912e133b790ae39ad44d (patch) | |
tree | f2becabd709f19e526adb978a29efce7697247e9 /cfg.c | |
parent | a390d8386961109a8e182897753080538dce8625 (diff) | |
download | lcd4linux-e2854bdb20aa686e18df912e133b790ae39ad44d.tar.gz |
[lcd4linux @ 2004-01-11 09:26:15 by reinelt]
layout starts to exist...
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@305 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'cfg.c')
-rw-r--r-- | cfg.c | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* $Id: cfg.c,v 1.24 2004/01/10 20:22:33 reinelt Exp $^ +/* $Id: cfg.c,v 1.25 2004/01/11 09:26:15 reinelt Exp $^ * * config file stuff * @@ -23,6 +23,9 @@ * * * $Log: cfg.c,v $ + * Revision 1.25 2004/01/11 09:26:15 reinelt + * layout starts to exist... + * * Revision 1.24 2004/01/10 20:22:33 reinelt * added new function 'cfg_list()' (not finished yet) * added layout.c (will replace processor.c someday) @@ -150,6 +153,11 @@ * cfg_cmd can be called _before_ cfg_read() * returns 0 if ok, -1 if arg cannot be parsed * + * cfg_list (section) + * returns a list of all keys in the specified section + * This list was allocated be cfg_list() and must be + * freed by the caller! + * * cfg_get (section, key, defval) * return the a value for a given key in a given section * or <defval> if key does not exist @@ -323,7 +331,7 @@ int l4l_cfg_cmd (char *arg) char *l4l_cfg_list (char *section) { int i, len; - char *key; + char *key, *list; // calculate key length len=strlen(section)+1; @@ -333,14 +341,21 @@ char *l4l_cfg_list (char *section) strcpy (key, section); strcat (key, "."); + // start with empty string + list=malloc(1); + *list='\0'; + // search matching entries for (i=0; i<nConfig; i++) { if (strncasecmp(Config[i].key, key, len)==0) { - debug ("found list: %s", Config[i].key); + list=realloc(list, strlen(list)+strlen(Config[i].key)-len+2); + strcat (list, "|"); + strcat (list, Config[i].key+len); } } - return NULL; + free (key); + return list; } |