ReactOS 0.4.17-dev-806-gffa4164
chm.c File Reference
#include "hhctrl.h"
#include "stream.h"
#include "winreg.h"
#include "shlwapi.h"
#include "wine/debug.h"
Include dependency graph for chm.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (htmlhelp)
 
static LPCSTR GetChmString (CHMInfo *chm, DWORD offset)
 
static BOOL ReadChmSystem (CHMInfo *chm)
 
LPWSTR FindContextAlias (CHMInfo *chm, DWORD index)
 
static WCHARFindHTMLHelpSetting (HHInfo *info, const WCHAR *extW)
 
static WCHARMergeChmString (LPCWSTR src, WCHAR **dst)
 
void MergeChmProperties (HH_WINTYPEW *src, HHInfo *info, BOOL override)
 
static WCHARConvertChmString (HHInfo *info, DWORD id)
 
static void wintype_free (HH_WINTYPEW *wintype)
 
BOOL LoadWinTypeFromCHM (HHInfo *info)
 
LPCWSTR skip_schema (LPCWSTR url)
 
void SetChmPath (ChmPath *file, LPCWSTR base_file, LPCWSTR path)
 
IStreamGetChmStream (CHMInfo *info, LPCWSTR parent_chm, ChmPath *chm_file)
 
WCHARGetDocumentTitle (CHMInfo *info, LPCWSTR document)
 
CHMInfoOpenCHM (LPCWSTR szFile)
 
CHMInfoCloseCHM (CHMInfo *chm)
 

Function Documentation

◆ CloseCHM()

CHMInfo * CloseCHM ( CHMInfo chm)

Definition at line 683 of file chm.c.

684{
685 if(chm->pITStorage)
686 IITStorage_Release(chm->pITStorage);
687
688 if(chm->pStorage)
689 IStorage_Release(chm->pStorage);
690
691 if(chm->strings_stream)
692 IStream_Release(chm->strings_stream);
693
694 if(chm->strings_size) {
695 DWORD i;
696
697 for(i=0; i<chm->strings_size; i++)
698 free(chm->strings[i]);
699 }
700
701 free(chm->strings);
702 free(chm->defWindow);
703 free(chm->defTitle);
704 free(chm->defTopic);
705 free(chm->defToc);
706 free(chm->szFile);
707 free(chm->compiledFile);
708 free(chm);
709
710 return NULL;
711}
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
WCHAR * defTopic
Definition: hhctrl.h:108
IStorage * pStorage
Definition: hhctrl.h:99
DWORD strings_size
Definition: hhctrl.h:104
WCHAR * defTitle
Definition: hhctrl.h:109
char ** strings
Definition: hhctrl.h:103
WCHAR * compiledFile
Definition: hhctrl.h:106
IITStorage * pITStorage
Definition: hhctrl.h:98
WCHAR * defToc
Definition: hhctrl.h:110
IStream * strings_stream
Definition: hhctrl.h:102
WCHAR * szFile
Definition: hhctrl.h:100
WCHAR * defWindow
Definition: hhctrl.h:107

Referenced by OpenCHM(), and ReleaseHelpViewer().

◆ ConvertChmString()

static WCHAR * ConvertChmString ( HHInfo info,
DWORD  id 
)
inlinestatic

Definition at line 327 of file chm.c.

328{
329 WCHAR *ret = NULL;
330
331 if(id)
332 ret = strdupAtoW(GetChmString(info->pCHMInfo, id));
333 return ret;
334}
static LPCSTR GetChmString(CHMInfo *chm, DWORD offset)
Definition: chm.c:35
static WCHAR * strdupAtoW(const char *str)
Definition: main.c:61
return ret
Definition: mutex.c:147
short WCHAR
Definition: pedump.c:58

Referenced by LoadWinTypeFromCHM().

◆ FindContextAlias()

LPWSTR FindContextAlias ( CHMInfo chm,
DWORD  index 
)

Definition at line 188 of file chm.c.

189{
190 IStream *ivb_stream;
191 DWORD size, read, i;
192 DWORD *buf;
193 LPCSTR ret = NULL;
195
196 static const WCHAR wszIVB[] = {'#','I','V','B',0};
197
198 hres = IStorage_OpenStream(chm->pStorage, wszIVB, NULL, STGM_READ, 0, &ivb_stream);
199 if(FAILED(hres)) {
200 WARN("Could not open #IVB stream: %08lx\n", hres);
201 return NULL;
202 }
203
204 hres = IStream_Read(ivb_stream, &size, sizeof(size), &read);
205 if(FAILED(hres)) {
206 WARN("Read failed: %08lx\n", hres);
207 IStream_Release(ivb_stream);
208 return NULL;
209 }
210
211 buf = malloc(size);
212 hres = IStream_Read(ivb_stream, buf, size, &read);
213 IStream_Release(ivb_stream);
214 if(FAILED(hres)) {
215 WARN("Read failed: %08lx\n", hres);
216 free(buf);
217 return NULL;
218 }
219
220 size /= 2*sizeof(DWORD);
221
222 for(i=0; i<size; i++) {
223 if(buf[2*i] == index) {
224 ret = GetChmString(chm, buf[2*i+1]);
225 break;
226 }
227 }
228
229 free(buf);
230
231 TRACE("returning %s\n", debugstr_a(ret));
232 return strdupAtoW(ret);
233}
#define read
Definition: acwin.h:97
#define WARN(fmt,...)
Definition: precomp.h:61
#define malloc
Definition: debug_ros.c:4
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_a
Definition: kernel32.h:31
HRESULT hres
Definition: protocol.c:465
#define DWORD
Definition: nt_native.h:44
#define STGM_READ
Definition: objbase.h:936
#define TRACE(s)
Definition: solgame.cpp:4
const char * LPCSTR
Definition: typedefs.h:52

Referenced by HtmlHelpW().

◆ FindHTMLHelpSetting()

static WCHAR * FindHTMLHelpSetting ( HHInfo info,
const WCHAR extW 
)
static

Definition at line 239 of file chm.c.

240{
241 static const WCHAR periodW[] = {'.',0};
242 IStorage *pStorage = info->pCHMInfo->pStorage;
243 IStream *pStream;
245 HRESULT hr;
246
247 filename = malloc( (wcslen(info->pCHMInfo->compiledFile)
248 + wcslen(periodW) + wcslen(extW) + 1) * sizeof(WCHAR) );
249 lstrcpyW(filename, info->pCHMInfo->compiledFile);
250 lstrcatW(filename, periodW);
251 lstrcatW(filename, extW);
252 hr = IStorage_OpenStream(pStorage, filename, NULL, STGM_READ, 0, &pStream);
253 if (FAILED(hr))
254 {
255 free(filename);
256 return strdupAtoW("");
257 }
258 IStream_Release(pStream);
259 return filename;
260}
HRESULT hr
Definition: delayimp.cpp:582
#define lstrcpyW
Definition: compat.h:749
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
const char * filename
Definition: ioapi.h:137
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

Referenced by LoadWinTypeFromCHM().

◆ GetChmStream()

IStream * GetChmStream ( CHMInfo info,
LPCWSTR  parent_chm,
ChmPath chm_file 
)

Definition at line 552 of file chm.c.

553{
557
558 TRACE("%s (%s :: %s)\n", debugstr_w(parent_chm), debugstr_w(chm_file->chm_file),
559 debugstr_w(chm_file->chm_index));
560
561 if(parent_chm || chm_file->chm_file) {
562 hres = IITStorage_StgOpenStorage(info->pITStorage,
563 chm_file->chm_file ? chm_file->chm_file : parent_chm, NULL,
565 if(FAILED(hres)) {
566 WARN("Could not open storage: %08lx\n", hres);
567 return NULL;
568 }
569 }else {
570 storage = info->pStorage;
571 IStorage_AddRef(info->pStorage);
572 }
573
574 hres = IStorage_OpenStream(storage, chm_file->chm_index, NULL, STGM_READ, 0, &stream);
575 IStorage_Release(storage);
576 if(FAILED(hres))
577 WARN("Could not open stream: %08lx\n", hres);
578
579 return stream;
580}
#define debugstr_w
Definition: kernel32.h:32
#define STGM_SHARE_DENY_WRITE
Definition: objbase.h:941
LPWSTR chm_file
Definition: hhctrl.h:54
LPWSTR chm_index
Definition: hhctrl.h:55
Definition: parse.h:23

Referenced by InitContent(), InitIndex(), and parse_sitemap_object().

◆ GetChmString()

static LPCSTR GetChmString ( CHMInfo chm,
DWORD  offset 
)
static

Definition at line 35 of file chm.c.

36{
37 LPCSTR str;
38 char **new_strings;
39 DWORD new_strings_size;
40
41 if(!chm->strings_stream)
42 return NULL;
43
44 if(chm->strings_size <= (offset >> BLOCK_BITS)) {
45 new_strings_size = (offset >> BLOCK_BITS) + 1;
46 new_strings = realloc(chm->strings, new_strings_size * sizeof(char*));
47 if(!new_strings)
48 return NULL;
49 memset(new_strings + chm->strings_size, 0,
50 (new_strings_size - chm->strings_size) * sizeof(char*));
51 chm->strings = new_strings;
52 chm->strings_size = new_strings_size;
53 }
54
55 if(!chm->strings[offset >> BLOCK_BITS]) {
57 DWORD read;
59
60 pos.QuadPart = offset & ~BLOCK_MASK;
61 hres = IStream_Seek(chm->strings_stream, pos, STREAM_SEEK_SET, NULL);
62 if(FAILED(hres)) {
63 WARN("Seek failed: %08lx\n", hres);
64 return NULL;
65 }
66
68
69 hres = IStream_Read(chm->strings_stream, chm->strings[offset >> BLOCK_BITS],
71 if(FAILED(hres)) {
72 WARN("Read failed: %08lx\n", hres);
73 free(chm->strings[offset >> BLOCK_BITS]);
74 chm->strings[offset >> BLOCK_BITS] = NULL;
75 return NULL;
76 }
77 }
78
80 TRACE("offset %#lx => %s\n", offset, debugstr_a(str));
81 return str;
82}
#define realloc
Definition: debug_ros.c:6
#define BLOCK_SIZE
Definition: dlist.c:220
#define BLOCK_MASK
Definition: stream.h:24
#define BLOCK_BITS
Definition: stream.h:22
GLintptr offset
Definition: glext.h:5920
const WCHAR * str
#define memset(x, y, z)
Definition: compat.h:39

Referenced by ConvertChmString(), and FindContextAlias().

◆ GetDocumentTitle()

WCHAR * GetDocumentTitle ( CHMInfo info,
LPCWSTR  document 
)

Definition at line 585 of file chm.c.

586{
587 strbuf_t node, node_name, content;
588 WCHAR *document_title = NULL;
589 IStream *str = NULL;
593
594 TRACE("%s\n", debugstr_w(document));
595
596 storage = info->pStorage;
597 if(!storage) {
598 WARN("Could not open storage to obtain the title for a document.\n");
599 return NULL;
600 }
601 IStorage_AddRef(storage);
602
603 hres = IStorage_OpenStream(storage, document, NULL, STGM_READ, 0, &str);
604 IStorage_Release(storage);
605 if(FAILED(hres))
606 WARN("Could not open stream: %08lx\n", hres);
607
611 strbuf_init(&node_name);
612
613 while(next_node(&stream, &node)) {
614 get_node_name(&node, &node_name);
615
616 TRACE("%s\n", node.buf);
617
618 if(!stricmp(node_name.buf, "title")) {
619 if(next_content(&stream, &content) && content.len > 1)
620 {
621 document_title = strdupnAtoW(&content.buf[1], content.len-1);
622 FIXME("magic: %s\n", debugstr_w(document_title));
623 break;
624 }
625 }
626
628 }
629
632 strbuf_free(&node_name);
633 IStream_Release(str);
634
635 return document_title;
636}
#define FIXME(fmt,...)
Definition: precomp.h:53
content
Definition: atl_ax.c:990
static void strbuf_init(strbuf *buf)
Definition: registrar.c:75
#define stricmp(_String1, _String2)
Definition: compat.h:24
void strbuf_free(strbuf_t *buf)
Definition: stream.c:38
BOOL next_node(stream_t *stream, strbuf_t *buf)
Definition: stream.c:140
BOOL next_content(stream_t *stream, strbuf_t *buf)
Definition: stream.c:105
void strbuf_zero(strbuf_t *buf)
Definition: stream.c:33
void stream_init(stream_t *stream, IStream *str)
Definition: stream.c:54
void get_node_name(strbuf_t *node, strbuf_t *name)
Definition: stream.c:88
static LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
Definition: hhctrl.h:250
char * buf
Definition: stream.h:27
Definition: dlist.c:348

Referenced by OnTopicChange().

◆ LoadWinTypeFromCHM()

BOOL LoadWinTypeFromCHM ( HHInfo info)

Definition at line 357 of file chm.c.

358{
359 LARGE_INTEGER liOffset;
360 IStorage *pStorage = info->pCHMInfo->pStorage;
361 IStream *pStream = NULL;
362 HH_WINTYPEW wintype;
363 HRESULT hr;
364 DWORD cbRead;
365 BOOL ret = FALSE;
366
367 static const WCHAR empty[] = {0};
368 static const WCHAR toc_extW[] = {'h','h','c',0};
369 static const WCHAR index_extW[] = {'h','h','k',0};
370 static const WCHAR windowsW[] = {'#','W','I','N','D','O','W','S',0};
371
372 /* HH_WINTYPE as stored on disk. It's identical to HH_WINTYPE except that the pointer fields
373 have been changed to DWORDs, so that the layout on 64-bit remains unchanged. */
374 struct file_wintype
375 {
376 int cbStruct;
377 BOOL fUniCodeStrings;
378 DWORD pszType;
379 DWORD fsValidMembers;
380 DWORD fsWinProperties;
381 DWORD pszCaption;
382 DWORD dwStyles;
383 DWORD dwExStyles;
384 RECT rcWindowPos;
385 int nShowState;
386 DWORD hwndHelp;
387 DWORD hwndCaller;
388 DWORD paInfoTypes;
389 DWORD hwndToolBar;
390 DWORD hwndNavigation;
391 DWORD hwndHTML;
392 int iNavWidth;
393 RECT rcHTML;
394 DWORD pszToc;
395 DWORD pszIndex;
396 DWORD pszFile;
397 DWORD pszHome;
398 DWORD fsToolBarFlags;
399 BOOL fNotExpanded;
400 int curNavType;
401 int tabpos;
402 int idNotify;
403 BYTE tabOrder[HH_MAX_TABS+1];
404 int cHistory;
405 DWORD pszJump1;
406 DWORD pszJump2;
407 DWORD pszUrlJump1;
408 DWORD pszUrlJump2;
409 RECT rcMinSize;
410 int cbInfoTypes;
411 DWORD pszCustomTabs;
412 } file_wintype;
413
414 memset(&wintype, 0, sizeof(wintype));
415 wintype.cbStruct = sizeof(wintype);
416 wintype.fUniCodeStrings = TRUE;
417
418 hr = IStorage_OpenStream(pStorage, windowsW, NULL, STGM_READ, 0, &pStream);
419 if (SUCCEEDED(hr))
420 {
421 /* jump past the #WINDOWS header */
422 liOffset.QuadPart = sizeof(DWORD) * 2;
423
424 hr = IStream_Seek(pStream, liOffset, STREAM_SEEK_SET, NULL);
425 if (FAILED(hr)) goto done;
426
427 /* read the HH_WINTYPE struct data */
428 hr = IStream_Read(pStream, &file_wintype, sizeof(file_wintype), &cbRead);
429 if (FAILED(hr)) goto done;
430
431 /* convert the #STRINGS offsets to actual strings */
432 wintype.pszType = ConvertChmString(info, file_wintype.pszType);
433 wintype.fsValidMembers = file_wintype.fsValidMembers;
434 wintype.fsWinProperties = file_wintype.fsWinProperties;
435 wintype.pszCaption = ConvertChmString(info, file_wintype.pszCaption);
436 wintype.dwStyles = file_wintype.dwStyles;
437 wintype.dwExStyles = file_wintype.dwExStyles;
438 wintype.rcWindowPos = file_wintype.rcWindowPos;
439 wintype.nShowState = file_wintype.nShowState;
440 wintype.iNavWidth = file_wintype.iNavWidth;
441 wintype.rcHTML = file_wintype.rcHTML;
442 wintype.pszToc = ConvertChmString(info, file_wintype.pszToc);
443 wintype.pszIndex = ConvertChmString(info, file_wintype.pszIndex);
444 wintype.pszFile = ConvertChmString(info, file_wintype.pszFile);
445 wintype.pszHome = ConvertChmString(info, file_wintype.pszHome);
446 wintype.fsToolBarFlags = file_wintype.fsToolBarFlags;
447 wintype.fNotExpanded = file_wintype.fNotExpanded;
448 wintype.curNavType = file_wintype.curNavType;
449 wintype.tabpos = file_wintype.tabpos;
450 wintype.idNotify = file_wintype.idNotify;
451 memcpy(&wintype.tabOrder, file_wintype.tabOrder, sizeof(wintype.tabOrder));
452 wintype.cHistory = file_wintype.cHistory;
453 wintype.pszJump1 = ConvertChmString(info, file_wintype.pszJump1);
454 wintype.pszJump2 = ConvertChmString(info, file_wintype.pszJump2);
455 wintype.pszUrlJump1 = ConvertChmString(info, file_wintype.pszUrlJump1);
456 wintype.pszUrlJump2 = ConvertChmString(info, file_wintype.pszUrlJump2);
457 wintype.rcMinSize = file_wintype.rcMinSize;
458 wintype.cbInfoTypes = file_wintype.cbInfoTypes;
459 }
460 else
461 {
462 /* no defined window types so use (hopefully) sane defaults */
463 static const WCHAR defaultwinW[] = {'d','e','f','a','u','l','t','w','i','n','\0'};
464 wintype.pszType = wcsdup(info->pCHMInfo->defWindow ? info->pCHMInfo->defWindow : defaultwinW);
465 wintype.pszToc = wcsdup(info->pCHMInfo->defToc ? info->pCHMInfo->defToc : empty);
466 wintype.pszIndex = wcsdup(empty);
467 wintype.fsValidMembers = 0;
469 wintype.dwStyles = WS_POPUP;
470 wintype.dwExStyles = 0;
471 wintype.nShowState = SW_SHOW;
473 }
474
475 /* merge the new data with any pre-existing HH_WINTYPE structure */
476 MergeChmProperties(&wintype, info, FALSE);
477 if (!info->WinType.pszCaption)
478#ifdef __REACTOS__
479 info->WinType.pszCaption = info->stringsW.pszCaption = (info->pCHMInfo->defTitle ? wcsdup(info->pCHMInfo->defTitle) : HH_LoadString(IDS_DEFTITLE));
480#else
481 info->WinType.pszCaption = info->stringsW.pszCaption = wcsdup(info->pCHMInfo->defTitle ? info->pCHMInfo->defTitle : empty);
482#endif
483 if (!info->WinType.pszFile)
484 info->WinType.pszFile = info->stringsW.pszFile = wcsdup(info->pCHMInfo->defTopic ? info->pCHMInfo->defTopic : empty);
485 if (!info->WinType.pszToc)
486 info->WinType.pszToc = info->stringsW.pszToc = FindHTMLHelpSetting(info, toc_extW);
487 if (!info->WinType.pszIndex)
488 info->WinType.pszIndex = info->stringsW.pszIndex = FindHTMLHelpSetting(info, index_extW);
489
490 wintype_free(&wintype);
491 ret = TRUE;
492
493done:
494 if (pStream)
495 IStream_Release(pStream);
496
497 return ret;
498}
static void wintype_free(HH_WINTYPEW *wintype)
Definition: chm.c:336
static WCHAR * ConvertChmString(HHInfo *info, DWORD id)
Definition: chm.c:327
static WCHAR * FindHTMLHelpSetting(HHInfo *info, const WCHAR *extW)
Definition: chm.c:239
void MergeChmProperties(HH_WINTYPEW *src, HHInfo *info, BOOL override)
Definition: chm.c:269
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR empty[1]
Definition: string.c:47
static LPWSTR HH_LoadString(DWORD dwID)
Definition: help.c:177
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
unsigned int BOOL
Definition: ntddk_ex.h:94
#define HH_MAX_TABS
Definition: htmlhelp.h:260
@ HHWIN_NAVTYPE_TOC
Definition: htmlhelp.h:217
#define HHWIN_PROP_TRI_PANE
Definition: htmlhelp.h:60
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define WS_POPUP
Definition: pedump.c:616
LPCWSTR pszIndex
Definition: htmlhelp.h:359
BYTE tabOrder[HH_MAX_TABS+1]
Definition: htmlhelp.h:367
LPCWSTR pszJump1
Definition: htmlhelp.h:369
LPCWSTR pszHome
Definition: htmlhelp.h:361
DWORD dwStyles
Definition: htmlhelp.h:346
RECT rcWindowPos
Definition: htmlhelp.h:348
DWORD dwExStyles
Definition: htmlhelp.h:347
LPCWSTR pszToc
Definition: htmlhelp.h:358
DWORD fsToolBarFlags
Definition: htmlhelp.h:362
LPCWSTR pszJump2
Definition: htmlhelp.h:370
DWORD fsValidMembers
Definition: htmlhelp.h:343
LPCWSTR pszType
Definition: htmlhelp.h:342
LPCWSTR pszUrlJump2
Definition: htmlhelp.h:372
LPCWSTR pszFile
Definition: htmlhelp.h:360
LPCWSTR pszCaption
Definition: htmlhelp.h:345
DWORD fsWinProperties
Definition: htmlhelp.h:344
BOOL fUniCodeStrings
Definition: htmlhelp.h:341
BOOL fNotExpanded
Definition: htmlhelp.h:363
LPCWSTR pszUrlJump1
Definition: htmlhelp.h:371
RECT rcMinSize
Definition: htmlhelp.h:373
LONGLONG QuadPart
Definition: typedefs.h:114
#define SW_SHOW
Definition: winuser.h:786
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CreateHelpViewer().

◆ MergeChmProperties()

void MergeChmProperties ( HH_WINTYPEW src,
HHInfo info,
BOOL  override 
)

Definition at line 269 of file chm.c.

270{
271 DWORD unhandled_params = src->fsValidMembers & ~(HHWIN_PARAM_PROPERTIES|HHWIN_PARAM_STYLES
276 HH_WINTYPEW *dst = &info->WinType;
277 DWORD merge = override ? src->fsValidMembers : src->fsValidMembers & ~dst->fsValidMembers;
278
279 if (unhandled_params)
280 FIXME("Unsupported fsValidMembers fields: 0x%lx\n", unhandled_params);
281
282 dst->fsValidMembers |= merge;
283 if (dst->cbStruct == 0)
284 {
285 /* If the structure has not been filled in yet then use all of the values */
286 dst->cbStruct = sizeof(HH_WINTYPEW);
287 merge = ~0;
288 }
289 if (merge & HHWIN_PARAM_PROPERTIES) dst->fsWinProperties = src->fsWinProperties;
290 if (merge & HHWIN_PARAM_STYLES) dst->dwStyles = src->dwStyles;
291 if (merge & HHWIN_PARAM_EXSTYLES) dst->dwExStyles = src->dwExStyles;
292 if (merge & HHWIN_PARAM_RECT) dst->rcWindowPos = src->rcWindowPos;
293 if (merge & HHWIN_PARAM_NAV_WIDTH) dst->iNavWidth = src->iNavWidth;
294 if (merge & HHWIN_PARAM_SHOWSTATE) dst->nShowState = src->nShowState;
295 if (merge & HHWIN_PARAM_INFOTYPES) dst->paInfoTypes = src->paInfoTypes;
296 if (merge & HHWIN_PARAM_TB_FLAGS) dst->fsToolBarFlags = src->fsToolBarFlags;
297 if (merge & HHWIN_PARAM_EXPANSION) dst->fNotExpanded = src->fNotExpanded;
298 if (merge & HHWIN_PARAM_TABPOS) dst->tabpos = src->tabpos;
299 if (merge & HHWIN_PARAM_TABORDER) memcpy(dst->tabOrder, src->tabOrder, sizeof(src->tabOrder));
300 if (merge & HHWIN_PARAM_HISTORY_COUNT) dst->cHistory = src->cHistory;
301 if (merge & HHWIN_PARAM_CUR_TAB) dst->curNavType = src->curNavType;
302
303 /*
304 * Note: We assume that hwndHelp, hwndCaller, hwndToolBar, hwndNavigation, and hwndHTML cannot be
305 * modified by the user. rcHTML and rcMinSize are not currently supported, so don't bother to copy them.
306 */
307
308 dst->pszType = MergeChmString(src->pszType, &info->stringsW.pszType);
309 dst->pszFile = MergeChmString(src->pszFile, &info->stringsW.pszFile);
310 dst->pszToc = MergeChmString(src->pszToc, &info->stringsW.pszToc);
311 dst->pszIndex = MergeChmString(src->pszIndex, &info->stringsW.pszIndex);
312 dst->pszCaption = MergeChmString(src->pszCaption, &info->stringsW.pszCaption);
313 dst->pszHome = MergeChmString(src->pszHome, &info->stringsW.pszHome);
314 dst->pszJump1 = MergeChmString(src->pszJump1, &info->stringsW.pszJump1);
315 dst->pszJump2 = MergeChmString(src->pszJump2, &info->stringsW.pszJump2);
316 dst->pszUrlJump1 = MergeChmString(src->pszUrlJump1, &info->stringsW.pszUrlJump1);
317 dst->pszUrlJump2 = MergeChmString(src->pszUrlJump2, &info->stringsW.pszUrlJump2);
318
319 /* FIXME: pszCustomTabs is a list of multiple zero-terminated strings so ReadString won't
320 * work in this case
321 */
322#if 0
323 dst->pszCustomTabs = MergeChmString(src->pszCustomTabs, &info->pszCustomTabs);
324#endif
325}
_STLP_MOVE_TO_STD_NAMESPACE _OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2, _OutputIter __result)
Definition: _algo.c:1419
static WCHAR * MergeChmString(LPCWSTR src, WCHAR **dst)
Definition: chm.c:262
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define HHWIN_PARAM_CUR_TAB
Definition: htmlhelp.h:97
#define HHWIN_PARAM_EXSTYLES
Definition: htmlhelp.h:87
struct tagHH_WINTYPEW HH_WINTYPEW
#define HHWIN_PARAM_TB_FLAGS
Definition: htmlhelp.h:92
#define HHWIN_PARAM_NAV_WIDTH
Definition: htmlhelp.h:89
#define HHWIN_PARAM_TABPOS
Definition: htmlhelp.h:94
#define HHWIN_PARAM_TABORDER
Definition: htmlhelp.h:95
#define HHWIN_PARAM_INFOTYPES
Definition: htmlhelp.h:91
#define HHWIN_PARAM_SHOWSTATE
Definition: htmlhelp.h:90
#define HHWIN_PARAM_PROPERTIES
Definition: htmlhelp.h:85
#define HHWIN_PARAM_RECT
Definition: htmlhelp.h:88
#define HHWIN_PARAM_EXPANSION
Definition: htmlhelp.h:93
#define HHWIN_PARAM_STYLES
Definition: htmlhelp.h:86
#define HHWIN_PARAM_HISTORY_COUNT
Definition: htmlhelp.h:96

Referenced by HtmlHelpW(), and LoadWinTypeFromCHM().

◆ MergeChmString()

static WCHAR * MergeChmString ( LPCWSTR  src,
WCHAR **  dst 
)
inlinestatic

Definition at line 262 of file chm.c.

263{
264 if(*dst == NULL)
265 *dst = wcsdup(src);
266 return *dst;
267}

Referenced by MergeChmProperties().

◆ OpenCHM()

CHMInfo * OpenCHM ( LPCWSTR  szFile)

Definition at line 639 of file chm.c.

640{
642 CHMInfo *ret;
643
644 static const WCHAR wszSTRINGS[] = {'#','S','T','R','I','N','G','S',0};
645
646 if (!(ret = calloc(1, sizeof(CHMInfo))))
647 return NULL;
648 ret->codePage = CP_ACP;
649
650 if (!(ret->szFile = wcsdup(szFile))) {
651 free(ret);
652 return NULL;
653 }
654
655 hres = CoCreateInstance(&CLSID_ITStorage, NULL, CLSCTX_INPROC_SERVER,
656 &IID_IITStorage, (void **) &ret->pITStorage) ;
657 if(FAILED(hres)) {
658 WARN("Could not create ITStorage: %08lx\n", hres);
659 return CloseCHM(ret);
660 }
661
662 hres = IITStorage_StgOpenStorage(ret->pITStorage, szFile, NULL,
663 STGM_READ | STGM_SHARE_DENY_WRITE, NULL, 0, &ret->pStorage);
664 if(FAILED(hres)) {
665 WARN("Could not open storage: %08lx\n", hres);
666 return CloseCHM(ret);
667 }
668 hres = IStorage_OpenStream(ret->pStorage, wszSTRINGS, NULL, STGM_READ, 0,
669 &ret->strings_stream);
670 if(FAILED(hres)) {
671 WARN("Could not open #STRINGS stream: %08lx\n", hres);
672 /* It's not critical, so we pass */
673 }
674
675 if(!ReadChmSystem(ret)) {
676 WARN("Could not read #SYSTEM\n");
677 return CloseCHM(ret);
678 }
679
680 return ret;
681}
CHMInfo * CloseCHM(CHMInfo *chm)
Definition: chm.c:683
static BOOL ReadChmSystem(CHMInfo *chm)
Definition: chm.c:84
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define CP_ACP
Definition: compat.h:109
#define calloc
Definition: rosglue.h:14
Definition: hhctrl.h:97

Referenced by CreateHelpViewer().

◆ ReadChmSystem()

static BOOL ReadChmSystem ( CHMInfo chm)
static

Definition at line 84 of file chm.c.

85{
87 DWORD ver=0xdeadbeef, read, buf_size;
88 char *buf, *new_buf;
90
91 struct {
92 WORD code;
93 WORD len;
94 } entry;
95
96 static const WCHAR wszSYSTEM[] = {'#','S','Y','S','T','E','M',0};
97
98 hres = IStorage_OpenStream(chm->pStorage, wszSYSTEM, NULL, STGM_READ, 0, &stream);
99 if(FAILED(hres)) {
100 WARN("Could not open #SYSTEM stream: %08lx\n", hres);
101 return FALSE;
102 }
103
104 IStream_Read(stream, &ver, sizeof(ver), &read);
105 TRACE("version is %lx\n", ver);
106
107 buf_size = 8 * sizeof(DWORD);
108 buf = malloc(buf_size);
109 if(!buf) {
110 IStream_Release(stream);
111 return FALSE;
112 }
113
114 while(1) {
115 hres = IStream_Read(stream, &entry, sizeof(entry), &read);
116 if(hres != S_OK)
117 break;
118
119 if(entry.len > buf_size) {
120 new_buf = realloc(buf, entry.len);
121 if(!new_buf) {
123 break;
124 }
125 buf = new_buf;
126 buf_size = entry.len;
127 }
128
129 hres = IStream_Read(stream, buf, entry.len, &read);
130 if(hres != S_OK)
131 break;
132
133 switch(entry.code) {
134 case 0x0:
135 TRACE("TOC is %s\n", debugstr_an(buf, entry.len));
136 free(chm->defToc);
137 chm->defToc = strdupnAtoW(buf, entry.len);
138 break;
139 case 0x2:
140 TRACE("Default topic is %s\n", debugstr_an(buf, entry.len));
141 free(chm->defTopic);
142 chm->defTopic = strdupnAtoW(buf, entry.len);
143 break;
144 case 0x3:
145 TRACE("Title is %s\n", debugstr_an(buf, entry.len));
146 free(chm->defTitle);
147 chm->defTitle = strdupnAtoW(buf, entry.len);
148 break;
149 case 0x4:
150 /* TODO: Currently only the Locale ID is loaded from this field */
151 TRACE("Locale is: %ld\n", *(LCID*)&buf[0]);
152 if(!GetLocaleInfoW(*(LCID*)&buf[0], LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER,
153 (WCHAR *)&chm->codePage, sizeof(chm->codePage)/sizeof(WCHAR)))
154 chm->codePage = CP_ACP;
155 break;
156 case 0x5:
157 TRACE("Window name is %s\n", debugstr_an(buf, entry.len));
158 chm->defWindow = strdupnAtoW(buf, entry.len);
159 break;
160 case 0x6:
161 TRACE("Compiled file is %s\n", debugstr_an(buf, entry.len));
162 free(chm->compiledFile);
163 chm->compiledFile = strdupnAtoW(buf, entry.len);
164 break;
165 case 0x9:
166 TRACE("Version is %s\n", debugstr_an(buf, entry.len));
167 break;
168 case 0xa:
169 TRACE("Time is %08lx\n", *(DWORD*)buf);
170 break;
171 case 0xc:
172 TRACE("Number of info types: %ld\n", *(DWORD*)buf);
173 break;
174 case 0xf:
175 TRACE("Check sum: %lx\n", *(DWORD*)buf);
176 break;
177 default:
178 TRACE("unhandled code %x, size %x\n", entry.code, entry.len);
179 }
180 }
181
182 free(buf);
183 IStream_Release(stream);
184
185 return SUCCEEDED(hres);
186}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1675
unsigned short WORD
Definition: ntddk_ex.h:93
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:52
uint32_t entry
Definition: isohybrid.c:63
DWORD LCID
Definition: nls.h:13
UINT codePage
Definition: hhctrl.h:112
Definition: inflate.c:139
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:48

Referenced by OpenCHM().

◆ SetChmPath()

void SetChmPath ( ChmPath file,
LPCWSTR  base_file,
LPCWSTR  path 
)

Definition at line 516 of file chm.c.

517{
518 LPCWSTR ptr;
519 static const WCHAR separatorW[] = {':',':',0};
520
522
524 if(ptr) {
525 WCHAR chm_file[MAX_PATH];
526 WCHAR rel_path[MAX_PATH];
527 WCHAR base_path[MAX_PATH];
528 LPWSTR p;
529
530 lstrcpyW(base_path, base_file);
531 p = wcsrchr(base_path, '\\');
532 if(p)
533 *p = 0;
534
535 memcpy(rel_path, path, (ptr-path)*sizeof(WCHAR));
536 rel_path[ptr-path] = 0;
537
538 PathCombineW(chm_file, base_path, rel_path);
539
540 file->chm_file = wcsdup(chm_file);
541 ptr += 2;
542 }else {
543 file->chm_file = wcsdup(base_file);
544 ptr = path;
545 }
546
547 file->chm_index = wcsdup(ptr);
548
549 TRACE("ChmFile = {%s %s}\n", debugstr_w(file->chm_file), debugstr_w(file->chm_index));
550}
LPCWSTR skip_schema(LPCWSTR url)
Definition: chm.c:500
#define wcsrchr
Definition: compat.h:16
#define MAX_PATH
Definition: compat.h:34
_ACRTIMP wchar_t *__cdecl wcsstr(const wchar_t *, const wchar_t *)
Definition: wcs.c:2998
GLfloat GLfloat p
Definition: glext.h:8902
static PVOID ptr
Definition: dispmode.c:27
static const WCHAR separatorW[]
Definition: itemdlg.c:1561
#define PathCombineW
Definition: pathcch.h:318
Definition: fci.c:123
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by InitContent(), InitIndex(), NavigateToUrl(), and parse_obj_node_param().

◆ skip_schema()

LPCWSTR skip_schema ( LPCWSTR  url)

Definition at line 500 of file chm.c.

501{
502 static const WCHAR its_schema[] = {'i','t','s',':'};
503 static const WCHAR msits_schema[] = {'m','s','-','i','t','s',':'};
504 static const WCHAR mk_schema[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':'};
505
506 if(!wcsnicmp(its_schema, url, ARRAY_SIZE(its_schema)))
507 return url + ARRAY_SIZE(its_schema);
508 if(!wcsnicmp(msits_schema, url, ARRAY_SIZE(msits_schema)))
509 return url + ARRAY_SIZE(msits_schema);
510 if(!wcsnicmp(mk_schema, url, ARRAY_SIZE(mk_schema)))
511 return url + ARRAY_SIZE(mk_schema);
512
513 return url;
514}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define wcsnicmp
Definition: compat.h:14
static const WCHAR url[]
Definition: encode.c:1384

Referenced by resolve_filename(), and SetChmPath().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( htmlhelp  )

◆ wintype_free()

static void wintype_free ( HH_WINTYPEW wintype)
inlinestatic

Definition at line 336 of file chm.c.

337{
338 free((void *)wintype->pszType);
339 free((void *)wintype->pszCaption);
340 free(wintype->paInfoTypes);
341 free((void *)wintype->pszToc);
342 free((void *)wintype->pszIndex);
343 free((void *)wintype->pszFile);
344 free((void *)wintype->pszHome);
345 free((void *)wintype->pszJump1);
346 free((void *)wintype->pszJump2);
347 free((void *)wintype->pszUrlJump1);
348 free((void *)wintype->pszUrlJump2);
349 free((void *)wintype->pszCustomTabs);
350}
PHH_INFOTYPE paInfoTypes
Definition: htmlhelp.h:352
LPCWSTR pszCustomTabs
Definition: htmlhelp.h:375

Referenced by LoadWinTypeFromCHM().