C CGI Example
[Geek Home] [PC Hints & Tips] [Internet] [Programming] [Nanet Sites]

This CGI performs a search on a flat file. This example can be altered to be used with any flat file data. You can get an idea of how to do this with your own flat file by reviewing the code and form. This CGI was written for a local University to return flat file results from a search.

For a more powerful data source, such as Oracle or DB2, see my Java Database Applet example.

All *.c source extensions have been changed to *.txt.

To begin, I utilized NCSA’s code segment provided in the sample program “util.c” I separated this CGI specific code into a file called cgi_lib.c:

cgi_lib.c
Following is the cgi_lib.h:

// #include "cgi_lib.h"
char x2c(char *);
void unescape_url(char *);
char **getcgivars() ;
void printSearch(char **);

I then created some string and HTML functions in str_lib.c:
str_lib.c
Following is the str_lib.h:

// #include "str_lib.h"

void stripquote(char *) ;
void trim( char * );
char * str_toupper(char *) ;

// HTML commands:

void printHeader(char *);
void printFooter(void);
void htmlPre(void);
void htmlPreOff(void);

And finally, I created the actual s_srch.c file containing the “main” and all necessary procedures and functions to return the dynamic web page results:
s_srch.c

Picture
 Source  Java Code  C CGI  JavaScript  Java DBF  VAJava & DB2
[Geek Home] [PC Hints & Tips] [Internet] [Programming] [Nanet Sites]

Modified: 02/11/99

Picture