4 * Copyright 1996 Ulrich Schmid
5 * Copyright 2002, 2008 Eric Pouech
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
22 #define WIN32_LEAN_AND_MEAN
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(winhelp
);
34 /**************************************************/
36 /**************************************************/
41 const char* arguments
;
45 static struct MacroDesc
*MACRO_Loaded
/* = NULL */;
46 static unsigned MACRO_NumLoaded
/* = 0 */;
48 /******* helper functions *******/
50 static char* StrDup(const char* str
)
53 dst
=HeapAlloc(GetProcessHeap(),0,strlen(str
)+1);
58 static WINHELP_BUTTON
** MACRO_LookupButton(WINHELP_WINDOW
* win
, LPCSTR name
)
62 for (b
= &win
->first_button
; *b
; b
= &(*b
)->next
)
63 if (!lstrcmpi(name
, (*b
)->lpszID
)) break;
67 /******* real macro implementation *******/
69 void CALLBACK
MACRO_CreateButton(LPCSTR id
, LPCSTR name
, LPCSTR macro
)
71 WINHELP_WINDOW
*win
= MACRO_CurrentWindow();
72 WINHELP_BUTTON
*button
, **b
;
76 WINE_TRACE("(\"%s\", \"%s\", %s)\n", id
, name
, macro
);
78 size
= sizeof(WINHELP_BUTTON
) + lstrlen(id
) + lstrlen(name
) + lstrlen(macro
) + 3;
80 button
= HeapAlloc(GetProcessHeap(), 0, size
);
86 ptr
= (char*)button
+ sizeof(WINHELP_BUTTON
);
90 ptr
+= lstrlen(id
) + 1;
93 button
->lpszName
= ptr
;
94 ptr
+= lstrlen(name
) + 1;
97 button
->lpszMacro
= ptr
;
99 button
->wParam
= WH_FIRST_BUTTON
;
100 for (b
= &win
->first_button
; *b
; b
= &(*b
)->next
)
101 button
->wParam
= max(button
->wParam
, (*b
)->wParam
+ 1);
104 WINHELP_LayoutMainWindow(win
);
107 static void CALLBACK
MACRO_DestroyButton(LPCSTR str
)
109 WINE_FIXME("(\"%s\")\n", str
);
112 void CALLBACK
MACRO_DisableButton(LPCSTR id
)
116 WINE_TRACE("(\"%s\")\n", id
);
118 b
= MACRO_LookupButton(MACRO_CurrentWindow(), id
);
119 if (!*b
) {WINE_FIXME("Couldn't find button '%s'\n", id
); return;}
121 EnableWindow((*b
)->hWnd
, FALSE
);
124 static void CALLBACK
MACRO_EnableButton(LPCSTR id
)
128 WINE_TRACE("(\"%s\")\n", id
);
130 b
= MACRO_LookupButton(MACRO_CurrentWindow(), id
);
131 if (!*b
) {WINE_FIXME("Couldn't find button '%s'\n", id
); return;}
133 EnableWindow((*b
)->hWnd
, TRUE
);
136 void CALLBACK
MACRO_JumpContents(LPCSTR lpszPath
, LPCSTR lpszWindow
)
140 WINE_TRACE("(\"%s\", \"%s\")\n", lpszPath
, lpszWindow
);
141 if ((hlpfile
= WINHELP_LookupHelpFile(lpszPath
)))
142 WINHELP_OpenHelpWindow(HLPFILE_PageByHash
, hlpfile
, 0,
143 WINHELP_GetWindowInfo(hlpfile
, lpszWindow
),
148 void CALLBACK
MACRO_About(void)
153 static void CALLBACK
MACRO_AddAccelerator(LONG u1
, LONG u2
, LPCSTR str
)
155 WINE_FIXME("(%u, %u, \"%s\")\n", u1
, u2
, str
);
158 static void CALLBACK
MACRO_ALink(LPCSTR str1
, LONG u
, LPCSTR str2
)
160 WINE_FIXME("(\"%s\", %u, \"%s\")\n", str1
, u
, str2
);
163 void CALLBACK
MACRO_Annotate(void)
168 static void CALLBACK
MACRO_AppendItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
)
170 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\")\n", str1
, str2
, str3
, str4
);
173 static void CALLBACK
MACRO_Back(void)
175 WINHELP_WINDOW
* win
= MACRO_CurrentWindow();
179 if (win
&& win
->back
.index
>= 2)
180 WINHELP_CreateHelpWindow(&win
->back
.set
[--win
->back
.index
- 1], SW_SHOW
, FALSE
);
183 static void CALLBACK
MACRO_BackFlush(void)
185 WINHELP_WINDOW
* win
= MACRO_CurrentWindow();
189 if (win
) WINHELP_DeleteBackSet(win
);
192 void CALLBACK
MACRO_BookmarkDefine(void)
197 static void CALLBACK
MACRO_BookmarkMore(void)
202 static void CALLBACK
MACRO_BrowseButtons(void)
204 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
209 MACRO_CreateButton("BTN_PREV", "&<<", "Prev()");
210 MACRO_CreateButton("BTN_NEXT", "&>>", "Next()");
212 if (!HLPFILE_PageByOffset(page
->file
, page
->browse_bwd
, &relative
))
213 MACRO_DisableButton("BTN_PREV");
214 if (!HLPFILE_PageByOffset(page
->file
, page
->browse_fwd
, &relative
))
215 MACRO_DisableButton("BTN_NEXT");
218 static void CALLBACK
MACRO_ChangeButtonBinding(LPCSTR id
, LPCSTR macro
)
220 WINHELP_WINDOW
* win
= MACRO_CurrentWindow();
221 WINHELP_BUTTON
* button
;
226 WINE_TRACE("(\"%s\", \"%s\")\n", id
, macro
);
228 b
= MACRO_LookupButton(win
, id
);
229 if (!*b
) {WINE_FIXME("Couldn't find button '%s'\n", id
); return;}
231 size
= sizeof(WINHELP_BUTTON
) + lstrlen(id
) +
232 lstrlen((*b
)->lpszName
) + lstrlen(macro
) + 3;
234 button
= HeapAlloc(GetProcessHeap(), 0, size
);
237 button
->next
= (*b
)->next
;
238 button
->hWnd
= (*b
)->hWnd
;
239 button
->wParam
= (*b
)->wParam
;
241 ptr
= (char*)button
+ sizeof(WINHELP_BUTTON
);
244 button
->lpszID
= ptr
;
245 ptr
+= lstrlen(id
) + 1;
247 lstrcpy(ptr
, (*b
)->lpszName
);
248 button
->lpszName
= ptr
;
249 ptr
+= lstrlen((*b
)->lpszName
) + 1;
252 button
->lpszMacro
= ptr
;
256 WINHELP_LayoutMainWindow(win
);
259 static void CALLBACK
MACRO_ChangeEnable(LPCSTR id
, LPCSTR macro
)
261 WINE_TRACE("(\"%s\", \"%s\")\n", id
, macro
);
263 MACRO_ChangeButtonBinding(id
, macro
);
264 MACRO_EnableButton(id
);
267 static void CALLBACK
MACRO_ChangeItemBinding(LPCSTR str1
, LPCSTR str2
)
269 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
272 static void CALLBACK
MACRO_CheckItem(LPCSTR str
)
274 WINE_FIXME("(\"%s\")\n", str
);
277 static void CALLBACK
MACRO_CloseSecondarys(void)
282 for (win
= Globals
.win_list
; win
; win
= win
->next
)
283 if (lstrcmpi(win
->info
->name
, "main"))
284 WINHELP_ReleaseWindow(win
);
287 static void CALLBACK
MACRO_CloseWindow(LPCSTR lpszWindow
)
291 WINE_TRACE("(\"%s\")\n", lpszWindow
);
293 if (!lpszWindow
|| !lpszWindow
[0]) lpszWindow
= "main";
295 for (win
= Globals
.win_list
; win
; win
= win
->next
)
296 if (!lstrcmpi(win
->info
->name
, lpszWindow
))
297 WINHELP_ReleaseWindow(win
);
300 static void CALLBACK
MACRO_Compare(LPCSTR str
)
302 WINE_FIXME("(\"%s\")\n", str
);
305 static void CALLBACK
MACRO_Contents(void)
307 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
312 MACRO_JumpContents(page
->file
->lpszPath
, NULL
);
315 static void CALLBACK
MACRO_ControlPanel(LPCSTR str1
, LPCSTR str2
, LONG u
)
317 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1
, str2
, u
);
320 void CALLBACK
MACRO_CopyDialog(void)
325 static void CALLBACK
MACRO_CopyTopic(void)
330 static void CALLBACK
MACRO_DeleteItem(LPCSTR str
)
332 WINE_FIXME("(\"%s\")\n", str
);
335 static void CALLBACK
MACRO_DeleteMark(LPCSTR str
)
337 WINE_FIXME("(\"%s\")\n", str
);
340 static void CALLBACK
MACRO_DisableItem(LPCSTR str
)
342 WINE_FIXME("(\"%s\")\n", str
);
345 static void CALLBACK
MACRO_EnableItem(LPCSTR str
)
347 WINE_FIXME("(\"%s\")\n", str
);
350 static void CALLBACK
MACRO_EndMPrint(void)
355 static void CALLBACK
MACRO_ExecFile(LPCSTR str1
, LPCSTR str2
, LONG u
, LPCSTR str3
)
357 WINE_FIXME("(\"%s\", \"%s\", %u, \"%s\")\n", str1
, str2
, u
, str3
);
360 static void CALLBACK
MACRO_ExecProgram(LPCSTR str
, LONG u
)
362 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
365 void CALLBACK
MACRO_Exit(void)
369 while (Globals
.win_list
)
370 WINHELP_ReleaseWindow(Globals
.win_list
);
373 static void CALLBACK
MACRO_ExtAbleItem(LPCSTR str
, LONG u
)
375 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
378 static void CALLBACK
MACRO_ExtInsertItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
, LONG u1
, LONG u2
)
380 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u, %u)\n", str1
, str2
, str3
, str4
, u1
, u2
);
383 static void CALLBACK
MACRO_ExtInsertMenu(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LONG u1
, LONG u2
)
385 WINE_FIXME("(\"%s\", \"%s\", \"%s\", %u, %u)\n", str1
, str2
, str3
, u1
, u2
);
388 static BOOL CALLBACK
MACRO_FileExist(LPCSTR str
)
390 WINE_TRACE("(\"%s\")\n", str
);
391 return GetFileAttributes(str
) != INVALID_FILE_ATTRIBUTES
;
394 void CALLBACK
MACRO_FileOpen(void)
396 char szFile
[MAX_PATH
];
398 if (WINHELP_GetOpenFileName(szFile
, MAX_PATH
))
400 MACRO_JumpContents(szFile
, "main");
404 static void CALLBACK
MACRO_Find(void)
409 static void CALLBACK
MACRO_Finder(void)
411 WINHELP_CreateIndexWindow(FALSE
);
414 static void CALLBACK
MACRO_FloatingMenu(void)
419 static void CALLBACK
MACRO_Flush(void)
424 static void CALLBACK
MACRO_FocusWindow(LPCSTR lpszWindow
)
428 WINE_TRACE("(\"%s\")\n", lpszWindow
);
430 if (!lpszWindow
|| !lpszWindow
[0]) lpszWindow
= "main";
432 for (win
= Globals
.win_list
; win
; win
= win
->next
)
433 if (!lstrcmpi(win
->info
->name
, lpszWindow
))
434 SetFocus(win
->hMainWnd
);
437 static void CALLBACK
MACRO_Generate(LPCSTR str
, LONG w
, LONG l
)
439 WINE_FIXME("(\"%s\", %x, %x)\n", str
, w
, l
);
442 static void CALLBACK
MACRO_GotoMark(LPCSTR str
)
444 WINE_FIXME("(\"%s\")\n", str
);
447 void CALLBACK
MACRO_HelpOn(void)
452 file
= MACRO_CurrentWindow()->page
->file
->help_on_file
;
454 file
= (Globals
.wVersion
> 4) ? "winhlp32.hlp" : "winhelp.hlp";
456 MACRO_JumpContents(file
, NULL
);
459 void CALLBACK
MACRO_HelpOnTop(void)
464 void CALLBACK
MACRO_History(void)
468 if (Globals
.active_win
&& !Globals
.active_win
->hHistoryWnd
)
470 HWND hWnd
= CreateWindow(HISTORY_WIN_CLASS_NAME
, "History", WS_OVERLAPPEDWINDOW
,
471 0, 0, 0, 0, 0, 0, Globals
.hInstance
, Globals
.active_win
);
472 ShowWindow(hWnd
, SW_NORMAL
);
476 static void CALLBACK
MACRO_IfThen(BOOL b
, LPCSTR t
)
478 if (b
) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t
);
481 static void CALLBACK
MACRO_IfThenElse(BOOL b
, LPCSTR t
, LPCSTR f
)
483 if (b
) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t
);
484 else MACRO_ExecuteMacro(MACRO_CurrentWindow(), f
);
487 static BOOL CALLBACK
MACRO_InitMPrint(void)
493 static void CALLBACK
MACRO_InsertItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
, LONG u
)
495 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u)\n", str1
, str2
, str3
, str4
, u
);
498 static void CALLBACK
MACRO_InsertMenu(LPCSTR str1
, LPCSTR str2
, LONG u
)
500 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1
, str2
, u
);
503 static BOOL CALLBACK
MACRO_IsBook(void)
506 return Globals
.isBook
;
509 static BOOL CALLBACK
MACRO_IsMark(LPCSTR str
)
511 WINE_FIXME("(\"%s\")\n", str
);
515 static BOOL CALLBACK
MACRO_IsNotMark(LPCSTR str
)
517 WINE_FIXME("(\"%s\")\n", str
);
521 void CALLBACK
MACRO_JumpContext(LPCSTR lpszPath
, LPCSTR lpszWindow
, LONG context
)
525 WINE_TRACE("(\"%s\", \"%s\", %d)\n", lpszPath
, lpszWindow
, context
);
526 hlpfile
= WINHELP_LookupHelpFile(lpszPath
);
527 /* Some madness: what user calls 'context', hlpfile calls 'map' */
528 WINHELP_OpenHelpWindow(HLPFILE_PageByMap
, hlpfile
, context
,
529 WINHELP_GetWindowInfo(hlpfile
, lpszWindow
),
533 void CALLBACK
MACRO_JumpHash(LPCSTR lpszPath
, LPCSTR lpszWindow
, LONG lHash
)
537 WINE_TRACE("(\"%s\", \"%s\", %u)\n", lpszPath
, lpszWindow
, lHash
);
538 if (!lpszPath
|| !lpszPath
[0])
539 hlpfile
= MACRO_CurrentWindow()->page
->file
;
541 hlpfile
= WINHELP_LookupHelpFile(lpszPath
);
542 WINHELP_OpenHelpWindow(HLPFILE_PageByHash
, hlpfile
, lHash
,
543 WINHELP_GetWindowInfo(hlpfile
, lpszWindow
),
547 static void CALLBACK
MACRO_JumpHelpOn(void)
552 static void CALLBACK
MACRO_JumpID(LPCSTR lpszPathWindow
, LPCSTR topic_id
)
556 WINE_TRACE("(\"%s\", \"%s\")\n", lpszPathWindow
, topic_id
);
557 if ((ptr
= strchr(lpszPathWindow
, '>')) != NULL
)
560 size_t sz
= ptr
- lpszPathWindow
;
562 tmp
= HeapAlloc(GetProcessHeap(), 0, sz
+ 1);
565 memcpy(tmp
, lpszPathWindow
, sz
);
567 MACRO_JumpHash(tmp
, ptr
+ 1, HLPFILE_Hash(topic_id
));
568 HeapFree(GetProcessHeap(), 0, tmp
);
572 MACRO_JumpHash(lpszPathWindow
, NULL
, HLPFILE_Hash(topic_id
));
575 /* FIXME: this macros is wrong
576 * it should only contain 2 strings, path & window are coded as path>window
578 static void CALLBACK
MACRO_JumpKeyword(LPCSTR lpszPath
, LPCSTR lpszWindow
, LPCSTR keyword
)
580 WINE_FIXME("(\"%s\", \"%s\", \"%s\")\n", lpszPath
, lpszWindow
, keyword
);
583 static void CALLBACK
MACRO_KLink(LPCSTR str1
, LONG u
, LPCSTR str2
, LPCSTR str3
)
585 WINE_FIXME("(\"%s\", %u, \"%s\", \"%s\")\n", str1
, u
, str2
, str3
);
588 static void CALLBACK
MACRO_Menu(void)
593 static void CALLBACK
MACRO_MPrintHash(LONG u
)
595 WINE_FIXME("(%u)\n", u
);
598 static void CALLBACK
MACRO_MPrintID(LPCSTR str
)
600 WINE_FIXME("(\"%s\")\n", str
);
603 static void CALLBACK
MACRO_Next(void)
608 wp
.page
= MACRO_CurrentWindow()->page
;
609 wp
.page
= HLPFILE_PageByOffset(wp
.page
->file
, wp
.page
->browse_fwd
, &wp
.relative
);
612 wp
.page
->file
->wRefCount
++;
613 wp
.wininfo
= MACRO_CurrentWindow()->info
;
614 WINHELP_CreateHelpWindow(&wp
, SW_NORMAL
, TRUE
);
618 static void CALLBACK
MACRO_NoShow(void)
623 void CALLBACK
MACRO_PopupContext(LPCSTR str
, LONG u
)
625 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
628 static void CALLBACK
MACRO_PopupHash(LPCSTR str
, LONG u
)
630 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
633 static void CALLBACK
MACRO_PopupId(LPCSTR str1
, LPCSTR str2
)
635 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
638 static void CALLBACK
MACRO_PositionWindow(LONG i1
, LONG i2
, LONG u1
, LONG u2
, LONG u3
, LPCSTR str
)
640 WINE_FIXME("(%i, %i, %u, %u, %u, \"%s\")\n", i1
, i2
, u1
, u2
, u3
, str
);
643 static void CALLBACK
MACRO_Prev(void)
648 wp
.page
= MACRO_CurrentWindow()->page
;
649 wp
.page
= HLPFILE_PageByOffset(wp
.page
->file
, wp
.page
->browse_bwd
, &wp
.relative
);
652 wp
.page
->file
->wRefCount
++;
653 wp
.wininfo
= MACRO_CurrentWindow()->info
;
654 WINHELP_CreateHelpWindow(&wp
, SW_NORMAL
, TRUE
);
658 void CALLBACK
MACRO_Print(void)
664 printer
.lStructSize
= sizeof(printer
);
665 printer
.hwndOwner
= MACRO_CurrentWindow()->hMainWnd
;
666 printer
.hInstance
= Globals
.hInstance
;
667 printer
.hDevMode
= 0;
668 printer
.hDevNames
= 0;
671 printer
.nFromPage
= 0;
673 printer
.nMinPage
= 0;
674 printer
.nMaxPage
= 0;
676 printer
.lCustData
= 0;
677 printer
.lpfnPrintHook
= 0;
678 printer
.lpfnSetupHook
= 0;
679 printer
.lpPrintTemplateName
= 0;
680 printer
.lpSetupTemplateName
= 0;
681 printer
.hPrintTemplate
= 0;
682 printer
.hSetupTemplate
= 0;
684 if (PrintDlgA(&printer
)) {
685 WINE_FIXME("Print()\n");
689 void CALLBACK
MACRO_PrinterSetup(void)
694 static void CALLBACK
MACRO_RegisterRoutine(LPCSTR dll_name
, LPCSTR proc
, LPCSTR args
)
700 WINE_TRACE("(\"%s\", \"%s\", \"%s\")\n", dll_name
, proc
, args
);
702 /* FIXME: are the registered DLLs global or linked to the current file ???
703 * We assume globals (as we did for macros, but is this really the case ???)
705 for (dll
= Globals
.dlls
; dll
; dll
= dll
->next
)
707 if (!strcmp(dll
->name
, dll_name
)) break;
711 HANDLE hLib
= LoadLibrary(dll_name
);
713 /* FIXME: the library will not be unloaded until exit of program
714 * We don't send the DW_TERM message
716 WINE_TRACE("Loading %s\n", dll_name
);
717 /* FIXME: should look in the directory where current hlpfile
722 /* FIXME: internationalisation for error messages */
723 WINE_FIXME("Cannot find dll %s\n", dll_name
);
725 else if ((dll
= HeapAlloc(GetProcessHeap(), 0, sizeof(*dll
))))
728 dll
->name
= StrDup(dll_name
); /* FIXME: never freed */
729 dll
->next
= Globals
.dlls
;
731 dll
->handler
= (WINHELP_LDLLHandler
)GetProcAddress(dll
->hLib
, "LDLLHandler");
732 dll
->class = dll
->handler
? (dll
->handler
)(DW_WHATMSG
, 0, 0) : DC_NOMSG
;
733 WINE_TRACE("Got class %x for DLL %s\n", dll
->class, dll_name
);
734 if (dll
->class & DC_INITTERM
) dll
->handler(DW_INIT
, 0, 0);
735 if (dll
->class & DC_CALLBACKS
) dll
->handler(DW_CALLBACKS
, (DWORD
)Callbacks
, 0);
737 else WINE_WARN("OOM\n");
739 if (dll
&& !(fn
= GetProcAddress(dll
->hLib
, proc
)))
741 /* FIXME: internationalisation for error messages */
742 WINE_FIXME("Cannot find proc %s in dll %s\n", dll_name
, proc
);
745 size
= ++MACRO_NumLoaded
* sizeof(struct MacroDesc
);
746 if (!MACRO_Loaded
) MACRO_Loaded
= HeapAlloc(GetProcessHeap(), 0, size
);
747 else MACRO_Loaded
= HeapReAlloc(GetProcessHeap(), 0, MACRO_Loaded
, size
);
748 MACRO_Loaded
[MACRO_NumLoaded
- 1].name
= StrDup(proc
); /* FIXME: never freed */
749 MACRO_Loaded
[MACRO_NumLoaded
- 1].alias
= NULL
;
750 MACRO_Loaded
[MACRO_NumLoaded
- 1].isBool
= 0;
751 MACRO_Loaded
[MACRO_NumLoaded
- 1].arguments
= StrDup(args
); /* FIXME: never freed */
752 MACRO_Loaded
[MACRO_NumLoaded
- 1].fn
= fn
;
753 WINE_TRACE("Added %s(%s) at %p\n", proc
, args
, fn
);
756 static void CALLBACK
MACRO_RemoveAccelerator(LONG u1
, LONG u2
)
758 WINE_FIXME("(%u, %u)\n", u1
, u2
);
761 static void CALLBACK
MACRO_ResetMenu(void)
766 static void CALLBACK
MACRO_SaveMark(LPCSTR str
)
768 WINE_FIXME("(\"%s\")\n", str
);
771 static void CALLBACK
MACRO_Search(void)
773 WINHELP_CreateIndexWindow(TRUE
);
776 void CALLBACK
MACRO_SetContents(LPCSTR str
, LONG u
)
778 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
781 static void CALLBACK
MACRO_SetHelpOnFile(LPCSTR str
)
783 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
785 WINE_TRACE("(\"%s\")\n", str
);
787 HeapFree(GetProcessHeap(), 0, page
->file
->help_on_file
);
788 page
->file
->help_on_file
= HeapAlloc(GetProcessHeap(), 0, strlen(str
) + 1);
789 if (page
->file
->help_on_file
)
790 strcpy(page
->file
->help_on_file
, str
);
793 static void CALLBACK
MACRO_SetPopupColor(LONG r
, LONG g
, LONG b
)
795 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
797 WINE_TRACE("(%x, %x, %x)\n", r
, g
, b
);
798 page
->file
->has_popup_color
= TRUE
;
799 page
->file
->popup_color
= RGB(r
, g
, b
);
802 static void CALLBACK
MACRO_ShellExecute(LPCSTR str1
, LPCSTR str2
, LONG u1
, LONG u2
, LPCSTR str3
, LPCSTR str4
)
804 WINE_FIXME("(\"%s\", \"%s\", %u, %u, \"%s\", \"%s\")\n", str1
, str2
, u1
, u2
, str3
, str4
);
807 static void CALLBACK
MACRO_ShortCut(LPCSTR str1
, LPCSTR str2
, LONG w
, LONG l
, LPCSTR str
)
809 WINE_FIXME("(\"%s\", \"%s\", %x, %x, \"%s\")\n", str1
, str2
, w
, l
, str
);
812 static void CALLBACK
MACRO_TCard(LONG u
)
814 WINE_FIXME("(%u)\n", u
);
817 static void CALLBACK
MACRO_Test(LONG u
)
819 WINE_FIXME("(%u)\n", u
);
822 static BOOL CALLBACK
MACRO_TestALink(LPCSTR str
)
824 WINE_FIXME("(\"%s\")\n", str
);
828 static BOOL CALLBACK
MACRO_TestKLink(LPCSTR str
)
830 WINE_FIXME("(\"%s\")\n", str
);
834 static void CALLBACK
MACRO_UncheckItem(LPCSTR str
)
836 WINE_FIXME("(\"%s\")\n", str
);
839 static void CALLBACK
MACRO_UpdateWindow(LPCSTR str1
, LPCSTR str2
)
841 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
845 /**************************************************/
847 /**************************************************/
850 * U: 32 bit unsigned int
851 * I: 32 bit signed int
853 * v: unknown (32 bit entity)
856 static struct MacroDesc MACRO_Builtins
[] = {
857 {"About", NULL
, 0, "", (FARPROC
)MACRO_About
},
858 {"AddAccelerator", "AA", 0, "UUS", (FARPROC
)MACRO_AddAccelerator
},
859 {"ALink", "AL", 0, "SUS", (FARPROC
)MACRO_ALink
},
860 {"Annotate", NULL
, 0, "", (FARPROC
)MACRO_Annotate
},
861 {"AppendItem", NULL
, 0, "SSSS", (FARPROC
)MACRO_AppendItem
},
862 {"Back", NULL
, 0, "", (FARPROC
)MACRO_Back
},
863 {"BackFlush", "BF", 0, "", (FARPROC
)MACRO_BackFlush
},
864 {"BookmarkDefine", NULL
, 0, "", (FARPROC
)MACRO_BookmarkDefine
},
865 {"BookmarkMore", NULL
, 0, "", (FARPROC
)MACRO_BookmarkMore
},
866 {"BrowseButtons", NULL
, 0, "", (FARPROC
)MACRO_BrowseButtons
},
867 {"ChangeButtonBinding", "CBB",0, "SS", (FARPROC
)MACRO_ChangeButtonBinding
},
868 {"ChangeEnable", "CE", 0, "SS", (FARPROC
)MACRO_ChangeEnable
},
869 {"ChangeItemBinding", "CIB",0, "SS", (FARPROC
)MACRO_ChangeItemBinding
},
870 {"CheckItem", "CI", 0, "S", (FARPROC
)MACRO_CheckItem
},
871 {"CloseSecondarys", "CS", 0, "", (FARPROC
)MACRO_CloseSecondarys
},
872 {"CloseWindow", "CW", 0, "S", (FARPROC
)MACRO_CloseWindow
},
873 {"Compare", NULL
, 0, "S", (FARPROC
)MACRO_Compare
},
874 {"Contents", NULL
, 0, "", (FARPROC
)MACRO_Contents
},
875 {"ControlPanel", NULL
, 0, "SSU", (FARPROC
)MACRO_ControlPanel
},
876 {"CopyDialog", NULL
, 0, "", (FARPROC
)MACRO_CopyDialog
},
877 {"CopyTopic", "CT", 0, "", (FARPROC
)MACRO_CopyTopic
},
878 {"CreateButton", "CB", 0, "SSS", (FARPROC
)MACRO_CreateButton
},
879 {"DeleteItem", NULL
, 0, "S", (FARPROC
)MACRO_DeleteItem
},
880 {"DeleteMark", NULL
, 0, "S", (FARPROC
)MACRO_DeleteMark
},
881 {"DestroyButton", NULL
, 0, "S", (FARPROC
)MACRO_DestroyButton
},
882 {"DisableButton", "DB", 0, "S", (FARPROC
)MACRO_DisableButton
},
883 {"DisableItem", "DI", 0, "S", (FARPROC
)MACRO_DisableItem
},
884 {"EnableButton", "EB", 0, "S", (FARPROC
)MACRO_EnableButton
},
885 {"EnableItem", "EI", 0, "S", (FARPROC
)MACRO_EnableItem
},
886 {"EndMPrint", NULL
, 0, "", (FARPROC
)MACRO_EndMPrint
},
887 {"ExecFile", "EF", 0, "SSUS", (FARPROC
)MACRO_ExecFile
},
888 {"ExecProgram", "EP", 0, "SU", (FARPROC
)MACRO_ExecProgram
},
889 {"Exit", NULL
, 0, "", (FARPROC
)MACRO_Exit
},
890 {"ExtAbleItem", NULL
, 0, "SU", (FARPROC
)MACRO_ExtAbleItem
},
891 {"ExtInsertItem", NULL
, 0, "SSSSUU", (FARPROC
)MACRO_ExtInsertItem
},
892 {"ExtInsertMenu", NULL
, 0, "SSSUU", (FARPROC
)MACRO_ExtInsertMenu
},
893 {"FileExist", "FE", 1, "S", (FARPROC
)MACRO_FileExist
},
894 {"FileOpen", "FO", 0, "", (FARPROC
)MACRO_FileOpen
},
895 {"Find", NULL
, 0, "", (FARPROC
)MACRO_Find
},
896 {"Finder", "FD", 0, "", (FARPROC
)MACRO_Finder
},
897 {"FloatingMenu", NULL
, 0, "", (FARPROC
)MACRO_FloatingMenu
},
898 {"Flush", "FH", 0, "", (FARPROC
)MACRO_Flush
},
899 {"FocusWindow", NULL
, 0, "S", (FARPROC
)MACRO_FocusWindow
},
900 {"Generate", NULL
, 0, "SUU", (FARPROC
)MACRO_Generate
},
901 {"GotoMark", NULL
, 0, "S", (FARPROC
)MACRO_GotoMark
},
902 {"HelpOn", NULL
, 0, "", (FARPROC
)MACRO_HelpOn
},
903 {"HelpOnTop", NULL
, 0, "", (FARPROC
)MACRO_HelpOnTop
},
904 {"History", NULL
, 0, "", (FARPROC
)MACRO_History
},
905 {"InitMPrint", NULL
, 1, "", (FARPROC
)MACRO_InitMPrint
},
906 {"InsertItem", NULL
, 0, "SSSSU", (FARPROC
)MACRO_InsertItem
},
907 {"InsertMenu", NULL
, 0, "SSU", (FARPROC
)MACRO_InsertMenu
},
908 {"IfThen", "IF", 0, "BS", (FARPROC
)MACRO_IfThen
},
909 {"IfThenElse", "IE", 0, "BSS", (FARPROC
)MACRO_IfThenElse
},
910 {"IsBook", NULL
, 1, "", (FARPROC
)MACRO_IsBook
},
911 {"IsMark", NULL
, 1, "S", (FARPROC
)MACRO_IsMark
},
912 {"IsNotMark", "NM", 1, "S", (FARPROC
)MACRO_IsNotMark
},
913 {"JumpContents", NULL
, 0, "SS", (FARPROC
)MACRO_JumpContents
},
914 {"JumpContext", "JC", 0, "SSU", (FARPROC
)MACRO_JumpContext
},
915 {"JumpHash", "JH", 0, "SSU", (FARPROC
)MACRO_JumpHash
},
916 {"JumpHelpOn", NULL
, 0, "", (FARPROC
)MACRO_JumpHelpOn
},
917 {"JumpID", "JI", 0, "SS", (FARPROC
)MACRO_JumpID
},
918 {"JumpKeyword", "JK", 0, "SSS", (FARPROC
)MACRO_JumpKeyword
},
919 {"KLink", "KL", 0, "SUSS", (FARPROC
)MACRO_KLink
},
920 {"Menu", "MU", 0, "", (FARPROC
)MACRO_Menu
},
921 {"MPrintHash", NULL
, 0, "U", (FARPROC
)MACRO_MPrintHash
},
922 {"MPrintID", NULL
, 0, "S", (FARPROC
)MACRO_MPrintID
},
923 {"Next", NULL
, 0, "", (FARPROC
)MACRO_Next
},
924 {"NoShow", "NS", 0, "", (FARPROC
)MACRO_NoShow
},
925 {"PopupContext", "PC", 0, "SU", (FARPROC
)MACRO_PopupContext
},
926 {"PopupHash", NULL
, 0, "SU", (FARPROC
)MACRO_PopupHash
},
927 {"PopupId", "PI", 0, "SS", (FARPROC
)MACRO_PopupId
},
928 {"PositionWindow", "PW", 0, "IIUUUS", (FARPROC
)MACRO_PositionWindow
},
929 {"Prev", NULL
, 0, "", (FARPROC
)MACRO_Prev
},
930 {"Print", NULL
, 0, "", (FARPROC
)MACRO_Print
},
931 {"PrinterSetup", NULL
, 0, "", (FARPROC
)MACRO_PrinterSetup
},
932 {"RegisterRoutine", "RR", 0, "SSS", (FARPROC
)MACRO_RegisterRoutine
},
933 {"RemoveAccelerator", "RA", 0, "UU", (FARPROC
)MACRO_RemoveAccelerator
},
934 {"ResetMenu", NULL
, 0, "", (FARPROC
)MACRO_ResetMenu
},
935 {"SaveMark", NULL
, 0, "S", (FARPROC
)MACRO_SaveMark
},
936 {"Search", NULL
, 0, "", (FARPROC
)MACRO_Search
},
937 {"SetContents", NULL
, 0, "SU", (FARPROC
)MACRO_SetContents
},
938 {"SetHelpOnFile", NULL
, 0, "S", (FARPROC
)MACRO_SetHelpOnFile
},
939 {"SetPopupColor", "SPC",0, "UUU", (FARPROC
)MACRO_SetPopupColor
},
940 {"ShellExecute", "SE", 0, "SSUUSS", (FARPROC
)MACRO_ShellExecute
},
941 {"ShortCut", "SH", 0, "SSUUS", (FARPROC
)MACRO_ShortCut
},
942 {"TCard", NULL
, 0, "U", (FARPROC
)MACRO_TCard
},
943 {"Test", NULL
, 0, "U", (FARPROC
)MACRO_Test
},
944 {"TestALink", NULL
, 1, "S", (FARPROC
)MACRO_TestALink
},
945 {"TestKLink", NULL
, 1, "S", (FARPROC
)MACRO_TestKLink
},
946 {"UncheckItem", "UI", 0, "S", (FARPROC
)MACRO_UncheckItem
},
947 {"UpdateWindow", "UW", 0, "SS", (FARPROC
)MACRO_UpdateWindow
},
948 {NULL
, NULL
, 0, NULL
, NULL
}
951 static int MACRO_DoLookUp(struct MacroDesc
* start
, const char* name
, struct lexret
* lr
, unsigned len
)
953 struct MacroDesc
* md
;
955 for (md
= start
; md
->name
&& len
!= 0; md
++, len
--)
957 if (strcasecmp(md
->name
, name
) == 0 || (md
->alias
!= NULL
&& strcasecmp(md
->alias
, name
) == 0))
959 lr
->proto
= md
->arguments
;
960 lr
->function
= md
->fn
;
961 return md
->isBool
? BOOL_FUNCTION
: VOID_FUNCTION
;
967 int MACRO_Lookup(const char* name
, struct lexret
* lr
)
971 if ((ret
= MACRO_DoLookUp(MACRO_Builtins
, name
, lr
, -1)) != EMPTY
)
973 if (MACRO_Loaded
&& (ret
= MACRO_DoLookUp(MACRO_Loaded
, name
, lr
, MACRO_NumLoaded
)) != EMPTY
)