chiark / gitweb /
Basic parsing/outputting done.
authorijackson <ijackson>
Mon, 21 Jun 1999 13:43:01 +0000 (13:43 +0000)
committerijackson <ijackson>
Mon, 21 Jun 1999 13:43:01 +0000 (13:43 +0000)
.cvsignore [new file with mode: 0644]
bcp5-registry.pl
config.pl
database.pl [new file with mode: 0644]
template.html

diff --git a/.cvsignore b/.cvsignore
new file mode 100644 (file)
index 0000000..b8ed2a7
--- /dev/null
@@ -0,0 +1 @@
+t.html
index 887b553d1395756da6e4e6f5053d306dcbca51ae..e9135825c025db167b2083e94bd96d8adf6637f0 100755 (executable)
@@ -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("<!-- $level $doing $_ -->");
+       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("<!-- $level $doing $do $q $v $_ -->");
+           }
            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("<!-- setvars_area @areas $area_i $area -->");
+}
+
+sub foreach_start_db { }
+sub foreach_cond_db { 0; }
+sub foreach_setvars_db { }
+sub foreach_incr_db { }
index 6fae0d13264bebf3dfff4dbc2ae43ba43102993c..2a16b3baf39da030d4e1de22d80fc9b1680ac9cf 100644 (file)
--- 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 (file)
index 0000000..a85cd67
--- /dev/null
@@ -0,0 +1,5 @@
+#
+
+sub database () { }
+
+1;
index dfa7e0a423ae65ddc25d0b0783f2258f09ed27e1..55f7048721e0c1f50afb5aa02b201a54378c4885 100644 (file)
@@ -9,7 +9,7 @@
 
 @@@if:picked@@@
 @@@net@@@ picked
-@@@endif
+@@@endif:@@@
 
 @@@if:details@@@
 details of @@@name@@@
@@ -142,7 +142,7 @@ the entry.
 
 @@@if:details|fulldetails@@@
 <h2>Entry details</h2>
-@@@endif
+@@@endif:@@@
 
 @@@if:created@@@
 <h2>Entry created</h2>
@@ -176,34 +176,36 @@ Network range:
 <br>
 
 Network name:
-<input type=text name="name" size=70 value="@@@name@@@"><br>
+<input type=text name="name" size="@@@nameboxlen@@@" value="@@@name@@@"><br>
 
-@@@if:showemail@@@
+@@@ifnot:hiddenemail@@@
 Contact email address:
 @@@endif:@@@
-@@@ifnot:showemail@@@
+@@@if:hiddenemail@@@
 Contact email address hidden.
 New address:
 @@@endif:@@@
-<input type=text name="email" size="70" value="@@@email@@@">
+<input type=text name="email" size="@@@emailboxlen@@@" value="@@@email@@@">
 <br>
 
 <input type=checkbox name="hide" value="yes" @@@emailhidechecked@@@>
 Hide email address from public database.
 
-<p>
-
 @@@if:registernew|picked@@@
 <input type=submit name="register" value="Register">
 @@@endif:@@@
 
 @@@if:details|fulldetails|created|updated@@@
+<p>
+
 Entry created: @@@datecreated@@@<br>
 Last update: @@@datechanged@@@<br>
 Confirmed/renewed: @@@dateconfirmed@@@
 @@@endif:@@@
 
 @@@if:details@@@
+<p>
+
 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: <br>
@@ -249,14 +251,14 @@ from
 
 @@@foreach:area@@@
 
-<input type=radio name=from value="@@@area_string@@@" @@@area_pickchecked@@@>
-@@@area_string@@@
+<input type=radio name=from value="@@@area@@@" @@@area_pickchecked@@@>
+@@@area@@@
 @@@if:area_recommended@@@
 <em>recommended</em>
-@@@endif
+@@@endif:@@@
 <br>
 
-@@@endforeach@@@
+@@@endforeach:@@@
 
 @@@ifnot:picked@@@
 <input type=submit name="pick" value="Pick network">
@@ -267,7 +269,7 @@ from
 
 </form>
 
-@@@endif@@@
+@@@endif:@@@
 
 
 @@@if:notfound@@@
@@ -281,16 +283,15 @@ registry administrator, @@@adminemail@@@, quoting identifier @@@id@@@.
 @@@endif:@@@
 
 
-@@@ifnot:notfound@@@
+@@@if:view@@@
 
 <h2>View database</h2>
 
-<form>
+<form method="GET" action="@@@cgi@@@">
 
 @@@ifnot:viewingall@@@
 
 <input type=submit name="viewall" value="Entire database">
-<p>
 
 @@@endif:@@@
 
@@ -299,24 +300,25 @@ registry administrator, @@@adminemail@@@, quoting identifier @@@id@@@.
 @@@foreach:area@@@
 
 @@@ifnot:area_viewing@@@
-<input type=submit name="viewarea" value="@@@area_string@@@">
+<input type=submit name="viewarea" value="@@@area@@@">
 @@@endif:@@@
 @@@if:area_viewing@@@
-@@@area_string@@@
+@@@area@@@
 @@@endif:@@@
-<p>
+<br>
 
 @@@endforeach:@@@
 
 @@@endif:@@@
 
-
+@@@if:view@@@
 <h3>Entries overlapping with</h3>
 
 <input type=text name="with" value="@@@viewoverlap@@@" size="30">
 <input type=submit name="viewoverlap" value="Search">
 
 </form>
+@@@endif:@@@
 
 @@@if:viewingall|viewingoverlap|viewingarea@@@
 
@@ -331,7 +333,7 @@ Entries which overlap with @@@viewoverlap@@@
 @@@endif:@@@
 @@@if:viewingarea@@@
 Database for entries allocated from @@@viewarea@@@
-@@@
+@@@endif:@@@
 </h3>
 
 @@@if:picked@@@
@@ -342,8 +344,6 @@ The range picked for you has been <em>emphasized</em> below.
 You can get details about an existing entry by clicking on its address
 range; this can also be used to modify it.
 
-@@@endif:@@@
-
 <table>
 <tr><td>Range <td>Name <td>Contact email
 </tr><br>