home *** CD-ROM | disk | FTP | other *** search
-
- #include "parsehtm.h"
- #include <stdio.h>
-
- void formHandler(String ts,String as,String et,Dictionary td)
- {
- String value = 0;
-
- /* Find the current method if it exists */
-
- value = dict_valueForKey(td,"METHOD");
-
- if(value)
- {
- string_setStringValue(value,"POST");
- }
- else/* No method, so add one */
- {
- value = string_alloc(5);
- string_setStringValue(value,"POST");
- dict_setValueForKey(td, "METHOD",value);
- }
-
- /* Find the current action if it exists */
- value = dict_valueForKey(td,"ACTION");
-
- if(value)
- {
- string_setStringValue(value,"form");
- }
- else /* No action, so add one */
- {
- value = string_alloc(5);
- string_setStringValue(value,"form");
- dict_setValueForKey(td, "ACTION",value);
- }
-
- /* Build a new tag string, and reset the old one to it */
-
- value = stringForTagDict(td);
-
- if(value)
- {
- string_setStringValue(ts,value->string);
-
- string_free(value);
- }
- }
-
- /* Test script */
-
- void main(int argc, char *argv[])
- {
- String output;
-
- /* Always do this first */
- initializeHtmlParsingLibrary();
-
- /* Register the handler */
- dict_setValueForKey(handlerDict,"FORM",formHandler);
-
- /* Parse the html file */
- output = parseHtml("f2_c.htm");
-
- /* Output the parsed data */
- if(output && output->string)
- {
- printf("Content-type: text/html\n\n");
- fwrite(output->string,sizeof(char),strlen(output->string),stdout);
- printf("\n");
-
- string_free(output);
- }
-
- exit(0);
- }
-
-