diff -u2 src.working/citation.c src/citation.c --- src.working/citation.c Mon Sep 11 22:28:39 1995 +++ src/citation.c Wed Sep 20 12:16:56 1995 @@ -145,7 +145,5 @@ read_one_citation (FILE *fp) { - char line[STRING_SIZE]; int retval; - char *s; CitationPtr C; char author[STRING_SIZE]; @@ -240,5 +238,5 @@ if (C->author) { s1 = C->author; - while (s2 = strchr(s1, ';')) { + while ((s2 = strchr(s1, ';'))) { *s2 = '\0'; fprintf (fp, "%%%c %s\n", REF_AUTHOR, s1); diff -u2 src.working/com-util.c src/com-util.c --- src.working/com-util.c Mon Sep 11 22:32:38 1995 +++ src/com-util.c Wed Sep 20 09:19:46 1995 @@ -1,4 +1,7 @@ #include +#include +#include #include +#include #include #include @@ -22,5 +25,4 @@ char buf[STRING_SIZE]; int status = 0; - int oldMask; /* open dst file as techrep */ @@ -125,15 +127,14 @@ int get_semaphore(char *semaphore_file) { - FILE *sem_fp; - if ((creat(semaphore_file,0000))==-1) sleep(2); - else return; + else return 0; if ((creat(semaphore_file,0000))==-1) sleep(2); - else return; + else return 0; if ((creat(semaphore_file,0000))==-1) sleep(2); - else return; + else return 0; if ((creat(semaphore_file,0000))==-1){ return(ERROR); } + return 0; } @@ -144,4 +145,5 @@ { unlink (semaphore_file); + return 0; } @@ -173,5 +175,5 @@ strcpy(array[x], ptr); while ((tmp = strchr(array[x], LINE_BREAK)) != NULL) - *tmp = NULL; /* remove `;' and '\n' from author */ + *tmp = '\0'; /* remove `;' and '\n' from author */ ptr = strchr(ptr, LINE_BREAK) + 1; } diff -u2 src.working/make_readme.c src/make_readme.c --- src.working/make_readme.c Tue Aug 29 16:54:18 1995 +++ src/make_readme.c Wed Sep 20 09:07:33 1995 @@ -21,5 +21,7 @@ #include #include +#include #include +#include #include "techrep.h" #include "sitespec.h" @@ -27,4 +29,5 @@ #include "citation.h" #include "make_readme.h" +#include "com-util.h" @@ -504,5 +507,4 @@ char citDbase[STRING_SIZE]; char reportDir[STRING_SIZE]; - char command[STRING_SIZE]; char indexName[STRING_SIZE]; char tmpName[STRING_SIZE]; @@ -519,5 +521,5 @@ /* create index in tmp file */ strcpy(citDbase, getCitationDataFilePath()); - sprintf(tmpName, "/tmp/%d-readme-tmp", getpid()); + sprintf(tmpName, "/tmp/%d-readme-tmp", (int)getpid()); make_formatted_citation_list(citDbase, tmpName); diff -u2 src.working/masterform.c src/masterform.c --- src.working/masterform.c Tue Sep 19 14:59:16 1995 +++ src/masterform.c Wed Sep 20 12:15:33 1995 @@ -1,5 +1,7 @@ #include +#include #include #include +#include #include #include "util.h" @@ -36,7 +38,8 @@ void tr_browse(); void techrep_menu_htmlform(); -int sendTechrepRequest(int methodID, char *tempFilename, char* trLocation); +void sendTechrepRequest(int methodID, char *tempFilename, char* trLocation); void printConfirmation (int methodID); +int main(int argc, char *argv[]) { @@ -280,5 +283,6 @@ techrep_menu_htmlform(); } - exit(0); + + return (0); } @@ -353,13 +357,5 @@ FILE *fp; char browsePage[MAX_COMMANDLINE]; - char tempfile[MAX_COMMANDLINE]; - char *passed_file; - char getdb_command[MAX_COMMANDLINE]; - char convert_command[MAX_COMMANDLINE]; - char permission_command[MAX_COMMANDLINE]; - int set_temp_permissions; - signed int tr_getdb_answer; - /* Theoretically, the interface is not supposed to know where */ /* the browse page is, it should get the info from techrep. */ @@ -381,8 +377,4 @@ tr_bulkload() { - char bulkload_command[MAX_COMMANDLINE]; - - signed int answer; - /* if there is no filepath, show the form again */ if (!C->filepath) { @@ -415,5 +407,4 @@ tr_single_view() { - register int x; FILE *fp; char tempfile[MAX_COMMANDLINE]; @@ -421,6 +412,4 @@ char get_command[MAX_COMMANDLINE]; - char permission_command[MAX_COMMANDLINE]; - int set_temp_permissions; signed int tr_get_answer; @@ -446,5 +435,5 @@ else { /*create and open a temporary file to send to techrep*/ - sprintf (tempfile, "/tmp/techrep%d.XXXXXX", getpid()); + sprintf (tempfile, "/tmp/techrep%d.XXXXXX", (int)getpid()); mktemp(tempfile); passed_file = strdup(tempfile); @@ -511,18 +500,9 @@ trdelete() { - register int x; FILE *fp; - FILE *fp2; char tempfile[MAX_COMMANDLINE]; char *passed_file; - char get_command[MAX_COMMANDLINE]; - char delete_command[MAX_COMMANDLINE]; - char permission_command[MAX_COMMANDLINE]; - int set_temp_permissions; - signed int tr_get_answer; - signed int tr_delete_answer; - /* if there is no TR num, show the form again */ if (!C->trId) { @@ -546,5 +526,5 @@ else { /*create and open a temporary file to send to techrep*/ - sprintf (tempfile, "/tmp/techrep%d.XXXXXX", getpid()); + sprintf (tempfile, "/tmp/techrep%d.XXXXXX", (int)getpid()); mktemp(tempfile); passed_file = strdup(tempfile); @@ -576,18 +556,8 @@ trpost_query() { - register int x; - FILE *fp; char tempfile[MAX_COMMANDLINE]; char *passed_file; - char list_array[N_STRINGS][STRING_SIZE]; - int listCount; - - char post_command[MAX_COMMANDLINE]; - char permission_command[MAX_COMMANDLINE]; - int set_temp_permissions; - signed int tr_post_answer; - /* Submit for Posting */ if (!(strcmp(choice,"Submit for Posting"))) { @@ -622,5 +592,5 @@ else { /*create and open a temporary file to write to*/ - sprintf (tempfile, "/tmp/techrep-%d.XXXXXX", getpid()); + sprintf (tempfile, "/tmp/techrep-%d.XXXXXX", (int)getpid()); mktemp (tempfile); passed_file = strdup(tempfile); @@ -801,17 +771,8 @@ trpost_update() { - register int x; FILE *fp; char tempfile[MAX_COMMANDLINE]; char *passed_file; - char list_array[N_STRINGS][STRING_SIZE]; - int listCount; - - char update_command[MAX_COMMANDLINE]; - char permission_command[MAX_COMMANDLINE]; - int set_temp_permissions; - signed int tr_update_answer; - /* Submit for RePosting */ if (!(strcmp(choice,"Submit for RePosting"))) { @@ -846,5 +807,5 @@ char *tempname; /*create a temporary file to write to*/ - sprintf (tempfile, "/tmp/techrep%d.XXXXXX", getpid()); + sprintf (tempfile, "/tmp/techrep%d.XXXXXX", (int)getpid()); mktemp(tempfile); passed_file = strdup(tempfile); @@ -857,8 +818,8 @@ fprintf (fp, "Comments: %s\n", comments); - if (tempname=getenv("REMOTE_HOST")) + if ((tempname=getenv("REMOTE_HOST"))) fprintf (fp, "Remote host: %s\n", tempname); - if (tempname=getenv("REMOTE_IDENT")) + if ((tempname=getenv("REMOTE_IDENT"))) fprintf (fp, "Remote ident: %s\n", tempname); @@ -912,6 +873,4 @@ trupdate() { - register int x; - FILE *fp; char tempfile[MAX_COMMANDLINE]; @@ -919,8 +878,5 @@ char get_command[MAX_COMMANDLINE]; - char permission_command[MAX_COMMANDLINE]; - int set_temp_permissions; signed int tr_get_answer; - signed int tr_update_answer; /* if there is no TR num, show the form again */ @@ -942,5 +898,5 @@ else { /*create and open a temporary file to send to techrep*/ - sprintf (tempfile, "/tmp/techrep%d.XXXXXX", getpid()); + sprintf (tempfile, "/tmp/techrep%d.XXXXXX", (int)getpid()); mktemp(tempfile); passed_file = strdup(tempfile); @@ -1001,5 +957,5 @@ } -int +void sendTechrepRequest(int methodID, char *tempFilename, char *trLocation) { diff -u2 src.working/sitespec.c src/sitespec.c --- src.working/sitespec.c Thu Aug 17 21:19:01 1995 +++ src/sitespec.c Tue Sep 19 16:27:39 1995 @@ -5,4 +5,5 @@ #include #include +#include #include "util.h" #include "techrep.h" diff -u2 src.working/techrep.c src/techrep.c --- src.working/techrep.c Tue Sep 12 10:30:42 1995 +++ src/techrep.c Wed Sep 20 12:16:03 1995 @@ -51,4 +51,9 @@ * Various code clean-up * September 1995 - CLV + * + * Fixed return/exit brokenness + * Fixed some close(FILE*) + * Made it compile (almost) clean with gcc -Wall + * September 1995 - Davin Milun * */ @@ -56,4 +61,7 @@ #include #include +#include +#include +#include #include #include @@ -77,10 +85,10 @@ void no_citation_database(); char *findTechnicalReport (char *trId); -int handle_post (CitationPtr newCit, char *trLocation); -int handle_get (char *temp_filename); -int handle_update (CitationPtr newCit, char *trLocation); -int handle_delete (CitationPtr newCit); -int handle_get_all (char *temp_filename); -int handle_bulk_load(); +int handle_post (CitationPtr newCit, char *trLocation); +int handle_get (char *temp_filename); +int handle_update (CitationPtr newCit, char *trLocation); +int handle_delete (CitationPtr newCit); +int handle_get_all (char *temp_filename); +int handle_bulk_load(); void error_log (char *errormessage); CitationPtr lookup_trnum (char *trId); @@ -93,5 +101,5 @@ -void +int main(int argc, char *argv[], char *envp) { @@ -117,15 +125,15 @@ if (argv[1][1] == 'p') { - handle_post(newCit, argv[3]); + return handle_post(newCit, argv[3]); } else if (argv[1][1] == 'g') { - handle_get(argv[2]); + return handle_get(argv[2]); } else if (argv[1][1] == 'u') { - handle_update(newCit, argv[3]); + return handle_update(newCit, argv[3]); } else if (argv[1][1] == 'd') { - handle_delete(newCit); + return handle_delete(newCit); } else if (argv[1][1] == 'b') { - handle_bulk_load(); + return handle_bulk_load(); } else if (argv[1][1] == 'a') { - handle_get_all(argv[2]); + return handle_get_all(argv[2]); } else { usage(); @@ -133,4 +141,5 @@ exit(BAD_CMD_LINE); } + return 0; } @@ -148,4 +157,5 @@ { fileCopy (temp_filename, getCitationDataFilePath(), 0644); + return 0; } @@ -153,5 +163,4 @@ { - char buf[STRING_SIZE]; CitationPtr C; FILE *citation_fp; @@ -161,5 +170,5 @@ no_citation_database(); error_log( "get: no cit-dbase so TR not found"); - exit(DOC_DOES_NOT_EXIST); + return(DOC_DOES_NOT_EXIST); } @@ -167,17 +176,17 @@ if (!C->trId) { fprintf (stderr, "Problem with Bulk Load - No report number\n"); - exit (1); + return (1); } if (!C->title) { fprintf (stderr, "Problem with Bulk Load - No title\n"); - exit (1); + return (1); } if (!C->author) { fprintf (stderr, "Problem with Bulk Load - No author\n"); - exit (1); + return (1); } if (!C->date) { fprintf (stderr, "Problem with Bulk Load - No date\n"); - exit (1); + return (1); } @@ -189,4 +198,5 @@ fclose (citation_fp); update_readme(); + return 0; } @@ -197,11 +207,11 @@ handle_post (CitationPtr newCit, char *trLoc) { - int answer, c, is_doc,i,is_compressed, in_url_line; - FILE *tmp_cit_fp, *cit_dbase_fp; + int answer, is_compressed; + FILE *cit_dbase_fp; CitationPtr tr_exists; char *trId, fname[STRING_SIZE], url[STRING_SIZE]; char copy_filename[STRING_SIZE]; - char suffix[STRING_SIZE], command[STRING_SIZE]; - char newDocFileName[STRING_SIZE], docFileName[STRING_SIZE]; + char command[STRING_SIZE]; + char newDocFileName[STRING_SIZE]; char *fextention,*fnameonly,*all_extentions; char trLocation[STRING_SIZE]; @@ -225,5 +235,5 @@ if (get_semaphore(getSemaphoreFilePath()) == ERROR) { error_log("You have been denied exclusive access to the citation data base. Please try your operation again.\n"); - exit(ACCESS_DENIED); + return(ACCESS_DENIED); } @@ -235,5 +245,5 @@ fprintf (stderr, "%s already exists so cannot be post-ed. Try update.\n", trId); release_semaphore(getSemaphoreFilePath()); - exit(DOC_EXISTS); + return(DOC_EXISTS); } @@ -296,5 +306,5 @@ release_semaphore(getSemaphoreFilePath()); error_log("Unable to copy and compress file"); - exit( FILE_NOT_COPIED ); + return( FILE_NOT_COPIED ); } @@ -328,4 +338,5 @@ free(trLocation); + return 0; } @@ -335,7 +346,5 @@ FILE *temp_fp, *citation_fp; CitationPtr Cit,C; - char *trId, c; - int tr_exists, error; - long begin_cit, end_cit; + char *trId; /* open temp_filename file */ @@ -347,5 +356,5 @@ if (get_semaphore(getSemaphoreFilePath()) == ERROR) { error_log("You have been denied exclusive access to the citation data base. Please try your operation again.\n"); - exit(ACCESS_DENIED); + return(ACCESS_DENIED); } @@ -355,5 +364,5 @@ error_log( "get: no cit-dbase so TR not found"); release_semaphore(getSemaphoreFilePath()); - exit(DOC_DOES_NOT_EXIST); + return(DOC_DOES_NOT_EXIST); } @@ -372,5 +381,5 @@ release_semaphore(getSemaphoreFilePath()); freeCitation (C); - return (0); + return 0; } freeCitation (C); @@ -380,5 +389,5 @@ error_log("TR doesn't exist\n"); release_semaphore(getSemaphoreFilePath()); - exit(DOC_DOES_NOT_EXIST); + return(DOC_DOES_NOT_EXIST); } @@ -391,10 +400,11 @@ handle_post(newCit, trLocation); } + return 0; } int handle_delete(CitationPtr newCit) { - int answer, result; - char *trId, *url, *newUrl, *trLocation; + int result; + char *trId, *url, *trLocation; FILE *citation_fp; CitationPtr Cit, tr_exists; @@ -408,5 +418,5 @@ if (get_semaphore(getSemaphoreFilePath()) == ERROR) { error_log("You have been denied exclusive access to the citation data base. Please try your operation again."); - exit(ACCESS_DENIED); + return(ACCESS_DENIED); } @@ -415,5 +425,5 @@ no_citation_database(); error_log("no cit dbase created one (in delete)"); - exit(DOC_DOES_NOT_EXIST); + return(DOC_DOES_NOT_EXIST); } @@ -460,4 +470,5 @@ error_log("Could not open temporary README file."); } + return 0; } @@ -503,5 +514,5 @@ CitationPtr C; - sprintf(tmpCitFileName, "/tmp/%d-tmp-cit-dbase", getpid()); + sprintf(tmpCitFileName, "/tmp/%d-tmp-cit-dbase", (int)getpid()); if ((new_dbase_fp = fopen(tmpCitFileName, "w")) == NULL) { error_log("Can't open tmp citation DB"); @@ -516,5 +527,5 @@ /* printf ("Reading ...,"); fflush (stdout); */ - while (C = read_one_citation(cit_dbase_fp)) { + while ((C = read_one_citation(cit_dbase_fp))) { /* printf ("Read %s,", getTrId(C)); fflush (stdout); */ if (strcmp (getTrId(C), trId)) { @@ -579,8 +590,8 @@ C = read_one_citation(fp); if (!C) { - close (fp); + fclose (fp); return NULL; } - close(fp); + fclose(fp); /* check url to make sure it's readable */ diff -u2 src.working/util.c src/util.c --- src.working/util.c Tue Sep 12 10:04:33 1995 +++ src/util.c Wed Sep 20 12:17:22 1995 @@ -2,4 +2,5 @@ #include #include +#include #include #include @@ -20,5 +21,5 @@ y=0; - while(line[y++] = line[x++]); + while((line[y++] = line[x++])); } @@ -34,5 +35,5 @@ y=0; - while(line[y++] = line[x++]); + while((line[y++] = line[x++])); return word; } @@ -117,5 +118,4 @@ void send_fd(FILE *f, FILE *fd) { - int num_chars=0; char c; @@ -144,6 +144,4 @@ stripLeadingBlanks (char *str) { - int c; - while (isspace(str[0])) str++; diff -u2 src.working/web-util.c src/web-util.c --- src.working/web-util.c Tue Sep 19 13:40:57 1995 +++ src/web-util.c Wed Sep 20 12:03:09 1995 @@ -37,5 +37,5 @@ { int x, y; - char *c, *s; + char *s; for (s=list_ptr, x=0; *s != '\0';s++) { @@ -651,5 +651,4 @@ PrintRestOfForm (CitationPtr C) { - int i; FILE *fp; char orgFile[STRING_SIZE];