Index: trunk/ippMonitor/generate
===================================================================
--- trunk/ippMonitor/generate	(revision 11490)
+++ trunk/ippMonitor/generate	(revision 13264)
@@ -14,4 +14,5 @@
 # @headcode, @tailcode                 : additional HTML or PHP code before or after table
 # @field, @width, @name, @show, @link, @extras : properties of each table column
+# @imagedefs, %image: array of image defines
 
 &parse_schema;
@@ -61,4 +62,14 @@
  	if ($key eq "HEAD") {
 	    push @headcode, $value;
+	}
+
+	# the IMAGE commands sets up a reference name
+	if ($key eq "IMAGE") {
+	    push @imagedefs, $value;
+	}
+
+	# the IMAGE commands sets up a reference name
+	if ($key eq "ARGS") {
+	    push @linkargs, $value;
 	}
 
@@ -94,4 +105,12 @@
     &define_where_string (@where);
 
+    foreach $linkarg (@linkargs) {
+	&parse_linkarg ($linkarg);
+    }
+
+    foreach $imagedef (@imagedefs) {
+	&parse_imagedef ($imagedef);
+    }
+
     if (0) {
 	print STDERR "show: $show[0]\n";
@@ -220,5 +239,5 @@
 	    printf FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
 	    # add extra GET data to target
-	    if ($extras[$i]) { &parse_extras ($extras[$i]); } 
+	    if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 
 	    # print the actual table cell line with the link...
 	    if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; }
@@ -229,5 +248,5 @@
 	if (($label eq "image") && !$link[$i]) {
 	    # print the actual table cell line with the image...
-	    printf FILE "  echo \"<td class=\\\"list\\\"><img src=\\\"getimage.php?name=$value\\\"></td>\\n\";\n";
+	    printf FILE "  echo \"<td class=\\\"list\\\"><img src=\\\"$image{$value}\\\"></td>\\n\";\n";
 	    next;
 	}
@@ -237,7 +256,7 @@
 	    printf FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
 	    # add extra php data to target
-	    if ($extras[$i]) { &parse_extras ($extras[$i]); } 
+	    if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 
 	    # print the actual table cell line with the link...
-	    printf FILE "  echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> <img src=\\\"getimage.php?name=$value\\\"> </a></td>\\n\";\n";
+	    printf FILE "  echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> <img src=\\\"$image{$value}\\\"> </a></td>\\n\";\n";
 	    next;
 	}
@@ -314,4 +333,19 @@
 	printf FILE "  \$link = \$link . \"&$outline\";\n";
     }
+}
+
+# each linkarg is an entry of the form "word name=value"
+# the entries for matching words are concatenated together
+# separated by commas to create the value $linkarg{word}
+sub parse_linkarg {
+    my ($word, $value);
+
+    ($word, $value) = split (" ", $_[0]);
+
+    if ($linkarg{$word}) {
+	$linkarg{$word} = "$linkarg{$word},$value";
+    } else {
+	$linkarg{$word} = $value;
+    }	
 }
 
@@ -360,4 +394,47 @@
 }
 
+# given a variable of the form $fieldname, return the corresponding
+# row entry in the form $row[N], otherwise return $fieldname
+# globals: field (list of field names), count (list of sequence)
+sub parse_fieldname {
+    my ($variable) = $_[0];
+    my ($i);
+    
+    unless ($variable =~ m|^\$|) {
+	return $variable;
+    }
+
+    $fieldname = substr ($variable, 1);
+
+    print STDERR "fieldname: $fieldname\n";
+
+    for ($i = 0; $i < @field; $i++) {
+	print STDERR "$i: $field[$i] : $fieldname\n";
+
+	if ($field[$i] eq "*") { next; }
+	if ($fieldname ne $field[$i]) { next; }
+
+
+	$Nrow = $count[$i];
+
+	$value = "\$row[$Nrow]";
+
+	print STDERR "found : $i : $count[$i] : $Nrow : $value\n";
+	return $value;
+    }
+    return $variable;
+}
+
+sub parse_imagedef {
+    my ($value) = $_[0];
+
+    ($var, $name, $rule, $camera, $class) = split (" ", $value);
+    $name   = &parse_fieldname ($name);
+    $camera = &parse_fieldname ($camera);
+    $class  = &parse_fieldname ($class);
+    $image{$var} = "getimage.php?name=$name&rule=$rule&camera=$camera&class_id=$class";
+    return 1;
+}
+
 sub init_key {
     my ($key)   = $_[0];
