/* Search the documentation pages for the string 'text', building the index if necessary */ void i7_search_window_search_documentation(I7SearchWindow *self) { GError *err; if(doc_index == NULL) { /* documentation index hasn't been built yet */ GFile *doc_file = i7_app_get_data_file_va(i7_app_get(), "Documentation", NULL); GFileEnumerator *docdir; if((docdir = g_file_enumerate_children(doc_file, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, &err)) == NULL) { IO_ERROR_DIALOG(GTK_WINDOW(self), doc_file, err, _("opening documentation directory")); g_object_unref(doc_file); return; } start_spinner(self); GFileInfo *info; while((info = g_file_enumerator_next_file(docdir, NULL, &err)) != NULL) { const char *basename = g_file_info_get_name(info); const char *displayname = g_file_info_get_display_name(info); if(!g_str_has_suffix(basename, ".html") || (!g_str_has_prefix(basename, "doc") && !g_str_has_prefix(basename, "Rdoc"))) continue; char *label = g_strdup_printf(_("Please be patient, indexing %s..."), displayname); gtk_label_set_text(GTK_LABEL(self->search_text), label); g_free(label); while(gtk_events_pending()) gtk_main_iteration(); GFile *file = g_file_get_child(doc_file, basename); GSList *doctexts = html_to_ascii(file, g_str_has_prefix(basename, "R")); g_object_unref(file); if(doctexts != NULL) { GSList *iter; /* Append the entries to the documentation index and search them right now while we're at it */ for(iter = doctexts; iter != NULL; iter = g_slist_next(iter)) { doc_index = g_list_prepend(doc_index, iter->data); search_documentation(iter->data, self); } g_slist_free(doctexts); } } g_object_unref(doc_file); stop_spinner(self); update_label(self); } else { start_spinner(self); g_list_foreach(doc_index, (GFunc)search_documentation, self); stop_spinner(self); } return; }
static void TestHTML2ASCII_line(void) { int fdin = 0;// STDIN const char *Err; StrBuf *Source; char *Target; Source = NewStrBuf(); while (fdin == 0) { StrBufTCP_read_line(Source, &fdin, 0, &Err); printf("the source:>%s<\n", ChrPtr(Source)); Target = html_to_ascii(ChrPtr(Source), StrLength(Source), 80, 0); printf("the target:>%s<\n", Target); FlushStrBuf(Source); free(Target); } FreeStrBuf(&Source); }