_____________________________________________________________________________
/ / Index / Goinfre / Resume / Links / Contact / Sitemap / .: v0.6.1.0 |^|
|\__/-------+ +--------+-------+---------+---------+-----------------+#|
| 1| /goinfre/libs/libcfgfile/tester.c |#|
| 2| ========================================== |#|
| 3| |#|
| 4| [ raw ] [ download ] |#|
| 5| ` `` ````````````````````` |#|
| 6| |#|
| 7| /** |#|
| 8| * libcfgfile/tester.c |#|
| 9| * |#|
| 10| * Copyright (c) Manfred Touron 2008 |#|
| 11| */ |#|
| 12| |#|
| 13| #include <stdio.h> |#|
| 14| |#|
| 15| #include "libcfgfile.h" |#|
| 16| |#|
| 17| void test(const char *filename, char *category, const char *key) |#|
| 18| { |#|
| 19| char *res; |#|
| 20| |#|
| 21| printf(" [+] Preliminary tests\n"); |#|
| 22| if (!cfgfile_cat_exists(filename, category)) |#|
| 23| printf(" [-] category %s does not exists\n", category); |#|
| 24| else |#|
| 25| { |#|
| 26| printf(" [+] category %s exists\n", category); |#|
| 27| if (!cfgfile_key_exists(filename, category, key)) |#|
| 28| printf(" [-] key %s does not exists\n", key); |#|
| 29| else |#|
| 30| { |#|
| 31| printf(" [+] key %s exists\n", key); |#|
| 32| res = cfgfile_getopt(filename, category, key); |#|
| 33| printf(" [+] result: [%s]\n", res); |#|
| 34| } |#|
| 35| } |#|
| 36| return ; |#|
| 37| } |#|
| 38| |#|
| 39| #define TEST(FILE, CAT, KEY) \ | |
| 40| printf("[+] Test: file=%s, cat=%s, key=%s\n", FILE, CAT, KEY); | |
| 41| \ | |
| 42| test(FILE, CAT, KEY); | |
| 43| | |
| 44| int main(int ac, char **av) | |
| 45| { | |
| 46| char *filename; | |
| 47| | |
| 48| filename = "example.conf"; | |
| 49| printf("[+] Initialisation\n"); | |
| 50| TEST(filename, "toto", "tata"); | |
| 51| printf("[+] Uninitialisation\n"); | |
| 52| return (0); | |
| 53| (void)ac; | |
| 54| (void)av; | |
| 55| } | |
| 56| | |
+---+ | |
\_ \______ mo5.so - normal - 1337.so - rev.so - video_r.so +---------------+ |
|__ \_____ plain.so - color.so - comment.so / moul 2008 (c) |V|
\-----\______\________________________________________/-----------------+-+