/*************************************************************************/ /* STR_LIB.C by Nannette Thacker */ /*************************************************************************/ #include #include #include #include #include "str_lib.h" /*************************************************************************/ // print the code for the HTML file, making sure to include the content-type void printHeader(char * title) { /* Print the HTML header */ printf("Content-type: text/html\n\n"); printf("\n"); printf("%s\n",title); printf("\n"); printf("

%s

\n",title); return ; } /*************************************************************************/ void htmlPre() { // print the commands to send the code to the screen pre-formatted for HTML printf("

\n"); return ; } void htmlPreOff() { // print the commands to send the code to the screen pre-formatted for HTML printf("
\n"); return ; } /*************************************************************************/ void printFooter() { // close out the HTML file printf("\n"); printf("\n"); return ; } // ***************************************************************** // convert the passed string to uppercase and return the converted string char * str_toupper(char *str) { int i ; for (i = 0 ; i < strlen(str); ++ i) if (islower(str[i])) str[i] = toupper(str[i]); return(str); } // ***************************************************************** void trim( char *string ) { int how_long; how_long = strlen( string ); while ((string[how_long - 1] == 13) || (string[how_long - 1] == 10 ) || (string[how_long - 1] == ' ')) { string[how_long - 1] = '\0'; how_long = strlen( string ); } } // ***************************************************************** void stripquote(char *string) { int testcnt,strcnt; char teststring[256]; int exitthis = 0 ; testcnt = strcnt = 0 ; // ***************************************************************** strcpy(teststring,string); // copy the string to a test string do { if(teststring[testcnt] != '"') // if a quote, strip it out { string[strcnt] = teststring[testcnt] ; // reload the string, skipping the quotes strcnt ++ ; } testcnt++; if(testcnt >= strlen(string)) exitthis = 1 ; }while(exitthis == 0) ; string[strcnt] = '\0' ; } // *****************************************************************