--------------------- PatchSet 11417 Date: 2007/05/13 12:34:31 Author: adrian Branch: HEAD Tag: (none) Log: Flesh out a little more for testing. I need to treat NAME entries with >1 configuration entry better. This does create partially-filed files with the content just to see how the creation process will hold together. Members: scripts/www/build-cfg-help.pl:1.1->1.2 Index: squid/scripts/www/build-cfg-help.pl =================================================================== RCS file: /cvsroot/squid/squid/scripts/www/build-cfg-help.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- squid/scripts/www/build-cfg-help.pl 13 May 2007 12:18:00 -0000 1.1 +++ squid/scripts/www/build-cfg-help.pl 13 May 2007 12:34:31 -0000 1.2 @@ -9,7 +9,7 @@ # # Adrian Chadd # -# $Id: build-cfg-help.pl,v 1.1 2007/05/13 12:18:00 adrian Exp $ +# $Id: build-cfg-help.pl,v 1.2 2007/05/13 12:34:31 adrian Exp $ # # The template file is reasonably simple to parse. There's a number of @@ -39,18 +39,38 @@ # bits, which we can use in the top-level index page. Nifty! # +# XXX NAME: can actually have multiple entries on it; we should generate +# XXX a configuration index entry for each, linking back to the one entry. +# XXX I'll probably just choose the first entry in the list. + # # This code is ugly, but meh. We'll keep reading, line by line, and appending # lines into 'state' variables until the next NAME comes up. We'll then # shuffle everything off to a function to generate the page. my ($state) = ""; +my ($path) = "/tmp"; my ($name, $doc, $nin, @nocomment, $type, $default, $ifdef, $comment, $loc); my ($default_if_none); +my (@names); +# +# Yes yes global variables suck. Rewrite it if you must. +# sub generate_page() { + # XXX should make sure the config option is a valid unix filename! + my ($fn) = $path . "/" . $name . ".html"; + + my ($fh) = new IO::File; + $fh->open($fn, "w") || die "Couldn't open $fn: $!\n"; + + print $fh "name: $name\n"; + print $fh "default value: $default\n"; + print $fh "default if none: $default_if_none\n"; + close $fh; + undef $fh; } while (<>) { @@ -58,7 +78,7 @@ next if (/^$/); if ($_ =~ /^NAME: (.*)$/) { # If we have a name already; shuffle the data off and blank - if ($name ne "") { + if (defined $name && $name ne "") { generate_page(); } $name = $1; @@ -72,6 +92,7 @@ $loc = ""; $comment = ""; $default_if_none = ""; + unshift @names, $name; print "DEBUG: new section: $name\n"; } elsif ($_ =~ /^COMMENT: (.*)$/) { $comment = $1;