CGIs
the simplest of libhtdb-driven programs have the following as
programmatic structure, and need to be compiled against
libhtdb.a.
here is the source code for main() of htdb itself.
/*
This software (HTDB and its components)
Copyright 1994-2024 David Whittemore del-at-htdb.org
*/
#include "htdb.h"
/*
the application information structure
*/
appinfo_t appinfo = {
/* the application name */
"htdb",
/* the application version */
"1.2.3",
/* command-line usage information */
"this program utilizes the built-in handler "
"to process .htdb documents. \n\n"
"in short, URI strings of the form \n"
"\t /htdb/site/index.html \n\n"
"are parsed into the values of "
"`db'=site and `page'=index.html \n\n"
"the `db'.htdb file is then processed "
"and we spit out what document \n"
"we find defined for `page'.",
/* initial htdb values */
"",
/* address of handler function */
htdb_page_handler,
/* serve this many pages per fastCGI loop */
FCGI_KEEPALIVE
};
int main(int argc, char **argv)
{
exit (htdb_main(argc, argv, &appinfo));
}
|
observations:
-
note that all work is actually performed in
htdb_main() ,
so there's not a whole lot to look at in such a simple program.
-
the 1st and 2nd arguments allow access to standard UNIX command line
parameters. these values are only available when running
libhtdb-based applications from the command line, otherwise, they are
not used, since the webserver process does not make them available.
when processed, the values will be available via the `argv[]->name' and `argv[]->value'
resource structures. `argv->numResults' will contain the result count.
typedef struct {
char *name,
*version,
*description,
*args;
void (*func)(void);
int fcgi_keepalive;
} appinfo_t;
|
-
the 3rd argument is a pointer to the
appinfo control structure,
whose elements are described below.
del - Wed Aug 15 22:14:00 PDT 2001
|