#include #include #include #include #include #include #include #define CONFIG "checkmod.cfg" void remove_first(char *inpstr); struct { char name[256]; char desc[200]; } webfile[200]; int main(void) { int i=0,configmode=0,numfiles=0,width=0,height=0; char PATH_TO_DOC_ROOT[256]; char BACKGROUND[256]; char TARGET[256]; char TEXTCOLOR[256]; char LINKCOLOR[256]; char VLINKCOLOR[256]; char HEADERCOLOR[256]; char MESSAGE[256]; char filename[512]; char line[457]; char timestr[32]; struct stat fileinfo; time_t tm; time_t filetime; FILE *fp; /* clear out structs */ for (i=0;i<200;++i) { webfile[i].name[0]=0; webfile[i].desc[0]=0; } /* open config file */ if (!(fp=fopen(CONFIG,"r"))) exit(0); numfiles=0; /* read file */ while(fgets(line,456,fp) != NULL) { line[strlen(line)-1]=0; /* get rid of newline */ if ((line[0]=='#') || !strlen(line)) continue; switch(configmode) { case 0: strcpy(PATH_TO_DOC_ROOT,line); configmode++; break; case 1: strcpy(TARGET,line); configmode++; break; case 2: strcpy(BACKGROUND,line); configmode++; break; case 3: strcpy(TEXTCOLOR,line); configmode++; break; case 4: strcpy(LINKCOLOR,line); configmode++; break; case 5: strcpy(VLINKCOLOR,line); configmode++; break; case 6: strcpy(MESSAGE,line); configmode++; break; case 7: strcpy(HEADERCOLOR,line); configmode++; break; case 8: sscanf(line,"%d %d",&width,&height); configmode++; break; default: sscanf(line,"%s ",webfile[numfiles].name); remove_first(line); strcpy(webfile[numfiles].desc,line); numfiles++; break; } /* end of switch */ } /* end of while */ fclose(fp); /* printf("MESSAGE: %s\n",MESSAGE); printf("HEADERCOLOR: %s\n",HEADERCOLOR); printf("width: %d\n",width); printf("height: %d\n",height); for (i=0;i\n"); printf("\n"); printf("\n\n"); return 1; } /* end of main */ /*** removes first word at front of string and moves rest down ***/ void remove_first(char *inpstr) { int newpos,oldpos; newpos=0; oldpos=0; /* find first word */ while(inpstr[oldpos]==' ') { if (!inpstr[oldpos]) { inpstr[0]=0; return; } oldpos++; } /* find end of first word */ while(inpstr[oldpos]!=' ') { if (!inpstr[oldpos]) { inpstr[0]=0; return; } oldpos++; } /* find second word */ while(inpstr[oldpos]==' ') { if (!inpstr[oldpos]) { inpstr[0]=0; return; } oldpos++; } while(inpstr[oldpos]!=0) inpstr[newpos++]=inpstr[oldpos++]; inpstr[newpos]='\0'; }