/* Input : A file containing lines, each with a word count, white space, and path to an HTML files, starting with "./" Output: same, but with a prepended ISO language code in front, and an appended title. */ #include #include #include #include #include #include #include "getfhtml.h" int main (int argc, char **argv) { static char count_and_path[1024]; FILE *fpi = stdin; FILE *fpo = stdout; while (fgets(count_and_path, sizeof count_and_path, fpi)) { char lang[3+1+2+1+4+1]; char *p, *htmlpath; p = strrchr(count_and_path, '\n'); if (p) *p = '\0'; htmlpath = strstr(count_and_path, "./"); if (!htmlpath || htmlpath < count_and_path + 1 || !isspace(htmlpath[-1])) continue; strcpy(lang, "??"); p = gfh_GetFromPath(htmlpath, 1 << 10, "html", "lang"); if (p) strcpy(lang, p); p = gfh_GetFromPath(htmlpath, 1 << 10, "title", ""); fprintf(fpo, "\t %s %s %s\n", lang, htmlpath + 2, p ? p : "NO TITLE FOUND", count_and_path); } return 0; }