/* sponsor.c - Picks a sponsor at random out of */ /* the proper sponsor datafile and prints it to the */ /* screen for output to a web-page. */ #include #include #include #define LINES 14 int random(); void getsponsor(int); void sponsorcounter(void); /* This is the sponsor structure. Global, boo. */ struct sponsor { char sponsorfile[15]; char sponsorimg[15]; char sponsoraddr[200]; }banner; void main() { int index; /* Now to select which sponsor to read, between 1 */ /* and the number of sponsors. */ index = random(); /* Read in the sponsor's name, address, & image. */ getsponsor(index); /* Finally, print the sponsor information. */ if((strcmp("gchance", banner.sponsorfile) !=0)) printf("", &banner.sponsorfile, &banner.sponsoraddr, &banner.sponsorimg); else printf("", &banner.sponsorfile, &banner.sponsoraddr, &banner.sponsorimg); /* if((strcmp("gchance", banner.sponsorfile) != 0)) printf("", &banner.sponsoraddr, &banner.sponsorimg); else printf("", &banner.sponsoraddr, &banner.sponsorimg); */ } int random(void) { int tmp=LINES; int number; srand((unsigned) time((time_t *)NULL)); number = (rand()%(tmp+1)); if(number<1) number = 1; else if(number>tmp) number = tmp; return(number); } void getsponsor(int index) { /* Open the sponsor file and read the indexth */ /* line--store it in the sponsor banner struct. */ char buffer[100]; int loop=0; FILE *fp; if ( (fp = fopen("/home/12Mega/html/cgi/datafile", "r") ) == NULL) { printf("List of sponsors could not be found!\n"); exit(); } while((fgets(buffer, 200, fp) != NULL) & (loop