home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
-
- require "parsehtm.pl";
-
- sub directiveHandler
- {
- local($tagString,$argString,$endString,%tagDict)
- = @_;
-
- local($retVal,$type,$endTag,$handler);
-
- $type = $tagDict{"TYPE"};
-
- #We are going to handle directives like tags
- # But the handlers are registered with their type
- # prepended by a directive.
-
- $type = "directive.".$type;
-
- # Look for an end tag. These are registered in the %endTags
- # global associative array.
-
- $endTag = $endTags{$type};
-
- # Look for a handler subroutine for the directive type.
- # These are registered in the %handlerDict global
- # associative array.
-
- $handler = $handlerDict{$type};
-
- # If no handler is found, remove the directive
-
- if(!($handler))
- {
- $retVal = "";
-
- return $retVal;
- }
-
- # If the tag wants the data to the end of the line
- # use mainHtmlParser to read to the end of the line, then
- # call the tag's handler subroutine with the data to the
- # end of the line.
-
- if($endTag eq "eol") # Tag that needs data to eol
- {
- $argString = &mainHtmlParser("","\n");
-
- $evalString = "&".$handler.'($tagString,$argString,0,%tagDict);';
- }
- elsif($endTag) # Tag with an end tag
- {
- # Use mainHtmlParser to read any text, up to
- # the end tag. Remove the end tag from the sting.
- #
- $argString = &mainHtmlParser($endTag,0);
- $argString =~ s/<.*>$//; # Remove the end tag
-
- # Call the tag's handler
- $evalString = "&".$handler.'($tagString,$argString,$endTag,%tagDict);';
- }
- else
- {
- #For unary tags, simply call the handler.
- $evalString = "&".$handler.'($tagString,0,0,%tagDict);';
- }
-
- $retVal = eval($evalString);
-
- return $retVal
- }
-
- $handlerDict{"DIRECTIVE"} = "directiveHandler";
-
- sub toolbarHandler
- {
- local($tagString,$argString,$endString,%tagDict)
- = @_;
- local($retVal);
-
- $retVal = "<INPUT TYPE=\"SUBMIT\" NAME=\"toolbar\" VALUE=\"Previous\">\n";
- $retVal .= "<INPUT TYPE=\"SUBMIT\" NAME=\"toolbar\" VALUE=\"First\">\n";
- $retVal .= "<INPUT TYPE=\"SUBMIT\" NAME=\"toolbar\" VALUE=\"Index\">\n";
- $retVal .= "<INPUT TYPE=\"SUBMIT\" NAME=\"toolbar\" VALUE=\"Next\">\n";
- $retVal .= "<P>";
-
- return $retVal;
- }
-
- $handlerDict{"directive.toolbar"} = "toolbarHandler";
-
- 1;
-
-
-
-
-