goinfre/libs/libcfgfile/cfgfile.c

goinfre/libs/libcfgfile/cfgfile.c

  _____________________________________________________________________________ 
 /   / Index / Goinfre / Resume / Links / Contact / Sitemap /    .: v0.6.1.0 |^|
|\__/-------+         +--------+-------+---------+---------+-----------------+#|
|  1| /goinfre/libs/libcfgfile/cfgfile.c                                     |#|
|  2| ==========================================                             |#|
|  3|                                                                        |#|
|  4|                                                   [ raw ] [ download ] |#|
|  5|                                             ` `` ````````````````````` |#|
|  6|                                                                        |#|
|  7| /**                                                                    |#|
|  8|  * libcfgfile/cfgfile.c                                                |#|
|  9|  *                                                                     |#|
| 10|  * Copyright (c) Manfred Touron 2008                                   |#|
| 11|  */                                                                    |#|
| 12|                                                                        |#|
| 13| #include <stdlib.h>                                                    |#|
| 14| #include <unistd.h>                                                    |#|
| 15| #include <stdio.h>                                                     |#|
| 16| #include <string.h>                                                    |#|
| 17|                                                                        |#|
| 18| #include "core.h"                                                      |#|
| 19|                                                                        |#|
| 20| char            *cfgfile_getopt(const char *filename, char *cat,       |#|
| 21|                         const char *key)                               |#|
| 22| {                                                                      |#|
| 23|   cfgfile      c;                                                      |#|
| 24|                                                                        |#|
| 25|   if ((c = cfgfile_find(filename)) == NULL)                            |#|
| 26|     return (NULL);                                                     |#|
| 27|   if (_cfgfile_key_exists(c, cat, key))                                |#|
| 28|     return (_cfgfile_getopt(c, cat, key));                             |#|
| 29|   return (NULL);                                                       |#|
| 30| }                                                                      |#|
| 31|                                                                        |#|
| 32| int            cfgfile_cat_exists(const char *filename, char *cat)     |#|
| 33| {                                                                      |#|
| 34|   cfgfile      c;                                                      |#|
| 35|                                                                        |#|
| 36|   if ((c = cfgfile_find(filename)) == NULL)                            | |
| 37|     return (0);                                                        | |
| 38|   return (_cfgfile_cat_exists(c, cat));                                | |
| 39| }                                                                      | |
| 40|                                                                        | |
| 41| int            cfgfile_key_exists(const char *filename, char *cat,     | |
| 42|                            const char *key)                            | |
| 43| {                                                                      | |
| 44|   cfgfile      c;                                                      | |
| 45|                                                                        | |
| 46|   if ((c = cfgfile_find(filename)) == NULL)                            | |
| 47|     return (0);                                                        | |
| 48|   if (_cfgfile_cat_exists(c, cat))                                     | |
| 49|     return (_cfgfile_key_exists(c, cat, key));                         | |
| 50|   return (0);                                                          | |
| 51| }                                                                      | |
| 52|                                                                        | |
+---+                                                                        | |
\_   \______ mo5.so - normal - 1337.so - rev.so - video_r.so +---------------+ |
  |__       \_____   plain.so - color.so - comment.so       /  moul 2008 (c) |V|
     \-----\______\________________________________________/-----------------+-+