Autosyncing with Wine HEAD

svn path=/trunk/; revision=31776
This commit is contained in:
The Wine Synchronizer 2008-01-14 12:56:22 +00:00
parent 3a6d558da6
commit d33ed41a92
7 changed files with 89 additions and 75 deletions

View file

@ -39,10 +39,10 @@ static LPCSTR GetChmString(CHMInfo *chm, DWORD offset)
if(chm->strings_size <= (offset >> BLOCK_BITS)) {
if(chm->strings)
chm->strings = hhctrl_realloc_zero(chm->strings,
chm->strings = heap_realloc_zero(chm->strings,
chm->strings_size = ((offset >> BLOCK_BITS)+1)*sizeof(char*));
else
chm->strings = hhctrl_alloc_zero(
chm->strings = heap_alloc_zero(
chm->strings_size = ((offset >> BLOCK_BITS)+1)*sizeof(char*));
}
@ -59,13 +59,13 @@ static LPCSTR GetChmString(CHMInfo *chm, DWORD offset)
return NULL;
}
chm->strings[offset >> BLOCK_BITS] = hhctrl_alloc(BLOCK_SIZE);
chm->strings[offset >> BLOCK_BITS] = heap_alloc(BLOCK_SIZE);
hres = IStream_Read(chm->strings_stream, chm->strings[offset >> BLOCK_BITS],
BLOCK_SIZE, &read);
if(FAILED(hres)) {
WARN("Read failed: %08x\n", hres);
hhctrl_free(chm->strings[offset >> BLOCK_BITS]);
heap_free(chm->strings[offset >> BLOCK_BITS]);
chm->strings[offset >> BLOCK_BITS] = NULL;
return NULL;
}
@ -97,7 +97,7 @@ static BOOL ReadChmSystem(CHMInfo *chm)
IStream_Read(stream, &ver, sizeof(ver), &read);
TRACE("version is %x\n", ver);
buf = hhctrl_alloc(8*sizeof(DWORD));
buf = heap_alloc(8*sizeof(DWORD));
buf_size = 8*sizeof(DWORD);
while(1) {
@ -106,7 +106,7 @@ static BOOL ReadChmSystem(CHMInfo *chm)
break;
if(entry.len > buf_size)
buf = hhctrl_realloc(buf, buf_size=entry.len);
buf = heap_realloc(buf, buf_size=entry.len);
hres = IStream_Read(stream, buf, entry.len, &read);
if(hres != S_OK)
@ -142,7 +142,7 @@ static BOOL ReadChmSystem(CHMInfo *chm)
}
}
hhctrl_free(buf);
heap_free(buf);
IStream_Release(stream);
return SUCCEEDED(hres);
@ -171,12 +171,12 @@ LPWSTR FindContextAlias(CHMInfo *chm, DWORD index)
return NULL;
}
buf = hhctrl_alloc(size);
buf = heap_alloc(size);
hres = IStream_Read(ivb_stream, buf, size, &read);
IStream_Release(ivb_stream);
if(FAILED(hres)) {
WARN("Read failed: %08x\n", hres);
hhctrl_free(buf);
heap_free(buf);
return NULL;
}
@ -189,7 +189,7 @@ LPWSTR FindContextAlias(CHMInfo *chm, DWORD index)
}
}
hhctrl_free(buf);
heap_free(buf);
TRACE("returning %s\n", debugstr_a(ret));
return strdupAtoW(ret);
@ -200,10 +200,10 @@ LPWSTR FindContextAlias(CHMInfo *chm, DWORD index)
* FIXME: There may be more than one window type in the file, so
* add the ability to choose a certain window type
*/
BOOL LoadWinTypeFromCHM(CHMInfo *pChmInfo, HH_WINTYPEW *pHHWinType)
BOOL LoadWinTypeFromCHM(HHInfo *info)
{
LARGE_INTEGER liOffset;
IStorage *pStorage = pChmInfo->pStorage;
IStorage *pStorage = info->pCHMInfo->pStorage;
IStream *pStream;
HRESULT hr;
DWORD cbRead;
@ -221,26 +221,26 @@ BOOL LoadWinTypeFromCHM(CHMInfo *pChmInfo, HH_WINTYPEW *pHHWinType)
if (FAILED(hr)) goto done;
/* read the HH_WINTYPE struct data */
hr = IStream_Read(pStream, pHHWinType, sizeof(*pHHWinType), &cbRead);
hr = IStream_Read(pStream, &info->WinType, sizeof(info->WinType), &cbRead);
if (FAILED(hr)) goto done;
/* convert the #STRINGS offsets to actual strings */
pHHWinType->pszType = strdupAtoW(GetChmString(pChmInfo, (DWORD)pHHWinType->pszType));
pHHWinType->pszCaption = strdupAtoW(GetChmString(pChmInfo, (DWORD)pHHWinType->pszCaption));
pHHWinType->pszToc = strdupAtoW(GetChmString(pChmInfo, (DWORD)pHHWinType->pszToc));
pHHWinType->pszIndex = strdupAtoW(GetChmString(pChmInfo, (DWORD)pHHWinType->pszIndex));
pHHWinType->pszFile = strdupAtoW(GetChmString(pChmInfo, (DWORD)pHHWinType->pszFile));
pHHWinType->pszHome = strdupAtoW(GetChmString(pChmInfo, (DWORD)pHHWinType->pszHome));
pHHWinType->pszJump1 = strdupAtoW(GetChmString(pChmInfo, (DWORD)pHHWinType->pszJump1));
pHHWinType->pszJump2 = strdupAtoW(GetChmString(pChmInfo, (DWORD)pHHWinType->pszJump2));
pHHWinType->pszUrlJump1 = strdupAtoW(GetChmString(pChmInfo, (DWORD)pHHWinType->pszUrlJump1));
pHHWinType->pszUrlJump2 = strdupAtoW(GetChmString(pChmInfo, (DWORD)pHHWinType->pszUrlJump2));
info->WinType.pszType = info->pszType = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszType));
info->WinType.pszCaption = info->pszCaption = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszCaption));
info->WinType.pszToc = info->pszToc = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszToc));
info->WinType.pszIndex = info->pszIndex = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszIndex));
info->WinType.pszFile = info->pszFile = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszFile));
info->WinType.pszHome = info->pszHome = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszHome));
info->WinType.pszJump1 = info->pszJump1 = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszJump1));
info->WinType.pszJump2 = info->pszJump2 = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszJump2));
info->WinType.pszUrlJump1 = info->pszUrlJump1 = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszUrlJump1));
info->WinType.pszUrlJump2 = info->pszUrlJump2 = strdupAtoW(GetChmString(info->pCHMInfo, (DWORD_PTR)info->WinType.pszUrlJump2));
/* FIXME: pszCustomTabs is a list of multiple zero-terminated strings so ReadString won't
* work in this case
*/
#if 0
pHHWinType->pszCustomTabs = CHM_ReadString(pChmInfo, (DWORD)pHHWinType->pszCustomTabs);
info->WinType.pszCustomTabs = info->pszCustomTabs = CHM_ReadString(pChmInfo, (DWORD_PTR)info->WinType.pszCustomTabs);
#endif
done:
@ -340,7 +340,7 @@ CHMInfo *OpenCHM(LPCWSTR szFile)
static const WCHAR wszSTRINGS[] = {'#','S','T','R','I','N','G','S',0};
CHMInfo *ret = hhctrl_alloc_zero(sizeof(CHMInfo));
CHMInfo *ret = heap_alloc_zero(sizeof(CHMInfo));
res = GetFullPathNameW(szFile, sizeof(file), file, NULL);
ret->szFile = strdupW(file);
@ -389,11 +389,11 @@ CHMInfo *CloseCHM(CHMInfo *chm)
int i;
for(i=0; i<chm->strings_size; i++)
hhctrl_free(chm->strings[i]);
heap_free(chm->strings[i]);
}
hhctrl_free(chm->strings);
hhctrl_free(chm);
heap_free(chm->strings);
heap_free(chm);
return NULL;
}

View file

@ -41,10 +41,10 @@ static void free_content_item(ContentItem *item)
free_content_item(item->child);
hhctrl_free(item->name);
hhctrl_free(item->local);
hhctrl_free(item->merge.chm_file);
hhctrl_free(item->merge.chm_index);
heap_free(item->name);
heap_free(item->local);
heap_free(item->merge.chm_file);
heap_free(item->merge.chm_index);
item = next;
}
@ -60,7 +60,7 @@ static void strbuf_init(strbuf_t *buf)
{
buf->size = 8;
buf->len = 0;
buf->buf = hhctrl_alloc(buf->size);
buf->buf = heap_alloc(buf->size);
}
static void strbuf_zero(strbuf_t *buf)
@ -70,14 +70,14 @@ static void strbuf_zero(strbuf_t *buf)
static void strbuf_free(strbuf_t *buf)
{
hhctrl_free(buf->buf);
heap_free(buf->buf);
}
static void strbuf_append(strbuf_t *buf, const char *data, int len)
{
if(buf->len+len > buf->size) {
buf->size = buf->len+len;
buf->buf = hhctrl_realloc(buf->buf, buf->size);
buf->buf = heap_realloc(buf->buf, buf->size);
}
memcpy(buf->buf+buf->len, data, len);
@ -208,13 +208,13 @@ static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const
}
wlen = MultiByteToWideChar(CP_ACP, 0, ptr, len, NULL, 0);
*param = hhctrl_alloc((wlen+1)*sizeof(WCHAR));
*param = heap_alloc((wlen+1)*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, ptr, len, *param, wlen);
(*param)[wlen] = 0;
if(param == &merge) {
SetChmPath(&item->merge, hhc_root->merge.chm_file, merge);
hhctrl_free(merge);
heap_free(merge);
}
}
@ -258,7 +258,7 @@ static ContentItem *parse_sitemap_object(HHInfo *info, stream_t *stream, Content
strbuf_init(&node);
strbuf_init(&node_name);
item = hhctrl_alloc_zero(sizeof(ContentItem));
item = heap_alloc_zero(sizeof(ContentItem));
while(next_node(stream, &node)) {
get_node_name(&node, &node_name);
@ -421,7 +421,7 @@ void InitContent(HHInfo *info)
IStream *stream;
insert_type_t insert_type;
info->content = hhctrl_alloc_zero(sizeof(ContentItem));
info->content = heap_alloc_zero(sizeof(ContentItem));
SetChmPath(&info->content->merge, info->pCHMInfo->szFile, info->WinType.pszToc);
stream = GetChmStream(info->pCHMInfo, info->pCHMInfo->szFile, &info->content->merge);

View file

@ -56,7 +56,7 @@ static LPWSTR HH_LoadString(DWORD dwID)
iSize = LoadStringW(hhctrl_hinstance, dwID, NULL, 0);
iSize += 2; /* some strings (tab text) needs double-null termination */
string = hhctrl_alloc(iSize * sizeof(WCHAR));
string = heap_alloc(iSize * sizeof(WCHAR));
LoadStringW(hhctrl_hinstance, dwID, string, iSize);
return string;
@ -95,8 +95,8 @@ BOOL NavigateToUrl(HHInfo *info, LPCWSTR surl)
SetChmPath(&chm_path, info->pCHMInfo->szFile, surl);
ret = NavigateToChm(info, chm_path.chm_file, chm_path.chm_index);
hhctrl_free(chm_path.chm_file);
hhctrl_free(chm_path.chm_index);
heap_free(chm_path.chm_file);
heap_free(chm_path.chm_index);
return ret;
}
@ -577,7 +577,7 @@ static BOOL HH_AddToolbar(HHInfo *pHHInfo)
szBuf[dwLen + 2] = 0; /* Double-null terminate */
buttons[dwIndex].iString = (DWORD)SendMessageW(hToolbar, TB_ADDSTRINGW, 0, (LPARAM)szBuf);
hhctrl_free(szBuf);
heap_free(szBuf);
}
SendMessageW(hToolbar, TB_ADDBUTTONSW, dwNumButtons, (LPARAM)&buttons);
@ -623,7 +623,7 @@ static DWORD NP_CreateTab(HINSTANCE hInstance, HWND hwndTabCtrl, DWORD index)
ret = SendMessageW( hwndTabCtrl, TCM_INSERTITEMW, index, (LPARAM)&tie );
hhctrl_free(tabText);
heap_free(tabText);
return ret;
}
@ -922,16 +922,16 @@ void ReleaseHelpViewer(HHInfo *info)
return;
/* Free allocated strings */
hhctrl_free((LPWSTR)info->WinType.pszType);
hhctrl_free((LPWSTR)info->WinType.pszCaption);
hhctrl_free((LPWSTR)info->WinType.pszToc);
hhctrl_free((LPWSTR)info->WinType.pszIndex);
hhctrl_free((LPWSTR)info->WinType.pszFile);
hhctrl_free((LPWSTR)info->WinType.pszHome);
hhctrl_free((LPWSTR)info->WinType.pszJump1);
hhctrl_free((LPWSTR)info->WinType.pszJump2);
hhctrl_free((LPWSTR)info->WinType.pszUrlJump1);
hhctrl_free((LPWSTR)info->WinType.pszUrlJump2);
heap_free(info->pszType);
heap_free(info->pszCaption);
heap_free(info->pszToc);
heap_free(info->pszIndex);
heap_free(info->pszFile);
heap_free(info->pszHome);
heap_free(info->pszJump1);
heap_free(info->pszJump2);
heap_free(info->pszUrlJump1);
heap_free(info->pszUrlJump2);
if (info->pCHMInfo)
CloseCHM(info->pCHMInfo);
@ -942,13 +942,13 @@ void ReleaseHelpViewer(HHInfo *info)
if(info->WinType.hwndHelp)
DestroyWindow(info->WinType.hwndHelp);
hhctrl_free(info);
heap_free(info);
OleUninitialize();
}
HHInfo *CreateHelpViewer(LPCWSTR filename)
{
HHInfo *info = hhctrl_alloc_zero(sizeof(HHInfo));
HHInfo *info = heap_alloc_zero(sizeof(HHInfo));
OleInitialize(NULL);
@ -958,7 +958,7 @@ HHInfo *CreateHelpViewer(LPCWSTR filename)
return NULL;
}
if (!LoadWinTypeFromCHM(info->pCHMInfo, &info->WinType)) {
if (!LoadWinTypeFromCHM(info)) {
ReleaseHelpViewer(info);
return NULL;
}

View file

@ -147,7 +147,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
return NULL;
NavigateToUrl(info, url);
hhctrl_free(url);
heap_free(url);
return NULL; /* FIXME */
}
@ -180,7 +180,7 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data
if (filename)
{
len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
wfile = hhctrl_alloc(len*sizeof(WCHAR));
wfile = heap_alloc(len*sizeof(WCHAR));
MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len );
}
@ -205,7 +205,7 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data
case HH_GET_WIN_HANDLE:
case HH_SAFE_DISPLAY_TOPIC:
len = MultiByteToWideChar( CP_ACP, 0, (const char*)data, -1, NULL, 0 );
wdata = hhctrl_alloc(len*sizeof(WCHAR));
wdata = heap_alloc(len*sizeof(WCHAR));
MultiByteToWideChar( CP_ACP, 0, (const char*)data, -1, wdata, len );
break;
@ -227,8 +227,8 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data
result = HtmlHelpW( caller, wfile, command, wdata ? (DWORD_PTR)wdata : data );
hhctrl_free(wfile);
hhctrl_free(wdata);
heap_free(wfile);
heap_free(wdata);
return result;
}

View file

@ -92,6 +92,19 @@ typedef struct {
IOleObject *wb_object;
HH_WINTYPEW WinType;
LPWSTR pszType;
LPWSTR pszCaption;
LPWSTR pszToc;
LPWSTR pszIndex;
LPWSTR pszFile;
LPWSTR pszHome;
LPWSTR pszJump1;
LPWSTR pszJump2;
LPWSTR pszUrlJump1;
LPWSTR pszUrlJump2;
LPWSTR pszCustomTabs;
CHMInfo *pCHMInfo;
ContentItem *content;
HWND hwndTabCtrl;
@ -111,7 +124,7 @@ void InitContent(HHInfo*);
void ReleaseContent(HHInfo*);
CHMInfo *OpenCHM(LPCWSTR szFile);
BOOL LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
BOOL LoadWinTypeFromCHM(HHInfo *info);
CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
void SetChmPath(ChmPath*,LPCWSTR,LPCWSTR);
IStream *GetChmStream(CHMInfo*,LPCWSTR,ChmPath*);
@ -124,27 +137,27 @@ BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
/* memory allocation functions */
static inline void *hhctrl_alloc(size_t len)
static inline void *heap_alloc(size_t len)
{
return HeapAlloc(GetProcessHeap(), 0, len);
}
static inline void *hhctrl_alloc_zero(size_t len)
static inline void *heap_alloc_zero(size_t len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
static inline void *hhctrl_realloc(void *mem, size_t len)
static inline void *heap_realloc(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), 0, mem, len);
}
static inline void *hhctrl_realloc_zero(void *mem, size_t len)
static inline void *heap_realloc_zero(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
}
static inline BOOL hhctrl_free(void *mem)
static inline BOOL heap_free(void *mem)
{
return HeapFree(GetProcessHeap(), 0, mem);
}
@ -158,7 +171,7 @@ static inline LPWSTR strdupW(LPCWSTR str)
return NULL;
size = (strlenW(str)+1)*sizeof(WCHAR);
ret = hhctrl_alloc(size);
ret = heap_alloc(size);
memcpy(ret, str, size);
return ret;
@ -173,7 +186,7 @@ static inline LPWSTR strdupAtoW(LPCSTR str)
return NULL;
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
ret = hhctrl_alloc(len*sizeof(WCHAR));
ret = heap_alloc(len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
return ret;

View file

@ -1,5 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<group>
<module name="hhctrl" type="win32ocx" baseaddress="${BASEADDRESS_HHCTRL}" installbase="system32" installname="hhctrl.ocx" allowwarnings="true">
<autoregister infsection="OleControlDlls" type="DllRegisterServer" />
<importlibrary definition="hhctrl.ocx.spec.def" />
@ -13,7 +14,6 @@
<library>wine</library>
<library>advapi32</library>
<library>comctl32</library>
<library>shell32</library>
<library>shlwapi</library>
<library>ole32</library>
<library>oleaut32</library>
@ -31,3 +31,4 @@
<file>hhctrl.rc</file>
<file>hhctrl.ocx.spec</file>
</module>
</group>

View file

@ -74,7 +74,7 @@ static ULONG STDMETHODCALLTYPE Site_Release(IOleClientSite *iface)
if (refCount)
return refCount;
hhctrl_free(This);
heap_free(This);
return 0;
}
@ -576,7 +576,7 @@ BOOL InitWebBrowser(HHInfo *info, HWND hwndParent)
HRESULT hr;
RECT rc;
iOleClientSiteImpl = hhctrl_alloc_zero(sizeof(IOleClientSiteImpl));
iOleClientSiteImpl = heap_alloc_zero(sizeof(IOleClientSiteImpl));
if (!iOleClientSiteImpl)
return FALSE;
@ -625,7 +625,7 @@ BOOL InitWebBrowser(HHInfo *info, HWND hwndParent)
error:
ReleaseWebBrowser(info);
hhctrl_free(iOleClientSiteImpl);
heap_free(iOleClientSiteImpl);
return FALSE;
}