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
= Globals
.active_win
;
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(Globals
.active_win
, 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(Globals
.active_win
, 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
= Globals
.active_win
;
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
= Globals
.active_win
;
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
= Globals
.active_win
->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
= Globals
.active_win
;
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 (win
->lpszName
&& lstrcmpi(win
->lpszName
, "main"))
284 DestroyWindow(win
->hMainWnd
);
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 (win
->lpszName
&& !lstrcmpi(win
->lpszName
, lpszWindow
))
297 DestroyWindow(win
->hMainWnd
);
300 static void CALLBACK
MACRO_Compare(LPCSTR str
)
302 WINE_FIXME("(\"%s\")\n", str
);
305 static void CALLBACK
MACRO_Contents(void)
309 if (Globals
.active_win
->page
)
310 MACRO_JumpContents(Globals
.active_win
->page
->file
->lpszPath
, NULL
);
313 static void CALLBACK
MACRO_ControlPanel(LPCSTR str1
, LPCSTR str2
, LONG u
)
315 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1
, str2
, u
);
318 void CALLBACK
MACRO_CopyDialog(void)
323 static void CALLBACK
MACRO_CopyTopic(void)
328 static void CALLBACK
MACRO_DeleteItem(LPCSTR str
)
330 WINE_FIXME("(\"%s\")\n", str
);
333 static void CALLBACK
MACRO_DeleteMark(LPCSTR str
)
335 WINE_FIXME("(\"%s\")\n", str
);
338 static void CALLBACK
MACRO_DisableItem(LPCSTR str
)
340 WINE_FIXME("(\"%s\")\n", str
);
343 static void CALLBACK
MACRO_EnableItem(LPCSTR str
)
345 WINE_FIXME("(\"%s\")\n", str
);
348 static void CALLBACK
MACRO_EndMPrint(void)
353 static void CALLBACK
MACRO_ExecFile(LPCSTR str1
, LPCSTR str2
, LONG u
, LPCSTR str3
)
355 WINE_FIXME("(\"%s\", \"%s\", %u, \"%s\")\n", str1
, str2
, u
, str3
);
358 static void CALLBACK
MACRO_ExecProgram(LPCSTR str
, LONG u
)
360 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
363 void CALLBACK
MACRO_Exit(void)
367 while (Globals
.win_list
)
368 DestroyWindow(Globals
.win_list
->hMainWnd
);
371 static void CALLBACK
MACRO_ExtAbleItem(LPCSTR str
, LONG u
)
373 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
376 static void CALLBACK
MACRO_ExtInsertItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
, LONG u1
, LONG u2
)
378 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u, %u)\n", str1
, str2
, str3
, str4
, u1
, u2
);
381 static void CALLBACK
MACRO_ExtInsertMenu(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LONG u1
, LONG u2
)
383 WINE_FIXME("(\"%s\", \"%s\", \"%s\", %u, %u)\n", str1
, str2
, str3
, u1
, u2
);
386 static BOOL CALLBACK
MACRO_FileExist(LPCSTR str
)
388 WINE_TRACE("(\"%s\")\n", str
);
389 return GetFileAttributes(str
) != INVALID_FILE_ATTRIBUTES
;
392 void CALLBACK
MACRO_FileOpen(void)
394 char szFile
[MAX_PATH
];
396 if (WINHELP_GetOpenFileName(szFile
, MAX_PATH
))
398 MACRO_JumpContents(szFile
, "main");
402 static void CALLBACK
MACRO_Find(void)
407 static void CALLBACK
MACRO_Finder(void)
409 WINHELP_CreateIndexWindow(FALSE
);
412 static void CALLBACK
MACRO_FloatingMenu(void)
417 static void CALLBACK
MACRO_Flush(void)
422 static void CALLBACK
MACRO_FocusWindow(LPCSTR lpszWindow
)
426 WINE_TRACE("(\"%s\")\n", lpszWindow
);
428 if (!lpszWindow
|| !lpszWindow
[0]) lpszWindow
= "main";
430 for (win
= Globals
.win_list
; win
; win
= win
->next
)
431 if (win
->lpszName
&& !lstrcmpi(win
->lpszName
, lpszWindow
))
432 SetFocus(win
->hMainWnd
);
435 static void CALLBACK
MACRO_Generate(LPCSTR str
, LONG w
, LONG l
)
437 WINE_FIXME("(\"%s\", %x, %x)\n", str
, w
, l
);
440 static void CALLBACK
MACRO_GotoMark(LPCSTR str
)
442 WINE_FIXME("(\"%s\")\n", str
);
445 void CALLBACK
MACRO_HelpOn(void)
450 file
= Globals
.active_win
->page
->file
->help_on_file
;
452 file
= (Globals
.wVersion
> 4) ? "winhlp32.hlp" : "winhelp.hlp";
454 MACRO_JumpContents(file
, NULL
);
457 void CALLBACK
MACRO_HelpOnTop(void)
462 void CALLBACK
MACRO_History(void)
466 if (Globals
.active_win
&& !Globals
.active_win
->hHistoryWnd
)
468 HWND hWnd
= CreateWindow(HISTORY_WIN_CLASS_NAME
, "History", WS_OVERLAPPEDWINDOW
,
469 0, 0, 0, 0, 0, 0, Globals
.hInstance
, Globals
.active_win
);
470 ShowWindow(hWnd
, SW_NORMAL
);
474 static void CALLBACK
MACRO_IfThen(BOOL b
, LPCSTR t
)
476 if (b
) MACRO_ExecuteMacro(t
);
479 static void CALLBACK
MACRO_IfThenElse(BOOL b
, LPCSTR t
, LPCSTR f
)
481 if (b
) MACRO_ExecuteMacro(t
); else MACRO_ExecuteMacro(f
);
484 static BOOL CALLBACK
MACRO_InitMPrint(void)
490 static void CALLBACK
MACRO_InsertItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
, LONG u
)
492 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u)\n", str1
, str2
, str3
, str4
, u
);
495 static void CALLBACK
MACRO_InsertMenu(LPCSTR str1
, LPCSTR str2
, LONG u
)
497 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1
, str2
, u
);
500 static BOOL CALLBACK
MACRO_IsBook(void)
503 return Globals
.isBook
;
506 static BOOL CALLBACK
MACRO_IsMark(LPCSTR str
)
508 WINE_FIXME("(\"%s\")\n", str
);
512 static BOOL CALLBACK
MACRO_IsNotMark(LPCSTR str
)
514 WINE_FIXME("(\"%s\")\n", str
);
518 void CALLBACK
MACRO_JumpContext(LPCSTR lpszPath
, LPCSTR lpszWindow
, LONG context
)
522 WINE_TRACE("(\"%s\", \"%s\", %d)\n", lpszPath
, lpszWindow
, context
);
523 hlpfile
= WINHELP_LookupHelpFile(lpszPath
);
524 /* Some madness: what user calls 'context', hlpfile calls 'map' */
525 WINHELP_OpenHelpWindow(HLPFILE_PageByMap
, hlpfile
, context
,
526 WINHELP_GetWindowInfo(hlpfile
, lpszWindow
),
530 void CALLBACK
MACRO_JumpHash(LPCSTR lpszPath
, LPCSTR lpszWindow
, LONG lHash
)
534 WINE_TRACE("(\"%s\", \"%s\", %u)\n", lpszPath
, lpszWindow
, lHash
);
535 hlpfile
= WINHELP_LookupHelpFile(lpszPath
);
536 WINHELP_OpenHelpWindow(HLPFILE_PageByHash
, hlpfile
, lHash
,
537 WINHELP_GetWindowInfo(hlpfile
, lpszWindow
),
541 static void CALLBACK
MACRO_JumpHelpOn(void)
546 static void CALLBACK
MACRO_JumpID(LPCSTR lpszPathWindow
, LPCSTR topic_id
)
550 WINE_TRACE("(\"%s\", \"%s\")\n", lpszPathWindow
, topic_id
);
551 if ((ptr
= strchr(lpszPathWindow
, '>')) != NULL
)
554 size_t sz
= ptr
- lpszPathWindow
;
556 tmp
= HeapAlloc(GetProcessHeap(), 0, sz
+ 1);
559 memcpy(tmp
, lpszPathWindow
, sz
);
561 MACRO_JumpHash(tmp
, ptr
+ 1, HLPFILE_Hash(topic_id
));
562 HeapFree(GetProcessHeap(), 0, tmp
);
566 MACRO_JumpHash(lpszPathWindow
, NULL
, HLPFILE_Hash(topic_id
));
569 /* FIXME: this macros is wrong
570 * it should only contain 2 strings, path & window are coded as path>window
572 static void CALLBACK
MACRO_JumpKeyword(LPCSTR lpszPath
, LPCSTR lpszWindow
, LPCSTR keyword
)
574 WINE_FIXME("(\"%s\", \"%s\", \"%s\")\n", lpszPath
, lpszWindow
, keyword
);
577 static void CALLBACK
MACRO_KLink(LPCSTR str1
, LONG u
, LPCSTR str2
, LPCSTR str3
)
579 WINE_FIXME("(\"%s\", %u, \"%s\", \"%s\")\n", str1
, u
, str2
, str3
);
582 static void CALLBACK
MACRO_Menu(void)
587 static void CALLBACK
MACRO_MPrintHash(LONG u
)
589 WINE_FIXME("(%u)\n", u
);
592 static void CALLBACK
MACRO_MPrintID(LPCSTR str
)
594 WINE_FIXME("(\"%s\")\n", str
);
597 static void CALLBACK
MACRO_Next(void)
602 wp
.page
= Globals
.active_win
->page
;
603 wp
.page
= HLPFILE_PageByOffset(wp
.page
->file
, wp
.page
->browse_fwd
, &wp
.relative
);
606 wp
.page
->file
->wRefCount
++;
607 wp
.wininfo
= Globals
.active_win
->info
;
608 WINHELP_CreateHelpWindow(&wp
, SW_NORMAL
, TRUE
);
612 static void CALLBACK
MACRO_NoShow(void)
617 void CALLBACK
MACRO_PopupContext(LPCSTR str
, LONG u
)
619 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
622 static void CALLBACK
MACRO_PopupHash(LPCSTR str
, LONG u
)
624 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
627 static void CALLBACK
MACRO_PopupId(LPCSTR str1
, LPCSTR str2
)
629 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
632 static void CALLBACK
MACRO_PositionWindow(LONG i1
, LONG i2
, LONG u1
, LONG u2
, LONG u3
, LPCSTR str
)
634 WINE_FIXME("(%i, %i, %u, %u, %u, \"%s\")\n", i1
, i2
, u1
, u2
, u3
, str
);
637 static void CALLBACK
MACRO_Prev(void)
642 wp
.page
= Globals
.active_win
->page
;
643 wp
.page
= HLPFILE_PageByOffset(wp
.page
->file
, wp
.page
->browse_bwd
, &wp
.relative
);
646 wp
.page
->file
->wRefCount
++;
647 wp
.wininfo
= Globals
.active_win
->info
;
648 WINHELP_CreateHelpWindow(&wp
, SW_NORMAL
, TRUE
);
652 void CALLBACK
MACRO_Print(void)
658 printer
.lStructSize
= sizeof(printer
);
659 printer
.hwndOwner
= Globals
.active_win
->hMainWnd
;
660 printer
.hInstance
= Globals
.hInstance
;
661 printer
.hDevMode
= 0;
662 printer
.hDevNames
= 0;
665 printer
.nFromPage
= 0;
667 printer
.nMinPage
= 0;
668 printer
.nMaxPage
= 0;
670 printer
.lCustData
= 0;
671 printer
.lpfnPrintHook
= 0;
672 printer
.lpfnSetupHook
= 0;
673 printer
.lpPrintTemplateName
= 0;
674 printer
.lpSetupTemplateName
= 0;
675 printer
.hPrintTemplate
= 0;
676 printer
.hSetupTemplate
= 0;
678 if (PrintDlgA(&printer
)) {
679 WINE_FIXME("Print()\n");
683 void CALLBACK
MACRO_PrinterSetup(void)
688 static void CALLBACK
MACRO_RegisterRoutine(LPCSTR dll_name
, LPCSTR proc
, LPCSTR args
)
694 WINE_TRACE("(\"%s\", \"%s\", \"%s\")\n", dll_name
, proc
, args
);
696 /* FIXME: are the registered DLLs global or linked to the current file ???
697 * We assume globals (as we did for macros, but is this really the case ???)
699 for (dll
= Globals
.dlls
; dll
; dll
= dll
->next
)
701 if (!strcmp(dll
->name
, dll_name
)) break;
705 HANDLE hLib
= LoadLibrary(dll_name
);
707 /* FIXME: the library will not be unloaded until exit of program
708 * We don't send the DW_TERM message
710 WINE_TRACE("Loading %s\n", dll_name
);
711 /* FIXME: should look in the directory where current hlpfile
716 /* FIXME: internationalisation for error messages */
717 WINE_FIXME("Cannot find dll %s\n", dll_name
);
719 else if ((dll
= HeapAlloc(GetProcessHeap(), 0, sizeof(*dll
))))
722 dll
->name
= StrDup(dll_name
); /* FIXME: never freed */
723 dll
->next
= Globals
.dlls
;
725 dll
->handler
= (WINHELP_LDLLHandler
)GetProcAddress(dll
->hLib
, "LDLLHandler");
726 dll
->class = dll
->handler
? (dll
->handler
)(DW_WHATMSG
, 0, 0) : DC_NOMSG
;
727 WINE_TRACE("Got class %x for DLL %s\n", dll
->class, dll_name
);
728 if (dll
->class & DC_INITTERM
) dll
->handler(DW_INIT
, 0, 0);
729 if (dll
->class & DC_CALLBACKS
) dll
->handler(DW_CALLBACKS
, (DWORD
)Callbacks
, 0);
731 else WINE_WARN("OOM\n");
733 if (dll
&& !(fn
= GetProcAddress(dll
->hLib
, proc
)))
735 /* FIXME: internationalisation for error messages */
736 WINE_FIXME("Cannot find proc %s in dll %s\n", dll_name
, proc
);
739 size
= ++MACRO_NumLoaded
* sizeof(struct MacroDesc
);
740 if (!MACRO_Loaded
) MACRO_Loaded
= HeapAlloc(GetProcessHeap(), 0, size
);
741 else MACRO_Loaded
= HeapReAlloc(GetProcessHeap(), 0, MACRO_Loaded
, size
);
742 MACRO_Loaded
[MACRO_NumLoaded
- 1].name
= StrDup(proc
); /* FIXME: never freed */
743 MACRO_Loaded
[MACRO_NumLoaded
- 1].alias
= NULL
;
744 MACRO_Loaded
[MACRO_NumLoaded
- 1].isBool
= 0;
745 MACRO_Loaded
[MACRO_NumLoaded
- 1].arguments
= StrDup(args
); /* FIXME: never freed */
746 MACRO_Loaded
[MACRO_NumLoaded
- 1].fn
= fn
;
747 WINE_TRACE("Added %s(%s) at %p\n", proc
, args
, fn
);
750 static void CALLBACK
MACRO_RemoveAccelerator(LONG u1
, LONG u2
)
752 WINE_FIXME("(%u, %u)\n", u1
, u2
);
755 static void CALLBACK
MACRO_ResetMenu(void)
760 static void CALLBACK
MACRO_SaveMark(LPCSTR str
)
762 WINE_FIXME("(\"%s\")\n", str
);
765 static void CALLBACK
MACRO_Search(void)
767 WINHELP_CreateIndexWindow(TRUE
);
770 void CALLBACK
MACRO_SetContents(LPCSTR str
, LONG u
)
772 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
775 static void CALLBACK
MACRO_SetHelpOnFile(LPCSTR str
)
777 WINE_TRACE("(\"%s\")\n", str
);
779 HeapFree(GetProcessHeap(), 0, Globals
.active_win
->page
->file
->help_on_file
);
780 Globals
.active_win
->page
->file
->help_on_file
= HeapAlloc(GetProcessHeap(), 0, strlen(str
) + 1);
781 if (Globals
.active_win
->page
->file
->help_on_file
)
782 strcpy(Globals
.active_win
->page
->file
->help_on_file
, str
);
785 static void CALLBACK
MACRO_SetPopupColor(LONG r
, LONG g
, LONG b
)
787 WINE_TRACE("(%x, %x, %x)\n", r
, g
, b
);
788 Globals
.active_win
->page
->file
->has_popup_color
= TRUE
;
789 Globals
.active_win
->page
->file
->popup_color
= RGB(r
, g
, b
);
792 static void CALLBACK
MACRO_ShellExecute(LPCSTR str1
, LPCSTR str2
, LONG u1
, LONG u2
, LPCSTR str3
, LPCSTR str4
)
794 WINE_FIXME("(\"%s\", \"%s\", %u, %u, \"%s\", \"%s\")\n", str1
, str2
, u1
, u2
, str3
, str4
);
797 static void CALLBACK
MACRO_ShortCut(LPCSTR str1
, LPCSTR str2
, LONG w
, LONG l
, LPCSTR str
)
799 WINE_FIXME("(\"%s\", \"%s\", %x, %x, \"%s\")\n", str1
, str2
, w
, l
, str
);
802 static void CALLBACK
MACRO_TCard(LONG u
)
804 WINE_FIXME("(%u)\n", u
);
807 static void CALLBACK
MACRO_Test(LONG u
)
809 WINE_FIXME("(%u)\n", u
);
812 static BOOL CALLBACK
MACRO_TestALink(LPCSTR str
)
814 WINE_FIXME("(\"%s\")\n", str
);
818 static BOOL CALLBACK
MACRO_TestKLink(LPCSTR str
)
820 WINE_FIXME("(\"%s\")\n", str
);
824 static void CALLBACK
MACRO_UncheckItem(LPCSTR str
)
826 WINE_FIXME("(\"%s\")\n", str
);
829 static void CALLBACK
MACRO_UpdateWindow(LPCSTR str1
, LPCSTR str2
)
831 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
835 /**************************************************/
837 /**************************************************/
840 * U: 32 bit unsigned int
841 * I: 32 bit signed int
843 * v: unknown (32 bit entity)
846 static struct MacroDesc MACRO_Builtins
[] = {
847 {"About", NULL
, 0, "", (FARPROC
)MACRO_About
},
848 {"AddAccelerator", "AA", 0, "UUS", (FARPROC
)MACRO_AddAccelerator
},
849 {"ALink", "AL", 0, "SUS", (FARPROC
)MACRO_ALink
},
850 {"Annotate", NULL
, 0, "", (FARPROC
)MACRO_Annotate
},
851 {"AppendItem", NULL
, 0, "SSSS", (FARPROC
)MACRO_AppendItem
},
852 {"Back", NULL
, 0, "", (FARPROC
)MACRO_Back
},
853 {"BackFlush", "BF", 0, "", (FARPROC
)MACRO_BackFlush
},
854 {"BookmarkDefine", NULL
, 0, "", (FARPROC
)MACRO_BookmarkDefine
},
855 {"BookmarkMore", NULL
, 0, "", (FARPROC
)MACRO_BookmarkMore
},
856 {"BrowseButtons", NULL
, 0, "", (FARPROC
)MACRO_BrowseButtons
},
857 {"ChangeButtonBinding", "CBB",0, "SS", (FARPROC
)MACRO_ChangeButtonBinding
},
858 {"ChangeEnable", "CE", 0, "SS", (FARPROC
)MACRO_ChangeEnable
},
859 {"ChangeItemBinding", "CIB",0, "SS", (FARPROC
)MACRO_ChangeItemBinding
},
860 {"CheckItem", "CI", 0, "S", (FARPROC
)MACRO_CheckItem
},
861 {"CloseSecondarys", "CS", 0, "", (FARPROC
)MACRO_CloseSecondarys
},
862 {"CloseWindow", "CW", 0, "S", (FARPROC
)MACRO_CloseWindow
},
863 {"Compare", NULL
, 0, "S", (FARPROC
)MACRO_Compare
},
864 {"Contents", NULL
, 0, "", (FARPROC
)MACRO_Contents
},
865 {"ControlPanel", NULL
, 0, "SSU", (FARPROC
)MACRO_ControlPanel
},
866 {"CopyDialog", NULL
, 0, "", (FARPROC
)MACRO_CopyDialog
},
867 {"CopyTopic", "CT", 0, "", (FARPROC
)MACRO_CopyTopic
},
868 {"CreateButton", "CB", 0, "SSS", (FARPROC
)MACRO_CreateButton
},
869 {"DeleteItem", NULL
, 0, "S", (FARPROC
)MACRO_DeleteItem
},
870 {"DeleteMark", NULL
, 0, "S", (FARPROC
)MACRO_DeleteMark
},
871 {"DestroyButton", NULL
, 0, "S", (FARPROC
)MACRO_DestroyButton
},
872 {"DisableButton", "DB", 0, "S", (FARPROC
)MACRO_DisableButton
},
873 {"DisableItem", "DI", 0, "S", (FARPROC
)MACRO_DisableItem
},
874 {"EnableButton", "EB", 0, "S", (FARPROC
)MACRO_EnableButton
},
875 {"EnableItem", "EI", 0, "S", (FARPROC
)MACRO_EnableItem
},
876 {"EndMPrint", NULL
, 0, "", (FARPROC
)MACRO_EndMPrint
},
877 {"ExecFile", "EF", 0, "SSUS", (FARPROC
)MACRO_ExecFile
},
878 {"ExecProgram", "EP", 0, "SU", (FARPROC
)MACRO_ExecProgram
},
879 {"Exit", NULL
, 0, "", (FARPROC
)MACRO_Exit
},
880 {"ExtAbleItem", NULL
, 0, "SU", (FARPROC
)MACRO_ExtAbleItem
},
881 {"ExtInsertItem", NULL
, 0, "SSSSUU", (FARPROC
)MACRO_ExtInsertItem
},
882 {"ExtInsertMenu", NULL
, 0, "SSSUU", (FARPROC
)MACRO_ExtInsertMenu
},
883 {"FileExist", "FE", 1, "S", (FARPROC
)MACRO_FileExist
},
884 {"FileOpen", "FO", 0, "", (FARPROC
)MACRO_FileOpen
},
885 {"Find", NULL
, 0, "", (FARPROC
)MACRO_Find
},
886 {"Finder", "FD", 0, "", (FARPROC
)MACRO_Finder
},
887 {"FloatingMenu", NULL
, 0, "", (FARPROC
)MACRO_FloatingMenu
},
888 {"Flush", "FH", 0, "", (FARPROC
)MACRO_Flush
},
889 {"FocusWindow", NULL
, 0, "S", (FARPROC
)MACRO_FocusWindow
},
890 {"Generate", NULL
, 0, "SUU", (FARPROC
)MACRO_Generate
},
891 {"GotoMark", NULL
, 0, "S", (FARPROC
)MACRO_GotoMark
},
892 {"HelpOn", NULL
, 0, "", (FARPROC
)MACRO_HelpOn
},
893 {"HelpOnTop", NULL
, 0, "", (FARPROC
)MACRO_HelpOnTop
},
894 {"History", NULL
, 0, "", (FARPROC
)MACRO_History
},
895 {"InitMPrint", NULL
, 1, "", (FARPROC
)MACRO_InitMPrint
},
896 {"InsertItem", NULL
, 0, "SSSSU", (FARPROC
)MACRO_InsertItem
},
897 {"InsertMenu", NULL
, 0, "SSU", (FARPROC
)MACRO_InsertMenu
},
898 {"IfThen", "IF", 0, "BS", (FARPROC
)MACRO_IfThen
},
899 {"IfThenElse", "IE", 0, "BSS", (FARPROC
)MACRO_IfThenElse
},
900 {"IsBook", NULL
, 1, "", (FARPROC
)MACRO_IsBook
},
901 {"IsMark", NULL
, 1, "S", (FARPROC
)MACRO_IsMark
},
902 {"IsNotMark", "NM", 1, "S", (FARPROC
)MACRO_IsNotMark
},
903 {"JumpContents", NULL
, 0, "SS", (FARPROC
)MACRO_JumpContents
},
904 {"JumpContext", "JC", 0, "SSU", (FARPROC
)MACRO_JumpContext
},
905 {"JumpHash", "JH", 0, "SSU", (FARPROC
)MACRO_JumpHash
},
906 {"JumpHelpOn", NULL
, 0, "", (FARPROC
)MACRO_JumpHelpOn
},
907 {"JumpID", "JI", 0, "SS", (FARPROC
)MACRO_JumpID
},
908 {"JumpKeyword", "JK", 0, "SSS", (FARPROC
)MACRO_JumpKeyword
},
909 {"KLink", "KL", 0, "SUSS", (FARPROC
)MACRO_KLink
},
910 {"Menu", "MU", 0, "", (FARPROC
)MACRO_Menu
},
911 {"MPrintHash", NULL
, 0, "U", (FARPROC
)MACRO_MPrintHash
},
912 {"MPrintID", NULL
, 0, "S", (FARPROC
)MACRO_MPrintID
},
913 {"Next", NULL
, 0, "", (FARPROC
)MACRO_Next
},
914 {"NoShow", NULL
, 0, "", (FARPROC
)MACRO_NoShow
},
915 {"PopupContext", "PC", 0, "SU", (FARPROC
)MACRO_PopupContext
},
916 {"PopupHash", NULL
, 0, "SU", (FARPROC
)MACRO_PopupHash
},
917 {"PopupId", "PI", 0, "SS", (FARPROC
)MACRO_PopupId
},
918 {"PositionWindow", "PW", 0, "IIUUUS", (FARPROC
)MACRO_PositionWindow
},
919 {"Prev", NULL
, 0, "", (FARPROC
)MACRO_Prev
},
920 {"Print", NULL
, 0, "", (FARPROC
)MACRO_Print
},
921 {"PrinterSetup", NULL
, 0, "", (FARPROC
)MACRO_PrinterSetup
},
922 {"RegisterRoutine", "RR", 0, "SSS", (FARPROC
)MACRO_RegisterRoutine
},
923 {"RemoveAccelerator", "RA", 0, "UU", (FARPROC
)MACRO_RemoveAccelerator
},
924 {"ResetMenu", NULL
, 0, "", (FARPROC
)MACRO_ResetMenu
},
925 {"SaveMark", NULL
, 0, "S", (FARPROC
)MACRO_SaveMark
},
926 {"Search", NULL
, 0, "", (FARPROC
)MACRO_Search
},
927 {"SetContents", NULL
, 0, "SU", (FARPROC
)MACRO_SetContents
},
928 {"SetHelpOnFile", NULL
, 0, "S", (FARPROC
)MACRO_SetHelpOnFile
},
929 {"SetPopupColor", "SPC",0, "UUU", (FARPROC
)MACRO_SetPopupColor
},
930 {"ShellExecute", "SE", 0, "SSUUSS", (FARPROC
)MACRO_ShellExecute
},
931 {"ShortCut", "SH", 0, "SSUUS", (FARPROC
)MACRO_ShortCut
},
932 {"TCard", NULL
, 0, "U", (FARPROC
)MACRO_TCard
},
933 {"Test", NULL
, 0, "U", (FARPROC
)MACRO_Test
},
934 {"TestALink", NULL
, 1, "S", (FARPROC
)MACRO_TestALink
},
935 {"TestKLink", NULL
, 1, "S", (FARPROC
)MACRO_TestKLink
},
936 {"UncheckItem", "UI", 0, "S", (FARPROC
)MACRO_UncheckItem
},
937 {"UpdateWindow", "UW", 0, "SS", (FARPROC
)MACRO_UpdateWindow
},
938 {NULL
, NULL
, 0, NULL
, NULL
}
941 static int MACRO_DoLookUp(struct MacroDesc
* start
, const char* name
, struct lexret
* lr
, unsigned len
)
943 struct MacroDesc
* md
;
945 for (md
= start
; md
->name
&& len
!= 0; md
++, len
--)
947 if (strcasecmp(md
->name
, name
) == 0 || (md
->alias
!= NULL
&& strcasecmp(md
->alias
, name
) == 0))
949 lr
->proto
= md
->arguments
;
950 lr
->function
= md
->fn
;
951 return md
->isBool
? BOOL_FUNCTION
: VOID_FUNCTION
;
957 int MACRO_Lookup(const char* name
, struct lexret
* lr
)
961 if ((ret
= MACRO_DoLookUp(MACRO_Builtins
, name
, lr
, -1)) != EMPTY
)
963 if (MACRO_Loaded
&& (ret
= MACRO_DoLookUp(MACRO_Loaded
, name
, lr
, MACRO_NumLoaded
)) != EMPTY
)