| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflhttp.h" int cgi_parse_file_vars ( SYMTAB *symtab, FILE *file, const char *prefix, size_t size)
Parses a CGI query string stored in a file, and loads the resulting variables into an existing symbol table, optionally prefixing each name with a string. Returns the number of variables loaded. The prefix can be NULL or empty if not required. The file data is assumed to be escaped (see http escape()); the data should not contain line breaks, spaces, or other unescaped chars. The file should already have been opened: a typical use for this function is to parse the values supplied in stdin. The maximum size for the file is CGI_QUERY_FILE_MAX characters.
{ /* Maximum size of a stream of HTTP query data coming from a file */ # define CGI_QUERY_FILE_MAX 65535U char *query; /* Data loaded from file */ size_t read_size; /* Amount of data read from file */ int variables = 0; /* Number of variables loaded */ ASSERT (file); ASSERT (symtab); ASSERT (size <= CGI_QUERY_FILE_MAX); if ((query = mem_alloc (size + 1)) == NULL) return (0); read_size = fread (query, 1, size, file); query [read_size] = '\0'; variables = cgi parse query vars (symtab, query, prefix); mem_free (query); return (variables); }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |