4 * Copyright 2005 James Hawkins
5 * Copyright 2007 Jacek Caban
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp
);
31 /* Reads a string from the #STRINGS section in the CHM file */
32 static LPCSTR
GetChmString(CHMInfo
*chm
, DWORD offset
)
36 DWORD new_strings_size
;
38 if(!chm
->strings_stream
)
41 if(chm
->strings_size
<= (offset
>> BLOCK_BITS
)) {
42 new_strings_size
= (offset
>> BLOCK_BITS
) + 1;
43 new_strings
= realloc(chm
->strings
, new_strings_size
* sizeof(char*));
46 memset(new_strings
+ chm
->strings_size
, 0,
47 (new_strings_size
- chm
->strings_size
) * sizeof(char*));
48 chm
->strings
= new_strings
;
49 chm
->strings_size
= new_strings_size
;
52 if(!chm
->strings
[offset
>> BLOCK_BITS
]) {
57 pos
.QuadPart
= offset
& ~BLOCK_MASK
;
58 hres
= IStream_Seek(chm
->strings_stream
, pos
, STREAM_SEEK_SET
, NULL
);
60 WARN("Seek failed: %08lx\n", hres
);
64 chm
->strings
[offset
>> BLOCK_BITS
] = malloc(BLOCK_SIZE
);
66 hres
= IStream_Read(chm
->strings_stream
, chm
->strings
[offset
>> BLOCK_BITS
],
69 WARN("Read failed: %08lx\n", hres
);
70 free(chm
->strings
[offset
>> BLOCK_BITS
]);
71 chm
->strings
[offset
>> BLOCK_BITS
] = NULL
;
76 str
= chm
->strings
[offset
>> BLOCK_BITS
] + (offset
& BLOCK_MASK
);
77 TRACE("offset %#lx => %s\n", offset
, debugstr_a(str
));
81 static BOOL
ReadChmSystem(CHMInfo
*chm
)
84 DWORD ver
=0xdeadbeef, read
, buf_size
;
93 static const WCHAR wszSYSTEM
[] = {'#','S','Y','S','T','E','M',0};
95 hres
= IStorage_OpenStream(chm
->pStorage
, wszSYSTEM
, NULL
, STGM_READ
, 0, &stream
);
97 WARN("Could not open #SYSTEM stream: %08lx\n", hres
);
101 IStream_Read(stream
, &ver
, sizeof(ver
), &read
);
102 TRACE("version is %lx\n", ver
);
104 buf_size
= 8 * sizeof(DWORD
);
105 buf
= malloc(buf_size
);
107 IStream_Release(stream
);
112 hres
= IStream_Read(stream
, &entry
, sizeof(entry
), &read
);
116 if(entry
.len
> buf_size
) {
117 new_buf
= realloc(buf
, entry
.len
);
119 hres
= E_OUTOFMEMORY
;
123 buf_size
= entry
.len
;
126 hres
= IStream_Read(stream
, buf
, entry
.len
, &read
);
132 TRACE("TOC is %s\n", debugstr_an(buf
, entry
.len
));
134 chm
->defToc
= strdupnAtoW(buf
, entry
.len
);
137 TRACE("Default topic is %s\n", debugstr_an(buf
, entry
.len
));
139 chm
->defTopic
= strdupnAtoW(buf
, entry
.len
);
142 TRACE("Title is %s\n", debugstr_an(buf
, entry
.len
));
144 chm
->defTitle
= strdupnAtoW(buf
, entry
.len
);
147 /* TODO: Currently only the Locale ID is loaded from this field */
148 TRACE("Locale is: %ld\n", *(LCID
*)&buf
[0]);
149 if(!GetLocaleInfoW(*(LCID
*)&buf
[0], LOCALE_IDEFAULTANSICODEPAGE
|LOCALE_RETURN_NUMBER
,
150 (WCHAR
*)&chm
->codePage
, sizeof(chm
->codePage
)/sizeof(WCHAR
)))
151 chm
->codePage
= CP_ACP
;
154 TRACE("Window name is %s\n", debugstr_an(buf
, entry
.len
));
155 chm
->defWindow
= strdupnAtoW(buf
, entry
.len
);
158 TRACE("Compiled file is %s\n", debugstr_an(buf
, entry
.len
));
159 free(chm
->compiledFile
);
160 chm
->compiledFile
= strdupnAtoW(buf
, entry
.len
);
163 TRACE("Version is %s\n", debugstr_an(buf
, entry
.len
));
166 TRACE("Time is %08lx\n", *(DWORD
*)buf
);
169 TRACE("Number of info types: %ld\n", *(DWORD
*)buf
);
172 TRACE("Check sum: %lx\n", *(DWORD
*)buf
);
175 TRACE("unhandled code %x, size %x\n", entry
.code
, entry
.len
);
180 IStream_Release(stream
);
182 return SUCCEEDED(hres
);
185 LPWSTR
FindContextAlias(CHMInfo
*chm
, DWORD index
)
193 static const WCHAR wszIVB
[] = {'#','I','V','B',0};
195 hres
= IStorage_OpenStream(chm
->pStorage
, wszIVB
, NULL
, STGM_READ
, 0, &ivb_stream
);
197 WARN("Could not open #IVB stream: %08lx\n", hres
);
201 hres
= IStream_Read(ivb_stream
, &size
, sizeof(size
), &read
);
203 WARN("Read failed: %08lx\n", hres
);
204 IStream_Release(ivb_stream
);
209 hres
= IStream_Read(ivb_stream
, buf
, size
, &read
);
210 IStream_Release(ivb_stream
);
212 WARN("Read failed: %08lx\n", hres
);
217 size
/= 2*sizeof(DWORD
);
219 for(i
=0; i
<size
; i
++) {
220 if(buf
[2*i
] == index
) {
221 ret
= GetChmString(chm
, buf
[2*i
+1]);
228 TRACE("returning %s\n", debugstr_a(ret
));
229 return strdupAtoW(ret
);
233 * Tests if the file <chmfile>.<ext> exists, used for loading Indices, Table of Contents, etc.
234 * when these files are not available from the HH_WINTYPE structure.
236 static WCHAR
*FindHTMLHelpSetting(HHInfo
*info
, const WCHAR
*extW
)
238 static const WCHAR periodW
[] = {'.',0};
239 IStorage
*pStorage
= info
->pCHMInfo
->pStorage
;
244 filename
= malloc( (wcslen(info
->pCHMInfo
->compiledFile
)
245 + wcslen(periodW
) + wcslen(extW
) + 1) * sizeof(WCHAR
) );
246 lstrcpyW(filename
, info
->pCHMInfo
->compiledFile
);
247 lstrcatW(filename
, periodW
);
248 lstrcatW(filename
, extW
);
249 hr
= IStorage_OpenStream(pStorage
, filename
, NULL
, STGM_READ
, 0, &pStream
);
253 return strdupAtoW("");
255 IStream_Release(pStream
);
259 static inline WCHAR
*MergeChmString(LPCWSTR src
, WCHAR
**dst
)
266 void MergeChmProperties(HH_WINTYPEW
*src
, HHInfo
*info
, BOOL override
)
268 DWORD unhandled_params
= src
->fsValidMembers
& ~(HHWIN_PARAM_PROPERTIES
|HHWIN_PARAM_STYLES
269 |HHWIN_PARAM_EXSTYLES
|HHWIN_PARAM_RECT
|HHWIN_PARAM_NAV_WIDTH
270 |HHWIN_PARAM_SHOWSTATE
|HHWIN_PARAM_INFOTYPES
|HHWIN_PARAM_TB_FLAGS
271 |HHWIN_PARAM_EXPANSION
|HHWIN_PARAM_TABPOS
|HHWIN_PARAM_TABORDER
272 |HHWIN_PARAM_HISTORY_COUNT
|HHWIN_PARAM_CUR_TAB
);
273 HH_WINTYPEW
*dst
= &info
->WinType
;
274 DWORD merge
= override
? src
->fsValidMembers
: src
->fsValidMembers
& ~dst
->fsValidMembers
;
276 if (unhandled_params
)
277 FIXME("Unsupported fsValidMembers fields: 0x%lx\n", unhandled_params
);
279 dst
->fsValidMembers
|= merge
;
280 if (dst
->cbStruct
== 0)
282 /* If the structure has not been filled in yet then use all of the values */
283 dst
->cbStruct
= sizeof(HH_WINTYPEW
);
286 if (merge
& HHWIN_PARAM_PROPERTIES
) dst
->fsWinProperties
= src
->fsWinProperties
;
287 if (merge
& HHWIN_PARAM_STYLES
) dst
->dwStyles
= src
->dwStyles
;
288 if (merge
& HHWIN_PARAM_EXSTYLES
) dst
->dwExStyles
= src
->dwExStyles
;
289 if (merge
& HHWIN_PARAM_RECT
) dst
->rcWindowPos
= src
->rcWindowPos
;
290 if (merge
& HHWIN_PARAM_NAV_WIDTH
) dst
->iNavWidth
= src
->iNavWidth
;
291 if (merge
& HHWIN_PARAM_SHOWSTATE
) dst
->nShowState
= src
->nShowState
;
292 if (merge
& HHWIN_PARAM_INFOTYPES
) dst
->paInfoTypes
= src
->paInfoTypes
;
293 if (merge
& HHWIN_PARAM_TB_FLAGS
) dst
->fsToolBarFlags
= src
->fsToolBarFlags
;
294 if (merge
& HHWIN_PARAM_EXPANSION
) dst
->fNotExpanded
= src
->fNotExpanded
;
295 if (merge
& HHWIN_PARAM_TABPOS
) dst
->tabpos
= src
->tabpos
;
296 if (merge
& HHWIN_PARAM_TABORDER
) memcpy(dst
->tabOrder
, src
->tabOrder
, sizeof(src
->tabOrder
));
297 if (merge
& HHWIN_PARAM_HISTORY_COUNT
) dst
->cHistory
= src
->cHistory
;
298 if (merge
& HHWIN_PARAM_CUR_TAB
) dst
->curNavType
= src
->curNavType
;
301 * Note: We assume that hwndHelp, hwndCaller, hwndToolBar, hwndNavigation, and hwndHTML cannot be
302 * modified by the user. rcHTML and rcMinSize are not currently supported, so don't bother to copy them.
305 dst
->pszType
= MergeChmString(src
->pszType
, &info
->stringsW
.pszType
);
306 dst
->pszFile
= MergeChmString(src
->pszFile
, &info
->stringsW
.pszFile
);
307 dst
->pszToc
= MergeChmString(src
->pszToc
, &info
->stringsW
.pszToc
);
308 dst
->pszIndex
= MergeChmString(src
->pszIndex
, &info
->stringsW
.pszIndex
);
309 dst
->pszCaption
= MergeChmString(src
->pszCaption
, &info
->stringsW
.pszCaption
);
310 dst
->pszHome
= MergeChmString(src
->pszHome
, &info
->stringsW
.pszHome
);
311 dst
->pszJump1
= MergeChmString(src
->pszJump1
, &info
->stringsW
.pszJump1
);
312 dst
->pszJump2
= MergeChmString(src
->pszJump2
, &info
->stringsW
.pszJump2
);
313 dst
->pszUrlJump1
= MergeChmString(src
->pszUrlJump1
, &info
->stringsW
.pszUrlJump1
);
314 dst
->pszUrlJump2
= MergeChmString(src
->pszUrlJump2
, &info
->stringsW
.pszUrlJump2
);
316 /* FIXME: pszCustomTabs is a list of multiple zero-terminated strings so ReadString won't
320 dst
->pszCustomTabs
= MergeChmString(src
->pszCustomTabs
, &info
->pszCustomTabs
);
324 static inline WCHAR
*ConvertChmString(HHInfo
*info
, DWORD id
)
329 ret
= strdupAtoW(GetChmString(info
->pCHMInfo
, id
));
333 static inline void wintype_free(HH_WINTYPEW
*wintype
)
335 free((void *)wintype
->pszType
);
336 free((void *)wintype
->pszCaption
);
337 free(wintype
->paInfoTypes
);
338 free((void *)wintype
->pszToc
);
339 free((void *)wintype
->pszIndex
);
340 free((void *)wintype
->pszFile
);
341 free((void *)wintype
->pszHome
);
342 free((void *)wintype
->pszJump1
);
343 free((void *)wintype
->pszJump2
);
344 free((void *)wintype
->pszUrlJump1
);
345 free((void *)wintype
->pszUrlJump2
);
346 free((void *)wintype
->pszCustomTabs
);
349 /* Loads the HH_WINTYPE data from the CHM file
351 * FIXME: There may be more than one window type in the file, so
352 * add the ability to choose a certain window type
354 BOOL
LoadWinTypeFromCHM(HHInfo
*info
)
356 LARGE_INTEGER liOffset
;
357 IStorage
*pStorage
= info
->pCHMInfo
->pStorage
;
358 IStream
*pStream
= NULL
;
364 static const WCHAR empty
[] = {0};
365 static const WCHAR toc_extW
[] = {'h','h','c',0};
366 static const WCHAR index_extW
[] = {'h','h','k',0};
367 static const WCHAR windowsW
[] = {'#','W','I','N','D','O','W','S',0};
369 /* HH_WINTYPE as stored on disk. It's identical to HH_WINTYPE except that the pointer fields
370 have been changed to DWORDs, so that the layout on 64-bit remains unchanged. */
374 BOOL fUniCodeStrings
;
376 DWORD fsValidMembers
;
377 DWORD fsWinProperties
;
387 DWORD hwndNavigation
;
395 DWORD fsToolBarFlags
;
400 BYTE tabOrder
[HH_MAX_TABS
+1];
411 memset(&wintype
, 0, sizeof(wintype
));
412 wintype
.cbStruct
= sizeof(wintype
);
413 wintype
.fUniCodeStrings
= TRUE
;
415 hr
= IStorage_OpenStream(pStorage
, windowsW
, NULL
, STGM_READ
, 0, &pStream
);
418 /* jump past the #WINDOWS header */
419 liOffset
.QuadPart
= sizeof(DWORD
) * 2;
421 hr
= IStream_Seek(pStream
, liOffset
, STREAM_SEEK_SET
, NULL
);
422 if (FAILED(hr
)) goto done
;
424 /* read the HH_WINTYPE struct data */
425 hr
= IStream_Read(pStream
, &file_wintype
, sizeof(file_wintype
), &cbRead
);
426 if (FAILED(hr
)) goto done
;
428 /* convert the #STRINGS offsets to actual strings */
429 wintype
.pszType
= ConvertChmString(info
, file_wintype
.pszType
);
430 wintype
.fsValidMembers
= file_wintype
.fsValidMembers
;
431 wintype
.fsWinProperties
= file_wintype
.fsWinProperties
;
432 wintype
.pszCaption
= ConvertChmString(info
, file_wintype
.pszCaption
);
433 wintype
.dwStyles
= file_wintype
.dwStyles
;
434 wintype
.dwExStyles
= file_wintype
.dwExStyles
;
435 wintype
.rcWindowPos
= file_wintype
.rcWindowPos
;
436 wintype
.nShowState
= file_wintype
.nShowState
;
437 wintype
.iNavWidth
= file_wintype
.iNavWidth
;
438 wintype
.rcHTML
= file_wintype
.rcHTML
;
439 wintype
.pszToc
= ConvertChmString(info
, file_wintype
.pszToc
);
440 wintype
.pszIndex
= ConvertChmString(info
, file_wintype
.pszIndex
);
441 wintype
.pszFile
= ConvertChmString(info
, file_wintype
.pszFile
);
442 wintype
.pszHome
= ConvertChmString(info
, file_wintype
.pszHome
);
443 wintype
.fsToolBarFlags
= file_wintype
.fsToolBarFlags
;
444 wintype
.fNotExpanded
= file_wintype
.fNotExpanded
;
445 wintype
.curNavType
= file_wintype
.curNavType
;
446 wintype
.tabpos
= file_wintype
.tabpos
;
447 wintype
.idNotify
= file_wintype
.idNotify
;
448 memcpy(&wintype
.tabOrder
, file_wintype
.tabOrder
, sizeof(wintype
.tabOrder
));
449 wintype
.cHistory
= file_wintype
.cHistory
;
450 wintype
.pszJump1
= ConvertChmString(info
, file_wintype
.pszJump1
);
451 wintype
.pszJump2
= ConvertChmString(info
, file_wintype
.pszJump2
);
452 wintype
.pszUrlJump1
= ConvertChmString(info
, file_wintype
.pszUrlJump1
);
453 wintype
.pszUrlJump2
= ConvertChmString(info
, file_wintype
.pszUrlJump2
);
454 wintype
.rcMinSize
= file_wintype
.rcMinSize
;
455 wintype
.cbInfoTypes
= file_wintype
.cbInfoTypes
;
459 /* no defined window types so use (hopefully) sane defaults */
460 static const WCHAR defaultwinW
[] = {'d','e','f','a','u','l','t','w','i','n','\0'};
461 wintype
.pszType
= wcsdup(info
->pCHMInfo
->defWindow
? info
->pCHMInfo
->defWindow
: defaultwinW
);
462 wintype
.pszToc
= wcsdup(info
->pCHMInfo
->defToc
? info
->pCHMInfo
->defToc
: empty
);
463 wintype
.pszIndex
= wcsdup(empty
);
464 wintype
.fsValidMembers
= 0;
465 wintype
.fsWinProperties
= HHWIN_PROP_TRI_PANE
;
466 wintype
.dwStyles
= WS_POPUP
;
467 wintype
.dwExStyles
= 0;
468 wintype
.nShowState
= SW_SHOW
;
469 wintype
.curNavType
= HHWIN_NAVTYPE_TOC
;
472 /* merge the new data with any pre-existing HH_WINTYPE structure */
473 MergeChmProperties(&wintype
, info
, FALSE
);
474 if (!info
->WinType
.pszCaption
)
475 info
->WinType
.pszCaption
= info
->stringsW
.pszCaption
= wcsdup(info
->pCHMInfo
->defTitle
? info
->pCHMInfo
->defTitle
: empty
);
476 if (!info
->WinType
.pszFile
)
477 info
->WinType
.pszFile
= info
->stringsW
.pszFile
= wcsdup(info
->pCHMInfo
->defTopic
? info
->pCHMInfo
->defTopic
: empty
);
478 if (!info
->WinType
.pszToc
)
479 info
->WinType
.pszToc
= info
->stringsW
.pszToc
= FindHTMLHelpSetting(info
, toc_extW
);
480 if (!info
->WinType
.pszIndex
)
481 info
->WinType
.pszIndex
= info
->stringsW
.pszIndex
= FindHTMLHelpSetting(info
, index_extW
);
483 wintype_free(&wintype
);
488 IStream_Release(pStream
);
493 LPCWSTR
skip_schema(LPCWSTR url
)
495 static const WCHAR its_schema
[] = {'i','t','s',':'};
496 static const WCHAR msits_schema
[] = {'m','s','-','i','t','s',':'};
497 static const WCHAR mk_schema
[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':'};
499 if(!wcsnicmp(its_schema
, url
, ARRAY_SIZE(its_schema
)))
500 return url
+ ARRAY_SIZE(its_schema
);
501 if(!wcsnicmp(msits_schema
, url
, ARRAY_SIZE(msits_schema
)))
502 return url
+ ARRAY_SIZE(msits_schema
);
503 if(!wcsnicmp(mk_schema
, url
, ARRAY_SIZE(mk_schema
)))
504 return url
+ ARRAY_SIZE(mk_schema
);
509 void SetChmPath(ChmPath
*file
, LPCWSTR base_file
, LPCWSTR path
)
512 static const WCHAR separatorW
[] = {':',':',0};
514 path
= skip_schema(path
);
516 ptr
= wcsstr(path
, separatorW
);
518 WCHAR chm_file
[MAX_PATH
];
519 WCHAR rel_path
[MAX_PATH
];
520 WCHAR base_path
[MAX_PATH
];
523 lstrcpyW(base_path
, base_file
);
524 p
= wcsrchr(base_path
, '\\');
528 memcpy(rel_path
, path
, (ptr
-path
)*sizeof(WCHAR
));
529 rel_path
[ptr
-path
] = 0;
531 PathCombineW(chm_file
, base_path
, rel_path
);
533 file
->chm_file
= wcsdup(chm_file
);
536 file
->chm_file
= wcsdup(base_file
);
540 file
->chm_index
= wcsdup(ptr
);
542 TRACE("ChmFile = {%s %s}\n", debugstr_w(file
->chm_file
), debugstr_w(file
->chm_index
));
545 IStream
*GetChmStream(CHMInfo
*info
, LPCWSTR parent_chm
, ChmPath
*chm_file
)
548 IStream
*stream
= NULL
;
551 TRACE("%s (%s :: %s)\n", debugstr_w(parent_chm
), debugstr_w(chm_file
->chm_file
),
552 debugstr_w(chm_file
->chm_index
));
554 if(parent_chm
|| chm_file
->chm_file
) {
555 hres
= IITStorage_StgOpenStorage(info
->pITStorage
,
556 chm_file
->chm_file
? chm_file
->chm_file
: parent_chm
, NULL
,
557 STGM_READ
| STGM_SHARE_DENY_WRITE
, NULL
, 0, &storage
);
559 WARN("Could not open storage: %08lx\n", hres
);
563 storage
= info
->pStorage
;
564 IStorage_AddRef(info
->pStorage
);
567 hres
= IStorage_OpenStream(storage
, chm_file
->chm_index
, NULL
, STGM_READ
, 0, &stream
);
568 IStorage_Release(storage
);
570 WARN("Could not open stream: %08lx\n", hres
);
576 * Retrieve a CHM document and parse the data from the <title> element to get the document's title.
578 WCHAR
*GetDocumentTitle(CHMInfo
*info
, LPCWSTR document
)
580 strbuf_t node
, node_name
, content
;
581 WCHAR
*document_title
= NULL
;
587 TRACE("%s\n", debugstr_w(document
));
589 storage
= info
->pStorage
;
591 WARN("Could not open storage to obtain the title for a document.\n");
594 IStorage_AddRef(storage
);
596 hres
= IStorage_OpenStream(storage
, document
, NULL
, STGM_READ
, 0, &str
);
597 IStorage_Release(storage
);
599 WARN("Could not open stream: %08lx\n", hres
);
601 stream_init(&stream
, str
);
603 strbuf_init(&content
);
604 strbuf_init(&node_name
);
606 while(next_node(&stream
, &node
)) {
607 get_node_name(&node
, &node_name
);
609 TRACE("%s\n", node
.buf
);
611 if(!stricmp(node_name
.buf
, "title")) {
612 if(next_content(&stream
, &content
) && content
.len
> 1)
614 document_title
= strdupnAtoW(&content
.buf
[1], content
.len
-1);
615 FIXME("magic: %s\n", debugstr_w(document_title
));
624 strbuf_free(&content
);
625 strbuf_free(&node_name
);
626 IStream_Release(str
);
628 return document_title
;
631 /* Opens the CHM file for reading */
632 CHMInfo
*OpenCHM(LPCWSTR szFile
)
637 static const WCHAR wszSTRINGS
[] = {'#','S','T','R','I','N','G','S',0};
639 if (!(ret
= calloc(1, sizeof(CHMInfo
))))
641 ret
->codePage
= CP_ACP
;
643 if (!(ret
->szFile
= wcsdup(szFile
))) {
648 hres
= CoCreateInstance(&CLSID_ITStorage
, NULL
, CLSCTX_INPROC_SERVER
,
649 &IID_IITStorage
, (void **) &ret
->pITStorage
) ;
651 WARN("Could not create ITStorage: %08lx\n", hres
);
652 return CloseCHM(ret
);
655 hres
= IITStorage_StgOpenStorage(ret
->pITStorage
, szFile
, NULL
,
656 STGM_READ
| STGM_SHARE_DENY_WRITE
, NULL
, 0, &ret
->pStorage
);
658 WARN("Could not open storage: %08lx\n", hres
);
659 return CloseCHM(ret
);
661 hres
= IStorage_OpenStream(ret
->pStorage
, wszSTRINGS
, NULL
, STGM_READ
, 0,
662 &ret
->strings_stream
);
664 WARN("Could not open #STRINGS stream: %08lx\n", hres
);
665 /* It's not critical, so we pass */
668 if(!ReadChmSystem(ret
)) {
669 WARN("Could not read #SYSTEM\n");
670 return CloseCHM(ret
);
676 CHMInfo
*CloseCHM(CHMInfo
*chm
)
679 IITStorage_Release(chm
->pITStorage
);
682 IStorage_Release(chm
->pStorage
);
684 if(chm
->strings_stream
)
685 IStream_Release(chm
->strings_stream
);
687 if(chm
->strings_size
) {
690 for(i
=0; i
<chm
->strings_size
; i
++)
691 free(chm
->strings
[i
]);
695 free(chm
->defWindow
);
700 free(chm
->compiledFile
);