#include #include #include #include #include "cgl.h" #define BUFFER_SIZE 100 // Generate a html message void HTMLMessage(const char* msg) { //First Headers printf("Content-type: text/html\n"); printf("\n"); //Body of html printf("\n"); printf("Thank You"); printf("\n"); printf("

%s


\n", msg); //printf("

Home

\n"); printf("\n"); return; } // Generate a html message, and then exit void HTMLErrorMessage(const char* msg) { HTMLMessage(msg); exit(1); } int main(int argc, char **argv) { char *ID, *RESERVE, *DLINE, *BID, *USER; double reserve, bid; char buf[BUFFER_SIZE]; //Initialize cgl's data structures if (cgl_init() == -1) HTMLErrorMessage("Something is wrong."); //Get the user name, it is stored in environment variable //REMOTE_USER USER = cgl_getenv("REMOTE_USER"); //Extract form data ID = cgl_getvalue("ID"); RESERVE = cgl_getvalue("RESERVE"); DLINE = cgl_getvalue("DLINE"); BID = cgl_getvalue("BID"); reserve = atof(RESERVE); bid = atof(BID); if (bid >= reserve) sprintf(buf, "User %s bid $%s on item %s. Reserve met.", USER, BID, ID); else sprintf(buf, "User %s bid $%s on item %s. Reserve not met.", USER, BID, ID); //Everything works out. Generate the reply HTML HTMLMessage(buf); //Free data structures used by cgl cgl_freeall(); }