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)
155 HICON icon
= LoadImageW( Globals
.hInstance
, MAKEINTRESOURCEW(IDI_WINHELP
),
156 IMAGE_ICON
, 48, 48, LR_SHARED
);
157 LoadStringW( Globals
.hInstance
, STID_WINE_HELP
, name
, sizeof(name
)/sizeof(WCHAR
) );
158 ShellAboutW( MACRO_CurrentWindow()->hMainWnd
, name
, NULL
, icon
);
161 static void CALLBACK
MACRO_AddAccelerator(LONG u1
, LONG u2
, LPCSTR str
)
163 WINE_FIXME("(%u, %u, \"%s\")\n", u1
, u2
, str
);
166 static void CALLBACK
MACRO_ALink(LPCSTR str1
, LONG u
, LPCSTR str2
)
168 WINE_FIXME("(\"%s\", %u, \"%s\")\n", str1
, u
, str2
);
171 void CALLBACK
MACRO_Annotate(void)
176 static void CALLBACK
MACRO_AppendItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
)
178 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\")\n", str1
, str2
, str3
, str4
);
181 static void CALLBACK
MACRO_Back(void)
183 WINHELP_WINDOW
* win
= MACRO_CurrentWindow();
187 if (win
&& win
->back
.index
>= 2)
188 WINHELP_CreateHelpWindow(&win
->back
.set
[--win
->back
.index
- 1], SW_SHOW
, FALSE
);
191 static void CALLBACK
MACRO_BackFlush(void)
193 WINHELP_WINDOW
* win
= MACRO_CurrentWindow();
197 if (win
) WINHELP_DeleteBackSet(win
);
200 void CALLBACK
MACRO_BookmarkDefine(void)
205 static void CALLBACK
MACRO_BookmarkMore(void)
210 static void CALLBACK
MACRO_BrowseButtons(void)
212 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
217 MACRO_CreateButton("BTN_PREV", "&<<", "Prev()");
218 MACRO_CreateButton("BTN_NEXT", "&>>", "Next()");
220 if (!HLPFILE_PageByOffset(page
->file
, page
->browse_bwd
, &relative
))
221 MACRO_DisableButton("BTN_PREV");
222 if (!HLPFILE_PageByOffset(page
->file
, page
->browse_fwd
, &relative
))
223 MACRO_DisableButton("BTN_NEXT");
226 static void CALLBACK
MACRO_ChangeButtonBinding(LPCSTR id
, LPCSTR macro
)
228 WINHELP_WINDOW
* win
= MACRO_CurrentWindow();
229 WINHELP_BUTTON
* button
;
234 WINE_TRACE("(\"%s\", \"%s\")\n", id
, macro
);
236 b
= MACRO_LookupButton(win
, id
);
237 if (!*b
) {WINE_FIXME("Couldn't find button '%s'\n", id
); return;}
239 size
= sizeof(WINHELP_BUTTON
) + lstrlen(id
) +
240 lstrlen((*b
)->lpszName
) + lstrlen(macro
) + 3;
242 button
= HeapAlloc(GetProcessHeap(), 0, size
);
245 button
->next
= (*b
)->next
;
246 button
->hWnd
= (*b
)->hWnd
;
247 button
->wParam
= (*b
)->wParam
;
249 ptr
= (char*)button
+ sizeof(WINHELP_BUTTON
);
252 button
->lpszID
= ptr
;
253 ptr
+= lstrlen(id
) + 1;
255 lstrcpy(ptr
, (*b
)->lpszName
);
256 button
->lpszName
= ptr
;
257 ptr
+= lstrlen((*b
)->lpszName
) + 1;
260 button
->lpszMacro
= ptr
;
264 WINHELP_LayoutMainWindow(win
);
267 static void CALLBACK
MACRO_ChangeEnable(LPCSTR id
, LPCSTR macro
)
269 WINE_TRACE("(\"%s\", \"%s\")\n", id
, macro
);
271 MACRO_ChangeButtonBinding(id
, macro
);
272 MACRO_EnableButton(id
);
275 static void CALLBACK
MACRO_ChangeItemBinding(LPCSTR str1
, LPCSTR str2
)
277 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
280 static void CALLBACK
MACRO_CheckItem(LPCSTR str
)
282 WINE_FIXME("(\"%s\")\n", str
);
285 static void CALLBACK
MACRO_CloseSecondarys(void)
288 WINHELP_WINDOW
*next
;
291 for (win
= Globals
.win_list
; win
; win
= next
)
294 if (lstrcmpi(win
->info
->name
, "main"))
295 WINHELP_ReleaseWindow(win
);
299 static void CALLBACK
MACRO_CloseWindow(LPCSTR lpszWindow
)
302 WINHELP_WINDOW
*next
;
304 WINE_TRACE("(\"%s\")\n", lpszWindow
);
306 if (!lpszWindow
|| !lpszWindow
[0]) lpszWindow
= "main";
308 for (win
= Globals
.win_list
; win
; win
= next
)
311 if (!lstrcmpi(win
->info
->name
, lpszWindow
))
312 WINHELP_ReleaseWindow(win
);
316 static void CALLBACK
MACRO_Compare(LPCSTR str
)
318 WINE_FIXME("(\"%s\")\n", str
);
321 static void CALLBACK
MACRO_Contents(void)
323 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
328 MACRO_JumpContents(page
->file
->lpszPath
, NULL
);
331 static void CALLBACK
MACRO_ControlPanel(LPCSTR str1
, LPCSTR str2
, LONG u
)
333 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1
, str2
, u
);
336 void CALLBACK
MACRO_CopyDialog(void)
341 static void CALLBACK
MACRO_CopyTopic(void)
346 static void CALLBACK
MACRO_DeleteItem(LPCSTR str
)
348 WINE_FIXME("(\"%s\")\n", str
);
351 static void CALLBACK
MACRO_DeleteMark(LPCSTR str
)
353 WINE_FIXME("(\"%s\")\n", str
);
356 static void CALLBACK
MACRO_DisableItem(LPCSTR str
)
358 WINE_FIXME("(\"%s\")\n", str
);
361 static void CALLBACK
MACRO_EnableItem(LPCSTR str
)
363 WINE_FIXME("(\"%s\")\n", str
);
366 static void CALLBACK
MACRO_EndMPrint(void)
371 static void CALLBACK
MACRO_ExecFile(LPCSTR pgm
, LPCSTR args
, LONG cmd_show
, LPCSTR topic
)
375 WINE_TRACE("(%s, %s, %u, %s)\n",
376 wine_dbgstr_a(pgm
), wine_dbgstr_a(args
), cmd_show
, wine_dbgstr_a(topic
));
378 ret
= ShellExecuteA(Globals
.active_win
? Globals
.active_win
->hMainWnd
: NULL
, "open",
379 pgm
, args
, ".", cmd_show
);
380 if ((DWORD_PTR
)ret
< 32)
382 WINE_WARN("Failed with %p\n", ret
);
383 if (topic
) MACRO_JumpID(NULL
, topic
);
387 static void CALLBACK
MACRO_ExecProgram(LPCSTR str
, LONG u
)
389 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
392 void CALLBACK
MACRO_Exit(void)
396 while (Globals
.win_list
)
397 WINHELP_ReleaseWindow(Globals
.win_list
);
400 static void CALLBACK
MACRO_ExtAbleItem(LPCSTR str
, LONG u
)
402 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
405 static void CALLBACK
MACRO_ExtInsertItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
, LONG u1
, LONG u2
)
407 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u, %u)\n", str1
, str2
, str3
, str4
, u1
, u2
);
410 static void CALLBACK
MACRO_ExtInsertMenu(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LONG u1
, LONG u2
)
412 WINE_FIXME("(\"%s\", \"%s\", \"%s\", %u, %u)\n", str1
, str2
, str3
, u1
, u2
);
415 static BOOL CALLBACK
MACRO_FileExist(LPCSTR str
)
417 WINE_TRACE("(\"%s\")\n", str
);
418 return GetFileAttributes(str
) != INVALID_FILE_ATTRIBUTES
;
421 void CALLBACK
MACRO_FileOpen(void)
423 char szFile
[MAX_PATH
];
425 if (WINHELP_GetOpenFileName(szFile
, MAX_PATH
))
427 MACRO_JumpContents(szFile
, "main");
431 static void CALLBACK
MACRO_Find(void)
436 static void CALLBACK
MACRO_Finder(void)
438 WINHELP_CreateIndexWindow(FALSE
);
441 static void CALLBACK
MACRO_FloatingMenu(void)
446 static void CALLBACK
MACRO_Flush(void)
451 static void CALLBACK
MACRO_FocusWindow(LPCSTR lpszWindow
)
455 WINE_TRACE("(\"%s\")\n", lpszWindow
);
457 if (!lpszWindow
|| !lpszWindow
[0]) lpszWindow
= "main";
459 for (win
= Globals
.win_list
; win
; win
= win
->next
)
460 if (!lstrcmpi(win
->info
->name
, lpszWindow
))
461 SetFocus(win
->hMainWnd
);
464 static void CALLBACK
MACRO_Generate(LPCSTR str
, LONG w
, LONG l
)
466 WINE_FIXME("(\"%s\", %x, %x)\n", str
, w
, l
);
469 static void CALLBACK
MACRO_GotoMark(LPCSTR str
)
471 WINE_FIXME("(\"%s\")\n", str
);
474 void CALLBACK
MACRO_HelpOn(void)
476 WINHELP_WINDOW
*win
= MACRO_CurrentWindow();
480 if (win
&& win
->page
&& win
->page
->file
)
481 file
= win
->page
->file
->help_on_file
;
484 file
= (Globals
.wVersion
> 4) ? "winhlp32.hlp" : "winhelp.hlp";
486 MACRO_JumpContents(file
, NULL
);
489 void CALLBACK
MACRO_HelpOnTop(void)
494 void CALLBACK
MACRO_History(void)
498 if (Globals
.active_win
&& !Globals
.active_win
->hHistoryWnd
)
500 HWND hWnd
= CreateWindow(HISTORY_WIN_CLASS_NAME
, "History", WS_OVERLAPPEDWINDOW
,
501 0, 0, 0, 0, 0, 0, Globals
.hInstance
, Globals
.active_win
);
502 ShowWindow(hWnd
, SW_NORMAL
);
506 static void CALLBACK
MACRO_IfThen(BOOL b
, LPCSTR t
)
508 if (b
) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t
);
511 static void CALLBACK
MACRO_IfThenElse(BOOL b
, LPCSTR t
, LPCSTR f
)
513 if (b
) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t
);
514 else MACRO_ExecuteMacro(MACRO_CurrentWindow(), f
);
517 static BOOL CALLBACK
MACRO_InitMPrint(void)
523 static void CALLBACK
MACRO_InsertItem(LPCSTR str1
, LPCSTR str2
, LPCSTR str3
, LPCSTR str4
, LONG u
)
525 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u)\n", str1
, str2
, str3
, str4
, u
);
528 static void CALLBACK
MACRO_InsertMenu(LPCSTR str1
, LPCSTR str2
, LONG u
)
530 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1
, str2
, u
);
533 static BOOL CALLBACK
MACRO_IsBook(void)
536 return Globals
.isBook
;
539 static BOOL CALLBACK
MACRO_IsMark(LPCSTR str
)
541 WINE_FIXME("(\"%s\")\n", str
);
545 static BOOL CALLBACK
MACRO_IsNotMark(LPCSTR str
)
547 WINE_FIXME("(\"%s\")\n", str
);
551 void CALLBACK
MACRO_JumpContext(LPCSTR lpszPath
, LPCSTR lpszWindow
, LONG context
)
555 WINE_TRACE("(\"%s\", \"%s\", %d)\n", lpszPath
, lpszWindow
, context
);
556 hlpfile
= WINHELP_LookupHelpFile(lpszPath
);
557 /* Some madness: what user calls 'context', hlpfile calls 'map' */
558 WINHELP_OpenHelpWindow(HLPFILE_PageByMap
, hlpfile
, context
,
559 WINHELP_GetWindowInfo(hlpfile
, lpszWindow
),
563 void CALLBACK
MACRO_JumpHash(LPCSTR lpszPath
, LPCSTR lpszWindow
, LONG lHash
)
567 WINE_TRACE("(\"%s\", \"%s\", %u)\n", lpszPath
, lpszWindow
, lHash
);
568 if (!lpszPath
|| !lpszPath
[0])
569 hlpfile
= MACRO_CurrentWindow()->page
->file
;
571 hlpfile
= WINHELP_LookupHelpFile(lpszPath
);
572 WINHELP_OpenHelpWindow(HLPFILE_PageByHash
, hlpfile
, lHash
,
573 WINHELP_GetWindowInfo(hlpfile
, lpszWindow
),
577 static void CALLBACK
MACRO_JumpHelpOn(void)
582 static void CALLBACK
MACRO_JumpID(LPCSTR lpszPathWindow
, LPCSTR topic_id
)
586 WINE_TRACE("(\"%s\", \"%s\")\n", lpszPathWindow
, topic_id
);
587 if ((ptr
= strchr(lpszPathWindow
, '>')) != NULL
)
592 tmp
= HeapAlloc(GetProcessHeap(), 0, strlen(lpszPathWindow
) + 1);
595 strcpy(tmp
, lpszPathWindow
);
596 tmp
[ptr
- lpszPathWindow
] = '\0';
597 ptr
+= tmp
- lpszPathWindow
; /* ptr now points to '>' in tmp buffer */
598 /* in some cases, we have a trailing space that we need to get rid of */
599 /* FIXME: check if it has to be done in lexer rather than here */
600 for (sz
= strlen(ptr
+ 1); sz
>= 1 && ptr
[sz
] == ' '; sz
--) ptr
[sz
] = '\0';
601 MACRO_JumpHash(tmp
, ptr
+ 1, HLPFILE_Hash(topic_id
));
602 HeapFree(GetProcessHeap(), 0, tmp
);
606 MACRO_JumpHash(lpszPathWindow
, NULL
, HLPFILE_Hash(topic_id
));
609 /* FIXME: this macros is wrong
610 * it should only contain 2 strings, path & window are coded as path>window
612 static void CALLBACK
MACRO_JumpKeyword(LPCSTR lpszPath
, LPCSTR lpszWindow
, LPCSTR keyword
)
614 WINE_FIXME("(\"%s\", \"%s\", \"%s\")\n", lpszPath
, lpszWindow
, keyword
);
617 static void CALLBACK
MACRO_KLink(LPCSTR str1
, LONG u
, LPCSTR str2
, LPCSTR str3
)
619 WINE_FIXME("(\"%s\", %u, \"%s\", \"%s\")\n", str1
, u
, str2
, str3
);
622 static void CALLBACK
MACRO_Menu(void)
627 static void CALLBACK
MACRO_MPrintHash(LONG u
)
629 WINE_FIXME("(%u)\n", u
);
632 static void CALLBACK
MACRO_MPrintID(LPCSTR str
)
634 WINE_FIXME("(\"%s\")\n", str
);
637 static void CALLBACK
MACRO_Next(void)
642 wp
.page
= MACRO_CurrentWindow()->page
;
643 wp
.page
= HLPFILE_PageByOffset(wp
.page
->file
, wp
.page
->browse_fwd
, &wp
.relative
);
646 wp
.page
->file
->wRefCount
++;
647 wp
.wininfo
= MACRO_CurrentWindow()->info
;
648 WINHELP_CreateHelpWindow(&wp
, SW_NORMAL
, TRUE
);
652 static void CALLBACK
MACRO_NoShow(void)
657 void CALLBACK
MACRO_PopupContext(LPCSTR str
, LONG u
)
659 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
662 static void CALLBACK
MACRO_PopupHash(LPCSTR str
, LONG u
)
664 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
667 static void CALLBACK
MACRO_PopupId(LPCSTR str1
, LPCSTR str2
)
669 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
672 static void CALLBACK
MACRO_PositionWindow(LONG i1
, LONG i2
, LONG u1
, LONG u2
, LONG u3
, LPCSTR str
)
674 WINE_FIXME("(%i, %i, %u, %u, %u, \"%s\")\n", i1
, i2
, u1
, u2
, u3
, str
);
677 static void CALLBACK
MACRO_Prev(void)
682 wp
.page
= MACRO_CurrentWindow()->page
;
683 wp
.page
= HLPFILE_PageByOffset(wp
.page
->file
, wp
.page
->browse_bwd
, &wp
.relative
);
686 wp
.page
->file
->wRefCount
++;
687 wp
.wininfo
= MACRO_CurrentWindow()->info
;
688 WINHELP_CreateHelpWindow(&wp
, SW_NORMAL
, TRUE
);
692 void CALLBACK
MACRO_Print(void)
698 printer
.lStructSize
= sizeof(printer
);
699 printer
.hwndOwner
= MACRO_CurrentWindow()->hMainWnd
;
700 printer
.hInstance
= Globals
.hInstance
;
701 printer
.hDevMode
= 0;
702 printer
.hDevNames
= 0;
705 printer
.nFromPage
= 0;
707 printer
.nMinPage
= 0;
708 printer
.nMaxPage
= 0;
710 printer
.lCustData
= 0;
711 printer
.lpfnPrintHook
= 0;
712 printer
.lpfnSetupHook
= 0;
713 printer
.lpPrintTemplateName
= 0;
714 printer
.lpSetupTemplateName
= 0;
715 printer
.hPrintTemplate
= 0;
716 printer
.hSetupTemplate
= 0;
718 if (PrintDlgA(&printer
)) {
719 WINE_FIXME("Print()\n");
723 void CALLBACK
MACRO_PrinterSetup(void)
728 static void CALLBACK
MACRO_RegisterRoutine(LPCSTR dll_name
, LPCSTR proc
, LPCSTR args
)
734 WINE_TRACE("(\"%s\", \"%s\", \"%s\")\n", dll_name
, proc
, args
);
736 /* FIXME: are the registered DLLs global or linked to the current file ???
737 * We assume globals (as we did for macros, but is this really the case ???)
739 for (dll
= Globals
.dlls
; dll
; dll
= dll
->next
)
741 if (!strcmp(dll
->name
, dll_name
)) break;
745 HANDLE hLib
= LoadLibrary(dll_name
);
747 /* FIXME: the library will not be unloaded until exit of program
748 * We don't send the DW_TERM message
750 WINE_TRACE("Loading %s\n", dll_name
);
751 /* FIXME: should look in the directory where current hlpfile
756 /* FIXME: internationalisation for error messages */
757 WINE_FIXME("Cannot find dll %s\n", dll_name
);
759 else if ((dll
= HeapAlloc(GetProcessHeap(), 0, sizeof(*dll
))))
762 dll
->name
= StrDup(dll_name
); /* FIXME: never freed */
763 dll
->next
= Globals
.dlls
;
765 dll
->handler
= (WINHELP_LDLLHandler
)GetProcAddress(dll
->hLib
, "LDLLHandler");
766 dll
->class = dll
->handler
? (dll
->handler
)(DW_WHATMSG
, 0, 0) : DC_NOMSG
;
767 WINE_TRACE("Got class %x for DLL %s\n", dll
->class, dll_name
);
768 if (dll
->class & DC_INITTERM
) dll
->handler(DW_INIT
, 0, 0);
769 if (dll
->class & DC_CALLBACKS
) dll
->handler(DW_CALLBACKS
, (LONG_PTR
)&Callbacks
, 0);
771 else WINE_WARN("OOM\n");
773 if (dll
&& !(fn
= GetProcAddress(dll
->hLib
, proc
)))
775 /* FIXME: internationalisation for error messages */
776 WINE_FIXME("Cannot find proc %s in dll %s\n", dll_name
, proc
);
779 size
= ++MACRO_NumLoaded
* sizeof(struct MacroDesc
);
780 if (!MACRO_Loaded
) MACRO_Loaded
= HeapAlloc(GetProcessHeap(), 0, size
);
781 else MACRO_Loaded
= HeapReAlloc(GetProcessHeap(), 0, MACRO_Loaded
, size
);
782 MACRO_Loaded
[MACRO_NumLoaded
- 1].name
= StrDup(proc
); /* FIXME: never freed */
783 MACRO_Loaded
[MACRO_NumLoaded
- 1].alias
= NULL
;
784 MACRO_Loaded
[MACRO_NumLoaded
- 1].isBool
= 0;
785 MACRO_Loaded
[MACRO_NumLoaded
- 1].arguments
= StrDup(args
); /* FIXME: never freed */
786 MACRO_Loaded
[MACRO_NumLoaded
- 1].fn
= fn
;
787 WINE_TRACE("Added %s(%s) at %p\n", proc
, args
, fn
);
790 static void CALLBACK
MACRO_RemoveAccelerator(LONG u1
, LONG u2
)
792 WINE_FIXME("(%u, %u)\n", u1
, u2
);
795 static void CALLBACK
MACRO_ResetMenu(void)
800 static void CALLBACK
MACRO_SaveMark(LPCSTR str
)
802 WINE_FIXME("(\"%s\")\n", str
);
805 static void CALLBACK
MACRO_Search(void)
807 WINHELP_CreateIndexWindow(TRUE
);
810 void CALLBACK
MACRO_SetContents(LPCSTR str
, LONG u
)
812 WINE_FIXME("(\"%s\", %u)\n", str
, u
);
815 static void CALLBACK
MACRO_SetHelpOnFile(LPCSTR str
)
817 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
819 WINE_TRACE("(\"%s\")\n", str
);
821 HeapFree(GetProcessHeap(), 0, page
->file
->help_on_file
);
822 page
->file
->help_on_file
= HeapAlloc(GetProcessHeap(), 0, strlen(str
) + 1);
823 if (page
->file
->help_on_file
)
824 strcpy(page
->file
->help_on_file
, str
);
827 static void CALLBACK
MACRO_SetPopupColor(LONG r
, LONG g
, LONG b
)
829 HLPFILE_PAGE
* page
= MACRO_CurrentWindow()->page
;
831 WINE_TRACE("(%x, %x, %x)\n", r
, g
, b
);
832 page
->file
->has_popup_color
= TRUE
;
833 page
->file
->popup_color
= RGB(r
, g
, b
);
836 static void CALLBACK
MACRO_ShellExecute(LPCSTR str1
, LPCSTR str2
, LONG u1
, LONG u2
, LPCSTR str3
, LPCSTR str4
)
838 WINE_FIXME("(\"%s\", \"%s\", %u, %u, \"%s\", \"%s\")\n", str1
, str2
, u1
, u2
, str3
, str4
);
841 static void CALLBACK
MACRO_ShortCut(LPCSTR str1
, LPCSTR str2
, LONG w
, LONG l
, LPCSTR str
)
843 WINE_FIXME("(\"%s\", \"%s\", %x, %x, \"%s\")\n", str1
, str2
, w
, l
, str
);
846 static void CALLBACK
MACRO_TCard(LONG u
)
848 WINE_FIXME("(%u)\n", u
);
851 static void CALLBACK
MACRO_Test(LONG u
)
853 WINE_FIXME("(%u)\n", u
);
856 static BOOL CALLBACK
MACRO_TestALink(LPCSTR str
)
858 WINE_FIXME("(\"%s\")\n", str
);
862 static BOOL CALLBACK
MACRO_TestKLink(LPCSTR str
)
864 WINE_FIXME("(\"%s\")\n", str
);
868 static void CALLBACK
MACRO_UncheckItem(LPCSTR str
)
870 WINE_FIXME("(\"%s\")\n", str
);
873 static void CALLBACK
MACRO_UpdateWindow(LPCSTR str1
, LPCSTR str2
)
875 WINE_FIXME("(\"%s\", \"%s\")\n", str1
, str2
);
879 /**************************************************/
881 /**************************************************/
884 * U: 32 bit unsigned int
885 * I: 32 bit signed int
887 * v: unknown (32 bit entity)
890 static struct MacroDesc MACRO_Builtins
[] = {
891 {"About", NULL
, 0, "", MACRO_About
},
892 {"AddAccelerator", "AA", 0, "UUS", MACRO_AddAccelerator
},
893 {"ALink", "AL", 0, "SUS", MACRO_ALink
},
894 {"Annotate", NULL
, 0, "", MACRO_Annotate
},
895 {"AppendItem", NULL
, 0, "SSSS", MACRO_AppendItem
},
896 {"Back", NULL
, 0, "", MACRO_Back
},
897 {"BackFlush", "BF", 0, "", MACRO_BackFlush
},
898 {"BookmarkDefine", NULL
, 0, "", MACRO_BookmarkDefine
},
899 {"BookmarkMore", NULL
, 0, "", MACRO_BookmarkMore
},
900 {"BrowseButtons", NULL
, 0, "", MACRO_BrowseButtons
},
901 {"ChangeButtonBinding", "CBB",0, "SS", MACRO_ChangeButtonBinding
},
902 {"ChangeEnable", "CE", 0, "SS", MACRO_ChangeEnable
},
903 {"ChangeItemBinding", "CIB",0, "SS", MACRO_ChangeItemBinding
},
904 {"CheckItem", "CI", 0, "S", MACRO_CheckItem
},
905 {"CloseSecondarys", "CS", 0, "", MACRO_CloseSecondarys
},
906 {"CloseWindow", "CW", 0, "S", MACRO_CloseWindow
},
907 {"Compare", NULL
, 0, "S", MACRO_Compare
},
908 {"Contents", NULL
, 0, "", MACRO_Contents
},
909 {"ControlPanel", NULL
, 0, "SSU", MACRO_ControlPanel
},
910 {"CopyDialog", NULL
, 0, "", MACRO_CopyDialog
},
911 {"CopyTopic", "CT", 0, "", MACRO_CopyTopic
},
912 {"CreateButton", "CB", 0, "SSS", MACRO_CreateButton
},
913 {"DeleteItem", NULL
, 0, "S", MACRO_DeleteItem
},
914 {"DeleteMark", NULL
, 0, "S", MACRO_DeleteMark
},
915 {"DestroyButton", NULL
, 0, "S", MACRO_DestroyButton
},
916 {"DisableButton", "DB", 0, "S", MACRO_DisableButton
},
917 {"DisableItem", "DI", 0, "S", MACRO_DisableItem
},
918 {"EnableButton", "EB", 0, "S", MACRO_EnableButton
},
919 {"EnableItem", "EI", 0, "S", MACRO_EnableItem
},
920 {"EndMPrint", NULL
, 0, "", MACRO_EndMPrint
},
921 {"ExecFile", "EF", 0, "SSUS", MACRO_ExecFile
},
922 {"ExecProgram", "EP", 0, "SU", MACRO_ExecProgram
},
923 {"Exit", NULL
, 0, "", MACRO_Exit
},
924 {"ExtAbleItem", NULL
, 0, "SU", MACRO_ExtAbleItem
},
925 {"ExtInsertItem", NULL
, 0, "SSSSUU", MACRO_ExtInsertItem
},
926 {"ExtInsertMenu", NULL
, 0, "SSSUU", MACRO_ExtInsertMenu
},
927 {"FileExist", "FE", 1, "S", MACRO_FileExist
},
928 {"FileOpen", "FO", 0, "", MACRO_FileOpen
},
929 {"Find", NULL
, 0, "", MACRO_Find
},
930 {"Finder", "FD", 0, "", MACRO_Finder
},
931 {"FloatingMenu", NULL
, 0, "", MACRO_FloatingMenu
},
932 {"Flush", "FH", 0, "", MACRO_Flush
},
933 {"FocusWindow", NULL
, 0, "S", MACRO_FocusWindow
},
934 {"Generate", NULL
, 0, "SUU", MACRO_Generate
},
935 {"GotoMark", NULL
, 0, "S", MACRO_GotoMark
},
936 {"HelpOn", NULL
, 0, "", MACRO_HelpOn
},
937 {"HelpOnTop", NULL
, 0, "", MACRO_HelpOnTop
},
938 {"History", NULL
, 0, "", MACRO_History
},
939 {"InitMPrint", NULL
, 1, "", MACRO_InitMPrint
},
940 {"InsertItem", NULL
, 0, "SSSSU", MACRO_InsertItem
},
941 {"InsertMenu", NULL
, 0, "SSU", MACRO_InsertMenu
},
942 {"IfThen", "IF", 0, "BS", MACRO_IfThen
},
943 {"IfThenElse", "IE", 0, "BSS", MACRO_IfThenElse
},
944 {"IsBook", NULL
, 1, "", MACRO_IsBook
},
945 {"IsMark", NULL
, 1, "S", MACRO_IsMark
},
946 {"IsNotMark", "NM", 1, "S", MACRO_IsNotMark
},
947 {"JumpContents", NULL
, 0, "SS", MACRO_JumpContents
},
948 {"JumpContext", "JC", 0, "SSU", MACRO_JumpContext
},
949 {"JumpHash", "JH", 0, "SSU", MACRO_JumpHash
},
950 {"JumpHelpOn", NULL
, 0, "", MACRO_JumpHelpOn
},
951 {"JumpID", "JI", 0, "SS", MACRO_JumpID
},
952 {"JumpKeyword", "JK", 0, "SSS", MACRO_JumpKeyword
},
953 {"KLink", "KL", 0, "SUSS", MACRO_KLink
},
954 {"Menu", "MU", 0, "", MACRO_Menu
},
955 {"MPrintHash", NULL
, 0, "U", MACRO_MPrintHash
},
956 {"MPrintID", NULL
, 0, "S", MACRO_MPrintID
},
957 {"Next", NULL
, 0, "", MACRO_Next
},
958 {"NoShow", "NS", 0, "", MACRO_NoShow
},
959 {"PopupContext", "PC", 0, "SU", MACRO_PopupContext
},
960 {"PopupHash", NULL
, 0, "SU", MACRO_PopupHash
},
961 {"PopupId", "PI", 0, "SS", MACRO_PopupId
},
962 {"PositionWindow", "PW", 0, "IIUUUS", MACRO_PositionWindow
},
963 {"Prev", NULL
, 0, "", MACRO_Prev
},
964 {"Print", NULL
, 0, "", MACRO_Print
},
965 {"PrinterSetup", NULL
, 0, "", MACRO_PrinterSetup
},
966 {"RegisterRoutine", "RR", 0, "SSS", MACRO_RegisterRoutine
},
967 {"RemoveAccelerator", "RA", 0, "UU", MACRO_RemoveAccelerator
},
968 {"ResetMenu", NULL
, 0, "", MACRO_ResetMenu
},
969 {"SaveMark", NULL
, 0, "S", MACRO_SaveMark
},
970 {"Search", NULL
, 0, "", MACRO_Search
},
971 {"SetContents", NULL
, 0, "SU", MACRO_SetContents
},
972 {"SetHelpOnFile", NULL
, 0, "S", MACRO_SetHelpOnFile
},
973 {"SetPopupColor", "SPC",0, "UUU", MACRO_SetPopupColor
},
974 {"ShellExecute", "SE", 0, "SSUUSS", MACRO_ShellExecute
},
975 {"ShortCut", "SH", 0, "SSUUS", MACRO_ShortCut
},
976 {"TCard", NULL
, 0, "U", MACRO_TCard
},
977 {"Test", NULL
, 0, "U", MACRO_Test
},
978 {"TestALink", NULL
, 1, "S", MACRO_TestALink
},
979 {"TestKLink", NULL
, 1, "S", MACRO_TestKLink
},
980 {"UncheckItem", "UI", 0, "S", MACRO_UncheckItem
},
981 {"UpdateWindow", "UW", 0, "SS", MACRO_UpdateWindow
},
982 {NULL
, NULL
, 0, NULL
, NULL
}
985 static int MACRO_DoLookUp(struct MacroDesc
* start
, const char* name
, struct lexret
* lr
, unsigned len
)
987 struct MacroDesc
* md
;
989 for (md
= start
; md
->name
&& len
!= 0; md
++, len
--)
991 if (strcasecmp(md
->name
, name
) == 0 || (md
->alias
!= NULL
&& strcasecmp(md
->alias
, name
) == 0))
993 lr
->proto
= md
->arguments
;
994 lr
->function
= md
->fn
;
995 return md
->isBool
? BOOL_FUNCTION
: VOID_FUNCTION
;
1001 int MACRO_Lookup(const char* name
, struct lexret
* lr
)
1005 if ((ret
= MACRO_DoLookUp(MACRO_Builtins
, name
, lr
, -1)) != EMPTY
)
1007 if (MACRO_Loaded
&& (ret
= MACRO_DoLookUp(MACRO_Loaded
, name
, lr
, MACRO_NumLoaded
)) != EMPTY
)