Parser v 1.1 for NCSA httpd 1.0

This page describes parser routine working with NCSA World-Wide Web server httpd 1.0. New version of httpd uses CGI (Common Gateway Interface). You can see CGI examples here

Let us consider following (ruther silly) form example. We would like to read parameters specified in the form into the C program variables :

We should define proper variables in our C program, initialize them and then just call parser routine.

parser reads environment CGI variables (they are placed in cgi structure - see parser.h), reads standard input and also needs translation table.

In partab_t table you have to specify variables types their names in the form and ponters to them in C program. Each entry in this table consist of three following fields :

Table is terminated through entry with pointer to variable equal NULL. You can find here partab_t table for our example program.

Return value from parser function is less than zero if internal error occurs. In other case it is equal to number of variables read from the form.

If parser is sucessful you can easily use variables read from the form. You can make calculations with int, long and float variables or deal with separately mallocked strings (char *). You can even check boolean variables or deal with tables of strings.

Additionall feature is that you can use all CGI environment variables read from the environment. External variable cgi is declared in parser.h and defined in parser.c. All cgi values except SERVER_PORT and CONTENT_LENGTH(which are int type) are separately mallocked strings (char *).

Now look for the working version of form and C program or look at the sources :

parser
parser.h
parser.c
form exmaple
example.html
example.c
You can also get tar file containing sources if you press here.

If you have any suggestions or comments press this.


This document is placed at FUW (Physics Department of Warsaw University). If you want to go to our home page press this.
Kacper Nowicki (kacper@fuw.edu.pl) - 94.01.18