From f282fc30d94338be07c13a86765fdbe3b2536c0c Mon Sep 17 00:00:00 2001 From: Robert Spalek Date: Sun, 23 Apr 2006 21:33:56 +0200 Subject: [PATCH] lib: converted to use conf2.c instead of conf.c --- lib/autoconf.cfg | 2 ++ lib/fb-mmap.c | 15 ++++++++------- lib/fb-temp.c | 13 +++++++------ lib/ipaccess.c | 5 +++-- lib/lizard-test.c | 5 +++-- lib/redblack-test.c | 7 ++++--- lib/redblack.h | 2 +- lib/sort-test.c | 6 ++++-- lib/sorter.c | 17 +++++++++-------- lib/url.c | 21 +++++++++++---------- 10 files changed, 52 insertions(+), 41 deletions(-) diff --git a/lib/autoconf.cfg b/lib/autoconf.cfg index 668c83ea..a6344e8b 100644 --- a/lib/autoconf.cfg +++ b/lib/autoconf.cfg @@ -164,6 +164,8 @@ if (IsSet("CONFIG_DEBUG")) { Set("DEBUG_ASSERTS"); Set("DEBUG_DIE_BY_ABORT") if Get("CONFIG_DEBUG") > 1; Set("CDEBUG" => "-ggdb"); + Set("COPT" => ""); + Set("COPT2" => ""); } else { # If building a release version: Append("COPT" => "-fomit-frame-pointer"); diff --git a/lib/fb-mmap.c b/lib/fb-mmap.c index 08a96729..ceb44c2a 100644 --- a/lib/fb-mmap.c +++ b/lib/fb-mmap.c @@ -10,7 +10,7 @@ #include "lib/lib.h" #include "lib/fastbuf.h" #include "lib/lfs.h" -#include "lib/conf.h" +#include "lib/conf2.h" #include #include @@ -21,16 +21,17 @@ static uns mmap_window_size = 16*PAGE_SIZE; static uns mmap_extend_size = 4*PAGE_SIZE; -static struct cfitem fbmm_config[] = { - { "FBMMap", CT_SECTION, NULL }, - { "WindowSize", CT_INT, &mmap_window_size }, - { "ExtendSize", CT_INT, &mmap_extend_size }, - { NULL, CT_STOP, NULL } +static struct cf_section fbmm_config = { + CF_ITEMS { + CF_UNS("WindowSize", &mmap_window_size), + CF_UNS("ExtendSize", &mmap_extend_size), + CF_END + } }; static void CONSTRUCTOR fbmm_init_config(void) { - cf_register(fbmm_config); + cf_declare_section("FBMMap", &fbmm_config, 0); } struct fb_mmap { diff --git a/lib/fb-temp.c b/lib/fb-temp.c index aff501e8..62c6e382 100644 --- a/lib/fb-temp.c +++ b/lib/fb-temp.c @@ -8,7 +8,7 @@ */ #include "lib/lib.h" -#include "lib/conf.h" +#include "lib/conf2.h" #include "lib/fastbuf.h" #include @@ -16,15 +16,16 @@ static byte *temp_template = "/tmp/temp%d.%d"; -static struct cfitem temp_config[] = { - { "Tempfiles", CT_SECTION, NULL }, - { "Template", CT_STRING, &temp_template }, - { NULL, CT_STOP, NULL } +static struct cf_section temp_config = { + CF_ITEMS { + CF_STRING("Template", &temp_template), + CF_END + } }; static void CONSTRUCTOR temp_init_config(void) { - cf_register(temp_config); + cf_declare_section("Tempfiles", &temp_config, 0); } struct fastbuf * diff --git a/lib/ipaccess.c b/lib/ipaccess.c index 4521c832..319a99ec 100644 --- a/lib/ipaccess.c +++ b/lib/ipaccess.c @@ -9,7 +9,7 @@ #include "lib/lib.h" #include "lib/lists.h" -#include "lib/conf.h" +#include "lib/conf2.h" #include "lib/chartype.h" #include "lib/ipaccess.h" @@ -37,6 +37,7 @@ ipaccess_init(void) return l; } +// FIXME: replace by cf_parse_ip() static byte * parse_ip(byte **p, u32 *varp) { @@ -81,7 +82,7 @@ ipaccess_parse(struct ipaccess_list *l, byte *c, int is_allow) { byte *p = strchr(c, '/'); char *q; - struct ipaccess_entry *a = cfg_malloc(sizeof(struct ipaccess_entry)); + struct ipaccess_entry *a = cf_malloc(sizeof(struct ipaccess_entry)); unsigned long pxlen; a->allow = is_allow; diff --git a/lib/lizard-test.c b/lib/lizard-test.c index 73200d19..22fc96e4 100644 --- a/lib/lizard-test.c +++ b/lib/lizard-test.c @@ -1,11 +1,12 @@ #include "lib/lib.h" -#include "lib/conf.h" +#include "lib/conf2.h" #include "lib/fastbuf.h" #include "lib/lizard.h" #include #include #include #include +#include #include static char *options = CF_SHORT_OPTS "cdtx"; @@ -34,7 +35,7 @@ main(int argc, char **argv) uns action = 't'; uns crash = 0; log_init(argv[0]); - while ((opt = cf_getopt(argc, argv, options, CF_NO_LONG_OPTS, NULL)) >= 0) + while ((opt = cf_get_opt(argc, argv, options, CF_NO_LONG_OPTS, NULL)) >= 0) switch (opt) { case 'c': diff --git a/lib/redblack-test.c b/lib/redblack-test.c index 575d645f..3c48f18f 100644 --- a/lib/redblack-test.c +++ b/lib/redblack-test.c @@ -5,10 +5,11 @@ */ #include "lib/lib.h" -#include "lib/conf.h" +#include "lib/conf2.h" #include "lib/fastbuf.h" #include #include +#include struct my1_node { @@ -127,9 +128,9 @@ main(int argc, char **argv) struct my_tree t; struct my2_tree t2; int i; - cfdeffile = NULL; + cf_def_file = NULL; log_init(argv[0]); - while ((opt = cf_getopt(argc, argv, options, CF_NO_LONG_OPTS, NULL)) >= 0) + while ((opt = cf_get_opt(argc, argv, options, CF_NO_LONG_OPTS, NULL)) >= 0) switch (opt) { case 'v': diff --git a/lib/redblack.h b/lib/redblack.h index 05544c36..b0254c59 100644 --- a/lib/redblack.h +++ b/lib/redblack.h @@ -262,7 +262,7 @@ typedef struct P(stack_entry) { static inline uns P(red_flag) (P(bucket) *node) { return ((addr_int_t) node->son[0]) & 1L; } static inline void P(set_red_flag) (P(bucket) *node, uns flag) - { (addr_int_t) node->son[0] = (((addr_int_t) node->son[0]) & ~1L) | (flag & 1L); } + { node->son[0] = (void*) ( (((addr_int_t) node->son[0]) & ~1L) | (flag & 1L) ); } static inline P(bucket) * P(tree_son) (P(bucket) *node, uns id) { return (void *) (((addr_int_t) node->son[id]) & ~1L); } static inline void P(set_tree_son) (P(bucket) *node, uns id, P(bucket) *son) diff --git a/lib/sort-test.c b/lib/sort-test.c index 448abdc3..14f4a658 100644 --- a/lib/sort-test.c +++ b/lib/sort-test.c @@ -1,11 +1,13 @@ /* Test for sorting routines */ #include "lib/lib.h" -#include "lib/conf.h" +#include "lib/conf2.h" #include "lib/fastbuf.h" +#include #include #include +#include struct key { char line[4096]; @@ -77,7 +79,7 @@ int main(int argc, char **argv) { log_init(NULL); - if (cf_getopt(argc, argv, CF_SHORT_OPTS, CF_NO_LONG_OPTS, NULL) >= 0 || + if (cf_get_opt(argc, argv, CF_SHORT_OPTS, CF_NO_LONG_OPTS, NULL) >= 0 || optind != argc - 2) { fputs("This program supports only the following command-line arguments:\n" CF_USAGE, stderr); diff --git a/lib/sorter.c b/lib/sorter.c index f53f2057..2272df72 100644 --- a/lib/sorter.c +++ b/lib/sorter.c @@ -8,7 +8,7 @@ */ #include "lib/lib.h" -#include "lib/conf.h" +#include "lib/conf2.h" #include "lib/fastbuf.h" #include @@ -21,17 +21,18 @@ uns sorter_trace; uns sorter_presort_bufsize = 65536; uns sorter_stream_bufsize = 65536; -static struct cfitem sorter_config[] = { - { "Sorter", CT_SECTION, NULL }, - { "Trace", CT_INT, &sorter_trace }, - { "PresortBuffer", CT_INT, &sorter_presort_bufsize }, - { "StreamBuffer", CT_INT, &sorter_stream_bufsize }, - { NULL, CT_STOP, NULL } +static struct cf_section sorter_config = { + CF_ITEMS { + CF_UNS("Trace", &sorter_trace), + CF_UNS("PresortBuffer", &sorter_presort_bufsize), + CF_UNS("StreamBuffer", &sorter_stream_bufsize), + CF_END + } }; static void CONSTRUCTOR sorter_init_config(void) { - cf_register(sorter_config); + cf_declare_section("Sorter", &sorter_config, 0); } uns sorter_pass_counter; diff --git a/lib/url.c b/lib/url.c index d5cbcea2..2419f71f 100644 --- a/lib/url.c +++ b/lib/url.c @@ -18,7 +18,7 @@ #include "lib/lib.h" #include "lib/url.h" #include "lib/chartype.h" -#include "lib/conf.h" +#include "lib/conf2.h" #include #include @@ -33,19 +33,20 @@ static byte *url_component_separators = ""; static uns url_min_repeat_count = 0x7fffffff; static uns url_max_repeat_length = 0; -static struct cfitem url_config[] = { - { "URL", CT_SECTION, NULL }, - { "IgnoreSpaces", CT_INT, &url_ignore_spaces }, - { "IgnoreUnderflow", CT_INT, &url_ignore_underflow }, - { "ComponentSeparators", CT_STRING, &url_component_separators }, - { "MinRepeatCount", CT_INT, &url_min_repeat_count }, - { "MaxRepeatLength", CT_INT, &url_max_repeat_length }, - { NULL, CT_STOP, NULL } +static struct cf_section url_config = { + CF_ITEMS { + CF_UNS("IgnoreSpaces", &url_ignore_spaces), + CF_UNS("IgnoreUnderflow", &url_ignore_underflow), + CF_STRING("ComponentSeparators", &url_component_separators), + CF_UNS("MinRepeatCount", &url_min_repeat_count), + CF_UNS("MaxRepeatLength", &url_max_repeat_length), + CF_END + } }; static void CONSTRUCTOR url_init_config(void) { - cf_register(url_config); + cf_declare_section("URL", &url_config, 0); } /* Escaping and de-escaping */ -- 2.39.2