void exToHt(char *filename) { char line[MaxLineLength], *line2; char *title, *pagename; FILE *inFile = fopen(filename, "r"); FILE *outFile; int len, i; struct timeval tvp; struct stat buf; if (inFile == NULL) { fprintf(stderr, "couldn't open %s for reading.\n", filename); return; } strcpy(line, "Menu"); strcat(line, filename); len = strlen(line); for (i = 0; i < len; i++) if (line[i] == '.') { line[i] = '\0'; break; } outFile = fopen(line, "w"); if (outFile == NULL) { fprintf(stderr, "couldn't open %s for writing.\n", line); return; } pagename = allocString(line); title = getExTitle(inFile, line); if (title == NULL) { return; } files[numFiles++] = pagename; emitCoverLink(pagename, title); emitHeader(outFile, pagename, title); while (fgets(line, MaxLineLength, inFile) != NULL) { if ((line2 = strPrefix("\\begin{page}{", line))) emitMenuEntry(line2, outFile); else if ((line2 = strPrefix("\\spadcommand{", line))) emitSpadCommand(line2, "\\spadcommand{", outFile); else if ((line2 = strPrefix("\\spadpaste{", line))) emitSpadCommand(line2, "\\spadpaste{", outFile); else if ((line2 = strPrefix("\\example{", line))) emitSpadCommand(line2, "\\example{", outFile); else if ((line2 = strPrefix("\\graphpaste{", line))) emitSpadCommand(line2, "\\graphpaste{", outFile); } emitFooter(outFile); fclose(inFile); fclose(outFile); stat(filename,&buf); tvp.tv_sec =buf.st_mtime; tvp.tv_usec =0; if timercmp(&tvp,&latest_date[1],>){ latest_date[1].tv_sec=buf.st_mtime; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // PBook::EcoSummary(): // Produce a summary from the PBook for the specified ECO code prefix. void PBook::EcoSummary (const char * ecoPrefix, DString * dstr) { uint depth = strLength (ecoPrefix); const char * prevEcoStr = ""; for (uint i=0; i < NodeListCount; i++) { bookNodeT * node = NodeList[i]; if (node == NULL) { continue; } const char * comment = node->data.comment; const char * ecoStr = epd_findOpcode (comment, "eco"); const char * movesStr = epd_findOpcode (comment, "moves"); if (ecoStr != NULL && strIsPrefix (ecoPrefix, ecoStr)) { if (depth < 3 && strPrefix (ecoStr, prevEcoStr) >= depth+1) { continue; } prevEcoStr = ecoStr; while (*ecoStr != '\n' && *ecoStr != 0) { dstr->AddChar (*ecoStr); ecoStr++; } dstr->Append (" "); while (*movesStr != '\n' && *movesStr != 0) { dstr->AddChar (*movesStr); movesStr++; } dstr->AddChar ('\n'); } } }
char * getExTitle(FILE *inFile, char *line) { char *title; while (fgets(line, MaxLineLength, inFile) != NULL) if ((title = strPrefix("% Title: ", line))) { title[strlen(title) - 1] = '\0'; return title; } fprintf(stderr, "No Title title line in the file!\n"); return NULL; }
static void check_spad_proc(char *file, char *prefix) { char *num; int pid; if ((num = strPrefix(prefix, file))) { pid = atoi(num); if (pid > 2) { kill(pid, 0); if (kill(pid, 0) == -1 && errno == ESRCH) { unlink(file); } } } }
HRESULT CXMLElement::SetNamespaceUri(LPCWSTR wszPrefix, int cchPrefix, LPCWSTR wszUri, int cchUri) { if (cchPrefix == -1) { cchPrefix = (int)wcslen(wszPrefix); } CStringW strPrefix(wszPrefix, cchPrefix); if (cchUri == -1) { cchUri = (int)wcslen(wszUri); } CStringW strUri(wszUri, cchUri); return SetNamespaceUri(strPrefix, strUri); }