#include #include #include #include #include #include "util.h" #include "citation.h" #include "web-util.h" #include "web-conf.h" extern char *emailAddress; extern char *comments; void PrintReferFormat (CitationPtr C); void PrintRestOfForm (CitationPtr C); void parseDate (char *curDate, char **month, char **day, char **year); void setDate (char **month, char **day, char **year); void reportText(); void dateText(); void titleText(); void authorText(); void filenameText(); void keywordsText(); void reviewsText(); void abstractText(); void directionsText(); void emailText(); void commentsText(); void orgText(); char monthList[13][15] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "Unknown"}; /*--------------------------------------------------------*/ /* ListtoArray: */ /* */ /* Puts the items (in list_ptr) in an array, */ /* counts how many there are, */ /* returns the integer number */ /*--------------------------------------------------------*/ int ListtoArray (char array[N_STRINGS][STRING_SIZE], char *list_ptr) { int x, y; char *s; for (s=list_ptr, x=0; *s != '\0';s++) { y = 0; while ((*s != ';') && (*s != '\n') && (*s != '\0')) { array[x][y] = *s; y++; s++; } array[x][y] = '\0'; x++; } return (x); } /*--------------------------------------------------------*/ /* PrintFilledForm: */ /* */ /* Puts its input parameters into an html form */ /* (TR posting form) */ /*--------------------------------------------------------*/ void PrintFilledForm (CitationPtr C) { directionsText(); /* form header stuff */ printf ("
\n", MASTERFORM); printf ("\n"); printf ("

Technical Report Bibliographic Information

\n"); printf ("
    "); /* TR number */ /* reportText(); */ /* if (!getTrId(C)) { */ /* printf ("

    \n"); */ /* } */ /* else { */ /* printf ("

    \n",getTrId(C)); */ /* } */ PrintRestOfForm (C); } /*--------------------------------------------------------*/ /* PrintUpdatedFilledForm: */ /* */ /* Puts its input parameters into an html form */ /* (TR update posting form) */ /*--------------------------------------------------------*/ void PrintUpdatedFilledForm (CitationPtr C) { directionsText(); /* print form header stuff */ printf ("\n", MASTERFORM); printf ("\n"); printf ("

    Technical Report Bibliographic Information

    \n"); printf ("
      "); /* tr number */ reportText(); printf ("\n",getTrId(C)); printf ("%s

      \n",getTrId(C)); C->url = NULL; /* forestalls some potential update problems later on */ PrintRestOfForm (C); }/*end of PrintUpdatedFilledForm*/ /*--------------------------------------------------------*/ /* DisplayReferEntry: */ /* */ /* Takes as input all the bibliographic data available. */ /* Puts its input parameters into html format for viewing.*/ /* (called by Refer2View) */ /*--------------------------------------------------------*/ void DisplayReferEntry (CitationPtr C) { /*printf ("

      TR Bibliographic Information

      \n");*/ printf ("
        "); /***There HAS to be one, so we should not check for one!!??*****/ if (getTrId(C)) { printf ("
      • TR NUMBER: "); printf (" %s\n

        ", getTrId(C)); } if (getDate(C)) { printf ("

      • DATE: "); printf (" %s\n

        ",getDate(C)); } if (getTitle(C)) { printf ("

      • TITLE: "); printf (" %s\n

        ",getTitle(C)); } if (getAuthor(C)) { printf ("

      • AUTHOR(S): "); printf (" %s\n

        ",getAuthor(C)); } if (getUrl(C)) { printf ("

      • URL: "); printf (" %s\n

        ",getUrl(C), getUrl(C)); } if (getAbstract(C)) { printf ("

      • ABSTRACT: "); printf ("%s\n

        ",getAbstract(C)); } if (getKeywords(C)) { printf ("

      • KEYWORDS:"); printf ("%s

        \n", getKeywords(C)); } if (getCategories(C)) { printf ("

      • CATEGORIES: "); printf ("%s

        \n", getCategories(C)); } if (getOrg(C)) { printf ("

      • TR Series Name: "); printf ("%s

        \n", getOrg(C)); } }/*end of DisplyReferEntry*/ /*--------------------------------------------------------*/ /* Refer2Form: */ /* */ /* reads a refer bib entry (in passedfilename) */ /* and passes the information to PrintUpdatedFilledForm. */ /* (used for updating) */ /*--------------------------------------------------------*/ void Refer2Form (char *passedfilename) { FILE *fp; CitationPtr C; /* The passed file should contain a single citation */ fp = fopen (passedfilename, "r"); if (!fp) { printf ("ERROR: Could not open file passed from techrep.\n"); return; } C = read_one_citation (fp); if (!C) { printf ("ERROR: Could not read citation passed from techrep.\n"); return; } fclose(fp); PrintUpdatedFilledForm (C); }/* end of Refer2Form */ /*--------------------------------------------------------*/ /* Refer2View: */ /* */ /* reads a refer bib entry (in passedfilename) */ /* and displays the information in html format. */ /* (by calling DisplayReferEntry) */ /* (used for previewing during posting) */ /*--------------------------------------------------------*/ void Refer2View (char *passedfilename) { FILE *fp; CitationPtr C; /* The passed file should contain a single citation */ fp = fopen (passedfilename, "r"); if (!fp) { printf ("ERROR: Could not open file passed from techrep.\n"); return; } C = read_one_citation (fp); if (!C) { printf ("ERROR: Could not read citation passed from techrep.\n"); return; } fclose(fp); DisplayReferEntry (C); }/* end of Refer2View */ /* * Prints html-ized refer for the given citation. */ void PrintReferFormat (CitationPtr C) { char temp_array[N_STRINGS][STRING_SIZE]; int listCount; int x; if (getAuthor(C)) { listCount = ListtoArray(temp_array, getAuthor(C)); for (x = 0; x < listCount; x++) { printf ("%%%c %s\n
        ", REF_AUTHOR, temp_array[x]); } } if (getTitle(C)) { printf ("%%%c %s\n
        ", REF_TITLE, getTitle(C)); } if (getOrg(C)) { printf ("%%%c %s\n
        ", REF_INST, getOrg(C)); } if (getTrId(C)) { printf ("%%%c %s\n
        ", REF_REPORT, getTrId(C)); } if (getDate(C)) { printf ("%%%c %s\n
        ", REF_DATE, getDate(C)); } if (getUrl(C)) { printf ("%%%c %s\n
        ", REF_URL, getUrl(C)); } if (getKeywords(C)) { printf ("%%%c ", REF_KEYWORDS); listCount = ListtoArray(temp_array, getKeywords(C)); for (x = 0; x < listCount; x++) { printf ("%s, ",temp_array[x]); } printf ("\n
        "); } if (getCategories(C)) { printf ("%%%c ", REF_CATEGORY); listCount = ListtoArray(temp_array, getCategories(C)); for (x = 0; x < listCount ; x++) { printf ("%s, ",temp_array[x]); } printf ("\n
        "); } if (getAbstract(C)) { printf ("%%%c %s\n
        ", REF_ABSTRACT,getAbstract(C)); } } void PrintRestOfForm (CitationPtr C) { FILE *fp; char orgFile[STRING_SIZE]; char line[STRING_SIZE], *org; int first = TRUE; char *month, *day, *year; int i; /* organization */ sprintf (orgFile, "%s/lib/TrSeriesNames", TR_HOME); if ((fp = fopen(orgFile, "r")) == NULL) { fprintf (stderr, "Could not find file containing organization names."); exit(1); } orgText (); printf ("

        \n"); fclose (fp); /* date */ dateText(); printf ("\n"); if (day) { printf ("\n", day); } else { printf ("\n"); } if (year) { printf ("

        \n", year); } else { printf ("

        \n"); } /* title */ titleText(); if (!getTitle(C)) { printf ("

        \n"); } else { printf ("

        \n",getTitle(C)); } /* authors */ authorText(); if (!getAuthor(C)) { printf ("

        \n"); } else { printf ("

        \n",getAuthor(C)); } emailText(); printf ("

        \n"); /* url */ filenameText(); if (!getUrl(C)) { printf ("

        \n"); } else { printf ("

        \n",getUrl(C)); } /* abstract */ abstractText(); if (!getAbstract(C)) { printf ("

        \n"); } else { printf ("

        \n",getAbstract(C)); } /* keywords */ keywordsText(); if (!getKeywords(C)) { printf ("

        \n"); } else { printf ("

        \n", getKeywords(C)); } /* cr subject categories */ reviewsText(); if (!getCategories(C)) { printf ("

        \n"); } else { printf ("

        \n", getCategories(C)); } commentsText(); printf ("

        \n"); printf ("

      \n"); printf ("

      \n"); /* printf ("

      \n");*/ printf ("

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

      \n"); printf ("

      \n"); } void directionsText() { printf ("

      Directions

      "); printf ("Fill out the form below. Be sure to specify your email address in the\n"); printf ("space provided. This information is collated and sent to %s,\n", TR_ADMIN); printf ("who is the report administrator at your site. The report administrator\n"); printf ("verifies the information on the form with you before posting it in\n"); printf ("the online archive.

      \n"); printf ("Be aware that when you submit a request it must be verified\n"); printf ("Thus there will be some delay\n"); printf ("in the appearance of your report in the online archive.

      \n"); printf ("\n"); } void reportText() { printf ("

    • TECHNICAL REPORT NUMBER:
      \n"); } void reportText2() { printf ("
    • TECHNICAL REPORT NUMBER:This is a unique string that identifies\n"); printf ("your TR. This is generally assigned by an 'official' source\n"); printf ("within your organization.
      \n"); } void dateText() { printf ("
    • DATE WRITTEN: The date format should be \"Month Day Year\",\n"); printf ("for example, \"July 4 1994\"
      \n"); } void titleText() { printf ("
    • TITLE OF TECHNICAL REPORT:
      \n"); } void authorText() { printf ("
    • AUTHORS: The general format for each author is"); printf ("\"{lastname}{suffix},{firstname}{other}\". Author names are separated\n"); printf ("by a semi-colon (\";\"). For example, a report authored by
      \n"); printf ("\"Thurston B. Howell III, J. E. B. Stuart, and J. von Neuman\"
      \n"); printf ("should be entered as
      \n"); printf ("\"Howell III, Thurston B.; Stuart, J. E. B.; von Neuman, J.\"
      \n"); } void filenameText() { printf ("
    • PATH AND FILENAME OF TECHNICAL REPORT:This file must be\n"); printf ("globally readable so that it can be copied to\n"); printf ("the on-line archive.
      \n"); } void abstractText() { printf ("
    • ABSTRACT: Put the full text of the abstract here.
      \n"); } void keywordsText() { printf ("
    • KEYWORDS:
      \n"); } void reviewsText() { printf ("
    • COMPUTING REVIEWS SUBJECT CATEGORIES (OPTIONAL):
      \n"); printf ("Here is a list of possible categories\n", HELP_URL); printf ("Separate category names with a semicolon \";\"
      \n"); } void commentsText() { printf ("
    • COMMENTS: Place any comments you need to make to the Report\n"); printf ("Administrator here. These comments are not saved as part of\n"); printf ("the bibliographic entry for your report.\n"); } void emailText() { printf ("
    • CONTACT PERSON: The email address (probably your own) of the\n"); printf ("person who will verify the information provided here.
      \n"); } void orgText() { printf ("
    • INSTITUTION/TR-SERIES: Select one from the list.
      \n"); } /* parse the date format making an attempt to be intelligent about it. */ void parseDate (char *curDate, char **month, char **day, char **year) { char *str, *tok1, *tok2, *tok3; char *p; int i, numTokens, len, tmpInt; *month = *day = *year = NULL; /* Count the number of tokens in the date */ str = strdup(curDate); stripTrailingBlanks(curDate); str = stripLeadingBlanks(curDate); tok1 = tok2 = tok3 = NULL; numTokens=0; p = str; tok1 = p; while (*p) { while (isalnum(*p) && *p) p++; numTokens++; while (isspace(*p) || ispunct(*p)) /* skip blanks, filling with nulls */ *p++ = '\0'; if (numTokens == 1) tok2 = p; else if (numTokens == 2) tok3 = p; } if (numTokens == 1) { /* probably year only */ *year = tok1; } else { /* probably month year or month day, year*/ len = strlen(tok1); if (isalpha(tok1[0])) /* for ease of comparison */ tok1[0] = toupper(tok1[0]); /* set the month */ for (i=0; i<12; i++) { if (strstr(monthList[i],tok1)) { *month = strdup(monthList[i]); break; } } if (!(*month)) { *month = strdup(monthList[12]); *year = NULL; *day = NULL; } else { /* Do the year */ if (numTokens == 2) { tmpInt = atoi(tok2); if (tmpInt) { *year = tok2; } } else { tmpInt = atoi(tok2); if ((tmpInt >= 1) && (tmpInt <= 31)) { *day = tok2; } tmpInt = atoi(tok3); if (tmpInt) { *year = tok3; } } } } } void setDate (char **month, char **day, char **year) { struct tm *curTime; time_t clock; char buf[STRING_SIZE]; char *s; int i; clock = time(0); curTime = localtime(&clock); strftime (buf, STRING_SIZE-1, "%B", curTime); *month = strdup(buf); strftime (buf, STRING_SIZE-1, "%d", curTime); *day = strdup(buf); strftime (buf, STRING_SIZE-1, "%Y", curTime); *year = strdup(buf); }