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
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(winhelp
);
35 /**************************************************/
37 /**************************************************/
42 const char* arguments
;
46 static struct MacroDesc
*MACRO_Loaded
/* = NULL */;
47 static unsigned MACRO_NumLoaded
/* = 0 */;
49 /******* helper functions *******/
51 static char* StrDup(const char* str
)
54 dst
=HeapAlloc(GetProcessHeap(),0,strlen(str
)+1);
59 static WINHELP_BUTTON
** MACRO_LookupButton(WINHELP_WINDOW
* win
, LPCSTR name
)
63 for (b
= &win
->first_button
; *b
; b
= &(*b
)->next
)
64 if (!lstrcmpi(name
, (*b
)->lpszID
)) break;
68 /******* some forward declarations *******/
69 static void CALLBACK
MACRO_JumpID(LPCSTR lpszPathWindow
, LPCSTR topic_id
);
71 /******* real macro implementation *******/
73 void CALLBACK
MACRO_CreateButton(LPCSTR id
, LPCSTR name
, LPCSTR macro
)
75 WINHELP_WINDOW
*win
= MACRO_CurrentWindow();
76 WINHELP_BUTTON
*button
, **b
;
80 WINE_TRACE("(\"%s\", \"%s\", %s)\n", id
, name
, macro
);
82 size
= sizeof(WINHELP_BUTTON
) + lstrlen(id
) + lstrlen(name
) + lstrlen(macro
) + 3;
84 button
= HeapAlloc(GetProcessHeap(), 0, size
);
90 ptr
= (char*)button
+ sizeof(WINHELP_BUTTON
);
94 ptr
+= lstrlen(id
) + 1;
97 button
->lpszName
= ptr
;
98 ptr
+= lstrlen(name
) + 1;
101 button
->lpszMacro
= ptr
;
103 button
->wParam
= WH_FIRST_BUTTON
;
104 for (b
= &win
->first_button
; *b
; b
= &(*b
)->next
)
105 button
->wParam
= max(button
->wParam
, (*b
)->wParam
+ 1);
108 WINHELP_LayoutMainWindow(win
);
111 static void CALLBACK
MACRO_DestroyButton(LPCSTR str
)
113 WINE_FIXME("(\"%s\")\n", str
);
116 void CALLBACK
MACRO_DisableButton(LPCSTR id
)
120 WINE_TRACE("(\"%s\")\n", id
);
122 b
= MACRO_LookupButton(MACRO_CurrentWindow(), id
);
123 if (!*b
) {WINE_FIXME("Couldn't find button '%s'\n", id
); return;}
125 EnableWindow((*b
)->hWnd
, FALSE
);
128 static void CALLBACK
MACRO_EnableButton(LPCSTR id
)
132 WINE_TRACE("(\"%s\")\n", id
);
134 b
= MACRO_LookupButton(MACRO_CurrentWindow(), id
);
135 if (!*b
) {WINE_FIXME("Couldn't find button '%s'\n", id
); return;}
137 EnableWindow((*b
)->hWnd
, TRUE
);
140 void CALLBACK
MACRO_JumpContents(LPCSTR lpszPath
, LPCSTR lpszWindow
)
144 WINE_TRACE("(\"%s\", \"%s\")\n", lpszPath
, lpszWindow
);
145 if ((hlpfile
= WINHELP_LookupHelpFile(lpszPath
)))
146 WINHELP_OpenHelpWindow(HLPFILE_PageByHash
, hlpfile
, 0,
147 WINHELP_GetWindowInfo(hlpfile
, lpszWindow
),
152 void CALLBACK
MACRO_About(void)
157 static void CALLBACK
MACRO_AddAccelerator(LONG u1
, LONG u2
, LPCSTR str
)
159 WINE_FIXME("(%u, %u, \"%s\")\n", u1
, u2
, str
);
162 static void CALLBACK
MACRO_ALink(LPCSTR str1
, LONG u
, LPCSTR str2
)
164 WINE_FIXME("(\"%s\", %u, \"%s\")\n", str1
, u
, str2
);
167 void CALLBACK
MACRO_Annotate(void)
172 static void CALLBACK
MACRO_AppendItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
)
174 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\")\n", str1
, str2
, str3
, str4
);
177 static void CALLBACK
MACRO_Back(void)
179 WINHELP_WINDOW
* win
= MACRO_CurrentWindow();
183 if (win
&& win
->back
.index
>= 2)
184 WINHELP_CreateHelpWindow(&win
->back
.set
[--win
->back
.index
- 1], SW_SHOW
, FALSE
);
187 static void CALLBACK
MACRO_BackFlush(void)
189 WINHELP_WINDOW
* win
= MACRO_CurrentWindow();
193 if (win
) WINHELP_DeleteBackSet(win
);
196 void CALLBACK
MACRO_BookmarkDefine(void)
201 static void CALLBACK
MACRO_BookmarkMore(void)
206 static void CALLBACK
MACRO_BrowseButtons(void)
208 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
213 MACRO_CreateButton("BTN_PREV", "&<<", "Prev()");
214 MACRO_CreateButton("BTN_NEXT", "&>>", "Next()");
216 if (!HLPFILE_PageByOffset(page
->file
, page
->browse_bwd
, &relative
))
217 MACRO_DisableButton("BTN_PREV");
218 if (!HLPFILE_PageByOffset(page
->file
, page
->browse_fwd
, &relative
))
219 MACRO_DisableButton("BTN_NEXT");
222 static void CALLBACK
MACRO_ChangeButtonBinding(LPCSTR id
, LPCSTR macro
)
224 WINHELP_WINDOW
* win
= MACRO_CurrentWindow();
225 WINHELP_BUTTON
* button
;
230 WINE_TRACE("(\"%s\", \"%s\")\n", id
, macro
);
232 b
= MACRO_LookupButton(win
, id
);
233 if (!*b
) {WINE_FIXME("Couldn't find button '%s'\n", id
); return;}
235 size
= sizeof(WINHELP_BUTTON
) + lstrlen(id
) +
236 lstrlen((*b
)->lpszName
) + lstrlen(macro
) + 3;
238 button
= HeapAlloc(GetProcessHeap(), 0, size
);
241 button
->next
= (*b
)->next
;
242 button
->hWnd
= (*b
)->hWnd
;
243 button
->wParam
= (*b
)->wParam
;
245 ptr
= (char*)button
+ sizeof(WINHELP_BUTTON
);
248 button
->lpszID
= ptr
;
249 ptr
+= lstrlen(id
) + 1;
251 lstrcpy(ptr
, (*b
)->lpszName
);
252 button
->lpszName
= ptr
;
253 ptr
+= lstrlen((*b
)->lpszName
) + 1;
256 button
->lpszMacro
= ptr
;
260 WINHELP_LayoutMainWindow(win
);
263 static void CALLBACK
MACRO_ChangeEnable(LPCSTR id
, LPCSTR macro
)
265 WINE_TRACE("(\"%s\", \"%s\")\n", id
, macro
);
267 MACRO_ChangeButtonBinding(id
, macro
);
268 MACRO_EnableButton(id
);
271 static void CALLBACK
MACRO_ChangeItemBinding(LPCSTR str1
, LPCSTR str2
)
273 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
276 static void CALLBACK
MACRO_CheckItem(LPCSTR str
)
278 WINE_FIXME("(\"%s\")\n", str
);
281 static void CALLBACK
MACRO_CloseSecondarys(void)
286 for (win
= Globals
.win_list
; win
; win
= win
->next
)
287 if (lstrcmpi(win
->info
->name
, "main"))
288 WINHELP_ReleaseWindow(win
);
291 static void CALLBACK
MACRO_CloseWindow(LPCSTR lpszWindow
)
295 WINE_TRACE("(\"%s\")\n", lpszWindow
);
297 if (!lpszWindow
|| !lpszWindow
[0]) lpszWindow
= "main";
299 for (win
= Globals
.win_list
; win
; win
= win
->next
)
300 if (!lstrcmpi(win
->info
->name
, lpszWindow
))
301 WINHELP_ReleaseWindow(win
);
304 static void CALLBACK
MACRO_Compare(LPCSTR str
)
306 WINE_FIXME("(\"%s\")\n", str
);
309 static void CALLBACK
MACRO_Contents(void)
311 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
316 MACRO_JumpContents(page
->file
->lpszPath
, NULL
);
319 static void CALLBACK
MACRO_ControlPanel(LPCSTR str1
, LPCSTR str2
, LONG u
)
321 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1
, str2
, u
);
324 void CALLBACK
MACRO_CopyDialog(void)
329 static void CALLBACK
MACRO_CopyTopic(void)
334 static void CALLBACK
MACRO_DeleteItem(LPCSTR str
)
336 WINE_FIXME("(\"%s\")\n", str
);
339 static void CALLBACK
MACRO_DeleteMark(LPCSTR str
)
341 WINE_FIXME("(\"%s\")\n", str
);
344 static void CALLBACK
MACRO_DisableItem(LPCSTR str
)
346 WINE_FIXME("(\"%s\")\n", str
);
349 static void CALLBACK
MACRO_EnableItem(LPCSTR str
)
351 WINE_FIXME("(\"%s\")\n", str
);
354 static void CALLBACK
MACRO_EndMPrint(void)
359 static void CALLBACK
MACRO_ExecFile(LPCSTR pgm
, LPCSTR args
, LONG cmd_show
, LPCSTR topic
)
363 WINE_TRACE("(%s, %s, %u, %s)\n",
364 wine_dbgstr_a(pgm
), wine_dbgstr_a(args
), cmd_show
, wine_dbgstr_a(topic
));
366 ret
= ShellExecuteA(Globals
.active_win
? Globals
.active_win
->hMainWnd
: NULL
, "open",
367 pgm
, args
, ".", cmd_show
);
368 if ((DWORD_PTR
)ret
< 32)
370 WINE_WARN("Failed with %p\n", ret
);
371 if (topic
) MACRO_JumpID(NULL
, topic
);
375 static void CALLBACK
MACRO_ExecProgram(LPCSTR str
, LONG u
)
377 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
380 void CALLBACK
MACRO_Exit(void)
384 while (Globals
.win_list
)
385 WINHELP_ReleaseWindow(Globals
.win_list
);
388 static void CALLBACK
MACRO_ExtAbleItem(LPCSTR str
, LONG u
)
390 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
393 static void CALLBACK
MACRO_ExtInsertItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
, LONG u1
, LONG u2
)
395 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u, %u)\n", str1
, str2
, str3
, str4
, u1
, u2
);
398 static void CALLBACK
MACRO_ExtInsertMenu(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LONG u1
, LONG u2
)
400 WINE_FIXME("(\"%s\", \"%s\", \"%s\", %u, %u)\n", str1
, str2
, str3
, u1
, u2
);
403 static BOOL CALLBACK
MACRO_FileExist(LPCSTR str
)
405 WINE_TRACE("(\"%s\")\n", str
);
406 return GetFileAttributes(str
) != INVALID_FILE_ATTRIBUTES
;
409 void CALLBACK
MACRO_FileOpen(void)
411 char szFile
[MAX_PATH
];
413 if (WINHELP_GetOpenFileName(szFile
, MAX_PATH
))
415 MACRO_JumpContents(szFile
, "main");
419 static void CALLBACK
MACRO_Find(void)
424 static void CALLBACK
MACRO_Finder(void)
426 WINHELP_CreateIndexWindow(FALSE
);
429 static void CALLBACK
MACRO_FloatingMenu(void)
434 static void CALLBACK
MACRO_Flush(void)
439 static void CALLBACK
MACRO_FocusWindow(LPCSTR lpszWindow
)
443 WINE_TRACE("(\"%s\")\n", lpszWindow
);
445 if (!lpszWindow
|| !lpszWindow
[0]) lpszWindow
= "main";
447 for (win
= Globals
.win_list
; win
; win
= win
->next
)
448 if (!lstrcmpi(win
->info
->name
, lpszWindow
))
449 SetFocus(win
->hMainWnd
);
452 static void CALLBACK
MACRO_Generate(LPCSTR str
, LONG w
, LONG l
)
454 WINE_FIXME("(\"%s\", %x, %x)\n", str
, w
, l
);
457 static void CALLBACK
MACRO_GotoMark(LPCSTR str
)
459 WINE_FIXME("(\"%s\")\n", str
);
462 void CALLBACK
MACRO_HelpOn(void)
464 WINHELP_WINDOW
*win
= MACRO_CurrentWindow();
468 if (win
&& win
->page
&& win
->page
->file
)
469 file
= win
->page
->file
->help_on_file
;
472 file
= (Globals
.wVersion
> 4) ? "winhlp32.hlp" : "winhelp.hlp";
474 MACRO_JumpContents(file
, NULL
);
477 void CALLBACK
MACRO_HelpOnTop(void)
482 void CALLBACK
MACRO_History(void)
486 if (Globals
.active_win
&& !Globals
.active_win
->hHistoryWnd
)
488 HWND hWnd
= CreateWindow(HISTORY_WIN_CLASS_NAME
, "History", WS_OVERLAPPEDWINDOW
,
489 0, 0, 0, 0, 0, 0, Globals
.hInstance
, Globals
.active_win
);
490 ShowWindow(hWnd
, SW_NORMAL
);
494 static void CALLBACK
MACRO_IfThen(BOOL b
, LPCSTR t
)
496 if (b
) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t
);
499 static void CALLBACK
MACRO_IfThenElse(BOOL b
, LPCSTR t
, LPCSTR f
)
501 if (b
) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t
);
502 else MACRO_ExecuteMacro(MACRO_CurrentWindow(), f
);
505 static BOOL CALLBACK
MACRO_InitMPrint(void)
511 static void CALLBACK
MACRO_InsertItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
, LONG u
)
513 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u)\n", str1
, str2
, str3
, str4
, u
);
516 static void CALLBACK
MACRO_InsertMenu(LPCSTR str1
, LPCSTR str2
, LONG u
)
518 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1
, str2
, u
);
521 static BOOL CALLBACK
MACRO_IsBook(void)
524 return Globals
.isBook
;
527 static BOOL CALLBACK
MACRO_IsMark(LPCSTR str
)
529 WINE_FIXME("(\"%s\")\n", str
);
533 static BOOL CALLBACK
MACRO_IsNotMark(LPCSTR str
)
535 WINE_FIXME("(\"%s\")\n", str
);
539 void CALLBACK
MACRO_JumpContext(LPCSTR lpszPath
, LPCSTR lpszWindow
, LONG context
)
543 WINE_TRACE("(\"%s\", \"%s\", %d)\n", lpszPath
, lpszWindow
, context
);
544 hlpfile
= WINHELP_LookupHelpFile(lpszPath
);
545 /* Some madness: what user calls 'context', hlpfile calls 'map' */
546 WINHELP_OpenHelpWindow(HLPFILE_PageByMap
, hlpfile
, context
,
547 WINHELP_GetWindowInfo(hlpfile
, lpszWindow
),
551 void CALLBACK
MACRO_JumpHash(LPCSTR lpszPath
, LPCSTR lpszWindow
, LONG lHash
)
555 WINE_TRACE("(\"%s\", \"%s\", %u)\n", lpszPath
, lpszWindow
, lHash
);
556 if (!lpszPath
|| !lpszPath
[0])
557 hlpfile
= MACRO_CurrentWindow()->page
->file
;
559 hlpfile
= WINHELP_LookupHelpFile(lpszPath
);
560 WINHELP_OpenHelpWindow(HLPFILE_PageByHash
, hlpfile
, lHash
,
561 WINHELP_GetWindowInfo(hlpfile
, lpszWindow
),
565 static void CALLBACK
MACRO_JumpHelpOn(void)
570 static void CALLBACK
MACRO_JumpID(LPCSTR lpszPathWindow
, LPCSTR topic_id
)
574 WINE_TRACE("(\"%s\", \"%s\")\n", lpszPathWindow
, topic_id
);
575 if ((ptr
= strchr(lpszPathWindow
, '>')) != NULL
)
578 size_t sz
= ptr
- lpszPathWindow
;
580 tmp
= HeapAlloc(GetProcessHeap(), 0, sz
+ 1);
583 memcpy(tmp
, lpszPathWindow
, sz
);
585 MACRO_JumpHash(tmp
, ptr
+ 1, HLPFILE_Hash(topic_id
));
586 HeapFree(GetProcessHeap(), 0, tmp
);
590 MACRO_JumpHash(lpszPathWindow
, NULL
, HLPFILE_Hash(topic_id
));
593 /* FIXME: this macros is wrong
594 * it should only contain 2 strings, path & window are coded as path>window
596 static void CALLBACK
MACRO_JumpKeyword(LPCSTR lpszPath
, LPCSTR lpszWindow
, LPCSTR keyword
)
598 WINE_FIXME("(\"%s\", \"%s\", \"%s\")\n", lpszPath
, lpszWindow
, keyword
);
601 static void CALLBACK
MACRO_KLink(LPCSTR str1
, LONG u
, LPCSTR str2
, LPCSTR str3
)
603 WINE_FIXME("(\"%s\", %u, \"%s\", \"%s\")\n", str1
, u
, str2
, str3
);
606 static void CALLBACK
MACRO_Menu(void)
611 static void CALLBACK
MACRO_MPrintHash(LONG u
)
613 WINE_FIXME("(%u)\n", u
);
616 static void CALLBACK
MACRO_MPrintID(LPCSTR str
)
618 WINE_FIXME("(\"%s\")\n", str
);
621 static void CALLBACK
MACRO_Next(void)
626 wp
.page
= MACRO_CurrentWindow()->page
;
627 wp
.page
= HLPFILE_PageByOffset(wp
.page
->file
, wp
.page
->browse_fwd
, &wp
.relative
);
630 wp
.page
->file
->wRefCount
++;
631 wp
.wininfo
= MACRO_CurrentWindow()->info
;
632 WINHELP_CreateHelpWindow(&wp
, SW_NORMAL
, TRUE
);
636 static void CALLBACK
MACRO_NoShow(void)
641 void CALLBACK
MACRO_PopupContext(LPCSTR str
, LONG u
)
643 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
646 static void CALLBACK
MACRO_PopupHash(LPCSTR str
, LONG u
)
648 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
651 static void CALLBACK
MACRO_PopupId(LPCSTR str1
, LPCSTR str2
)
653 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
656 static void CALLBACK
MACRO_PositionWindow(LONG i1
, LONG i2
, LONG u1
, LONG u2
, LONG u3
, LPCSTR str
)
658 WINE_FIXME("(%i, %i, %u, %u, %u, \"%s\")\n", i1
, i2
, u1
, u2
, u3
, str
);
661 static void CALLBACK
MACRO_Prev(void)
666 wp
.page
= MACRO_CurrentWindow()->page
;
667 wp
.page
= HLPFILE_PageByOffset(wp
.page
->file
, wp
.page
->browse_bwd
, &wp
.relative
);
670 wp
.page
->file
->wRefCount
++;
671 wp
.wininfo
= MACRO_CurrentWindow()->info
;
672 WINHELP_CreateHelpWindow(&wp
, SW_NORMAL
, TRUE
);
676 void CALLBACK
MACRO_Print(void)
682 printer
.lStructSize
= sizeof(printer
);
683 printer
.hwndOwner
= MACRO_CurrentWindow()->hMainWnd
;
684 printer
.hInstance
= Globals
.hInstance
;
685 printer
.hDevMode
= 0;
686 printer
.hDevNames
= 0;
689 printer
.nFromPage
= 0;
691 printer
.nMinPage
= 0;
692 printer
.nMaxPage
= 0;
694 printer
.lCustData
= 0;
695 printer
.lpfnPrintHook
= 0;
696 printer
.lpfnSetupHook
= 0;
697 printer
.lpPrintTemplateName
= 0;
698 printer
.lpSetupTemplateName
= 0;
699 printer
.hPrintTemplate
= 0;
700 printer
.hSetupTemplate
= 0;
702 if (PrintDlgA(&printer
)) {
703 WINE_FIXME("Print()\n");
707 void CALLBACK
MACRO_PrinterSetup(void)
712 static void CALLBACK
MACRO_RegisterRoutine(LPCSTR dll_name
, LPCSTR proc
, LPCSTR args
)
718 WINE_TRACE("(\"%s\", \"%s\", \"%s\")\n", dll_name
, proc
, args
);
720 /* FIXME: are the registered DLLs global or linked to the current file ???
721 * We assume globals (as we did for macros, but is this really the case ???)
723 for (dll
= Globals
.dlls
; dll
; dll
= dll
->next
)
725 if (!strcmp(dll
->name
, dll_name
)) break;
729 HANDLE hLib
= LoadLibrary(dll_name
);
731 /* FIXME: the library will not be unloaded until exit of program
732 * We don't send the DW_TERM message
734 WINE_TRACE("Loading %s\n", dll_name
);
735 /* FIXME: should look in the directory where current hlpfile
740 /* FIXME: internationalisation for error messages */
741 WINE_FIXME("Cannot find dll %s\n", dll_name
);
743 else if ((dll
= HeapAlloc(GetProcessHeap(), 0, sizeof(*dll
))))
746 dll
->name
= StrDup(dll_name
); /* FIXME: never freed */
747 dll
->next
= Globals
.dlls
;
749 dll
->handler
= (WINHELP_LDLLHandler
)GetProcAddress(dll
->hLib
, "LDLLHandler");
750 dll
->class = dll
->handler
? (dll
->handler
)(DW_WHATMSG
, 0, 0) : DC_NOMSG
;
751 WINE_TRACE("Got class %x for DLL %s\n", dll
->class, dll_name
);
752 if (dll
->class & DC_INITTERM
) dll
->handler(DW_INIT
, 0, 0);
753 if (dll
->class & DC_CALLBACKS
) dll
->handler(DW_CALLBACKS
, (LONG_PTR
)&Callbacks
, 0);
755 else WINE_WARN("OOM\n");
757 if (dll
&& !(fn
= GetProcAddress(dll
->hLib
, proc
)))
759 /* FIXME: internationalisation for error messages */
760 WINE_FIXME("Cannot find proc %s in dll %s\n", dll_name
, proc
);
763 size
= ++MACRO_NumLoaded
* sizeof(struct MacroDesc
);
764 if (!MACRO_Loaded
) MACRO_Loaded
= HeapAlloc(GetProcessHeap(), 0, size
);
765 else MACRO_Loaded
= HeapReAlloc(GetProcessHeap(), 0, MACRO_Loaded
, size
);
766 MACRO_Loaded
[MACRO_NumLoaded
- 1].name
= StrDup(proc
); /* FIXME: never freed */
767 MACRO_Loaded
[MACRO_NumLoaded
- 1].alias
= NULL
;
768 MACRO_Loaded
[MACRO_NumLoaded
- 1].isBool
= 0;
769 MACRO_Loaded
[MACRO_NumLoaded
- 1].arguments
= StrDup(args
); /* FIXME: never freed */
770 MACRO_Loaded
[MACRO_NumLoaded
- 1].fn
= fn
;
771 WINE_TRACE("Added %s(%s) at %p\n", proc
, args
, fn
);
774 static void CALLBACK
MACRO_RemoveAccelerator(LONG u1
, LONG u2
)
776 WINE_FIXME("(%u, %u)\n", u1
, u2
);
779 static void CALLBACK
MACRO_ResetMenu(void)
784 static void CALLBACK
MACRO_SaveMark(LPCSTR str
)
786 WINE_FIXME("(\"%s\")\n", str
);
789 static void CALLBACK
MACRO_Search(void)
791 WINHELP_CreateIndexWindow(TRUE
);
794 void CALLBACK
MACRO_SetContents(LPCSTR str
, LONG u
)
796 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
799 static void CALLBACK
MACRO_SetHelpOnFile(LPCSTR str
)
801 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
803 WINE_TRACE("(\"%s\")\n", str
);
805 HeapFree(GetProcessHeap(), 0, page
->file
->help_on_file
);
806 page
->file
->help_on_file
= HeapAlloc(GetProcessHeap(), 0, strlen(str
) + 1);
807 if (page
->file
->help_on_file
)
808 strcpy(page
->file
->help_on_file
, str
);
811 static void CALLBACK
MACRO_SetPopupColor(LONG r
, LONG g
, LONG b
)
813 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
815 WINE_TRACE("(%x, %x, %x)\n", r
, g
, b
);
816 page
->file
->has_popup_color
= TRUE
;
817 page
->file
->popup_color
= RGB(r
, g
, b
);
820 static void CALLBACK
MACRO_ShellExecute(LPCSTR str1
, LPCSTR str2
, LONG u1
, LONG u2
, LPCSTR str3
, LPCSTR str4
)
822 WINE_FIXME("(\"%s\", \"%s\", %u, %u, \"%s\", \"%s\")\n", str1
, str2
, u1
, u2
, str3
, str4
);
825 static void CALLBACK
MACRO_ShortCut(LPCSTR str1
, LPCSTR str2
, LONG w
, LONG l
, LPCSTR str
)
827 WINE_FIXME("(\"%s\", \"%s\", %x, %x, \"%s\")\n", str1
, str2
, w
, l
, str
);
830 static void CALLBACK
MACRO_TCard(LONG u
)
832 WINE_FIXME("(%u)\n", u
);
835 static void CALLBACK
MACRO_Test(LONG u
)
837 WINE_FIXME("(%u)\n", u
);
840 static BOOL CALLBACK
MACRO_TestALink(LPCSTR str
)
842 WINE_FIXME("(\"%s\")\n", str
);
846 static BOOL CALLBACK
MACRO_TestKLink(LPCSTR str
)
848 WINE_FIXME("(\"%s\")\n", str
);
852 static void CALLBACK
MACRO_UncheckItem(LPCSTR str
)
854 WINE_FIXME("(\"%s\")\n", str
);
857 static void CALLBACK
MACRO_UpdateWindow(LPCSTR str1
, LPCSTR str2
)
859 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
863 /**************************************************/
865 /**************************************************/
868 * U: 32 bit unsigned int
869 * I: 32 bit signed int
871 * v: unknown (32 bit entity)
874 static struct MacroDesc MACRO_Builtins
[] = {
875 {"About", NULL
, 0, "", MACRO_About
},
876 {"AddAccelerator", "AA", 0, "UUS", MACRO_AddAccelerator
},
877 {"ALink", "AL", 0, "SUS", MACRO_ALink
},
878 {"Annotate", NULL
, 0, "", MACRO_Annotate
},
879 {"AppendItem", NULL
, 0, "SSSS", MACRO_AppendItem
},
880 {"Back", NULL
, 0, "", MACRO_Back
},
881 {"BackFlush", "BF", 0, "", MACRO_BackFlush
},
882 {"BookmarkDefine", NULL
, 0, "", MACRO_BookmarkDefine
},
883 {"BookmarkMore", NULL
, 0, "", MACRO_BookmarkMore
},
884 {"BrowseButtons", NULL
, 0, "", MACRO_BrowseButtons
},
885 {"ChangeButtonBinding", "CBB",0, "SS", MACRO_ChangeButtonBinding
},
886 {"ChangeEnable", "CE", 0, "SS", MACRO_ChangeEnable
},
887 {"ChangeItemBinding", "CIB",0, "SS", MACRO_ChangeItemBinding
},
888 {"CheckItem", "CI", 0, "S", MACRO_CheckItem
},
889 {"CloseSecondarys", "CS", 0, "", MACRO_CloseSecondarys
},
890 {"CloseWindow", "CW", 0, "S", MACRO_CloseWindow
},
891 {"Compare", NULL
, 0, "S", MACRO_Compare
},
892 {"Contents", NULL
, 0, "", MACRO_Contents
},
893 {"ControlPanel", NULL
, 0, "SSU", MACRO_ControlPanel
},
894 {"CopyDialog", NULL
, 0, "", MACRO_CopyDialog
},
895 {"CopyTopic", "CT", 0, "", MACRO_CopyTopic
},
896 {"CreateButton", "CB", 0, "SSS", MACRO_CreateButton
},
897 {"DeleteItem", NULL
, 0, "S", MACRO_DeleteItem
},
898 {"DeleteMark", NULL
, 0, "S", MACRO_DeleteMark
},
899 {"DestroyButton", NULL
, 0, "S", MACRO_DestroyButton
},
900 {"DisableButton", "DB", 0, "S", MACRO_DisableButton
},
901 {"DisableItem", "DI", 0, "S", MACRO_DisableItem
},
902 {"EnableButton", "EB", 0, "S", MACRO_EnableButton
},
903 {"EnableItem", "EI", 0, "S", MACRO_EnableItem
},
904 {"EndMPrint", NULL
, 0, "", MACRO_EndMPrint
},
905 {"ExecFile", "EF", 0, "SSUS", MACRO_ExecFile
},
906 {"ExecProgram", "EP", 0, "SU", MACRO_ExecProgram
},
907 {"Exit", NULL
, 0, "", MACRO_Exit
},
908 {"ExtAbleItem", NULL
, 0, "SU", MACRO_ExtAbleItem
},
909 {"ExtInsertItem", NULL
, 0, "SSSSUU", MACRO_ExtInsertItem
},
910 {"ExtInsertMenu", NULL
, 0, "SSSUU", MACRO_ExtInsertMenu
},
911 {"FileExist", "FE", 1, "S", MACRO_FileExist
},
912 {"FileOpen", "FO", 0, "", MACRO_FileOpen
},
913 {"Find", NULL
, 0, "", MACRO_Find
},
914 {"Finder", "FD", 0, "", MACRO_Finder
},
915 {"FloatingMenu", NULL
, 0, "", MACRO_FloatingMenu
},
916 {"Flush", "FH", 0, "", MACRO_Flush
},
917 {"FocusWindow", NULL
, 0, "S", MACRO_FocusWindow
},
918 {"Generate", NULL
, 0, "SUU", MACRO_Generate
},
919 {"GotoMark", NULL
, 0, "S", MACRO_GotoMark
},
920 {"HelpOn", NULL
, 0, "", MACRO_HelpOn
},
921 {"HelpOnTop", NULL
, 0, "", MACRO_HelpOnTop
},
922 {"History", NULL
, 0, "", MACRO_History
},
923 {"InitMPrint", NULL
, 1, "", MACRO_InitMPrint
},
924 {"InsertItem", NULL
, 0, "SSSSU", MACRO_InsertItem
},
925 {"InsertMenu", NULL
, 0, "SSU", MACRO_InsertMenu
},
926 {"IfThen", "IF", 0, "BS", MACRO_IfThen
},
927 {"IfThenElse", "IE", 0, "BSS", MACRO_IfThenElse
},
928 {"IsBook", NULL
, 1, "", MACRO_IsBook
},
929 {"IsMark", NULL
, 1, "S", MACRO_IsMark
},
930 {"IsNotMark", "NM", 1, "S", MACRO_IsNotMark
},
931 {"JumpContents", NULL
, 0, "SS", MACRO_JumpContents
},
932 {"JumpContext", "JC", 0, "SSU", MACRO_JumpContext
},
933 {"JumpHash", "JH", 0, "SSU", MACRO_JumpHash
},
934 {"JumpHelpOn", NULL
, 0, "", MACRO_JumpHelpOn
},
935 {"JumpID", "JI", 0, "SS", MACRO_JumpID
},
936 {"JumpKeyword", "JK", 0, "SSS", MACRO_JumpKeyword
},
937 {"KLink", "KL", 0, "SUSS", MACRO_KLink
},
938 {"Menu", "MU", 0, "", MACRO_Menu
},
939 {"MPrintHash", NULL
, 0, "U", MACRO_MPrintHash
},
940 {"MPrintID", NULL
, 0, "S", MACRO_MPrintID
},
941 {"Next", NULL
, 0, "", MACRO_Next
},
942 {"NoShow", "NS", 0, "", MACRO_NoShow
},
943 {"PopupContext", "PC", 0, "SU", MACRO_PopupContext
},
944 {"PopupHash", NULL
, 0, "SU", MACRO_PopupHash
},
945 {"PopupId", "PI", 0, "SS", MACRO_PopupId
},
946 {"PositionWindow", "PW", 0, "IIUUUS", MACRO_PositionWindow
},
947 {"Prev", NULL
, 0, "", MACRO_Prev
},
948 {"Print", NULL
, 0, "", MACRO_Print
},
949 {"PrinterSetup", NULL
, 0, "", MACRO_PrinterSetup
},
950 {"RegisterRoutine", "RR", 0, "SSS", MACRO_RegisterRoutine
},
951 {"RemoveAccelerator", "RA", 0, "UU", MACRO_RemoveAccelerator
},
952 {"ResetMenu", NULL
, 0, "", MACRO_ResetMenu
},
953 {"SaveMark", NULL
, 0, "S", MACRO_SaveMark
},
954 {"Search", NULL
, 0, "", MACRO_Search
},
955 {"SetContents", NULL
, 0, "SU", MACRO_SetContents
},
956 {"SetHelpOnFile", NULL
, 0, "S", MACRO_SetHelpOnFile
},
957 {"SetPopupColor", "SPC",0, "UUU", MACRO_SetPopupColor
},
958 {"ShellExecute", "SE", 0, "SSUUSS", MACRO_ShellExecute
},
959 {"ShortCut", "SH", 0, "SSUUS", MACRO_ShortCut
},
960 {"TCard", NULL
, 0, "U", MACRO_TCard
},
961 {"Test", NULL
, 0, "U", MACRO_Test
},
962 {"TestALink", NULL
, 1, "S", MACRO_TestALink
},
963 {"TestKLink", NULL
, 1, "S", MACRO_TestKLink
},
964 {"UncheckItem", "UI", 0, "S", MACRO_UncheckItem
},
965 {"UpdateWindow", "UW", 0, "SS", MACRO_UpdateWindow
},
966 {NULL
, NULL
, 0, NULL
, NULL
}
969 static int MACRO_DoLookUp(struct MacroDesc
* start
, const char* name
, struct lexret
* lr
, unsigned len
)
971 struct MacroDesc
* md
;
973 for (md
= start
; md
->name
&& len
!= 0; md
++, len
--)
975 if (strcasecmp(md
->name
, name
) == 0 || (md
->alias
!= NULL
&& strcasecmp(md
->alias
, name
) == 0))
977 lr
->proto
= md
->arguments
;
978 lr
->function
= md
->fn
;
979 return md
->isBool
? BOOL_FUNCTION
: VOID_FUNCTION
;
985 int MACRO_Lookup(const char* name
, struct lexret
* lr
)
989 if ((ret
= MACRO_DoLookUp(MACRO_Builtins
, name
, lr
, -1)) != EMPTY
)
991 if (MACRO_Loaded
&& (ret
= MACRO_DoLookUp(MACRO_Loaded
, name
, lr
, MACRO_NumLoaded
)) != EMPTY
)