/* parser v 1.1 * Kacper Nowicki (Kacper.Nowicki@fuw.edu.pl), 1994 */ /* Variables types */ #define PARSER_BOOL 1 /* (int) */ #define PARSER_CHAR 2 /* (char) */ #define PARSER_STRING 3 /* (char *) */ #define PARSER_MULTIS 4 /* (char **) */ #define PARSER_INT 5 /* (int) */ #define PARSER_LONG 6 /* (long) */ #define PARSER_FLOAT 7 /* (float) */ #define PARSER_FD 0 /* File descriptor for input stream */ /* Structure for CGI environment variables */ typedef struct { char *SERVER_SOFTWARE; /* Name/version of WWW server */ char *SERVER_NAME; /* Server's hostname or IP address*/ char *GATEWAY_INTERFACE; /* CGI/revision */ char *SERVER_PROTOCOL; /* Protocol/revision */ int SERVER_PORT; /* Number of port */ char *REQUEST_METHOD; /* ex. "GET", "POST" */ char *HTTP_ACCEPT; /* MIME types accepted by client */ char *PATH_INFO; /* Extra PATH added to virtual */ char *PATH_TRANSLATED; /* Physical path */ char *SCRIPT_NAME; /* Virtual path to the script */ char *QUERY_STRING; /* Information following ? in the URL*/ char *REMOTE_HOST; /* Client hostname */ char *REMOTE_ADDR; /* Client IP address */ char *AUTH_TYPE; /* Authentication method */ char *REMOTE_USER; /* User name - authenticated scripts */ char *CONTENT_TYPE; /* Content type */ int CONTENT_LENGTH; /* Length of the content */ } cgi_t; typedef struct /* Parser input table entry */ { void *varptr; /* Pointer to variable */ char *varname; /* Name of the variable */ int vartype; /* variable type */ } partab_t; /* Structure containing CGI environment variables */ extern cgi_t cgi; /* This function reads standard input and gets table. * Environment (readen through getenv) is needed for CGI variables * (command line arguments are no longer needed) * * Table is terminated by entry with varptr == NULL * * If varname is not found, variable value is not changed * If varname is found and value is empty, 0 or NULL is set * * Length of standard input is taken from CGI CONTENT_LENGTH variable * * Boolean variables (int) are set to 1 if the variable with given * name is found. Variable value is ignored. * * Char is taken as first character from the string (rest is ignored) * * String variables are mallocked separately, so you can free * any of them. * * Multi string variables (for <select multiple> HTML command) * are also mallocked separately. char ** table entries point to * separately mallocked strings. Initial value of such a variable * have to be (!) NULL. * * Numbers are readen as long as they are valid and rest is ignored. * */ extern int parser(partab_t *table);