#include #include #include #include #include "util.h" #include "citation.h" #include "web-util.h" #include "web-conf.h" CitationPtr C; char* emailAddress; char *comments; char* choice; int error_flag = 0; typedef struct { char *name; char *val; } entry; void trupdate(); void trupdate_htmlform(); void trpost_update(); void trpost_htmlform(); void trdelete_htmlform(); void tr_single_view_htmlform(); void tr_bulkload_htmlform(); void tr_bulkload(); void trpost_update_repeat(); void trpost_repeat(); void trpost_query(); void trdelete(); void tr_single_view(); void tr_browse(); void techrep_menu_htmlform(); int sendTechrepRequest(int methodID, char *tempFilename, char* trLocation); void printConfirmation (int methodID); main(int argc, char *argv[]) { entry entries[MAX_ENTRIES]; register int x,m=0; int cl; char* cur_data; char* tr_task_data; int tr_task_miss = 0; tr_task_data = NULL; emailAddress = NULL; comments = NULL; /* print out the proper cgi-script heading: */ printf ("Content-type: text/html%c%c",10,10); /* check for various form errors */ if(strcmp(getenv("REQUEST_METHOD"),"POST")) { /* By default, just go to the main menu if something is screwy, the generated forms will take care of it from there */ techrep_menu_htmlform(); exit(1); } if(strcmp(getenv("CONTENT_TYPE"),"application/x-www-form-urlencoded")) { printf ("This script can only be used to decode form results. \n"); exit(1); } /* use environment variable to determine how much data there is */ cl = atoi(getenv("CONTENT_LENGTH")); /* put name-value pairs from form into an array for processing */ for(x=0;cl && (!feof(stdin));x++) { m=x; entries[x].val = fmakeword(stdin,'&',&cl); plustospace(entries[x].val); unescape_url(entries[x].val); entries[x].name = makeword(entries[x].val,'='); } /* allocate Citation space */ C = initCitation(); if (!C) { printf ("Allocation problems.\n"); exit (1); } /* read values from form; put into _data variables; set error flags*/ for(x=0; x <= m; x++) { /* tr_task_data = the next form to go to. */ if (!strcmp(entries[x].name,"tr_task_data")) { tr_task_data = strdup(entries[x].val); if (!strcmp(tr_task_data,"")) { /* The tr_task attribute was defined but not set in the invoking form. Not Good, but we can deal. */ tr_task_data = NULL; tr_task_miss = 1; } } /* choice */ else if (!strcmp(entries[x].name,"choice")) { choice = strdup(entries[x].val); } /* trnum */ else if (!strcmp(entries[x].name,"trnum")) { cur_data = strdup(entries[x].val); stripTrailingBlanks (cur_data); if (!strcmp(cur_data,"")) { C->trId = NULL; error_flag = 1; } else { C->trId = cur_data; } } /* date */ else if (!strcmp(entries[x].name,"date")) { cur_data = strdup(entries[x].val); stripTrailingBlanks (cur_data); if (!strcmp(cur_data,"")) { C->date = NULL; error_flag = 1; } else { C->date = cur_data; } } /* title */ else if (!strcmp(entries[x].name,"title")) { cur_data = strdup(entries[x].val); stripTrailingBlanks (cur_data); if (!strcmp(cur_data,"")) { C->title = NULL; error_flag = 1; } else { C->title = cur_data; } } /* authors */ else if (!strcmp(entries[x].name,"authors")) { cur_data = strdup(entries[x].val); stripTrailingBlanks (cur_data); if (!strcmp(cur_data,"")) { C->author= NULL; error_flag = 1; } else { C->author = cur_data; } } /* url */ else if (!strcmp(entries[x].name,"url")) { cur_data = strdup(entries[x].val); stripTrailingBlanks (cur_data); if (!strcmp(cur_data,"")) { C->url = NULL; } else { C->url = cur_data; } } /* keywords */ else if (!strcmp(entries[x].name,"keywords")) { cur_data = strdup(entries[x].val); stripTrailingBlanks (cur_data); if (!strcmp(cur_data,"")) { C->keywords= NULL; } else { C->keywords = cur_data; } } /* categories */ else if (!strcmp(entries[x].name,"categories")) { cur_data = strdup(entries[x].val); stripTrailingBlanks (cur_data); if (!strcmp(cur_data,"")) { C->categories = NULL; } else { C->categories = cur_data; } } /* abstract */ else if (!strcmp(entries[x].name,"abstract")) { cur_data = strdup(entries[x].val); stripBlankLines (cur_data); if (!strcmp(cur_data,"")) { C->abstract = NULL; } else { C->abstract = cur_data; } } /* filepath */ else if (!strcmp(entries[x].name,"filepath")) { cur_data = strdup(entries[x].val); stripTrailingBlanks (cur_data); if (!strcmp(cur_data,"")) { C->filepath = NULL; } else { C->filepath = cur_data; } } /* organization */ else if (!strcmp(entries[x].name,"organization")) { cur_data = strdup(entries[x].val); stripBlankLines (cur_data); if (!strcmp(cur_data,"")) { C->org = NULL; } else { C->org = cur_data; } } /* comments */ else if (!strcmp(entries[x].name,"comments")) { cur_data = strdup(entries[x].val); stripBlankLines (cur_data); if (!strcmp(cur_data,"")) { comments = NULL; } else { comments = cur_data; } } /* email */ else if (!strcmp(entries[x].name,"email")) { cur_data = strdup(entries[x].val); stripBlankLines (cur_data); if (!strcmp(cur_data,"")) { emailAddress = NULL; error_flag = 1; } else { emailAddress = cur_data; } } } /*end of for loop- finished going through form data */ if( strcmp(tr_task_data,"trupdate")==0){ trupdate(); } else if ( strcmp(tr_task_data,"trupdate-htmlform")==0){ trupdate_htmlform(); } else if ( strcmp(tr_task_data,"trpost-update")==0){ trpost_update(); } else if ( strcmp(tr_task_data,"trpost-htmlform")==0){ trpost_htmlform(); } else if ( strcmp(tr_task_data,"trdelete-htmlform")==0){ trdelete_htmlform(); } else if ( strcmp(tr_task_data,"tr-single-view-htmlform")==0){ tr_single_view_htmlform(); } else if ( strcmp(tr_task_data,"tr-bulkload-htmlform")==0){ tr_bulkload_htmlform(); } else if ( strcmp(tr_task_data,"trpost-update-repeat")==0){ trpost_update_repeat(); } else if ( strcmp(tr_task_data,"trpost-repeat")==0){ trpost_repeat(); } else if ( strcmp(tr_task_data,"trpost-query")==0){ trpost_query(); } else if ( strcmp(tr_task_data,"tr-bulkload")==0){ tr_bulkload(); } else if ( strcmp(tr_task_data,"trdelete")==0){ trdelete(); } else if ( strcmp(tr_task_data,"tr-single-view")==0){ tr_single_view(); } else if ( strcmp(tr_task_data,"tr-browse")==0){ tr_browse(); } else if ( strcmp(tr_task_data,"techrep-menu-htmlform")==0){ techrep_menu_htmlform(); } else { /* If we can't tell where to go, just go to the main menu. */ techrep_menu_htmlform(); } exit(0); } void techrep_menu_htmlform() { printf ("Techrep\n"); printf ("

Techrep

\n"); printf ("

Technical Report Bibliographic Utility

\n"); printf ("
\n"); printf ("
\n", MASTERFORM); printf (" \n"); printf ("

\n"); printf ("\n"); printf ("

\n"); printf ("

\n"); printf ("
\n", MASTERFORM); printf (" \n"); printf ("

\n"); printf ("\n"); printf ("

\n"); printf ("

\n"); printf ("
\n", MASTERFORM); printf (" \n"); printf ("

\n"); printf ("\n"); printf ("

\n"); printf ("

\n"); printf ("
\n", MASTERFORM); printf (" \n"); printf ("

\n"); printf ("\n"); printf ("

\n"); printf ("

\n"); printf ("

\n"); printf ("

\n"); printf ("

\n", MASTERFORM); printf (" \n"); printf ("

\n"); printf ("\n"); printf ("

\n"); printf ("

\n"); printf ("

\n"); printf ("


\n"); printf ("

\n"); printf ("

\n", HELP_URL); printf ("

\n"); printf ("\n"); printf ("

\n"); printf ("

\n"); printf ("

\n"); printf ("

\n"); printf ("


\n"); printf ("

\n"); } void tr_browse() { int c; 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. */ /* Oh well. */ /* open the browse page and send it along */ sprintf (browsePage, "%s/README.html", TR_REPORT_DIR); if ((fp = fopen(browsePage, "r")) == NULL) { printf ("Could not get browse page.\n"); } else { while ((c = getc(fp)) != EOF) putchar(c); fclose (fp); } } void tr_bulkload() { char bulkload_command[MAX_COMMANDLINE]; signed int answer; /* if there is no filepath, show the form again */ if (!C->filepath) { printf ("Technical Report BulkLoad Form"); printf ("

Technical Report BulkLoad Form

"); printf ("
    "); printf ("
  • \n", MASTERFORM); printf ("\n"); printf ("

    Please enter the full path name of the file you want appended to the bibliographic database.\n

    "); printf ("FILE:"); printf ("

    "); printf ("\n"); printf ("

    "); printf ("
    \n", MASTERFORM); printf ("\n"); printf ("

    \n"); printf ("

    \n"); } /*end of if no file path entered*/ /* if no error, go ahead and bulkload */ else { sendTechrepRequest (BULK, C->filepath, NULL); printConfirmation(BULK); } /*end of if no error (a file path was entered)*/ } void tr_single_view() { register int x; FILE *fp; char tempfile[MAX_COMMANDLINE]; char *passed_file; char get_command[MAX_COMMANDLINE]; char permission_command[MAX_COMMANDLINE]; int set_temp_permissions; signed int tr_get_answer; /* if there is no TR num, show the form again */ if(!C->trId) { printf ("TR Bibliographic Info Form"); printf ("

    TR Bibliographic Info Form

    "); printf ("
      "); printf ("
    • \n", MASTERFORM); printf ("\n"); printf ("

      Please enter the TR number of the document for which you want to view the bibliographic information.\n

      "); printf ("TECHNICAL REPORT NUMBER:"); printf ("

      "); printf ("\n"); printf ("

      "); printf ("
      \n", MASTERFORM); printf ("\n"); printf ("

      \n"); printf ("

      \n"); } /* end of if no tr num entered */ /* if trnum was entered, get info from techrep */ else { /*create and open a temporary file to send to techrep*/ sprintf (tempfile, "/tmp/techrep%d.XXXXXX", getpid()); mktemp(tempfile); passed_file = strdup(tempfile); fp=fopen(passed_file,"w"); /* write the tr number in the file (in refer format) */ fprintf (fp,"%%%c %s\n\n", REF_REPORT, C->trId); fclose(fp); /* make sure the tempfile has world read and write permissions */ /* sprintf (permission_command, "%s ugo+rw %s", CHMOD_CMD, passed_file);*/ /* set_temp_permissions = system(permission_command);*/ chmod (passed_file, 0666); /* CALL TECHREP */ sprintf (get_command, "%s/bin/techrep -g %s", TR_HOME, passed_file); tr_get_answer = system(get_command); /* get the upper 8 bits of the returned code and convert to neg int */ tr_get_answer = ((~(tr_get_answer>>8)&255)+1)*(-1); /* tr_get_answer = DOC_DOES_NOT_EXIST;*/ if (tr_get_answer == DOC_DOES_NOT_EXIST) { /*NOT IN DATABASE*/ printf ("Viewing Error\n"); printf ("

      Viewing Error

      \n"); printf ("

      TR number %s is not in database

      \n

      ", C->trId); printf ("

      \n", MASTERFORM); printf ("\n"); printf ("

      \n"); printf ("

      \n"); } /*end of if- trnum not in database (call to get)*/ else if (tr_get_answer == ACCESS_DENIED) { /*CANNOT GET EXCLUSIVE ACCESS*/ printf ("Database Access Error\n"); printf ("

      Database Access Error

      \n"); printf ("

      You have been denied exclusive access to the bibliographic database\n

      "); printf ("

      \n", MASTERFORM); printf ("\n"); printf ("

      \n"); printf ("

      \n"); } /*end of elseif- exclusive access denied (call to get)*/ else { /*TRNUM IN DATABASE*/ /* read the passed back file and create a view */ fp=fopen(passed_file,"r"); printf ("TR Bibliographic Info\n"); printf ("

      TR Bibligraphic Info

      \n"); printf ("


      "); Refer2View(passed_file); printf ("

      \n", MASTERFORM); printf ("\n"); printf ("

      \n"); printf ("

      \n"); fclose (fp); } /*end of else- okay to view (trnum in database) */ /* delete the temp file */ unlink (passed_file); } /*end of else- no error in view entry, try to get bib info*/ } void 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) { printf ("Technical Report Delete Form"); printf ("

      Technical Report Delete Form

      "); printf ("
        "); printf ("
      • \n", MASTERFORM); printf ("\n"); printf ("

        Please enter the TR number of the document for which you want to update or modify bibliographic information.\n

        "); printf ("TECHNICAL REPORT NUMBER:"); printf ("

        "); printf ("\n"); printf ("

        "); printf ("
        \n", MASTERFORM); printf ("\n"); printf ("

        \n"); printf ("

        \n"); } /*end of if no tr num entered*/ /* if no error, go ahead and delete */ else { /*create and open a temporary file to send to techrep*/ sprintf (tempfile, "/tmp/techrep%d.XXXXXX", getpid()); mktemp(tempfile); passed_file = strdup(tempfile); fp=fopen(passed_file,"w"); if (emailAddress) fprintf (fp, "ContactPerson: %s\n", emailAddress); if (comments) fprintf (fp, "Comments: %s\n", comments); /* write the TRnum in the file (in refer format) */ fprintf (fp, "### Begin Citation ### Do not delete this line ###\n"); write_one_citation (fp, C); fclose(fp); /* make sure the temp file is world readable and writable*/ chmod (passed_file, 0666); /* Send request */ sendTechrepRequest (DELETE, passed_file, NULL); printConfirmation (DELETE); unlink (passed_file); } /*end of if no error (a trnum was entered)*/ } void 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"))) { /* if there is missing data, create error heading for form */ if (error_flag != 0) { error_flag = 0; /* reset flag */ printf ("TR Posting Modification Form\n"); printf ("

        TR Posting Modification Form


        \n"); printf ("

        INFORMATION ERROR!

        \n"); printf ("

        You MUST provide the TR Number, Date, Title, and Author(s) of a Technical Report to be posted!

        \n"); printf ("

        \n"); printf ("

        This entry is missing the following:

        \n"); printf ("
          "); if (!C->trId) printf ("
        1. Technical Report Number

          \n"); if (!C->date) printf ("
        2. Date Written

          \n"); if (!C->title) printf ("
        3. Title of Report

          \n"); if (!C->author) printf ("
        4. Author(s)

          \n"); if (!emailAddress) printf ("
        5. Email address of contact person

          \n"); printf ("
        "); printf ("
        \n"); /* create form with rest of the data */ PrintFilledForm(C); } /*end of if- to show error screen*/ /* if there is no error, go ahead with post */ else { /*create and open a temporary file to write to*/ sprintf (tempfile, "/tmp/techrep-%d.XXXXXX", getpid()); mktemp (tempfile); passed_file = strdup(tempfile); fp=fopen(passed_file,"w"); if (comments) { fprintf (fp, "Comments: %s\n", comments); } if (emailAddress) { fprintf (fp, "ContactPerson: %s\n", emailAddress); } fprintf (fp, "### Begin Citation ### Do not delete this line ###\n"); write_one_citation(fp, C); /* okay, everything has been written to the temp file */ fclose(fp); /* make sure the temp file is world readable */ /* sprintf (permission_command, "%s ugo+r %s", CHMOD_CMD, passed_file);*/ /* set_temp_permissions = system(permission_command);*/ chmod (passed_file, 0666); sendTechrepRequest (POST_FILE, passed_file, C->url); printConfirmation (POST_FILE); /* Delete the tempfile */ unlink (passed_file); } /*end of else- go ahead and post*/ } /* end of Post */ /* Preview */ else { PreviewReferFormat (C); } /*end of Preview*/ } void trpost_repeat() { /* Submit for Posting */ if (!(strcmp(choice,"Submit for Posting"))) { printf ("Technical Report Posting Form\n"); printf ("

        Technical Report Posting Form

        \n"); printf ("
        \n"); PrintFilledForm(C); } /* end of post choice */ /* Preview First */ else { PreviewReferFormat (C); } /*end of else preview*/ } void trpost_update_repeat() { /* Submit for Posting */ if (!(strcmp(choice,"Submit for Posting"))) { printf ("Technical Report Posting Form\n"); printf ("

        Technical Report Posting Form

        \n"); printf ("
        \n"); PrintUpdatedFilledForm(C); } /* end of choice post */ /* Preview First */ else { PreviewUpdatedReferFormat (C); } /*end of choice preview*/ } void tr_bulkload_htmlform() { printf ("Technical Report BulkLoad Form\n"); printf ("

        Technical Report BulkLoad Form

        \n"); printf ("
        \n"); printf ("
          \n"); printf ("
        • \n", MASTERFORM); printf ("\n"); printf ("

          Please enter the full path name of the file you want appended to the bibliographic database.

          \n"); printf ("

          Please note that the file must be world readable!

          \n"); printf ("

          \n"); printf ("FILE:\n"); printf ("

          \n"); printf ("

          \n"); printf ("

          \n"); printf ("

          \n"); printf ("

          \n"); printf ("
          \n", MASTERFORM); printf ("\n"); printf ("

          \n"); printf ("

          \n"); } void tr_single_view_htmlform() { printf ("TR Bibliographic Info Form\n"); printf ("

          TR Bibliographic Info Form

          \n"); printf ("
          \n"); printf ("
            \n"); printf ("
          • \n", MASTERFORM); printf ("\n"); printf ("

            Please enter the TR number of the document for which you want to view bibliographic information

            \n"); printf ("

            \n"); printf ("TECHNICAL REPORT NUMBER:\n"); printf ("

            \n"); printf ("

            \n"); printf ("

            \n"); printf ("

            \n"); printf ("

            \n"); printf ("
            \n", MASTERFORM); printf ("\n"); printf ("

            \n"); printf ("

            \n"); } void trdelete_htmlform() { printf ("Technical Report Delete Form\n"); printf ("

            Technical Report Delete Form

            \n"); printf ("
            \n"); printf ("
            \n", MASTERFORM); printf ("\n"); printf ("

            Please enter the TR number of the document you want deleted from the bibliographic database.

            \n"); printf ("

            \n"); printf ("TECHNICAL REPORT NUMBER:\n"); printf ("

            \n"); printf ("

            \n"); printf ("CONTACT PERSON: The email address (probably your own) of the\n"); printf ("person who will verify the information provided here.
            \n"); printf ("

            \n"); printf ("

            \n"); printf ("

            \n"); printf ("

            \n"); printf ("
            \n", MASTERFORM); printf ("\n"); printf ("

            \n"); printf ("

            \n"); } void trpost_htmlform() { printf ("Technical Report Posting Form\n"); printf ("

            Technical Report Posting Form

            \n"); printf ("
            \n"); /* C here is essentially empty */ PrintFilledForm (C); } void 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"))) { /* if there is an error, create error header for form */ if (error_flag != 0) { error_flag= 0; /* reset flag */ printf ("TR Posting Modification Form\n"); printf ("

            TR Posting Modification Form


            \n"); printf ("

            INFORMATION ERROR!

            \n"); printf ("

            You MUST provide the TR Number, Date, Title, and Author(s) of a Technical Report to be posted!

            \n"); printf ("

            \n"); printf ("

            This entry is missing the following:

            \n"); printf ("
              "); if (!C->trId) printf ("
            1. Technical Report Number

              \n"); if (!C->date) printf ("
            2. Date Written

              \n"); if (!C->title) printf ("
            3. Title of Report

              \n"); if (!C->author) printf ("
            4. Author(s)

              \n"); if (!emailAddress) printf ("
            5. Email address of contact person

              \n"); printf ("
            "); printf ("
            \n"); PrintUpdatedFilledForm(C); } /*end of if- missing data error*/ /* if no missing data, go ahead with post */ else { char *tempname; /*create a temporary file to write to*/ sprintf (tempfile, "/tmp/techrep%d.XXXXXX", getpid()); mktemp(tempfile); passed_file = strdup(tempfile); fp=fopen(passed_file,"w"); if (emailAddress) fprintf (fp, "ContactPerson: %s\n", emailAddress); if (comments) fprintf (fp, "Comments: %s\n", comments); if (tempname=getenv("REMOTE_HOST")) fprintf (fp, "Remote host: %s\n", tempname); if (tempname=getenv("REMOTE_IDENT")) fprintf (fp, "Remote ident: %s\n", tempname); fprintf (fp, "### Begin Citation ### Do not delete this line ###\n"); write_one_citation (fp, C); /* okay, everything has been written to the temp file */ fclose(fp); /* make sure the temp file is world readable */ chmod (passed_file, 0666); sendTechrepRequest (UPDATE_FILE, passed_file, C->url); printConfirmation (UPDATE_FILE); unlink (passed_file); } /* end of else- final posting */ } /* end of post choice */ else { PreviewUpdatedReferFormat (C); } /* end of preview choice */ } void trupdate_htmlform() { printf ("Technical Report Update Request\n"); printf ("

            Technical Report Update Request

            \n"); printf ("
            \n"); printf ("
            \n", MASTERFORM); printf (" \n"); printf ("

            Please enter the TR number of the document for which you want to update or modify bibliographic information.

            \n"); printf ("

            \n"); printf ("TECHNICAL REPORT NUMBER:\n"); printf ("

            \n"); printf ("

            \n"); printf ("

            \n"); printf ("

            \n"); printf ("

            \n"); printf ("
            \n", MASTERFORM); printf (" \n"); printf ("

            \n"); printf ("

            \n"); } void trupdate() { register int x; FILE *fp; char tempfile[MAX_COMMANDLINE]; char *passed_file; 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 */ if (!C->trId) { printf ("Technical Report Update Request"); printf ("

            Technical Report Update Request

            "); printf ("
              "); printf ("
              \n", MASTERFORM); printf (" \n"); printf ("

              Please enter the TR number of the document for which you want to update or modify bibliographic information.\n

              "); printf ("TECHNICAL REPORT NUMBER:"); printf ("

              "); printf ("\n"); printf ("

              "); } /* end of if no tr num entered */ /* if a TR num is entered, go ahead with getting the update info from techrep */ else { /*create and open a temporary file to send to techrep*/ sprintf (tempfile, "/tmp/techrep%d.XXXXXX", getpid()); mktemp(tempfile); passed_file = strdup(tempfile); fp=fopen(passed_file,"w"); /* write the trnumber to the file (in refer format) */ fprintf (fp,"%%R %s\n\n",C->trId); fclose(fp); /* make sure the tempfile has world read and write permissions */ /* sprintf (permission_command, "%s ugo+rw %s", CHMOD_CMD, passed_file);*/ /* set_temp_permissions = system(permission_command);*/ chmod (passed_file, 0666); /* CALL TECHREP */ sprintf (get_command, "%s/bin/techrep -g %s", TR_HOME, passed_file); tr_get_answer = system(get_command); /* get the upper 8 bits of the returned code */ /* and convert to negative int */ tr_get_answer = ((~(tr_get_answer>>8)&255)+1)*(-1); if (tr_get_answer == DOC_DOES_NOT_EXIST) { /*NOT IN DATABASE*/ printf ("Update Error\n"); printf ("

              Update Error

              \n"); printf ("

              TR number %s is not in database\n

              ", C->trId); printf ("

              \n", MASTERFORM); printf (" \n"); printf ("

              \n"); printf ("

              \n"); } /* end of trnum not in database (on call to get) */ else if (tr_get_answer == ACCESS_DENIED) { /*CANNOT GET EXCLUSIVE ACCESS*/ printf ("Database Access Error\n"); printf ("

              Database Access Error

              \n"); printf ("

              You have been denied exclusive access to the bibliographic database\n

              "); printf ("

              \n", MASTERFORM); printf (" \n"); printf ("

              \n"); printf ("

              \n"); } /* end of denied access (on call to get) */ else { /*TRNUM IN DATABASE*/ /* open file techrep has written to, for reading */ fp=fopen(passed_file,"r"); /* Create form header and parse the file (by calling Refer2Form) */ printf ("Technical Report Update Form\n"); printf ("

              Technical Report Update Form

              \n"); printf ("


              "); Refer2Form(passed_file); } /* end of go ahead with update (after call to get) */ /* delete the temp file */ unlink (passed_file); } /*end of else- no error in update entry, try to get bib info*/ } int sendTechrepRequest(int methodID, char *tempFilename, char *trLocation) { char methodString[STRING_SIZE]; char mailCommand[STRING_SIZE]; switch (methodID) { case POST: case POST_FILE: strcpy (methodString, "techrep: POST request"); break; case UPDATE: case UPDATE_FILE: strcpy (methodString, "techrep: UPDATE request"); break; case DELETE: strcpy (methodString, "techrep: DELETE request"); break; case BULK: strcpy (methodString, "techrep: BULK request"); break; } sprintf (mailCommand, "/usr/ucb/mail -s \"%s\" %s < %s", methodString, TR_ADMIN, tempFilename); system (mailCommand); } void printConfirmation(int methodID) { switch (methodID) { case POST: case POST_FILE: printf ("Posting Confirmation"); printf ("

              Your POST request has been sent to the Report Administrator

              "); break; case UPDATE: case UPDATE_FILE: printf ("Update Confirmation"); printf ("

              Your UPDATE request has been sent to the Report Administrator

              "); break; case DELETE: printf ("Delete Confirmation"); printf ("

              Your DELETE request has been sent to the Report Administrator

              "); break; case BULK: printf ("Bulk Load Confirmation"); printf ("

              Your BULK LOAD request has been sent to the Report Administrator

              "); break; } printf ("
              \n", MASTERFORM); printf ("\n"); printf ("

              \n"); printf ("

              \n"); }