From: ijackson Date: Mon, 21 Jun 1999 13:43:01 +0000 (+0000) Subject: Basic parsing/outputting done. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=3ee4f4e14f4344e72127ab8b6d4204fe18297e3c;p=bcp5-registry.git Basic parsing/outputting done. --- diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..b8ed2a7 --- /dev/null +++ b/.cvsignore @@ -0,0 +1 @@ +t.html diff --git a/bcp5-registry.pl b/bcp5-registry.pl index 887b553..e913582 100755 --- a/bcp5-registry.pl +++ b/bcp5-registry.pl @@ -13,17 +13,46 @@ if ("$ARGV[1]" eq '--cgi') { } } +@areas= split(/ /,'10.0.0.0/8 172.16.0.0/12 192.168.0.0/16'); +$rec_area= '172.16.0.0/12'; + +$current_area= $rec_area; +$view_area= ''; +$viewoverlap= ''; + +$intro= 0; +$registernew= 0; +$pick= 0; +$details= 0; +$fulldetails= 0; +$created= 0; +$updated= 0; +$picked= 0; +$viewingall= 0; +$view= 1; +$notfound= 0; +$id= ''; +$name= ''; +$email= ''; +$emailhidechecked= 0; +$hiddenemail= 0; +$viewingarea= length $view_area; +$viewingoverlap= length $viewoverlap; + if ($in{'dbid'}) { database(); - $id= $in{$dbid}; + $id= $in{'dbid'}; if (!exists $db{$id}) { - $notfound= 1; - } else { + $notfound= 1; + $view= 0; + } else { $details= 1; getinfo(); } } else { $intro= 1; + $registernew= 1; + $pick= 1; } open X, "template.html" or die $!; @@ -34,28 +63,78 @@ $x[$#x] eq "\@\@\@eof:\@\@\@\n" or die $!; $#x--; $cl= 0; +$level= -1; process(1); +close STDOUT or die $!; + +sub out ($) { + print $_[0],"\n" or die $!; +} + sub process ($) { my ($doing) = @_; + my ($bcl); + $level++; for (;;) { return if $cl > $#x; $_= $x[$cl++]; s/\n$//; s/\s*$//; - return if m/^\@\@\@end\w+\:\@\@\@$/; +# out(""); + last if m/^\@\@\@end\w+\:\@\@\@$/; - if (m/^\@\@\@(if|ifnot):(\w+)\@\@\@$/) { - $v= $$2; - $do= $1 eq 'if' ? !!$v : !$v; + if (m/^\@\@\@(if|ifnot):([0-9a-z_|]+)\@\@\@$/) { + $q=$1; $v=$2; + $do= 0; + if ($doing) { + map { $do=1 if getvar($_); } split(/\|/,$v); + $do= !$do if $q eq 'ifnot'; +# out(""); + } process($doing && $do); - } elsif (m/^\@\@\@foreach\: + } elsif (m/^\@\@\@foreach\:(area|db)\@\@\@$/) { + if ($doing) { + $bcl= $cl; + for (&{"foreach_start_$1"}; + &{"foreach_cond_$1"}; + &{"foreach_incr_$1"}) { + &{"foreach_setvars_$1"}; + process($doing); + $cl= $bcl; + } + } + process(0); + } elsif (m/\S/) { + if ($doing) { + s/\@\@\@(\w+)\@\@\@/ getvar("$1") /ge; + out($_); } else { - - $do= $1 eq 'if' ? ${$2} : $$ - $ifnot= $1; - $v= eval $2; - - while ($i < $e) { - - -$i= process(0,$#x); + s/\@\@\@\w+\@\@\@//g; + } + die "$cl:unknown $_\n" if m/\@\@\@/; + } + } + $level--; +} + +sub getvar ($) { + my ($vn) = @_; + defined $$vn or die "$cl:undefined $vn\n$out"; + return $$vn; +} + +sub foreach_start_area { $area_i=0; } +sub foreach_cond_area { return $area_i < @areas; } +sub foreach_incr_area { $area_i++; } +sub foreach_setvars_area { + $area= $areas[$area_i]; + $area_recommended= $area eq $rec_area; + $area_pickchecked= $area eq $current_area ? 'checked' : ''; + $area_viewing= $area eq $viewing_area; + out(""); +} + +sub foreach_start_db { } +sub foreach_cond_db { 0; } +sub foreach_setvars_db { } +sub foreach_incr_db { } diff --git a/config.pl b/config.pl index 6fae0d1..2a16b3b 100644 --- a/config.pl +++ b/config.pl @@ -1,2 +1,5 @@ $whose= "Cambridge Geeks'"; -$adminemail= ;ijackson+cam-bcp5@chiark.greenend.org.uk'; +$adminemail= 'ijackson+cam-bcp5@chiark.greenend.org.uk'; +$nameboxlen= 55; +$emailboxlen= 55; +$cgi= 'http://www.chiark.greenend.org.uk/ucgi/~ijackson/bcp5-registry'; diff --git a/database.pl b/database.pl new file mode 100644 index 0000000..a85cd67 --- /dev/null +++ b/database.pl @@ -0,0 +1,5 @@ +# + +sub database () { } + +1; diff --git a/template.html b/template.html index dfa7e0a..55f7048 100644 --- a/template.html +++ b/template.html @@ -9,7 +9,7 @@ @@@if:picked@@@ @@@net@@@ picked -@@@endif +@@@endif:@@@ @@@if:details@@@ details of @@@name@@@ @@ -142,7 +142,7 @@ the entry. @@@if:details|fulldetails@@@

Entry details

-@@@endif +@@@endif:@@@ @@@if:created@@@

Entry created

@@ -176,34 +176,36 @@ Network range:
Network name: -
+
-@@@if:showemail@@@ +@@@ifnot:hiddenemail@@@ Contact email address: @@@endif:@@@ -@@@ifnot:showemail@@@ +@@@if:hiddenemail@@@ Contact email address hidden. New address: @@@endif:@@@ - +
Hide email address from public database. -

- @@@if:registernew|picked@@@ @@@endif:@@@ @@@if:details|fulldetails|created|updated@@@ +

+ Entry created: @@@datecreated@@@
Last update: @@@datechanged@@@
Confirmed/renewed: @@@dateconfirmed@@@ @@@endif:@@@ @@@if:details@@@ +

+ Use this to obtain your password. Passwords expire after a while; if you do not have a recent notification of your password, you should request a current password:
@@ -249,14 +251,14 @@ from @@@foreach:area@@@ - -@@@area_string@@@ + +@@@area@@@ @@@if:area_recommended@@@ recommended -@@@endif +@@@endif:@@@
-@@@endforeach@@@ +@@@endforeach:@@@ @@@ifnot:picked@@@ @@ -267,7 +269,7 @@ from -@@@endif@@@ +@@@endif:@@@ @@@if:notfound@@@ @@ -281,16 +283,15 @@ registry administrator, @@@adminemail@@@, quoting identifier @@@id@@@. @@@endif:@@@ -@@@ifnot:notfound@@@ +@@@if:view@@@

View database

-
+ @@@ifnot:viewingall@@@ -

@@@endif:@@@ @@ -299,24 +300,25 @@ registry administrator, @@@adminemail@@@, quoting identifier @@@id@@@. @@@foreach:area@@@ @@@ifnot:area_viewing@@@ - + @@@endif:@@@ @@@if:area_viewing@@@ -@@@area_string@@@ +@@@area@@@ @@@endif:@@@ -

+
@@@endforeach:@@@ @@@endif:@@@ - +@@@if:view@@@

Entries overlapping with

+@@@endif:@@@ @@@if:viewingall|viewingoverlap|viewingarea@@@ @@ -331,7 +333,7 @@ Entries which overlap with @@@viewoverlap@@@ @@@endif:@@@ @@@if:viewingarea@@@ Database for entries allocated from @@@viewarea@@@ -@@@ +@@@endif:@@@ @@@if:picked@@@ @@ -342,8 +344,6 @@ The range picked for you has been emphasized below. You can get details about an existing entry by clicking on its address range; this can also be used to modify it. -@@@endif:@@@ -
Range Name Contact email