]> mj.ucw.cz Git - libucw.git/commitdiff
lib: converted to use conf2.c instead of conf.c
authorRobert Spalek <robert@ucw.cz>
Sun, 23 Apr 2006 19:33:56 +0000 (21:33 +0200)
committerRobert Spalek <robert@ucw.cz>
Sun, 23 Apr 2006 19:33:56 +0000 (21:33 +0200)
lib/autoconf.cfg
lib/fb-mmap.c
lib/fb-temp.c
lib/ipaccess.c
lib/lizard-test.c
lib/redblack-test.c
lib/redblack.h
lib/sort-test.c
lib/sorter.c
lib/url.c

index 668c83ea14051294f1e59f58bbee964984062028..a6344e8b0f43acc6cf52de17393570e46c0194f4 100644 (file)
@@ -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");
index 08a96729044cec03cc2cd97686a19ffeb0e831eb..ceb44c2ae419116c729f02bda22c6a509340a8fe 100644 (file)
@@ -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 <string.h>
 #include <fcntl.h>
 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 {
index aff501e8d46966476b4e0a72f603153e0fac25d2..62c6e3820f963a9434365e18ee87508707207e65 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "lib/lib.h"
-#include "lib/conf.h"
+#include "lib/conf2.h"
 #include "lib/fastbuf.h"
 
 #include <unistd.h>
 
 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 *
index 4521c8327a326518c27a22d98f986a3f3111b308..319a99ec4997bea964dfce1222f30429a637fc23 100644 (file)
@@ -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;
index 73200d19dcf9bb4a926335ecca1b87fb67f0d03d..22fc96e49a60cf69a4f7976c3d2bf5b9f8e7742c 100644 (file)
@@ -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 <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <sys/user.h>
 
 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':
index 575d645f13ce7a14469c1ce338d15b92d114dc37..3c48f18f5010f639c753598296867be186302282 100644 (file)
@@ -5,10 +5,11 @@
  */
 
 #include "lib/lib.h"
-#include "lib/conf.h"
+#include "lib/conf2.h"
 #include "lib/fastbuf.h"
 #include <stdio.h>
 #include <stdlib.h>
+#include <getopt.h>
 
 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':
index 05544c36a04ac22503cca216cee4450c60108494..b0254c5992c88a3be92da5f12680545c2d638cd5 100644 (file)
@@ -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)
index 448abdc31b517fe72e0b39e0c64898613b005a96..14f4a65866de59b902b9a308a597ac967ff4c455 100644 (file)
@@ -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 <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <getopt.h>
 
 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);
index f53f205735c930384e35bc3a651f4bf46cca0a52..2272df7260f3fe120a3dc697ecfd9f99b6bfcd81 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "lib/lib.h"
-#include "lib/conf.h"
+#include "lib/conf2.h"
 #include "lib/fastbuf.h"
 
 #include <unistd.h>
@@ -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;
index d5cbcea21a34d718b7e9b70f6ee09131574deaa4..2419f71f8e388845f33ffc40a91d69b0613b4c84 100644 (file)
--- 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 <string.h>
 #include <stdlib.h>
@@ -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 */