--------------------- PatchSet 1633 Date: 2001/02/22 12:20:01 Author: rbcollins Branch: generic_modules Tag: (none) Log: default values the responsibility of the name registrar Members: src/cache_cf.c:1.18.4.12->1.18.4.13 src/cf_gen.c:1.7.8.6->1.7.8.7 Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_cf.c,v retrieving revision 1.18.4.12 retrieving revision 1.18.4.13 diff -u -r1.18.4.12 -r1.18.4.13 --- squid/src/cache_cf.c 22 Feb 2001 10:43:44 -0000 1.18.4.12 +++ squid/src/cache_cf.c 22 Feb 2001 12:20:01 -0000 1.18.4.13 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.18.4.12 2001/02/22 10:43:44 rbcollins Exp $ + * $Id: cache_cf.c,v 1.18.4.13 2001/02/22 12:20:01 rbcollins Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -64,7 +64,6 @@ static PARSER_PARSE parse_ushort; static PARSER_PARSE parse_string; PARSER_PARSE parse_wordlist; -static void default_all(void); static void defaults_if_none(void); static void default_line(const char *); static int parse_line(char *); @@ -278,7 +277,6 @@ parserDeregisterAllTypes(); parserRegisterAllTypes(); parserRegisterAllNames(); - default_all(); err_count=parseConfigFile(file_name); defaults_if_none(); configDoConfigure(); Index: squid/src/cf_gen.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cf_gen.c,v retrieving revision 1.7.8.6 retrieving revision 1.7.8.7 diff -u -r1.7.8.6 -r1.7.8.7 --- squid/src/cf_gen.c 22 Feb 2001 10:43:44 -0000 1.7.8.6 +++ squid/src/cf_gen.c 22 Feb 2001 12:20:01 -0000 1.7.8.7 @@ -1,6 +1,6 @@ /* - * $Id: cf_gen.c,v 1.7.8.6 2001/02/22 10:43:44 rbcollins Exp $ + * $Id: cf_gen.c,v 1.7.8.7 2001/02/22 12:20:01 rbcollins Exp $ * * DEBUG: none Generate squid.conf and cf_parser.c * AUTHOR: Max Okumoto @@ -43,9 +43,7 @@ * initializes variables with the default * values, parserRegisterAllTypes() which registers * all the cf.data.pre types, parserRegisterAllNames() - * which registers all the cf.data.pre Names, and - * parserDeregisterAll(Types|Names) which are the - * converse to the RegisterAll functions. + * which registers all the cf.data.pre Names. * squid.conf - default configuration file given to the server * administrator. *****************************************************************************/ @@ -110,10 +108,9 @@ static const char WS[] = " \t"; -static int gen_default(Entry *, FILE *); static void gen_conf(Entry *, FILE *); static void gen_registertypes(Entry *, FILE *); -static void gen_registernames(Entry *, FILE *); +static int gen_registernames(Entry *, FILE *); static void gen_default_if_none(Entry *, FILE *); static void @@ -324,7 +321,6 @@ /*-------------------------------------------------------------------* * Generate parserRegisterAllTypes() * Generate parserRegisterAllNames() - * Generate default_all() * Generate example squid.conf file *-------------------------------------------------------------------*/ @@ -346,10 +342,9 @@ "\n", input_filename, argv[0] ); - rc = gen_default(entries, fp); gen_default_if_none(entries, fp); gen_registertypes(entries, fp); - gen_registernames(entries, fp); + rc = gen_registernames(entries, fp); fclose(fp); /* Open output x.conf file */ @@ -366,52 +361,6 @@ return (rc); } -static int -gen_default(Entry * head, FILE * fp) -{ - Entry *entry; - int rc = 0; - fprintf(fp, - "static void\n" - "default_all(void)\n" - "{\n" - "\tcfg_filename = \"Default Configuration\";\n" - "\tconfig_lineno = 0;\n" - ); - for (entry = head; entry != NULL; entry = entry->next) { - assert(entry->name); - assert(entry != entry->next); - - if (!strcmp(entry->name, "comment")) - continue; - if (entry->loc == NULL) { - fprintf(stderr, "NO LOCATION FOR %s\n", entry->name); - rc |= 1; - continue; - } - if (entry->default_value == NULL) { - fprintf(stderr, "NO DEFAULT FOR %s\n", entry->name); - rc |= 1; - continue; - } - assert(entry->default_value); - if (entry->ifdef) - fprintf(fp, "#if %s\n", entry->ifdef); - if (strcmp(entry->default_value, "none") == 0) { - fprintf(fp, "\t/* No default for %s */\n", entry->name); - } else { - fprintf(fp, "\tdefault_line(\"%s %s\");\n", - entry->name, - entry->default_value); - } - if (entry->ifdef) - fprintf(fp, "#endif\n"); - } - fprintf(fp, "\tcfg_filename = NULL;\n"); - fprintf(fp, "}\n\n"); - return rc; -} - static void gen_default_if_none(Entry * head, FILE * fp) { @@ -438,10 +387,10 @@ "\t\tdefault_line(\"%s %s\");\n", entry->name, line->data); - fprintf(fp, "\t}\n}\n\n"); + fprintf(fp, "\t}\n}\n%s", entry->ifdef ? "" : "\n"); } if (entry->ifdef) - fprintf(fp, "#endif\n"); + fprintf(fp, "#endif\n%s", entry->ifdef ? "\n" : ""); } } @@ -471,14 +420,17 @@ fprintf(fp, "}\n\n"); } -static void +static int gen_registernames(Entry * head, FILE * fp) { Entry *entry; + int rc=0; fprintf(fp, "#define default_if_none_NULL NULL\nstatic void\n" "parserRegisterAllNames(void)\n" "{\n" + "\tcfg_filename=\"Default Configuration\";" + "\tconfig_lineno = 0;" ); for (entry = head; entry != NULL; entry = entry->next) { assert(entry->loc); @@ -496,10 +448,22 @@ entry->loc, entry->array_flag ? "[0]" : "", entry->default_if_none ? entry->name : "NULL"); + if (entry->default_value == NULL) { + fprintf(stderr, "NO DEFAULT FOR %s\n", entry->name); + rc |= 1; + } + if (strcmp(entry->default_value, "none") == 0) { + fprintf(fp, "\t/* No default for %s */\n", entry->name); + } else { + fprintf(fp, "\tdefault_line(\"%s %s\");\n", + entry->name, + entry->default_value); + } if (entry->ifdef) fprintf(fp, "#endif\n"); } fprintf(fp, "}\n\n"); + return rc; } static int