"); sprintf (sql_msg, str_buf, sqlca.sqlerrm); cgi_print_text (sql_msg); cgi_print_text (""); } } /* See if there's an ISAM error code and message to print */ if (sqlca.sqlerrd [1] != 0) { sprintf (str_buf, "ISAM ERROR = %d \n", sqlca.sqlerrd [1]); cgi_print_text (str_buf); if (rgetlmsg (sqlca.sqlerrd [1], sql_msg, 2048, &msg_len) == 0) { cgi_print_text ("
"); cgi_print_text (sql_msg); cgi_print_text (""); } } /* Rollback any transactions that were in progress */ $ WHENEVER SQLERROR CONTINUE; $ WHENEVER SQLWARNING CONTINUE; $ ROLLBACK WORK; /* Exit program */ exit (0); } /************************************************************************/ /* */ /* FUNCTION: main AUTHOR: Tim Sabin/Matthew Eichler */ /* DESCRIPTION: main controls what this CGI program does. If the user */ /* has requested this form for the first time, an empty form will be */ /* displayed. Otherwise, either an appropriate SELECT or INSERT */ /* statement will be generated, and the results will be displayed. */ /* DATE CREATED: 06/07/1995 LAST UPDATED: 10/14/1996 */ /* */ /************************************************************************/ main (int argc, char **argv) { FILE *uid; char *user, line [81], *linePtr, *name, *token, *ptr; int uidNo; /* Change the user ID according to the user name */ sprintf (line, "/netscape_docs/cgi-bin/%c-log.log", argv [0][0]); log = fopen (line, "a"); /* Find out our user ID */ uid = fopen ("/etc/passwd", "r"); for (linePtr = fgets (line, 80, uid); linePtr; linePtr = fgets (line, 80, uid)) { name = strtok (line, ":"); token = strtok (NULL, ":"); token = strtok (NULL, ":"); if (atoi (token) == getuid ()) break; } fclose (uid); strcpy (nameSav, name); /* IF this is the 1st time through (the userID is netscape) THEN */ if (!strcmp (name, "netscape")) { /* Make sure that anyone can write to the log */ fchmod (fileno (log), 0666); /* Find out the UNIX user name */ uid = fopen ("/netscape_docs/etc/passwd", "r"); for (linePtr = fgets (line, 80, uid); linePtr; linePtr = fgets (line, 80, uid)) { name = strtok (line, ":"); if (!strcmp (name, getenv ("REMOTE_USER"))) break; } fclose (uid); token = strtok (NULL, ":"); token [strlen (token) -1] = '\0';/* Get rid trailing newline */ /* Clean up */ /* Change user ID through an intermediate process */ execl ("/netscape_docs/./etc/./para", "/netscape_docs/./etc/./para", "-d", ".", "-lrm", token, "rte", "-f", argv [0], NULL); /* ENDIF */ } /* Always send the content type first so CGI will know what you're sending*/ cgi_mimetype ("text/html"); /* Get things started */ if (cgi_start () != 0) htmlErrorMsg (); sprintf (m_script_name, "\"%s\"", cgi_env.script_name); if (informixEnv ()) htmlErrorMsg (); $ WHENEVER SQLERROR CALL htmlErrorMsg; $ DATABASE LED; /* How were we called? "GET" & No Query means 1st fetch. Else, should be */ /* "POST". Anything else is an error. */ if ((strncasecmp (cgi_env.request_method, "GET", 3) == 0) && (cgi_env.query_string [0] == NULL)) { createForm (NEW_FORM); } else if (strncasecmp (cgi_env.request_method, "POST", 4) == 0) { evaluateForm (); } else htmlErrorMsg (); $ CLOSE DATABASE; cgi_free (); fclose (log); return; } /************************************************************************/ /* */ /* FUNCTION: boldPrint AUTHOR: Tim Sabin */ /* DESCRIPTION: Print the passed message in bold print. */ /* DATE CREATED:09/03/1996 LAST UPDATED: 09/03/1996 */ /* */ /************************************************************************/ void boldPrint (char *msg) { cgi_print_text (""); cgi_print_text (msg); cgi_print_text (""); } /************************************************************************/ /* */ /* FUNCTION: htmlTitle AUTHOR: Tim Sabin */ /* DESCRIPTION: Issue the HTML for the browser and page titles. */ /* DATE CREATED: 08/28/1996 LAST UPDATED: 09/20/1996 */ /* */ /************************************************************************/ void htmlTitle (char *brTitle, char *backFile, char *iconFile, char *pgTitle1, char *pgTitle2) { cgi_print_text ("\n
| \n");
if (iconFile) {
cgi_print_text (" | \n");
cgi_print_text ("");
cgi_print_text (pgTitle1);
if (pgTitle2) {
cgi_print_text (" \n"); cgi_print_text (pgTitle2); } cgi_print_text (" |