/* Search the entire CHM file for the requested text and add all of * the found items to a ListView for the user to choose the item * they want. */ void InitSearch(HHInfo *info, const char *needle) { CHMInfo *chm = info->pCHMInfo; SearchItem *root_item = alloc_search_item(NULL, NULL); SearchCHM_Storage(root_item, chm->pStorage, needle); fill_search_tree(info->search.hwndList, root_item->next); if(info->search.root) ReleaseSearch(info); info->search.root = root_item; }
/* Search all children of a CHM storage object for the requested text and * return the last found search item. */ static SearchItem *SearchCHM_Storage(SearchItem *item, IStorage *pStorage, const char *needle) { const WCHAR szHTMext[] = {'.','h','t','m',0}; IEnumSTATSTG *elem = NULL; WCHAR *filename = NULL; STATSTG entries; HRESULT hres; ULONG retr; hres = IStorage_EnumElements(pStorage, 0, NULL, 0, &elem); if(hres != S_OK) { FIXME("Could not enumerate '/' storage elements: %08x\n", hres); return NULL; } while (IEnumSTATSTG_Next(elem, 1, &entries, &retr) == NOERROR) { switch(entries.type) { case STGTY_STORAGE: item = SearchCHM_Folder(item, pStorage, entries.pwcsName, needle); break; case STGTY_STREAM: filename = entries.pwcsName; while(strchrW(filename, '/')) filename = strchrW(filename, '/')+1; if(strstrW(filename, szHTMext)) { WCHAR *title = SearchCHM_File(pStorage, filename, needle); if(title) { item->next = alloc_search_item(title, entries.pwcsName); item = item->next; } } break; default: FIXME("Unhandled IStorage stream element.\n"); } } IEnumSTATSTG_Release(elem); return item; }