push 460a69df99a5ad9f5823a97170ef7a215171c033
[wine/hacks.git] / programs / winhlp32 / macro.c
blob0eeaa9b2b27dafecd27d6a41b0011ccf7a3b333f
1 /*
2 * Help Viewer
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
24 #include <stdio.h>
26 #include "windows.h"
27 #include "commdlg.h"
28 #include "winhelp.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(winhelp);
34 /**************************************************/
35 /* Macro table */
36 /**************************************************/
37 struct MacroDesc {
38 const char* name;
39 const char* alias;
40 BOOL isBool;
41 const char* arguments;
42 FARPROC fn;
45 static struct MacroDesc*MACRO_Loaded /* = NULL */;
46 static unsigned MACRO_NumLoaded /* = 0 */;
48 /******* helper functions *******/
50 static WINHELP_BUTTON** MACRO_LookupButton(WINHELP_WINDOW* win, LPCSTR name)
52 WINHELP_BUTTON** b;
54 for (b = &win->first_button; *b; b = &(*b)->next)
55 if (!lstrcmpi(name, (*b)->lpszID)) break;
56 return b;
59 /******* real macro implementation *******/
61 void CALLBACK MACRO_CreateButton(LPCSTR id, LPCSTR name, LPCSTR macro)
63 WINHELP_WINDOW *win = Globals.active_win;
64 WINHELP_BUTTON *button, **b;
65 LONG size;
66 LPSTR ptr;
68 WINE_TRACE("(\"%s\", \"%s\", %s)\n", id, name, macro);
70 size = sizeof(WINHELP_BUTTON) + lstrlen(id) + lstrlen(name) + lstrlen(macro) + 3;
72 button = HeapAlloc(GetProcessHeap(), 0, size);
73 if (!button) return;
75 button->next = 0;
76 button->hWnd = 0;
78 ptr = (char*)button + sizeof(WINHELP_BUTTON);
80 lstrcpy(ptr, id);
81 button->lpszID = ptr;
82 ptr += lstrlen(id) + 1;
84 lstrcpy(ptr, name);
85 button->lpszName = ptr;
86 ptr += lstrlen(name) + 1;
88 lstrcpy(ptr, macro);
89 button->lpszMacro = ptr;
91 button->wParam = WH_FIRST_BUTTON;
92 for (b = &win->first_button; *b; b = &(*b)->next)
93 button->wParam = max(button->wParam, (*b)->wParam + 1);
94 *b = button;
96 WINHELP_LayoutMainWindow(win);
99 static void CALLBACK MACRO_DestroyButton(LPCSTR str)
101 WINE_FIXME("(\"%s\")\n", str);
104 void CALLBACK MACRO_DisableButton(LPCSTR id)
106 WINHELP_BUTTON** b;
108 WINE_TRACE("(\"%s\")\n", id);
110 b = MACRO_LookupButton(Globals.active_win, id);
111 if (!*b) {WINE_FIXME("Couldn't find button '%s'\n", id); return;}
113 EnableWindow((*b)->hWnd, FALSE);
116 static void CALLBACK MACRO_EnableButton(LPCSTR id)
118 WINHELP_BUTTON** b;
120 WINE_TRACE("(\"%s\")\n", id);
122 b = MACRO_LookupButton(Globals.active_win, id);
123 if (!*b) {WINE_FIXME("Couldn't find button '%s'\n", id); return;}
125 EnableWindow((*b)->hWnd, TRUE);
128 void CALLBACK MACRO_JumpContents(LPCSTR lpszPath, LPCSTR lpszWindow)
130 HLPFILE* hlpfile;
132 WINE_TRACE("(\"%s\", \"%s\")\n", lpszPath, lpszWindow);
133 if ((hlpfile = WINHELP_LookupHelpFile(lpszPath)))
134 WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, 0,
135 WINHELP_GetWindowInfo(hlpfile, lpszWindow),
136 SW_NORMAL);
140 void CALLBACK MACRO_About(void)
142 WINE_FIXME("()\n");
145 static void CALLBACK MACRO_AddAccelerator(LONG u1, LONG u2, LPCSTR str)
147 WINE_FIXME("(%u, %u, \"%s\")\n", u1, u2, str);
150 static void CALLBACK MACRO_ALink(LPCSTR str1, LONG u, LPCSTR str2)
152 WINE_FIXME("(\"%s\", %u, \"%s\")\n", str1, u, str2);
155 void CALLBACK MACRO_Annotate(void)
157 WINE_FIXME("()\n");
160 static void CALLBACK MACRO_AppendItem(LPCSTR str1, LPCSTR str2, LPCSTR str3, LPCSTR str4)
162 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\")\n", str1, str2, str3, str4);
165 static void CALLBACK MACRO_Back(void)
167 WINHELP_WINDOW* win = Globals.active_win;
169 WINE_TRACE("()\n");
171 if (win && win->back.index >= 2)
172 WINHELP_CreateHelpWindow(&win->back.set[--win->back.index - 1], SW_SHOW, FALSE);
175 static void CALLBACK MACRO_BackFlush(void)
177 WINHELP_WINDOW* win = Globals.active_win;
179 WINE_TRACE("()\n");
181 if (win) WINHELP_DeleteBackSet(win);
184 void CALLBACK MACRO_BookmarkDefine(void)
186 WINE_FIXME("()\n");
189 static void CALLBACK MACRO_BookmarkMore(void)
191 WINE_FIXME("()\n");
194 static void CALLBACK MACRO_BrowseButtons(void)
196 HLPFILE_PAGE* page = Globals.active_win->page;
197 ULONG relative;
199 WINE_TRACE("()\n");
201 MACRO_CreateButton("BTN_PREV", "&<<", "Prev()");
202 MACRO_CreateButton("BTN_NEXT", "&>>", "Next()");
204 if (!HLPFILE_PageByOffset(page->file, page->browse_bwd, &relative))
205 MACRO_DisableButton("BTN_PREV");
206 if (!HLPFILE_PageByOffset(page->file, page->browse_fwd, &relative))
207 MACRO_DisableButton("BTN_NEXT");
210 static void CALLBACK MACRO_ChangeButtonBinding(LPCSTR id, LPCSTR macro)
212 WINHELP_WINDOW* win = Globals.active_win;
213 WINHELP_BUTTON* button;
214 WINHELP_BUTTON** b;
215 LONG size;
216 LPSTR ptr;
218 WINE_TRACE("(\"%s\", \"%s\")\n", id, macro);
220 b = MACRO_LookupButton(win, id);
221 if (!*b) {WINE_FIXME("Couldn't find button '%s'\n", id); return;}
223 size = sizeof(WINHELP_BUTTON) + lstrlen(id) +
224 lstrlen((*b)->lpszName) + lstrlen(macro) + 3;
226 button = HeapAlloc(GetProcessHeap(), 0, size);
227 if (!button) return;
229 button->next = (*b)->next;
230 button->hWnd = (*b)->hWnd;
231 button->wParam = (*b)->wParam;
233 ptr = (char*)button + sizeof(WINHELP_BUTTON);
235 lstrcpy(ptr, id);
236 button->lpszID = ptr;
237 ptr += lstrlen(id) + 1;
239 lstrcpy(ptr, (*b)->lpszName);
240 button->lpszName = ptr;
241 ptr += lstrlen((*b)->lpszName) + 1;
243 lstrcpy(ptr, macro);
244 button->lpszMacro = ptr;
246 *b = button;
248 WINHELP_LayoutMainWindow(win);
251 static void CALLBACK MACRO_ChangeEnable(LPCSTR id, LPCSTR macro)
253 WINE_TRACE("(\"%s\", \"%s\")\n", id, macro);
255 MACRO_ChangeButtonBinding(id, macro);
256 MACRO_EnableButton(id);
259 static void CALLBACK MACRO_ChangeItemBinding(LPCSTR str1, LPCSTR str2)
261 WINE_FIXME("(\"%s\", \"%s\")\n", str1, str2);
264 static void CALLBACK MACRO_CheckItem(LPCSTR str)
266 WINE_FIXME("(\"%s\")\n", str);
269 static void CALLBACK MACRO_CloseSecondarys(void)
271 WINHELP_WINDOW *win;
273 WINE_TRACE("()\n");
274 for (win = Globals.win_list; win; win = win->next)
275 if (win->lpszName && lstrcmpi(win->lpszName, "main"))
276 DestroyWindow(win->hMainWnd);
279 static void CALLBACK MACRO_CloseWindow(LPCSTR lpszWindow)
281 WINHELP_WINDOW *win;
283 WINE_TRACE("(\"%s\")\n", lpszWindow);
285 if (!lpszWindow || !lpszWindow[0]) lpszWindow = "main";
287 for (win = Globals.win_list; win; win = win->next)
288 if (win->lpszName && !lstrcmpi(win->lpszName, lpszWindow))
289 DestroyWindow(win->hMainWnd);
292 static void CALLBACK MACRO_Compare(LPCSTR str)
294 WINE_FIXME("(\"%s\")\n", str);
297 static void CALLBACK MACRO_Contents(void)
299 WINE_TRACE("()\n");
301 if (Globals.active_win->page)
302 MACRO_JumpContents(Globals.active_win->page->file->lpszPath, NULL);
305 static void CALLBACK MACRO_ControlPanel(LPCSTR str1, LPCSTR str2, LONG u)
307 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1, str2, u);
310 void CALLBACK MACRO_CopyDialog(void)
312 WINE_FIXME("()\n");
315 static void CALLBACK MACRO_CopyTopic(void)
317 WINE_FIXME("()\n");
320 static void CALLBACK MACRO_DeleteItem(LPCSTR str)
322 WINE_FIXME("(\"%s\")\n", str);
325 static void CALLBACK MACRO_DeleteMark(LPCSTR str)
327 WINE_FIXME("(\"%s\")\n", str);
330 static void CALLBACK MACRO_DisableItem(LPCSTR str)
332 WINE_FIXME("(\"%s\")\n", str);
335 static void CALLBACK MACRO_EnableItem(LPCSTR str)
337 WINE_FIXME("(\"%s\")\n", str);
340 static void CALLBACK MACRO_EndMPrint(void)
342 WINE_FIXME("()\n");
345 static void CALLBACK MACRO_ExecFile(LPCSTR str1, LPCSTR str2, LONG u, LPCSTR str3)
347 WINE_FIXME("(\"%s\", \"%s\", %u, \"%s\")\n", str1, str2, u, str3);
350 static void CALLBACK MACRO_ExecProgram(LPCSTR str, LONG u)
352 WINE_FIXME("(\"%s\", %u)\n", str, u);
355 void CALLBACK MACRO_Exit(void)
357 WINE_TRACE("()\n");
359 while (Globals.win_list)
360 DestroyWindow(Globals.win_list->hMainWnd);
363 static void CALLBACK MACRO_ExtAbleItem(LPCSTR str, LONG u)
365 WINE_FIXME("(\"%s\", %u)\n", str, u);
368 static void CALLBACK MACRO_ExtInsertItem(LPCSTR str1, LPCSTR str2, LPCSTR str3, LPCSTR str4, LONG u1, LONG u2)
370 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u, %u)\n", str1, str2, str3, str4, u1, u2);
373 static void CALLBACK MACRO_ExtInsertMenu(LPCSTR str1, LPCSTR str2, LPCSTR str3, LONG u1, LONG u2)
375 WINE_FIXME("(\"%s\", \"%s\", \"%s\", %u, %u)\n", str1, str2, str3, u1, u2);
378 static BOOL CALLBACK MACRO_FileExist(LPCSTR str)
380 WINE_TRACE("(\"%s\")\n", str);
381 return GetFileAttributes(str) != INVALID_FILE_ATTRIBUTES;
384 void CALLBACK MACRO_FileOpen(void)
386 char szFile[MAX_PATH];
388 if (WINHELP_GetOpenFileName(szFile, MAX_PATH))
390 MACRO_JumpContents(szFile, "main");
394 static void CALLBACK MACRO_Find(void)
396 WINE_FIXME("()\n");
399 static void CALLBACK MACRO_Finder(void)
401 WINHELP_CreateIndexWindow(FALSE);
404 static void CALLBACK MACRO_FloatingMenu(void)
406 WINE_FIXME("()\n");
409 static void CALLBACK MACRO_Flush(void)
411 WINE_FIXME("()\n");
414 static void CALLBACK MACRO_FocusWindow(LPCSTR lpszWindow)
416 WINHELP_WINDOW *win;
418 WINE_TRACE("(\"%s\")\n", lpszWindow);
420 if (!lpszWindow || !lpszWindow[0]) lpszWindow = "main";
422 for (win = Globals.win_list; win; win = win->next)
423 if (win->lpszName && !lstrcmpi(win->lpszName, lpszWindow))
424 SetFocus(win->hMainWnd);
427 static void CALLBACK MACRO_Generate(LPCSTR str, LONG w, LONG l)
429 WINE_FIXME("(\"%s\", %x, %x)\n", str, w, l);
432 static void CALLBACK MACRO_GotoMark(LPCSTR str)
434 WINE_FIXME("(\"%s\")\n", str);
437 void CALLBACK MACRO_HelpOn(void)
439 LPCSTR file;
441 WINE_TRACE("()\n");
442 file = Globals.active_win->page->file->help_on_file;
443 if (!file)
444 file = (Globals.wVersion > 4) ? "winhlp32.hlp" : "winhelp.hlp";
446 MACRO_JumpContents(file, NULL);
449 void CALLBACK MACRO_HelpOnTop(void)
451 WINE_FIXME("()\n");
454 void CALLBACK MACRO_History(void)
456 WINE_TRACE("()\n");
458 if (Globals.active_win && !Globals.active_win->hHistoryWnd)
460 HWND hWnd = CreateWindow(HISTORY_WIN_CLASS_NAME, "History", WS_OVERLAPPEDWINDOW,
461 0, 0, 0, 0, 0, 0, Globals.hInstance, Globals.active_win);
462 ShowWindow(hWnd, SW_NORMAL);
466 static void CALLBACK MACRO_IfThen(BOOL b, LPCSTR t)
468 if (b) MACRO_ExecuteMacro(t);
471 static void CALLBACK MACRO_IfThenElse(BOOL b, LPCSTR t, LPCSTR f)
473 if (b) MACRO_ExecuteMacro(t); else MACRO_ExecuteMacro(f);
476 static BOOL CALLBACK MACRO_InitMPrint(void)
478 WINE_FIXME("()\n");
479 return FALSE;
482 static void CALLBACK MACRO_InsertItem(LPCSTR str1, LPCSTR str2, LPCSTR str3, LPCSTR str4, LONG u)
484 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u)\n", str1, str2, str3, str4, u);
487 static void CALLBACK MACRO_InsertMenu(LPCSTR str1, LPCSTR str2, LONG u)
489 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1, str2, u);
492 static BOOL CALLBACK MACRO_IsBook(void)
494 WINE_TRACE("()\n");
495 return Globals.isBook;
498 static BOOL CALLBACK MACRO_IsMark(LPCSTR str)
500 WINE_FIXME("(\"%s\")\n", str);
501 return FALSE;
504 static BOOL CALLBACK MACRO_IsNotMark(LPCSTR str)
506 WINE_FIXME("(\"%s\")\n", str);
507 return TRUE;
510 void CALLBACK MACRO_JumpContext(LPCSTR lpszPath, LPCSTR lpszWindow, LONG context)
512 HLPFILE* hlpfile;
514 WINE_TRACE("(\"%s\", \"%s\", %d)\n", lpszPath, lpszWindow, context);
515 hlpfile = WINHELP_LookupHelpFile(lpszPath);
516 /* Some madness: what user calls 'context', hlpfile calls 'map' */
517 WINHELP_OpenHelpWindow(HLPFILE_PageByMap, hlpfile, context,
518 WINHELP_GetWindowInfo(hlpfile, lpszWindow),
519 SW_NORMAL);
522 void CALLBACK MACRO_JumpHash(LPCSTR lpszPath, LPCSTR lpszWindow, LONG lHash)
524 HLPFILE* hlpfile;
526 WINE_TRACE("(\"%s\", \"%s\", %u)\n", lpszPath, lpszWindow, lHash);
527 hlpfile = WINHELP_LookupHelpFile(lpszPath);
528 WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, lHash,
529 WINHELP_GetWindowInfo(hlpfile, lpszWindow),
530 SW_NORMAL);
533 static void CALLBACK MACRO_JumpHelpOn(void)
535 WINE_FIXME("()\n");
538 static void CALLBACK MACRO_JumpID(LPCSTR lpszPathWindow, LPCSTR topic_id)
540 LPSTR ptr;
542 WINE_TRACE("(\"%s\", \"%s\")\n", lpszPathWindow, topic_id);
543 if ((ptr = strchr(lpszPathWindow, '>')) != NULL)
545 LPSTR tmp;
546 size_t sz = ptr - lpszPathWindow;
548 tmp = HeapAlloc(GetProcessHeap(), 0, sz + 1);
549 if (tmp)
551 memcpy(tmp, lpszPathWindow, sz);
552 tmp[sz] = '\0';
553 MACRO_JumpHash(tmp, ptr + 1, HLPFILE_Hash(topic_id));
554 HeapFree(GetProcessHeap(), 0, tmp);
557 else
558 MACRO_JumpHash(lpszPathWindow, NULL, HLPFILE_Hash(topic_id));
561 /* FIXME: this macros is wrong
562 * it should only contain 2 strings, path & window are coded as path>window
564 static void CALLBACK MACRO_JumpKeyword(LPCSTR lpszPath, LPCSTR lpszWindow, LPCSTR keyword)
566 WINE_FIXME("(\"%s\", \"%s\", \"%s\")\n", lpszPath, lpszWindow, keyword);
569 static void CALLBACK MACRO_KLink(LPCSTR str1, LONG u, LPCSTR str2, LPCSTR str3)
571 WINE_FIXME("(\"%s\", %u, \"%s\", \"%s\")\n", str1, u, str2, str3);
574 static void CALLBACK MACRO_Menu(void)
576 WINE_FIXME("()\n");
579 static void CALLBACK MACRO_MPrintHash(LONG u)
581 WINE_FIXME("(%u)\n", u);
584 static void CALLBACK MACRO_MPrintID(LPCSTR str)
586 WINE_FIXME("(\"%s\")\n", str);
589 static void CALLBACK MACRO_Next(void)
591 WINHELP_WNDPAGE wp;
593 WINE_TRACE("()\n");
594 wp.page = Globals.active_win->page;
595 wp.page = HLPFILE_PageByOffset(wp.page->file, wp.page->browse_fwd, &wp.relative);
596 if (wp.page)
598 wp.page->file->wRefCount++;
599 wp.wininfo = Globals.active_win->info;
600 WINHELP_CreateHelpWindow(&wp, SW_NORMAL, TRUE);
604 static void CALLBACK MACRO_NoShow(void)
606 WINE_FIXME("()\n");
609 void CALLBACK MACRO_PopupContext(LPCSTR str, LONG u)
611 WINE_FIXME("(\"%s\", %u)\n", str, u);
614 static void CALLBACK MACRO_PopupHash(LPCSTR str, LONG u)
616 WINE_FIXME("(\"%s\", %u)\n", str, u);
619 static void CALLBACK MACRO_PopupId(LPCSTR str1, LPCSTR str2)
621 WINE_FIXME("(\"%s\", \"%s\")\n", str1, str2);
624 static void CALLBACK MACRO_PositionWindow(LONG i1, LONG i2, LONG u1, LONG u2, LONG u3, LPCSTR str)
626 WINE_FIXME("(%i, %i, %u, %u, %u, \"%s\")\n", i1, i2, u1, u2, u3, str);
629 static void CALLBACK MACRO_Prev(void)
631 WINHELP_WNDPAGE wp;
633 WINE_TRACE("()\n");
634 wp.page = Globals.active_win->page;
635 wp.page = HLPFILE_PageByOffset(wp.page->file, wp.page->browse_bwd, &wp.relative);
636 if (wp.page)
638 wp.page->file->wRefCount++;
639 wp.wininfo = Globals.active_win->info;
640 WINHELP_CreateHelpWindow(&wp, SW_NORMAL, TRUE);
644 void CALLBACK MACRO_Print(void)
646 PRINTDLG printer;
648 WINE_TRACE("()\n");
650 printer.lStructSize = sizeof(printer);
651 printer.hwndOwner = Globals.active_win->hMainWnd;
652 printer.hInstance = Globals.hInstance;
653 printer.hDevMode = 0;
654 printer.hDevNames = 0;
655 printer.hDC = 0;
656 printer.Flags = 0;
657 printer.nFromPage = 0;
658 printer.nToPage = 0;
659 printer.nMinPage = 0;
660 printer.nMaxPage = 0;
661 printer.nCopies = 0;
662 printer.lCustData = 0;
663 printer.lpfnPrintHook = 0;
664 printer.lpfnSetupHook = 0;
665 printer.lpPrintTemplateName = 0;
666 printer.lpSetupTemplateName = 0;
667 printer.hPrintTemplate = 0;
668 printer.hSetupTemplate = 0;
670 if (PrintDlgA(&printer)) {
671 WINE_FIXME("Print()\n");
675 void CALLBACK MACRO_PrinterSetup(void)
677 WINE_FIXME("()\n");
680 static void CALLBACK MACRO_RegisterRoutine(LPCSTR dll_name, LPCSTR proc, LPCSTR args)
682 FARPROC fn = NULL;
683 int size;
684 WINHELP_DLL* dll;
686 WINE_TRACE("(\"%s\", \"%s\", \"%s\")\n", dll_name, proc, args);
688 /* FIXME: are the registered DLLs global or linked to the current file ???
689 * We assume globals (as we did for macros, but is this really the case ???)
691 for (dll = Globals.dlls; dll; dll = dll->next)
693 if (!strcmp(dll->name, dll_name)) break;
695 if (!dll)
697 HANDLE hLib = LoadLibrary(dll_name);
699 /* FIXME: the library will not be unloaded until exit of program
700 * We don't send the DW_TERM message
702 WINE_TRACE("Loading %s\n", dll_name);
703 /* FIXME: should look in the directory where current hlpfile
704 * is loaded from
706 if (hLib == NULL)
708 /* FIXME: internationalisation for error messages */
709 WINE_FIXME("Cannot find dll %s\n", dll_name);
711 else if ((dll = HeapAlloc(GetProcessHeap(), 0, sizeof(*dll))))
713 dll->hLib = hLib;
714 dll->name = strdup(dll_name); /* FIXME */
715 dll->next = Globals.dlls;
716 Globals.dlls = dll;
717 dll->handler = (WINHELP_LDLLHandler)GetProcAddress(dll->hLib, "LDLLHandler");
718 dll->class = dll->handler ? (dll->handler)(DW_WHATMSG, 0, 0) : DC_NOMSG;
719 WINE_TRACE("Got class %x for DLL %s\n", dll->class, dll_name);
720 if (dll->class & DC_INITTERM) dll->handler(DW_INIT, 0, 0);
721 if (dll->class & DC_CALLBACKS) dll->handler(DW_CALLBACKS, (DWORD)Callbacks, 0);
723 else WINE_WARN("OOM\n");
725 if (dll && !(fn = GetProcAddress(dll->hLib, proc)))
727 /* FIXME: internationalisation for error messages */
728 WINE_FIXME("Cannot find proc %s in dll %s\n", dll_name, proc);
731 size = ++MACRO_NumLoaded * sizeof(struct MacroDesc);
732 if (!MACRO_Loaded) MACRO_Loaded = HeapAlloc(GetProcessHeap(), 0, size);
733 else MACRO_Loaded = HeapReAlloc(GetProcessHeap(), 0, MACRO_Loaded, size);
734 MACRO_Loaded[MACRO_NumLoaded - 1].name = strdup(proc); /* FIXME */
735 MACRO_Loaded[MACRO_NumLoaded - 1].alias = NULL;
736 MACRO_Loaded[MACRO_NumLoaded - 1].isBool = 0;
737 MACRO_Loaded[MACRO_NumLoaded - 1].arguments = strdup(args); /* FIXME */
738 MACRO_Loaded[MACRO_NumLoaded - 1].fn = fn;
739 WINE_TRACE("Added %s(%s) at %p\n", proc, args, fn);
742 static void CALLBACK MACRO_RemoveAccelerator(LONG u1, LONG u2)
744 WINE_FIXME("(%u, %u)\n", u1, u2);
747 static void CALLBACK MACRO_ResetMenu(void)
749 WINE_FIXME("()\n");
752 static void CALLBACK MACRO_SaveMark(LPCSTR str)
754 WINE_FIXME("(\"%s\")\n", str);
757 static void CALLBACK MACRO_Search(void)
759 WINHELP_CreateIndexWindow(TRUE);
762 void CALLBACK MACRO_SetContents(LPCSTR str, LONG u)
764 WINE_FIXME("(\"%s\", %u)\n", str, u);
767 static void CALLBACK MACRO_SetHelpOnFile(LPCSTR str)
769 WINE_TRACE("(\"%s\")\n", str);
771 HeapFree(GetProcessHeap(), 0, Globals.active_win->page->file->help_on_file);
772 Globals.active_win->page->file->help_on_file = HeapAlloc(GetProcessHeap(), 0, strlen(str) + 1);
773 if (Globals.active_win->page->file->help_on_file)
774 strcpy(Globals.active_win->page->file->help_on_file, str);
777 static void CALLBACK MACRO_SetPopupColor(LONG r, LONG g, LONG b)
779 WINE_TRACE("(%x, %x, %x)\n", r, g, b);
780 Globals.active_win->page->file->has_popup_color = TRUE;
781 Globals.active_win->page->file->popup_color = RGB(r, g, b);
784 static void CALLBACK MACRO_ShellExecute(LPCSTR str1, LPCSTR str2, LONG u1, LONG u2, LPCSTR str3, LPCSTR str4)
786 WINE_FIXME("(\"%s\", \"%s\", %u, %u, \"%s\", \"%s\")\n", str1, str2, u1, u2, str3, str4);
789 static void CALLBACK MACRO_ShortCut(LPCSTR str1, LPCSTR str2, LONG w, LONG l, LPCSTR str)
791 WINE_FIXME("(\"%s\", \"%s\", %x, %x, \"%s\")\n", str1, str2, w, l, str);
794 static void CALLBACK MACRO_TCard(LONG u)
796 WINE_FIXME("(%u)\n", u);
799 static void CALLBACK MACRO_Test(LONG u)
801 WINE_FIXME("(%u)\n", u);
804 static BOOL CALLBACK MACRO_TestALink(LPCSTR str)
806 WINE_FIXME("(\"%s\")\n", str);
807 return FALSE;
810 static BOOL CALLBACK MACRO_TestKLink(LPCSTR str)
812 WINE_FIXME("(\"%s\")\n", str);
813 return FALSE;
816 static void CALLBACK MACRO_UncheckItem(LPCSTR str)
818 WINE_FIXME("(\"%s\")\n", str);
821 static void CALLBACK MACRO_UpdateWindow(LPCSTR str1, LPCSTR str2)
823 WINE_FIXME("(\"%s\", \"%s\")\n", str1, str2);
827 /**************************************************/
828 /* Macro table */
829 /**************************************************/
831 /* types:
832 * U: 32 bit unsigned int
833 * I: 32 bit signed int
834 * S: string
835 * v: unknown (32 bit entity)
838 static struct MacroDesc MACRO_Builtins[] = {
839 {"About", NULL, 0, "", (FARPROC)MACRO_About},
840 {"AddAccelerator", "AA", 0, "UUS", (FARPROC)MACRO_AddAccelerator},
841 {"ALink", "AL", 0, "SUS", (FARPROC)MACRO_ALink},
842 {"Annotate", NULL, 0, "", (FARPROC)MACRO_Annotate},
843 {"AppendItem", NULL, 0, "SSSS", (FARPROC)MACRO_AppendItem},
844 {"Back", NULL, 0, "", (FARPROC)MACRO_Back},
845 {"BackFlush", "BF", 0, "", (FARPROC)MACRO_BackFlush},
846 {"BookmarkDefine", NULL, 0, "", (FARPROC)MACRO_BookmarkDefine},
847 {"BookmarkMore", NULL, 0, "", (FARPROC)MACRO_BookmarkMore},
848 {"BrowseButtons", NULL, 0, "", (FARPROC)MACRO_BrowseButtons},
849 {"ChangeButtonBinding", "CBB",0, "SS", (FARPROC)MACRO_ChangeButtonBinding},
850 {"ChangeEnable", "CE", 0, "SS", (FARPROC)MACRO_ChangeEnable},
851 {"ChangeItemBinding", "CIB",0, "SS", (FARPROC)MACRO_ChangeItemBinding},
852 {"CheckItem", "CI", 0, "S", (FARPROC)MACRO_CheckItem},
853 {"CloseSecondarys", "CS", 0, "", (FARPROC)MACRO_CloseSecondarys},
854 {"CloseWindow", "CW", 0, "S", (FARPROC)MACRO_CloseWindow},
855 {"Compare", NULL, 0, "S", (FARPROC)MACRO_Compare},
856 {"Contents", NULL, 0, "", (FARPROC)MACRO_Contents},
857 {"ControlPanel", NULL, 0, "SSU", (FARPROC)MACRO_ControlPanel},
858 {"CopyDialog", NULL, 0, "", (FARPROC)MACRO_CopyDialog},
859 {"CopyTopic", "CT", 0, "", (FARPROC)MACRO_CopyTopic},
860 {"CreateButton", "CB", 0, "SSS", (FARPROC)MACRO_CreateButton},
861 {"DeleteItem", NULL, 0, "S", (FARPROC)MACRO_DeleteItem},
862 {"DeleteMark", NULL, 0, "S", (FARPROC)MACRO_DeleteMark},
863 {"DestroyButton", NULL, 0, "S", (FARPROC)MACRO_DestroyButton},
864 {"DisableButton", "DB", 0, "S", (FARPROC)MACRO_DisableButton},
865 {"DisableItem", "DI", 0, "S", (FARPROC)MACRO_DisableItem},
866 {"EnableButton", "EB", 0, "S", (FARPROC)MACRO_EnableButton},
867 {"EnableItem", "EI", 0, "S", (FARPROC)MACRO_EnableItem},
868 {"EndMPrint", NULL, 0, "", (FARPROC)MACRO_EndMPrint},
869 {"ExecFile", "EF", 0, "SSUS", (FARPROC)MACRO_ExecFile},
870 {"ExecProgram", "EP", 0, "SU", (FARPROC)MACRO_ExecProgram},
871 {"Exit", NULL, 0, "", (FARPROC)MACRO_Exit},
872 {"ExtAbleItem", NULL, 0, "SU", (FARPROC)MACRO_ExtAbleItem},
873 {"ExtInsertItem", NULL, 0, "SSSSUU", (FARPROC)MACRO_ExtInsertItem},
874 {"ExtInsertMenu", NULL, 0, "SSSUU", (FARPROC)MACRO_ExtInsertMenu},
875 {"FileExist", "FE", 1, "S", (FARPROC)MACRO_FileExist},
876 {"FileOpen", "FO", 0, "", (FARPROC)MACRO_FileOpen},
877 {"Find", NULL, 0, "", (FARPROC)MACRO_Find},
878 {"Finder", "FD", 0, "", (FARPROC)MACRO_Finder},
879 {"FloatingMenu", NULL, 0, "", (FARPROC)MACRO_FloatingMenu},
880 {"Flush", "FH", 0, "", (FARPROC)MACRO_Flush},
881 {"FocusWindow", NULL, 0, "S", (FARPROC)MACRO_FocusWindow},
882 {"Generate", NULL, 0, "SUU", (FARPROC)MACRO_Generate},
883 {"GotoMark", NULL, 0, "S", (FARPROC)MACRO_GotoMark},
884 {"HelpOn", NULL, 0, "", (FARPROC)MACRO_HelpOn},
885 {"HelpOnTop", NULL, 0, "", (FARPROC)MACRO_HelpOnTop},
886 {"History", NULL, 0, "", (FARPROC)MACRO_History},
887 {"InitMPrint", NULL, 1, "", (FARPROC)MACRO_InitMPrint},
888 {"InsertItem", NULL, 0, "SSSSU", (FARPROC)MACRO_InsertItem},
889 {"InsertMenu", NULL, 0, "SSU", (FARPROC)MACRO_InsertMenu},
890 {"IfThen", "IF", 0, "BS", (FARPROC)MACRO_IfThen},
891 {"IfThenElse", "IE", 0, "BSS", (FARPROC)MACRO_IfThenElse},
892 {"IsBook", NULL, 1, "", (FARPROC)MACRO_IsBook},
893 {"IsMark", NULL, 1, "S", (FARPROC)MACRO_IsMark},
894 {"IsNotMark", "NM", 1, "S", (FARPROC)MACRO_IsNotMark},
895 {"JumpContents", NULL, 0, "SS", (FARPROC)MACRO_JumpContents},
896 {"JumpContext", "JC", 0, "SSU", (FARPROC)MACRO_JumpContext},
897 {"JumpHash", "JH", 0, "SSU", (FARPROC)MACRO_JumpHash},
898 {"JumpHelpOn", NULL, 0, "", (FARPROC)MACRO_JumpHelpOn},
899 {"JumpID", "JI", 0, "SS", (FARPROC)MACRO_JumpID},
900 {"JumpKeyword", "JK", 0, "SSS", (FARPROC)MACRO_JumpKeyword},
901 {"KLink", "KL", 0, "SUSS", (FARPROC)MACRO_KLink},
902 {"Menu", "MU", 0, "", (FARPROC)MACRO_Menu},
903 {"MPrintHash", NULL, 0, "U", (FARPROC)MACRO_MPrintHash},
904 {"MPrintID", NULL, 0, "S", (FARPROC)MACRO_MPrintID},
905 {"Next", NULL, 0, "", (FARPROC)MACRO_Next},
906 {"NoShow", NULL, 0, "", (FARPROC)MACRO_NoShow},
907 {"PopupContext", "PC", 0, "SU", (FARPROC)MACRO_PopupContext},
908 {"PopupHash", NULL, 0, "SU", (FARPROC)MACRO_PopupHash},
909 {"PopupId", "PI", 0, "SS", (FARPROC)MACRO_PopupId},
910 {"PositionWindow", "PW", 0, "IIUUUS", (FARPROC)MACRO_PositionWindow},
911 {"Prev", NULL, 0, "", (FARPROC)MACRO_Prev},
912 {"Print", NULL, 0, "", (FARPROC)MACRO_Print},
913 {"PrinterSetup", NULL, 0, "", (FARPROC)MACRO_PrinterSetup},
914 {"RegisterRoutine", "RR", 0, "SSS", (FARPROC)MACRO_RegisterRoutine},
915 {"RemoveAccelerator", "RA", 0, "UU", (FARPROC)MACRO_RemoveAccelerator},
916 {"ResetMenu", NULL, 0, "", (FARPROC)MACRO_ResetMenu},
917 {"SaveMark", NULL, 0, "S", (FARPROC)MACRO_SaveMark},
918 {"Search", NULL, 0, "", (FARPROC)MACRO_Search},
919 {"SetContents", NULL, 0, "SU", (FARPROC)MACRO_SetContents},
920 {"SetHelpOnFile", NULL, 0, "S", (FARPROC)MACRO_SetHelpOnFile},
921 {"SetPopupColor", "SPC",0, "UUU", (FARPROC)MACRO_SetPopupColor},
922 {"ShellExecute", "SE", 0, "SSUUSS", (FARPROC)MACRO_ShellExecute},
923 {"ShortCut", "SH", 0, "SSUUS", (FARPROC)MACRO_ShortCut},
924 {"TCard", NULL, 0, "U", (FARPROC)MACRO_TCard},
925 {"Test", NULL, 0, "U", (FARPROC)MACRO_Test},
926 {"TestALink", NULL, 1, "S", (FARPROC)MACRO_TestALink},
927 {"TestKLink", NULL, 1, "S", (FARPROC)MACRO_TestKLink},
928 {"UncheckItem", "UI", 0, "S", (FARPROC)MACRO_UncheckItem},
929 {"UpdateWindow", "UW", 0, "SS", (FARPROC)MACRO_UpdateWindow},
930 {NULL, NULL, 0, NULL, NULL}
933 static int MACRO_DoLookUp(struct MacroDesc* start, const char* name, struct lexret* lr, unsigned len)
935 struct MacroDesc* md;
937 for (md = start; md->name && len != 0; md++, len--)
939 if (strcasecmp(md->name, name) == 0 || (md->alias != NULL && strcasecmp(md->alias, name) == 0))
941 lr->proto = md->arguments;
942 lr->function = md->fn;
943 return md->isBool ? BOOL_FUNCTION : VOID_FUNCTION;
946 return EMPTY;
949 int MACRO_Lookup(const char* name, struct lexret* lr)
951 int ret;
953 if ((ret = MACRO_DoLookUp(MACRO_Builtins, name, lr, -1)) != EMPTY)
954 return ret;
955 if (MACRO_Loaded && (ret = MACRO_DoLookUp(MACRO_Loaded, name, lr, MACRO_NumLoaded)) != EMPTY)
956 return ret;
958 lr->string = name;
959 return IDENTIFIER;