APPENDICES SECTION APPENDIX C

CGI written in C

/*

*cusc_block.c

*Description: sample C source code of CGI for customized block page

*Replace <ProxyBlocker IP> with real IP and recompile before using

*Revision: 1

*Date: 03/08/2004

*/

#include <stdio.h>

struct {

char *name; char *val;

} entries[20];

char szIP[16]; char szURL[1024]; char szUserName[1024]; char szCategory[8];

/*function prototypes*/ void printhtml();

void unescape_url(char *url); char x2c(char *what);

char *makeword(char *line, char stop); void plustospace(char *str);

char *fmakeword(FILE *f, char stop, int *cl); int to_upper(char *string);

void getquery(char *paramd, char **paramv); void getnextquery(char **paramv);

int main(int argc, char **argv)

{

int data_size; /* size (in bytes) of POST input */ int index;

char *paramd, *paramn, *paramv; char step[120];

printf("content-type: text/html\n\n");

/* If using the GET method */

if (strcmp((char *)getenv("REQUEST_METHOD"), "GET") == 0)

{

paramd = (char *)strdup((char *)getenv("QUERY_STRING")); getquery(paramd, ¶mv);

while (paramv)

{

plustospace(paramv);

8E6 TECHNOLOGIES, PROXYBLOCKER USER GUIDE

417

Page 431
Image 431
8e6 Technologies ProxyBlocker manual CGI written in C, Entries20