break;
switch(entry.code) {
+ case 0x0:
+ TRACE("TOC is %s\n", debugstr_an(buf, entry.len));
+ heap_free(chm->defToc);
+ chm->defToc = strdupnAtoW(buf, entry.len);
+ break;
case 0x2:
TRACE("Default topic is %s\n", debugstr_an(buf, entry.len));
+ heap_free(chm->defTopic);
+ chm->defTopic = strdupnAtoW(buf, entry.len);
break;
case 0x3:
TRACE("Title is %s\n", debugstr_an(buf, entry.len));
+ heap_free(chm->defTitle);
+ chm->defTitle = strdupnAtoW(buf, entry.len);
break;
case 0x5:
TRACE("Default window is %s\n", debugstr_an(buf, entry.len));
hr = IStorage_OpenStream(pStorage, windowsW, NULL, STGM_READ, 0, &pStream);
if (FAILED(hr))
- return FALSE;
+ {
+ /* no defined window types so use (hopefully) sane defaults */
+ static const WCHAR defaultwinW[] = {'d','e','f','a','u','l','t','w','i','n','\0'};
+ static const WCHAR null[] = {0};
+ memset((void*)&(info->WinType), 0, sizeof(info->WinType));
+ info->WinType.cbStruct=sizeof(info->WinType);
+ info->WinType.fUniCodeStrings=TRUE;
+ info->WinType.pszType=strdupW(defaultwinW);
+ info->WinType.pszToc = strdupW(info->pCHMInfo->defToc);
+ info->WinType.pszIndex = strdupW(null);
+ info->WinType.fsValidMembers=0;
+ info->WinType.fsWinProperties=HHWIN_PROP_TRI_PANE;
+ info->WinType.pszCaption=strdupW(info->pCHMInfo->defTitle);
+ info->WinType.dwStyles=WS_POPUP;
+ info->WinType.dwExStyles=0;
+ info->WinType.nShowState=SW_SHOW;
+ info->WinType.pszFile=strdupW(info->pCHMInfo->defTopic);
+ info->WinType.curNavType=HHWIN_NAVTYPE_TOC;
+ return TRUE;
+ }
/* jump past the #WINDOWS header */
liOffset.QuadPart = sizeof(DWORD) * 2;
}
heap_free(chm->strings);
+ heap_free(chm->defTitle);
+ heap_free(chm->defTopic);
+ heap_free(chm->defToc);
heap_free(chm);
return NULL;
IStream *strings_stream;
char **strings;
DWORD strings_size;
+
+ WCHAR *defTopic;
+ WCHAR *defTitle;
+ WCHAR *defToc;
} CHMInfo;
#define TAB_CONTENTS 0
return ret;
}
-static inline LPWSTR strdupAtoW(LPCSTR str)
+static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
{
LPWSTR ret;
DWORD len;
if(!str)
return NULL;
- len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+ if (lenA > 0)
+ {
+ /* find length of string */
+ LPCSTR eos = memchr(str, 0, lenA);
+ if (eos) lenA = eos - str;
+ }
+
+ len = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0)+1; /* +1 for null pad */
ret = heap_alloc(len*sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
+ MultiByteToWideChar(CP_ACP, 0, str, lenA, ret, len);
+ ret[len-1] = 0;
return ret;
}
+static inline LPWSTR strdupAtoW(LPCSTR str)
+{
+ return strdupnAtoW(str, -1);
+}
+
+
+
extern HINSTANCE hhctrl_hinstance;
extern BOOL hh_process;