blob: ca0fc8c54d290808d671128cc44327fa21e64170 [file] [log] [blame]
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001/*
2 * Help Viewer
3 *
4 * Copyright 1996 Ulrich Schmid
Eric Pouech448fed22008-07-12 10:37:01 +02005 * Copyright 2002, 2008 Eric Pouech
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00006 *
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.
11 *
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.
16 *
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
Jonathan Ernst360a3f92006-05-18 14:49:52 +020019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000020 */
21
Mike McCormack002e1432006-01-18 14:23:11 +010022#define WIN32_LEAN_AND_MEAN
23
Eric Pouech81b7b912002-11-15 01:34:57 +000024#include <stdio.h>
25
Alexandre Julliard9ea19e51997-01-01 17:29:55 +000026#include "windows.h"
27#include "commdlg.h"
Eric Pouechd18d2512010-06-09 21:22:22 +020028#include "shellapi.h"
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000029#include "winhelp.h"
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000030
Eric Pouech75792872002-07-16 01:46:29 +000031#include "wine/debug.h"
32
33WINE_DEFAULT_DEBUG_CHANNEL(winhelp);
34
Eric Pouech81b7b912002-11-15 01:34:57 +000035/**************************************************/
36/* Macro table */
37/**************************************************/
38struct MacroDesc {
Mike McCormackae511352005-06-02 15:11:32 +000039 const char* name;
40 const char* alias;
Eric Pouech81b7b912002-11-15 01:34:57 +000041 BOOL isBool;
Mike McCormackae511352005-06-02 15:11:32 +000042 const char* arguments;
Alexandre Julliard15751f22009-10-07 13:40:00 +020043 void *fn;
Eric Pouech81b7b912002-11-15 01:34:57 +000044};
45
Eric Pouech81b7b912002-11-15 01:34:57 +000046static struct MacroDesc*MACRO_Loaded /* = NULL */;
47static unsigned MACRO_NumLoaded /* = 0 */;
48
Eric Pouech1cf1b5e2002-10-21 18:20:23 +000049/******* helper functions *******/
Eric Pouech81b7b912002-11-15 01:34:57 +000050
Francois Gougete7f8aa72009-05-13 10:28:45 +020051static char* StrDup(const char* str)
52{
53 char* dst;
54 dst=HeapAlloc(GetProcessHeap(),0,strlen(str)+1);
55 strcpy(dst, str);
56 return dst;
57}
58
Eric Pouechdff8de62004-12-13 21:06:46 +000059static WINHELP_BUTTON** MACRO_LookupButton(WINHELP_WINDOW* win, LPCSTR name)
Eric Pouech1cf1b5e2002-10-21 18:20:23 +000060{
61 WINHELP_BUTTON** b;
62
63 for (b = &win->first_button; *b; b = &(*b)->next)
64 if (!lstrcmpi(name, (*b)->lpszID)) break;
65 return b;
66}
67
Eric Pouechd18d2512010-06-09 21:22:22 +020068/******* some forward declarations *******/
69static void CALLBACK MACRO_JumpID(LPCSTR lpszPathWindow, LPCSTR topic_id);
70
Eric Pouech1cf1b5e2002-10-21 18:20:23 +000071/******* real macro implementation *******/
72
Francois Gougetef35bfd2009-01-08 14:16:40 +010073void CALLBACK MACRO_CreateButton(LPCSTR id, LPCSTR name, LPCSTR macro)
74{
Eric Pouech29f865c2009-05-30 14:26:39 +020075 WINHELP_WINDOW *win = MACRO_CurrentWindow();
Francois Gougetef35bfd2009-01-08 14:16:40 +010076 WINHELP_BUTTON *button, **b;
77 LONG size;
78 LPSTR ptr;
79
80 WINE_TRACE("(\"%s\", \"%s\", %s)\n", id, name, macro);
81
82 size = sizeof(WINHELP_BUTTON) + lstrlen(id) + lstrlen(name) + lstrlen(macro) + 3;
83
84 button = HeapAlloc(GetProcessHeap(), 0, size);
85 if (!button) return;
86
87 button->next = 0;
88 button->hWnd = 0;
89
90 ptr = (char*)button + sizeof(WINHELP_BUTTON);
91
92 lstrcpy(ptr, id);
93 button->lpszID = ptr;
94 ptr += lstrlen(id) + 1;
95
96 lstrcpy(ptr, name);
97 button->lpszName = ptr;
98 ptr += lstrlen(name) + 1;
99
100 lstrcpy(ptr, macro);
101 button->lpszMacro = ptr;
102
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);
106 *b = button;
107
108 WINHELP_LayoutMainWindow(win);
109}
110
Francois Gouget49679842009-01-08 14:16:50 +0100111static void CALLBACK MACRO_DestroyButton(LPCSTR str)
Francois Gougetef35bfd2009-01-08 14:16:40 +0100112{
113 WINE_FIXME("(\"%s\")\n", str);
114}
115
116void CALLBACK MACRO_DisableButton(LPCSTR id)
117{
118 WINHELP_BUTTON** b;
119
120 WINE_TRACE("(\"%s\")\n", id);
121
Eric Pouech29f865c2009-05-30 14:26:39 +0200122 b = MACRO_LookupButton(MACRO_CurrentWindow(), id);
Francois Gougetef35bfd2009-01-08 14:16:40 +0100123 if (!*b) {WINE_FIXME("Couldn't find button '%s'\n", id); return;}
124
125 EnableWindow((*b)->hWnd, FALSE);
126}
127
Francois Gouget49679842009-01-08 14:16:50 +0100128static void CALLBACK MACRO_EnableButton(LPCSTR id)
Francois Gougetef35bfd2009-01-08 14:16:40 +0100129{
130 WINHELP_BUTTON** b;
131
132 WINE_TRACE("(\"%s\")\n", id);
133
Eric Pouech29f865c2009-05-30 14:26:39 +0200134 b = MACRO_LookupButton(MACRO_CurrentWindow(), id);
Francois Gougetef35bfd2009-01-08 14:16:40 +0100135 if (!*b) {WINE_FIXME("Couldn't find button '%s'\n", id); return;}
136
137 EnableWindow((*b)->hWnd, TRUE);
138}
139
140void CALLBACK MACRO_JumpContents(LPCSTR lpszPath, LPCSTR lpszWindow)
141{
142 HLPFILE* hlpfile;
143
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),
148 SW_NORMAL);
149}
150
151
Eric Pouechdff8de62004-12-13 21:06:46 +0000152void CALLBACK MACRO_About(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000153{
Eric Pouech81b7b912002-11-15 01:34:57 +0000154 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000155}
156
Francois Gouget49679842009-01-08 14:16:50 +0100157static void CALLBACK MACRO_AddAccelerator(LONG u1, LONG u2, LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000158{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200159 WINE_FIXME("(%u, %u, \"%s\")\n", u1, u2, str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000160}
161
Francois Gouget49679842009-01-08 14:16:50 +0100162static void CALLBACK MACRO_ALink(LPCSTR str1, LONG u, LPCSTR str2)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000163{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200164 WINE_FIXME("(\"%s\", %u, \"%s\")\n", str1, u, str2);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000165}
166
Eric Pouechdff8de62004-12-13 21:06:46 +0000167void CALLBACK MACRO_Annotate(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000168{
Eric Pouech81b7b912002-11-15 01:34:57 +0000169 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000170}
171
Francois Gouget49679842009-01-08 14:16:50 +0100172static void CALLBACK MACRO_AppendItem(LPCSTR str1, LPCSTR str2, LPCSTR str3, LPCSTR str4)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000173{
Eric Pouech81b7b912002-11-15 01:34:57 +0000174 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\")\n", str1, str2, str3, str4);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000175}
176
Francois Gouget49679842009-01-08 14:16:50 +0100177static void CALLBACK MACRO_Back(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000178{
Eric Pouech29f865c2009-05-30 14:26:39 +0200179 WINHELP_WINDOW* win = MACRO_CurrentWindow();
Eric Pouech2b855de2002-11-20 19:46:18 +0000180
181 WINE_TRACE("()\n");
182
Eric Pouech6d40dbe2008-04-22 21:59:38 +0200183 if (win && win->back.index >= 2)
Eric Pouech4a89d292008-04-22 22:00:20 +0200184 WINHELP_CreateHelpWindow(&win->back.set[--win->back.index - 1], SW_SHOW, FALSE);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000185}
186
Francois Gouget49679842009-01-08 14:16:50 +0100187static void CALLBACK MACRO_BackFlush(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000188{
Eric Pouech29f865c2009-05-30 14:26:39 +0200189 WINHELP_WINDOW* win = MACRO_CurrentWindow();
Eric Pouech2b855de2002-11-20 19:46:18 +0000190
191 WINE_TRACE("()\n");
192
Eric Pouechccd75352008-04-22 21:59:57 +0200193 if (win) WINHELP_DeleteBackSet(win);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000194}
195
Eric Pouechdff8de62004-12-13 21:06:46 +0000196void CALLBACK MACRO_BookmarkDefine(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000197{
Eric Pouech81b7b912002-11-15 01:34:57 +0000198 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000199}
200
Francois Gouget49679842009-01-08 14:16:50 +0100201static void CALLBACK MACRO_BookmarkMore(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000202{
Eric Pouech81b7b912002-11-15 01:34:57 +0000203 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000204}
205
Francois Gouget49679842009-01-08 14:16:50 +0100206static void CALLBACK MACRO_BrowseButtons(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000207{
Eric Pouech29f865c2009-05-30 14:26:39 +0200208 HLPFILE_PAGE* page = MACRO_CurrentWindow()->page;
Eric Pouecha4480362008-04-22 22:00:56 +0200209 ULONG relative;
Eric Pouech3ae5ad82008-04-22 22:00:38 +0200210
Eric Pouech81b7b912002-11-15 01:34:57 +0000211 WINE_TRACE("()\n");
212
Eric Pouech75792872002-07-16 01:46:29 +0000213 MACRO_CreateButton("BTN_PREV", "&<<", "Prev()");
214 MACRO_CreateButton("BTN_NEXT", "&>>", "Next()");
Eric Pouech3ae5ad82008-04-22 22:00:38 +0200215
Eric Pouecha4480362008-04-22 22:00:56 +0200216 if (!HLPFILE_PageByOffset(page->file, page->browse_bwd, &relative))
Eric Pouech3ae5ad82008-04-22 22:00:38 +0200217 MACRO_DisableButton("BTN_PREV");
Eric Pouecha4480362008-04-22 22:00:56 +0200218 if (!HLPFILE_PageByOffset(page->file, page->browse_fwd, &relative))
Eric Pouech3ae5ad82008-04-22 22:00:38 +0200219 MACRO_DisableButton("BTN_NEXT");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000220}
221
Francois Gouget49679842009-01-08 14:16:50 +0100222static void CALLBACK MACRO_ChangeButtonBinding(LPCSTR id, LPCSTR macro)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000223{
Eric Pouech29f865c2009-05-30 14:26:39 +0200224 WINHELP_WINDOW* win = MACRO_CurrentWindow();
Eric Pouech1cf1b5e2002-10-21 18:20:23 +0000225 WINHELP_BUTTON* button;
226 WINHELP_BUTTON** b;
227 LONG size;
228 LPSTR ptr;
229
Eric Pouech81b7b912002-11-15 01:34:57 +0000230 WINE_TRACE("(\"%s\", \"%s\")\n", id, macro);
231
Eric Pouech1cf1b5e2002-10-21 18:20:23 +0000232 b = MACRO_LookupButton(win, id);
233 if (!*b) {WINE_FIXME("Couldn't find button '%s'\n", id); return;}
234
Jon Griffithscea5e752004-09-27 20:07:03 +0000235 size = sizeof(WINHELP_BUTTON) + lstrlen(id) +
Eric Pouech1cf1b5e2002-10-21 18:20:23 +0000236 lstrlen((*b)->lpszName) + lstrlen(macro) + 3;
237
238 button = HeapAlloc(GetProcessHeap(), 0, size);
239 if (!button) return;
240
241 button->next = (*b)->next;
242 button->hWnd = (*b)->hWnd;
243 button->wParam = (*b)->wParam;
244
245 ptr = (char*)button + sizeof(WINHELP_BUTTON);
246
Eric Pouechdff8de62004-12-13 21:06:46 +0000247 lstrcpy(ptr, id);
Eric Pouech1cf1b5e2002-10-21 18:20:23 +0000248 button->lpszID = ptr;
249 ptr += lstrlen(id) + 1;
250
Eric Pouechdff8de62004-12-13 21:06:46 +0000251 lstrcpy(ptr, (*b)->lpszName);
Eric Pouech1cf1b5e2002-10-21 18:20:23 +0000252 button->lpszName = ptr;
253 ptr += lstrlen((*b)->lpszName) + 1;
254
Eric Pouechdff8de62004-12-13 21:06:46 +0000255 lstrcpy(ptr, macro);
Eric Pouech1cf1b5e2002-10-21 18:20:23 +0000256 button->lpszMacro = ptr;
257
258 *b = button;
259
Eric Pouechd58ab512008-04-18 21:33:51 +0200260 WINHELP_LayoutMainWindow(win);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000261}
262
Francois Gouget49679842009-01-08 14:16:50 +0100263static void CALLBACK MACRO_ChangeEnable(LPCSTR id, LPCSTR macro)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000264{
Eric Pouech81b7b912002-11-15 01:34:57 +0000265 WINE_TRACE("(\"%s\", \"%s\")\n", id, macro);
266
Eric Pouech1cf1b5e2002-10-21 18:20:23 +0000267 MACRO_ChangeButtonBinding(id, macro);
268 MACRO_EnableButton(id);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000269}
270
Francois Gouget49679842009-01-08 14:16:50 +0100271static void CALLBACK MACRO_ChangeItemBinding(LPCSTR str1, LPCSTR str2)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000272{
Eric Pouech81b7b912002-11-15 01:34:57 +0000273 WINE_FIXME("(\"%s\", \"%s\")\n", str1, str2);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000274}
275
Francois Gouget49679842009-01-08 14:16:50 +0100276static void CALLBACK MACRO_CheckItem(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000277{
Eric Pouech81b7b912002-11-15 01:34:57 +0000278 WINE_FIXME("(\"%s\")\n", str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000279}
280
Francois Gouget49679842009-01-08 14:16:50 +0100281static void CALLBACK MACRO_CloseSecondarys(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000282{
Eric Pouech75792872002-07-16 01:46:29 +0000283 WINHELP_WINDOW *win;
Eric Pouech3b07c852010-06-12 21:55:05 +0200284 WINHELP_WINDOW *next;
Eric Pouech81b7b912002-11-15 01:34:57 +0000285
286 WINE_TRACE("()\n");
Eric Pouech3b07c852010-06-12 21:55:05 +0200287 for (win = Globals.win_list; win; win = next)
288 {
289 next = win->next;
Eric Poueche3beef02009-05-30 14:26:58 +0200290 if (lstrcmpi(win->info->name, "main"))
Eric Pouech82ffc042009-05-30 14:27:04 +0200291 WINHELP_ReleaseWindow(win);
Eric Pouech3b07c852010-06-12 21:55:05 +0200292 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000293}
294
Francois Gouget49679842009-01-08 14:16:50 +0100295static void CALLBACK MACRO_CloseWindow(LPCSTR lpszWindow)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000296{
Eric Pouech75792872002-07-16 01:46:29 +0000297 WINHELP_WINDOW *win;
Eric Pouech3b07c852010-06-12 21:55:05 +0200298 WINHELP_WINDOW *next;
Eric Pouech81b7b912002-11-15 01:34:57 +0000299
300 WINE_TRACE("(\"%s\")\n", lpszWindow);
301
Eric Pouech75792872002-07-16 01:46:29 +0000302 if (!lpszWindow || !lpszWindow[0]) lpszWindow = "main";
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000303
Eric Pouech3b07c852010-06-12 21:55:05 +0200304 for (win = Globals.win_list; win; win = next)
305 {
306 next = win->next;
Eric Poueche3beef02009-05-30 14:26:58 +0200307 if (!lstrcmpi(win->info->name, lpszWindow))
Eric Pouech82ffc042009-05-30 14:27:04 +0200308 WINHELP_ReleaseWindow(win);
Eric Pouech3b07c852010-06-12 21:55:05 +0200309 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000310}
311
Francois Gouget49679842009-01-08 14:16:50 +0100312static void CALLBACK MACRO_Compare(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000313{
Eric Pouech81b7b912002-11-15 01:34:57 +0000314 WINE_FIXME("(\"%s\")\n", str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000315}
316
Francois Gouget49679842009-01-08 14:16:50 +0100317static void CALLBACK MACRO_Contents(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000318{
Eric Pouech29f865c2009-05-30 14:26:39 +0200319 HLPFILE_PAGE* page = MACRO_CurrentWindow()->page;
320
Eric Pouech81b7b912002-11-15 01:34:57 +0000321 WINE_TRACE("()\n");
322
Eric Pouech29f865c2009-05-30 14:26:39 +0200323 if (page)
324 MACRO_JumpContents(page->file->lpszPath, NULL);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000325}
326
Francois Gouget49679842009-01-08 14:16:50 +0100327static void CALLBACK MACRO_ControlPanel(LPCSTR str1, LPCSTR str2, LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000328{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200329 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1, str2, u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000330}
331
Eric Pouechdff8de62004-12-13 21:06:46 +0000332void CALLBACK MACRO_CopyDialog(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000333{
Eric Pouech81b7b912002-11-15 01:34:57 +0000334 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000335}
336
Francois Gouget49679842009-01-08 14:16:50 +0100337static void CALLBACK MACRO_CopyTopic(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000338{
Eric Pouech81b7b912002-11-15 01:34:57 +0000339 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000340}
341
Francois Gouget49679842009-01-08 14:16:50 +0100342static void CALLBACK MACRO_DeleteItem(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000343{
Eric Pouech81b7b912002-11-15 01:34:57 +0000344 WINE_FIXME("(\"%s\")\n", str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000345}
346
Francois Gouget49679842009-01-08 14:16:50 +0100347static void CALLBACK MACRO_DeleteMark(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000348{
Eric Pouech81b7b912002-11-15 01:34:57 +0000349 WINE_FIXME("(\"%s\")\n", str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000350}
351
Francois Gouget49679842009-01-08 14:16:50 +0100352static void CALLBACK MACRO_DisableItem(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000353{
Eric Pouech81b7b912002-11-15 01:34:57 +0000354 WINE_FIXME("(\"%s\")\n", str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000355}
356
Francois Gouget49679842009-01-08 14:16:50 +0100357static void CALLBACK MACRO_EnableItem(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000358{
Eric Pouech81b7b912002-11-15 01:34:57 +0000359 WINE_FIXME("(\"%s\")\n", str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000360}
361
Francois Gouget49679842009-01-08 14:16:50 +0100362static void CALLBACK MACRO_EndMPrint(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000363{
Eric Pouech81b7b912002-11-15 01:34:57 +0000364 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000365}
366
Eric Pouechd18d2512010-06-09 21:22:22 +0200367static void CALLBACK MACRO_ExecFile(LPCSTR pgm, LPCSTR args, LONG cmd_show, LPCSTR topic)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000368{
Eric Pouechd18d2512010-06-09 21:22:22 +0200369 HINSTANCE ret;
370
371 WINE_TRACE("(%s, %s, %u, %s)\n",
372 wine_dbgstr_a(pgm), wine_dbgstr_a(args), cmd_show, wine_dbgstr_a(topic));
373
374 ret = ShellExecuteA(Globals.active_win ? Globals.active_win->hMainWnd : NULL, "open",
375 pgm, args, ".", cmd_show);
376 if ((DWORD_PTR)ret < 32)
377 {
378 WINE_WARN("Failed with %p\n", ret);
379 if (topic) MACRO_JumpID(NULL, topic);
380 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000381}
382
Francois Gouget49679842009-01-08 14:16:50 +0100383static void CALLBACK MACRO_ExecProgram(LPCSTR str, LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000384{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200385 WINE_FIXME("(\"%s\", %u)\n", str, u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000386}
387
Eric Pouechdff8de62004-12-13 21:06:46 +0000388void CALLBACK MACRO_Exit(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000389{
Eric Pouech81b7b912002-11-15 01:34:57 +0000390 WINE_TRACE("()\n");
391
Eric Pouech75792872002-07-16 01:46:29 +0000392 while (Globals.win_list)
Eric Pouech82ffc042009-05-30 14:27:04 +0200393 WINHELP_ReleaseWindow(Globals.win_list);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000394}
395
Francois Gouget49679842009-01-08 14:16:50 +0100396static void CALLBACK MACRO_ExtAbleItem(LPCSTR str, LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000397{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200398 WINE_FIXME("(\"%s\", %u)\n", str, u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000399}
400
Francois Gouget49679842009-01-08 14:16:50 +0100401static void CALLBACK MACRO_ExtInsertItem(LPCSTR str1, LPCSTR str2, LPCSTR str3, LPCSTR str4, LONG u1, LONG u2)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000402{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200403 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u, %u)\n", str1, str2, str3, str4, u1, u2);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000404}
405
Francois Gouget49679842009-01-08 14:16:50 +0100406static void CALLBACK MACRO_ExtInsertMenu(LPCSTR str1, LPCSTR str2, LPCSTR str3, LONG u1, LONG u2)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000407{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200408 WINE_FIXME("(\"%s\", \"%s\", \"%s\", %u, %u)\n", str1, str2, str3, u1, u2);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000409}
410
Francois Gouget49679842009-01-08 14:16:50 +0100411static BOOL CALLBACK MACRO_FileExist(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000412{
Eric Pouech81b7b912002-11-15 01:34:57 +0000413 WINE_TRACE("(\"%s\")\n", str);
Rolf Kalbermatter76f13de2003-10-16 19:12:49 +0000414 return GetFileAttributes(str) != INVALID_FILE_ATTRIBUTES;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000415}
416
Eric Pouechdff8de62004-12-13 21:06:46 +0000417void CALLBACK MACRO_FileOpen(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000418{
Kirill K. Smirnov4f2819f2006-11-06 15:07:01 +0300419 char szFile[MAX_PATH];
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000420
Kirill K. Smirnov4f2819f2006-11-06 15:07:01 +0300421 if (WINHELP_GetOpenFileName(szFile, MAX_PATH))
Eric Pouech7d75cfe2002-11-18 19:48:11 +0000422 {
Eric Pouech3f1b62f2008-04-22 22:01:08 +0200423 MACRO_JumpContents(szFile, "main");
Eric Pouech7d75cfe2002-11-18 19:48:11 +0000424 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000425}
426
Francois Gouget49679842009-01-08 14:16:50 +0100427static void CALLBACK MACRO_Find(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000428{
Eric Pouech81b7b912002-11-15 01:34:57 +0000429 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000430}
431
Francois Gouget49679842009-01-08 14:16:50 +0100432static void CALLBACK MACRO_Finder(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000433{
Eric Pouech841720e2008-07-05 21:33:19 +0200434 WINHELP_CreateIndexWindow(FALSE);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000435}
436
Francois Gouget49679842009-01-08 14:16:50 +0100437static void CALLBACK MACRO_FloatingMenu(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000438{
Eric Pouech81b7b912002-11-15 01:34:57 +0000439 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000440}
441
Francois Gouget49679842009-01-08 14:16:50 +0100442static void CALLBACK MACRO_Flush(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000443{
Eric Pouech81b7b912002-11-15 01:34:57 +0000444 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000445}
446
Francois Gouget49679842009-01-08 14:16:50 +0100447static void CALLBACK MACRO_FocusWindow(LPCSTR lpszWindow)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000448{
Eric Pouech81b7b912002-11-15 01:34:57 +0000449 WINHELP_WINDOW *win;
450
451 WINE_TRACE("(\"%s\")\n", lpszWindow);
452
453 if (!lpszWindow || !lpszWindow[0]) lpszWindow = "main";
454
455 for (win = Globals.win_list; win; win = win->next)
Eric Poueche3beef02009-05-30 14:26:58 +0200456 if (!lstrcmpi(win->info->name, lpszWindow))
Eric Pouech81b7b912002-11-15 01:34:57 +0000457 SetFocus(win->hMainWnd);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000458}
459
Francois Gouget49679842009-01-08 14:16:50 +0100460static void CALLBACK MACRO_Generate(LPCSTR str, LONG w, LONG l)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000461{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200462 WINE_FIXME("(\"%s\", %x, %x)\n", str, w, l);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000463}
464
Francois Gouget49679842009-01-08 14:16:50 +0100465static void CALLBACK MACRO_GotoMark(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000466{
Eric Pouech81b7b912002-11-15 01:34:57 +0000467 WINE_FIXME("(\"%s\")\n", str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000468}
469
Eric Pouechdff8de62004-12-13 21:06:46 +0000470void CALLBACK MACRO_HelpOn(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000471{
Owen Rudgeb4f2c552009-07-22 00:48:28 -0300472 WINHELP_WINDOW *win = MACRO_CurrentWindow();
473 LPCSTR file = NULL;
Eric Pouech448fed22008-07-12 10:37:01 +0200474
Eric Pouech81b7b912002-11-15 01:34:57 +0000475 WINE_TRACE("()\n");
Owen Rudgeb4f2c552009-07-22 00:48:28 -0300476 if (win && win->page && win->page->file)
477 file = win->page->file->help_on_file;
478
Eric Pouech448fed22008-07-12 10:37:01 +0200479 if (!file)
480 file = (Globals.wVersion > 4) ? "winhlp32.hlp" : "winhelp.hlp";
481
482 MACRO_JumpContents(file, NULL);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000483}
484
Eric Pouechdff8de62004-12-13 21:06:46 +0000485void CALLBACK MACRO_HelpOnTop(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000486{
Eric Pouech81b7b912002-11-15 01:34:57 +0000487 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000488}
489
Eric Pouechdff8de62004-12-13 21:06:46 +0000490void CALLBACK MACRO_History(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000491{
Eric Pouech2b855de2002-11-20 19:46:18 +0000492 WINE_TRACE("()\n");
493
494 if (Globals.active_win && !Globals.active_win->hHistoryWnd)
495 {
496 HWND hWnd = CreateWindow(HISTORY_WIN_CLASS_NAME, "History", WS_OVERLAPPEDWINDOW,
497 0, 0, 0, 0, 0, 0, Globals.hInstance, Globals.active_win);
498 ShowWindow(hWnd, SW_NORMAL);
499 }
Eric Pouech81b7b912002-11-15 01:34:57 +0000500}
501
Francois Gouget49679842009-01-08 14:16:50 +0100502static void CALLBACK MACRO_IfThen(BOOL b, LPCSTR t)
Eric Pouech81b7b912002-11-15 01:34:57 +0000503{
Eric Pouech042bbf92009-05-30 14:26:33 +0200504 if (b) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t);
Eric Pouech81b7b912002-11-15 01:34:57 +0000505}
506
Francois Gouget49679842009-01-08 14:16:50 +0100507static void CALLBACK MACRO_IfThenElse(BOOL b, LPCSTR t, LPCSTR f)
Eric Pouech81b7b912002-11-15 01:34:57 +0000508{
Eric Pouech042bbf92009-05-30 14:26:33 +0200509 if (b) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t);
510 else MACRO_ExecuteMacro(MACRO_CurrentWindow(), f);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000511}
512
Francois Gouget49679842009-01-08 14:16:50 +0100513static BOOL CALLBACK MACRO_InitMPrint(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000514{
Eric Pouech81b7b912002-11-15 01:34:57 +0000515 WINE_FIXME("()\n");
Eric Pouech75792872002-07-16 01:46:29 +0000516 return FALSE;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000517}
518
Francois Gouget49679842009-01-08 14:16:50 +0100519static void CALLBACK MACRO_InsertItem(LPCSTR str1, LPCSTR str2, LPCSTR str3, LPCSTR str4, LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000520{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200521 WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u)\n", str1, str2, str3, str4, u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000522}
523
Francois Gouget49679842009-01-08 14:16:50 +0100524static void CALLBACK MACRO_InsertMenu(LPCSTR str1, LPCSTR str2, LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000525{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200526 WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1, str2, u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000527}
528
Francois Gouget49679842009-01-08 14:16:50 +0100529static BOOL CALLBACK MACRO_IsBook(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000530{
Eric Pouech81b7b912002-11-15 01:34:57 +0000531 WINE_TRACE("()\n");
532 return Globals.isBook;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000533}
534
Francois Gouget49679842009-01-08 14:16:50 +0100535static BOOL CALLBACK MACRO_IsMark(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000536{
Eric Pouech81b7b912002-11-15 01:34:57 +0000537 WINE_FIXME("(\"%s\")\n", str);
Eric Pouech75792872002-07-16 01:46:29 +0000538 return FALSE;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000539}
540
Francois Gouget49679842009-01-08 14:16:50 +0100541static BOOL CALLBACK MACRO_IsNotMark(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000542{
Eric Pouech81b7b912002-11-15 01:34:57 +0000543 WINE_FIXME("(\"%s\")\n", str);
Eric Pouech75792872002-07-16 01:46:29 +0000544 return TRUE;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000545}
546
Eric Pouechdff8de62004-12-13 21:06:46 +0000547void CALLBACK MACRO_JumpContext(LPCSTR lpszPath, LPCSTR lpszWindow, LONG context)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000548{
Kirill K Smirnov8e0bc112006-10-26 13:21:44 +0400549 HLPFILE* hlpfile;
550
Francois Gougetdc6731e2006-11-02 19:58:32 +0100551 WINE_TRACE("(\"%s\", \"%s\", %d)\n", lpszPath, lpszWindow, context);
Kirill K Smirnov8e0bc112006-10-26 13:21:44 +0400552 hlpfile = WINHELP_LookupHelpFile(lpszPath);
553 /* Some madness: what user calls 'context', hlpfile calls 'map' */
Eric Pouech3f1b62f2008-04-22 22:01:08 +0200554 WINHELP_OpenHelpWindow(HLPFILE_PageByMap, hlpfile, context,
555 WINHELP_GetWindowInfo(hlpfile, lpszWindow),
556 SW_NORMAL);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000557}
558
Eric Pouechdff8de62004-12-13 21:06:46 +0000559void CALLBACK MACRO_JumpHash(LPCSTR lpszPath, LPCSTR lpszWindow, LONG lHash)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000560{
Eric Pouech7d75cfe2002-11-18 19:48:11 +0000561 HLPFILE* hlpfile;
562
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200563 WINE_TRACE("(\"%s\", \"%s\", %u)\n", lpszPath, lpszWindow, lHash);
Eric Pouechaba7b3d2009-05-30 14:26:46 +0200564 if (!lpszPath || !lpszPath[0])
565 hlpfile = MACRO_CurrentWindow()->page->file;
566 else
567 hlpfile = WINHELP_LookupHelpFile(lpszPath);
Eric Pouech3f1b62f2008-04-22 22:01:08 +0200568 WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, lHash,
569 WINHELP_GetWindowInfo(hlpfile, lpszWindow),
570 SW_NORMAL);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000571}
572
Francois Gouget49679842009-01-08 14:16:50 +0100573static void CALLBACK MACRO_JumpHelpOn(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000574{
Eric Pouech81b7b912002-11-15 01:34:57 +0000575 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000576}
577
Francois Gouget49679842009-01-08 14:16:50 +0100578static void CALLBACK MACRO_JumpID(LPCSTR lpszPathWindow, LPCSTR topic_id)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000579{
Eric Pouech7ae1bb22008-04-22 22:00:32 +0200580 LPSTR ptr;
581
582 WINE_TRACE("(\"%s\", \"%s\")\n", lpszPathWindow, topic_id);
583 if ((ptr = strchr(lpszPathWindow, '>')) != NULL)
584 {
585 LPSTR tmp;
Eric Pouech2d20a1a2010-06-12 21:54:59 +0200586 size_t sz;
Eric Pouech7ae1bb22008-04-22 22:00:32 +0200587
Eric Pouech2d20a1a2010-06-12 21:54:59 +0200588 tmp = HeapAlloc(GetProcessHeap(), 0, strlen(lpszPathWindow) + 1);
Eric Pouech7ae1bb22008-04-22 22:00:32 +0200589 if (tmp)
590 {
Eric Pouech2d20a1a2010-06-12 21:54:59 +0200591 strcpy(tmp, lpszPathWindow);
592 tmp[ptr - lpszPathWindow] = '\0';
593 ptr += tmp - lpszPathWindow; /* ptr now points to '>' in tmp buffer */
594 /* in some cases, we have a trailing space that we need to get rid of */
595 /* FIXME: check if it has to be done in lexer rather than here */
596 for (sz = strlen(ptr + 1); sz >= 1 && ptr[sz] == ' '; sz--) ptr[sz] = '\0';
Eric Pouech7ae1bb22008-04-22 22:00:32 +0200597 MACRO_JumpHash(tmp, ptr + 1, HLPFILE_Hash(topic_id));
598 HeapFree(GetProcessHeap(), 0, tmp);
599 }
600 }
601 else
602 MACRO_JumpHash(lpszPathWindow, NULL, HLPFILE_Hash(topic_id));
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000603}
604
Eric Pouech7ae1bb22008-04-22 22:00:32 +0200605/* FIXME: this macros is wrong
606 * it should only contain 2 strings, path & window are coded as path>window
607 */
Francois Gouget49679842009-01-08 14:16:50 +0100608static void CALLBACK MACRO_JumpKeyword(LPCSTR lpszPath, LPCSTR lpszWindow, LPCSTR keyword)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000609{
Eric Pouech81b7b912002-11-15 01:34:57 +0000610 WINE_FIXME("(\"%s\", \"%s\", \"%s\")\n", lpszPath, lpszWindow, keyword);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000611}
612
Francois Gouget49679842009-01-08 14:16:50 +0100613static void CALLBACK MACRO_KLink(LPCSTR str1, LONG u, LPCSTR str2, LPCSTR str3)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000614{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200615 WINE_FIXME("(\"%s\", %u, \"%s\", \"%s\")\n", str1, u, str2, str3);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000616}
617
Francois Gouget49679842009-01-08 14:16:50 +0100618static void CALLBACK MACRO_Menu(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000619{
Eric Pouech81b7b912002-11-15 01:34:57 +0000620 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000621}
622
Francois Gouget49679842009-01-08 14:16:50 +0100623static void CALLBACK MACRO_MPrintHash(LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000624{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200625 WINE_FIXME("(%u)\n", u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000626}
627
Francois Gouget49679842009-01-08 14:16:50 +0100628static void CALLBACK MACRO_MPrintID(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000629{
Eric Pouech81b7b912002-11-15 01:34:57 +0000630 WINE_FIXME("(\"%s\")\n", str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000631}
632
Francois Gouget49679842009-01-08 14:16:50 +0100633static void CALLBACK MACRO_Next(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000634{
Eric Pouech6d40dbe2008-04-22 21:59:38 +0200635 WINHELP_WNDPAGE wp;
Eric Pouech7d75cfe2002-11-18 19:48:11 +0000636
Eric Pouech81b7b912002-11-15 01:34:57 +0000637 WINE_TRACE("()\n");
Eric Pouech29f865c2009-05-30 14:26:39 +0200638 wp.page = MACRO_CurrentWindow()->page;
Eric Pouecha4480362008-04-22 22:00:56 +0200639 wp.page = HLPFILE_PageByOffset(wp.page->file, wp.page->browse_fwd, &wp.relative);
Eric Pouech6d40dbe2008-04-22 21:59:38 +0200640 if (wp.page)
Eric Pouech7d75cfe2002-11-18 19:48:11 +0000641 {
Eric Pouech6d40dbe2008-04-22 21:59:38 +0200642 wp.page->file->wRefCount++;
Eric Pouech29f865c2009-05-30 14:26:39 +0200643 wp.wininfo = MACRO_CurrentWindow()->info;
Eric Pouech4a89d292008-04-22 22:00:20 +0200644 WINHELP_CreateHelpWindow(&wp, SW_NORMAL, TRUE);
Eric Pouech7d75cfe2002-11-18 19:48:11 +0000645 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000646}
647
Francois Gouget49679842009-01-08 14:16:50 +0100648static void CALLBACK MACRO_NoShow(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000649{
Eric Pouech81b7b912002-11-15 01:34:57 +0000650 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000651}
652
Eric Pouechdff8de62004-12-13 21:06:46 +0000653void CALLBACK MACRO_PopupContext(LPCSTR str, LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000654{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200655 WINE_FIXME("(\"%s\", %u)\n", str, u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000656}
657
Francois Gouget49679842009-01-08 14:16:50 +0100658static void CALLBACK MACRO_PopupHash(LPCSTR str, LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000659{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200660 WINE_FIXME("(\"%s\", %u)\n", str, u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000661}
662
Francois Gouget49679842009-01-08 14:16:50 +0100663static void CALLBACK MACRO_PopupId(LPCSTR str1, LPCSTR str2)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000664{
Eric Pouech81b7b912002-11-15 01:34:57 +0000665 WINE_FIXME("(\"%s\", \"%s\")\n", str1, str2);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000666}
667
Francois Gouget49679842009-01-08 14:16:50 +0100668static void CALLBACK MACRO_PositionWindow(LONG i1, LONG i2, LONG u1, LONG u2, LONG u3, LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000669{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200670 WINE_FIXME("(%i, %i, %u, %u, %u, \"%s\")\n", i1, i2, u1, u2, u3, str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000671}
672
Francois Gouget49679842009-01-08 14:16:50 +0100673static void CALLBACK MACRO_Prev(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000674{
Eric Pouech6d40dbe2008-04-22 21:59:38 +0200675 WINHELP_WNDPAGE wp;
Eric Pouech7d75cfe2002-11-18 19:48:11 +0000676
Eric Pouech81b7b912002-11-15 01:34:57 +0000677 WINE_TRACE("()\n");
Eric Pouech29f865c2009-05-30 14:26:39 +0200678 wp.page = MACRO_CurrentWindow()->page;
Eric Pouecha4480362008-04-22 22:00:56 +0200679 wp.page = HLPFILE_PageByOffset(wp.page->file, wp.page->browse_bwd, &wp.relative);
Eric Pouech6d40dbe2008-04-22 21:59:38 +0200680 if (wp.page)
Eric Pouech7d75cfe2002-11-18 19:48:11 +0000681 {
Eric Pouech6d40dbe2008-04-22 21:59:38 +0200682 wp.page->file->wRefCount++;
Eric Pouech29f865c2009-05-30 14:26:39 +0200683 wp.wininfo = MACRO_CurrentWindow()->info;
Eric Pouech4a89d292008-04-22 22:00:20 +0200684 WINHELP_CreateHelpWindow(&wp, SW_NORMAL, TRUE);
Eric Pouech7d75cfe2002-11-18 19:48:11 +0000685 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000686}
687
Eric Pouechdff8de62004-12-13 21:06:46 +0000688void CALLBACK MACRO_Print(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000689{
Alexandre Julliard54c27111998-03-29 19:44:57 +0000690 PRINTDLG printer;
Vincent Béron9a624912002-05-31 23:06:46 +0000691
Eric Pouech81b7b912002-11-15 01:34:57 +0000692 WINE_TRACE("()\n");
693
Alexandre Julliard54c27111998-03-29 19:44:57 +0000694 printer.lStructSize = sizeof(printer);
Eric Pouech29f865c2009-05-30 14:26:39 +0200695 printer.hwndOwner = MACRO_CurrentWindow()->hMainWnd;
Alexandre Julliard54c27111998-03-29 19:44:57 +0000696 printer.hInstance = Globals.hInstance;
697 printer.hDevMode = 0;
698 printer.hDevNames = 0;
699 printer.hDC = 0;
700 printer.Flags = 0;
701 printer.nFromPage = 0;
702 printer.nToPage = 0;
703 printer.nMinPage = 0;
704 printer.nMaxPage = 0;
705 printer.nCopies = 0;
706 printer.lCustData = 0;
707 printer.lpfnPrintHook = 0;
708 printer.lpfnSetupHook = 0;
709 printer.lpPrintTemplateName = 0;
710 printer.lpSetupTemplateName = 0;
711 printer.hPrintTemplate = 0;
712 printer.hSetupTemplate = 0;
Vincent Béron9a624912002-05-31 23:06:46 +0000713
Alexandre Julliard27b790b2000-06-08 04:58:18 +0000714 if (PrintDlgA(&printer)) {
Eric Pouech75792872002-07-16 01:46:29 +0000715 WINE_FIXME("Print()\n");
716 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000717}
718
Eric Pouechdff8de62004-12-13 21:06:46 +0000719void CALLBACK MACRO_PrinterSetup(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000720{
Eric Pouech81b7b912002-11-15 01:34:57 +0000721 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000722}
723
Francois Gouget49679842009-01-08 14:16:50 +0100724static void CALLBACK MACRO_RegisterRoutine(LPCSTR dll_name, LPCSTR proc, LPCSTR args)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000725{
Alexandre Julliard15751f22009-10-07 13:40:00 +0200726 void *fn = NULL;
Eric Pouechdff8de62004-12-13 21:06:46 +0000727 int size;
728 WINHELP_DLL* dll;
Eric Pouech81b7b912002-11-15 01:34:57 +0000729
Eric Pouechdff8de62004-12-13 21:06:46 +0000730 WINE_TRACE("(\"%s\", \"%s\", \"%s\")\n", dll_name, proc, args);
Eric Pouech81b7b912002-11-15 01:34:57 +0000731
Eric Pouechdff8de62004-12-13 21:06:46 +0000732 /* FIXME: are the registered DLLs global or linked to the current file ???
733 * We assume globals (as we did for macros, but is this really the case ???)
734 */
735 for (dll = Globals.dlls; dll; dll = dll->next)
736 {
737 if (!strcmp(dll->name, dll_name)) break;
738 }
739 if (!dll)
740 {
741 HANDLE hLib = LoadLibrary(dll_name);
742
743 /* FIXME: the library will not be unloaded until exit of program
744 * We don't send the DW_TERM message
745 */
746 WINE_TRACE("Loading %s\n", dll_name);
747 /* FIXME: should look in the directory where current hlpfile
748 * is loaded from
749 */
750 if (hLib == NULL)
751 {
752 /* FIXME: internationalisation for error messages */
753 WINE_FIXME("Cannot find dll %s\n", dll_name);
754 }
755 else if ((dll = HeapAlloc(GetProcessHeap(), 0, sizeof(*dll))))
756 {
757 dll->hLib = hLib;
Francois Gougete7f8aa72009-05-13 10:28:45 +0200758 dll->name = StrDup(dll_name); /* FIXME: never freed */
Eric Pouechdff8de62004-12-13 21:06:46 +0000759 dll->next = Globals.dlls;
760 Globals.dlls = dll;
761 dll->handler = (WINHELP_LDLLHandler)GetProcAddress(dll->hLib, "LDLLHandler");
762 dll->class = dll->handler ? (dll->handler)(DW_WHATMSG, 0, 0) : DC_NOMSG;
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200763 WINE_TRACE("Got class %x for DLL %s\n", dll->class, dll_name);
Eric Pouechdff8de62004-12-13 21:06:46 +0000764 if (dll->class & DC_INITTERM) dll->handler(DW_INIT, 0, 0);
Alexandre Julliarde2d22db2009-10-07 13:31:32 +0200765 if (dll->class & DC_CALLBACKS) dll->handler(DW_CALLBACKS, (LONG_PTR)&Callbacks, 0);
Eric Pouechdff8de62004-12-13 21:06:46 +0000766 }
767 else WINE_WARN("OOM\n");
768 }
769 if (dll && !(fn = GetProcAddress(dll->hLib, proc)))
Eric Pouech81b7b912002-11-15 01:34:57 +0000770 {
771 /* FIXME: internationalisation for error messages */
Eric Pouechdff8de62004-12-13 21:06:46 +0000772 WINE_FIXME("Cannot find proc %s in dll %s\n", dll_name, proc);
Eric Pouech81b7b912002-11-15 01:34:57 +0000773 }
774
Dimitrie O. Paun921df712003-10-11 05:25:31 +0000775 size = ++MACRO_NumLoaded * sizeof(struct MacroDesc);
776 if (!MACRO_Loaded) MACRO_Loaded = HeapAlloc(GetProcessHeap(), 0, size);
777 else MACRO_Loaded = HeapReAlloc(GetProcessHeap(), 0, MACRO_Loaded, size);
Francois Gougete7f8aa72009-05-13 10:28:45 +0200778 MACRO_Loaded[MACRO_NumLoaded - 1].name = StrDup(proc); /* FIXME: never freed */
Eric Pouech81b7b912002-11-15 01:34:57 +0000779 MACRO_Loaded[MACRO_NumLoaded - 1].alias = NULL;
780 MACRO_Loaded[MACRO_NumLoaded - 1].isBool = 0;
Francois Gougete7f8aa72009-05-13 10:28:45 +0200781 MACRO_Loaded[MACRO_NumLoaded - 1].arguments = StrDup(args); /* FIXME: never freed */
Eric Pouech81b7b912002-11-15 01:34:57 +0000782 MACRO_Loaded[MACRO_NumLoaded - 1].fn = fn;
Eric Pouechdff8de62004-12-13 21:06:46 +0000783 WINE_TRACE("Added %s(%s) at %p\n", proc, args, fn);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000784}
785
Francois Gouget49679842009-01-08 14:16:50 +0100786static void CALLBACK MACRO_RemoveAccelerator(LONG u1, LONG u2)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000787{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200788 WINE_FIXME("(%u, %u)\n", u1, u2);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000789}
790
Francois Gouget49679842009-01-08 14:16:50 +0100791static void CALLBACK MACRO_ResetMenu(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000792{
Eric Pouech81b7b912002-11-15 01:34:57 +0000793 WINE_FIXME("()\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000794}
795
Francois Gouget49679842009-01-08 14:16:50 +0100796static void CALLBACK MACRO_SaveMark(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000797{
Eric Pouech81b7b912002-11-15 01:34:57 +0000798 WINE_FIXME("(\"%s\")\n", str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000799}
800
Francois Gouget49679842009-01-08 14:16:50 +0100801static void CALLBACK MACRO_Search(void)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000802{
Eric Pouech841720e2008-07-05 21:33:19 +0200803 WINHELP_CreateIndexWindow(TRUE);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000804}
805
Eric Pouechdff8de62004-12-13 21:06:46 +0000806void CALLBACK MACRO_SetContents(LPCSTR str, LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000807{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200808 WINE_FIXME("(\"%s\", %u)\n", str, u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000809}
810
Francois Gouget49679842009-01-08 14:16:50 +0100811static void CALLBACK MACRO_SetHelpOnFile(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000812{
Eric Pouech29f865c2009-05-30 14:26:39 +0200813 HLPFILE_PAGE* page = MACRO_CurrentWindow()->page;
814
Eric Pouech448fed22008-07-12 10:37:01 +0200815 WINE_TRACE("(\"%s\")\n", str);
816
Eric Pouech29f865c2009-05-30 14:26:39 +0200817 HeapFree(GetProcessHeap(), 0, page->file->help_on_file);
818 page->file->help_on_file = HeapAlloc(GetProcessHeap(), 0, strlen(str) + 1);
819 if (page->file->help_on_file)
820 strcpy(page->file->help_on_file, str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000821}
822
Francois Gouget49679842009-01-08 14:16:50 +0100823static void CALLBACK MACRO_SetPopupColor(LONG r, LONG g, LONG b)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000824{
Eric Pouech29f865c2009-05-30 14:26:39 +0200825 HLPFILE_PAGE* page = MACRO_CurrentWindow()->page;
826
Eric Pouech7d0b6bd2008-07-12 10:37:08 +0200827 WINE_TRACE("(%x, %x, %x)\n", r, g, b);
Eric Pouech29f865c2009-05-30 14:26:39 +0200828 page->file->has_popup_color = TRUE;
829 page->file->popup_color = RGB(r, g, b);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000830}
831
Francois Gouget49679842009-01-08 14:16:50 +0100832static void CALLBACK MACRO_ShellExecute(LPCSTR str1, LPCSTR str2, LONG u1, LONG u2, LPCSTR str3, LPCSTR str4)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000833{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200834 WINE_FIXME("(\"%s\", \"%s\", %u, %u, \"%s\", \"%s\")\n", str1, str2, u1, u2, str3, str4);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000835}
836
Francois Gouget49679842009-01-08 14:16:50 +0100837static void CALLBACK MACRO_ShortCut(LPCSTR str1, LPCSTR str2, LONG w, LONG l, LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000838{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200839 WINE_FIXME("(\"%s\", \"%s\", %x, %x, \"%s\")\n", str1, str2, w, l, str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000840}
841
Francois Gouget49679842009-01-08 14:16:50 +0100842static void CALLBACK MACRO_TCard(LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000843{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200844 WINE_FIXME("(%u)\n", u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000845}
846
Francois Gouget49679842009-01-08 14:16:50 +0100847static void CALLBACK MACRO_Test(LONG u)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000848{
Michael Stefaniuc3dbe7152006-10-02 23:20:26 +0200849 WINE_FIXME("(%u)\n", u);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000850}
851
Francois Gouget49679842009-01-08 14:16:50 +0100852static BOOL CALLBACK MACRO_TestALink(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000853{
Eric Pouech81b7b912002-11-15 01:34:57 +0000854 WINE_FIXME("(\"%s\")\n", str);
Eric Pouech75792872002-07-16 01:46:29 +0000855 return FALSE;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000856}
857
Francois Gouget49679842009-01-08 14:16:50 +0100858static BOOL CALLBACK MACRO_TestKLink(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000859{
Eric Pouech81b7b912002-11-15 01:34:57 +0000860 WINE_FIXME("(\"%s\")\n", str);
Eric Pouech75792872002-07-16 01:46:29 +0000861 return FALSE;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000862}
863
Francois Gouget49679842009-01-08 14:16:50 +0100864static void CALLBACK MACRO_UncheckItem(LPCSTR str)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000865{
Eric Pouech81b7b912002-11-15 01:34:57 +0000866 WINE_FIXME("(\"%s\")\n", str);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000867}
868
Francois Gouget49679842009-01-08 14:16:50 +0100869static void CALLBACK MACRO_UpdateWindow(LPCSTR str1, LPCSTR str2)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000870{
Eric Pouech81b7b912002-11-15 01:34:57 +0000871 WINE_FIXME("(\"%s\", \"%s\")\n", str1, str2);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000872}
Francois Gougetef35bfd2009-01-08 14:16:40 +0100873
874
875/**************************************************/
876/* Macro table */
877/**************************************************/
878
879/* types:
880 * U: 32 bit unsigned int
881 * I: 32 bit signed int
882 * S: string
883 * v: unknown (32 bit entity)
884 */
885
886static struct MacroDesc MACRO_Builtins[] = {
Alexandre Julliard15751f22009-10-07 13:40:00 +0200887 {"About", NULL, 0, "", MACRO_About},
888 {"AddAccelerator", "AA", 0, "UUS", MACRO_AddAccelerator},
889 {"ALink", "AL", 0, "SUS", MACRO_ALink},
890 {"Annotate", NULL, 0, "", MACRO_Annotate},
891 {"AppendItem", NULL, 0, "SSSS", MACRO_AppendItem},
892 {"Back", NULL, 0, "", MACRO_Back},
893 {"BackFlush", "BF", 0, "", MACRO_BackFlush},
894 {"BookmarkDefine", NULL, 0, "", MACRO_BookmarkDefine},
895 {"BookmarkMore", NULL, 0, "", MACRO_BookmarkMore},
896 {"BrowseButtons", NULL, 0, "", MACRO_BrowseButtons},
897 {"ChangeButtonBinding", "CBB",0, "SS", MACRO_ChangeButtonBinding},
898 {"ChangeEnable", "CE", 0, "SS", MACRO_ChangeEnable},
899 {"ChangeItemBinding", "CIB",0, "SS", MACRO_ChangeItemBinding},
900 {"CheckItem", "CI", 0, "S", MACRO_CheckItem},
901 {"CloseSecondarys", "CS", 0, "", MACRO_CloseSecondarys},
902 {"CloseWindow", "CW", 0, "S", MACRO_CloseWindow},
903 {"Compare", NULL, 0, "S", MACRO_Compare},
904 {"Contents", NULL, 0, "", MACRO_Contents},
905 {"ControlPanel", NULL, 0, "SSU", MACRO_ControlPanel},
906 {"CopyDialog", NULL, 0, "", MACRO_CopyDialog},
907 {"CopyTopic", "CT", 0, "", MACRO_CopyTopic},
908 {"CreateButton", "CB", 0, "SSS", MACRO_CreateButton},
909 {"DeleteItem", NULL, 0, "S", MACRO_DeleteItem},
910 {"DeleteMark", NULL, 0, "S", MACRO_DeleteMark},
911 {"DestroyButton", NULL, 0, "S", MACRO_DestroyButton},
912 {"DisableButton", "DB", 0, "S", MACRO_DisableButton},
913 {"DisableItem", "DI", 0, "S", MACRO_DisableItem},
914 {"EnableButton", "EB", 0, "S", MACRO_EnableButton},
915 {"EnableItem", "EI", 0, "S", MACRO_EnableItem},
916 {"EndMPrint", NULL, 0, "", MACRO_EndMPrint},
917 {"ExecFile", "EF", 0, "SSUS", MACRO_ExecFile},
918 {"ExecProgram", "EP", 0, "SU", MACRO_ExecProgram},
919 {"Exit", NULL, 0, "", MACRO_Exit},
920 {"ExtAbleItem", NULL, 0, "SU", MACRO_ExtAbleItem},
921 {"ExtInsertItem", NULL, 0, "SSSSUU", MACRO_ExtInsertItem},
922 {"ExtInsertMenu", NULL, 0, "SSSUU", MACRO_ExtInsertMenu},
923 {"FileExist", "FE", 1, "S", MACRO_FileExist},
924 {"FileOpen", "FO", 0, "", MACRO_FileOpen},
925 {"Find", NULL, 0, "", MACRO_Find},
926 {"Finder", "FD", 0, "", MACRO_Finder},
927 {"FloatingMenu", NULL, 0, "", MACRO_FloatingMenu},
928 {"Flush", "FH", 0, "", MACRO_Flush},
929 {"FocusWindow", NULL, 0, "S", MACRO_FocusWindow},
930 {"Generate", NULL, 0, "SUU", MACRO_Generate},
931 {"GotoMark", NULL, 0, "S", MACRO_GotoMark},
932 {"HelpOn", NULL, 0, "", MACRO_HelpOn},
933 {"HelpOnTop", NULL, 0, "", MACRO_HelpOnTop},
934 {"History", NULL, 0, "", MACRO_History},
935 {"InitMPrint", NULL, 1, "", MACRO_InitMPrint},
936 {"InsertItem", NULL, 0, "SSSSU", MACRO_InsertItem},
937 {"InsertMenu", NULL, 0, "SSU", MACRO_InsertMenu},
938 {"IfThen", "IF", 0, "BS", MACRO_IfThen},
939 {"IfThenElse", "IE", 0, "BSS", MACRO_IfThenElse},
940 {"IsBook", NULL, 1, "", MACRO_IsBook},
941 {"IsMark", NULL, 1, "S", MACRO_IsMark},
942 {"IsNotMark", "NM", 1, "S", MACRO_IsNotMark},
943 {"JumpContents", NULL, 0, "SS", MACRO_JumpContents},
944 {"JumpContext", "JC", 0, "SSU", MACRO_JumpContext},
945 {"JumpHash", "JH", 0, "SSU", MACRO_JumpHash},
946 {"JumpHelpOn", NULL, 0, "", MACRO_JumpHelpOn},
947 {"JumpID", "JI", 0, "SS", MACRO_JumpID},
948 {"JumpKeyword", "JK", 0, "SSS", MACRO_JumpKeyword},
949 {"KLink", "KL", 0, "SUSS", MACRO_KLink},
950 {"Menu", "MU", 0, "", MACRO_Menu},
951 {"MPrintHash", NULL, 0, "U", MACRO_MPrintHash},
952 {"MPrintID", NULL, 0, "S", MACRO_MPrintID},
953 {"Next", NULL, 0, "", MACRO_Next},
954 {"NoShow", "NS", 0, "", MACRO_NoShow},
955 {"PopupContext", "PC", 0, "SU", MACRO_PopupContext},
956 {"PopupHash", NULL, 0, "SU", MACRO_PopupHash},
957 {"PopupId", "PI", 0, "SS", MACRO_PopupId},
958 {"PositionWindow", "PW", 0, "IIUUUS", MACRO_PositionWindow},
959 {"Prev", NULL, 0, "", MACRO_Prev},
960 {"Print", NULL, 0, "", MACRO_Print},
961 {"PrinterSetup", NULL, 0, "", MACRO_PrinterSetup},
962 {"RegisterRoutine", "RR", 0, "SSS", MACRO_RegisterRoutine},
963 {"RemoveAccelerator", "RA", 0, "UU", MACRO_RemoveAccelerator},
964 {"ResetMenu", NULL, 0, "", MACRO_ResetMenu},
965 {"SaveMark", NULL, 0, "S", MACRO_SaveMark},
966 {"Search", NULL, 0, "", MACRO_Search},
967 {"SetContents", NULL, 0, "SU", MACRO_SetContents},
968 {"SetHelpOnFile", NULL, 0, "S", MACRO_SetHelpOnFile},
969 {"SetPopupColor", "SPC",0, "UUU", MACRO_SetPopupColor},
970 {"ShellExecute", "SE", 0, "SSUUSS", MACRO_ShellExecute},
971 {"ShortCut", "SH", 0, "SSUUS", MACRO_ShortCut},
972 {"TCard", NULL, 0, "U", MACRO_TCard},
973 {"Test", NULL, 0, "U", MACRO_Test},
974 {"TestALink", NULL, 1, "S", MACRO_TestALink},
975 {"TestKLink", NULL, 1, "S", MACRO_TestKLink},
976 {"UncheckItem", "UI", 0, "S", MACRO_UncheckItem},
977 {"UpdateWindow", "UW", 0, "SS", MACRO_UpdateWindow},
Francois Gougetef35bfd2009-01-08 14:16:40 +0100978 {NULL, NULL, 0, NULL, NULL}
979};
980
981static int MACRO_DoLookUp(struct MacroDesc* start, const char* name, struct lexret* lr, unsigned len)
982{
983 struct MacroDesc* md;
984
985 for (md = start; md->name && len != 0; md++, len--)
986 {
987 if (strcasecmp(md->name, name) == 0 || (md->alias != NULL && strcasecmp(md->alias, name) == 0))
988 {
989 lr->proto = md->arguments;
990 lr->function = md->fn;
991 return md->isBool ? BOOL_FUNCTION : VOID_FUNCTION;
992 }
993 }
994 return EMPTY;
995}
996
997int MACRO_Lookup(const char* name, struct lexret* lr)
998{
999 int ret;
1000
1001 if ((ret = MACRO_DoLookUp(MACRO_Builtins, name, lr, -1)) != EMPTY)
1002 return ret;
1003 if (MACRO_Loaded && (ret = MACRO_DoLookUp(MACRO_Loaded, name, lr, MACRO_NumLoaded)) != EMPTY)
1004 return ret;
1005
1006 lr->string = name;
1007 return IDENTIFIER;
1008}