static void AnalyzeUserPage(const char *username) { Scanner s = NULL; char filename[PATH_MAX]; struct wordlist list; const char *extensions[] = {"html", "htm", "shtml", "shtm"}; int numExtensions = sizeof (extensions) / sizeof (extensions[0]); int i; for (i = 0; s == NULL && i < numExtensions; i++) { sprintf(filename, "/afs/ir.stanford.edu/users/%c/%c/%s/WWW/index.%s", username[0], username[1], username, extensions[i]); s = NewScannerFromFilename(filename, DELIMITERS, false); } if (s == NULL) { printf("\nSorry, there appears to be no page for \"%s\".\n", username); return; } printf("\nExtracting words from the home page of \"%s\"...\n", username); list.count = 0; ExtractWordsIntoList(s, &list); PrintList(&list); FreeList(&list); FreeScanner(s); }
int FinalizePreprocessor(void) { # define CPP_STUFF true # ifdef CPP_STUFF FreeAtomTable(atable); FreeCPPStruct(); FreeScanner(); # endif return 0; }
main() { scannerADT myScanner; string token; int nTokens; myScanner = NewScanner(); printf("Enter input line: "); SetScannerString(myScanner, GetLine()); nTokens = 0; while (MoreTokensExist(myScanner)) { token = ReadToken(myScanner); nTokens++; printf("%2d: \"%s\"\n", nTokens, token); } FreeScanner(myScanner); }
void FreeCommandScanner(cmdScannerADT cs) { FreeSymbolTable(cs->cmdTable); FreeScanner(cs->scanner); FreeBlock(cs); }