void CheckRejectList() { FILE *in; char *remoteAddress; remoteAddress = getenv("REMOTE_ADDR"); if (!remoteAddress) { return; } in = fopen("/home/boutell/forbidden.txt", "r"); if (!in) { /* Bad news -- can't access the list */ return; } while (!feof(in)) { char s[80]; char address[80]; if (!fgets(s, 80, in)) { break; } /* Call the RemoveSpaces function, introduced in chapter 4. You will need to include that function from wbw1.c if you use this code. */ RemoveSpaces(address, s); /* Check for a match. */ if (!strcmp(remoteAddress, address)) { printf("Content-type: text/html\n\n"); printf("\n"); printf("Access Forbidden\n"); printf("\n"); printf("\n"); printf("

Access Forbidden

\n"); printf("Access to this program from your IP address\n"); printf("is forbidden due to abusive actions on the\n"); printf("part of a user at that address.\n"); printf("\n"); /* Make sure the message gets sent by flushing standard output */ fflush(stdout); /* Force an early exit from the program */ fclose(in); exit(0); } } fclose(in); /* All is well; return normally */ }