ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

macro.c
Go to the documentation of this file.
00001 /*
00002  * Help Viewer
00003  *
00004  * Copyright 1996 Ulrich Schmid
00005  * Copyright 2002, 2008 Eric Pouech
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00020  */
00021 
00022 #define WIN32_LEAN_AND_MEAN
00023 
00024 #include <stdio.h>
00025 
00026 #include "windows.h"
00027 #include "commdlg.h"
00028 #include "shellapi.h"
00029 #include "winhelp.h"
00030 
00031 #include "wine/debug.h"
00032 
00033 WINE_DEFAULT_DEBUG_CHANNEL(winhelp);
00034 
00035 /**************************************************/
00036 /*               Macro table                      */
00037 /**************************************************/
00038 struct MacroDesc {
00039     const char* name;
00040     const char* alias;
00041     BOOL        isBool;
00042     const char* arguments;
00043     void       *fn;
00044 };
00045 
00046 static struct MacroDesc*MACRO_Loaded /* = NULL */;
00047 static unsigned         MACRO_NumLoaded /* = 0 */;
00048 
00049 /*******      helper functions     *******/
00050 
00051 static char* StrDup(const char* str)
00052 {
00053     char* dst;
00054     dst=HeapAlloc(GetProcessHeap(),0,strlen(str)+1);
00055     strcpy(dst, str);
00056     return dst;
00057 }
00058 
00059 static WINHELP_BUTTON**        MACRO_LookupButton(WINHELP_WINDOW* win, LPCSTR name)
00060 {
00061     WINHELP_BUTTON**    b;
00062 
00063     for (b = &win->first_button; *b; b = &(*b)->next)
00064         if (!lstrcmpi(name, (*b)->lpszID)) break;
00065     return b;
00066 }
00067 
00068 /******* some forward declarations *******/
00069 static void CALLBACK MACRO_JumpID(LPCSTR lpszPathWindow, LPCSTR topic_id);
00070 
00071 /******* real macro implementation *******/
00072 
00073 void CALLBACK MACRO_CreateButton(LPCSTR id, LPCSTR name, LPCSTR macro)
00074 {
00075     WINHELP_WINDOW *win = MACRO_CurrentWindow();
00076     WINHELP_BUTTON *button, **b;
00077     LONG            size;
00078     LPSTR           ptr;
00079 
00080     WINE_TRACE("(\"%s\", \"%s\", %s)\n", id, name, macro);
00081 
00082     size = sizeof(WINHELP_BUTTON) + lstrlen(id) + lstrlen(name) + lstrlen(macro) + 3;
00083 
00084     button = HeapAlloc(GetProcessHeap(), 0, size);
00085     if (!button) return;
00086 
00087     button->next  = 0;
00088     button->hWnd  = 0;
00089 
00090     ptr = (char*)button + sizeof(WINHELP_BUTTON);
00091 
00092     lstrcpy(ptr, id);
00093     button->lpszID = ptr;
00094     ptr += lstrlen(id) + 1;
00095 
00096     lstrcpy(ptr, name);
00097     button->lpszName = ptr;
00098     ptr += lstrlen(name) + 1;
00099 
00100     lstrcpy(ptr, macro);
00101     button->lpszMacro = ptr;
00102 
00103     button->wParam = WH_FIRST_BUTTON;
00104     for (b = &win->first_button; *b; b = &(*b)->next)
00105         button->wParam = max(button->wParam, (*b)->wParam + 1);
00106     *b = button;
00107 
00108     WINHELP_LayoutMainWindow(win);
00109 }
00110 
00111 static void CALLBACK MACRO_DestroyButton(LPCSTR str)
00112 {
00113     WINE_FIXME("(\"%s\")\n", str);
00114 }
00115 
00116 void CALLBACK MACRO_DisableButton(LPCSTR id)
00117 {
00118     WINHELP_BUTTON**    b;
00119 
00120     WINE_TRACE("(\"%s\")\n", id);
00121 
00122     b = MACRO_LookupButton(MACRO_CurrentWindow(), id);
00123     if (!*b) {WINE_FIXME("Couldn't find button '%s'\n", id); return;}
00124 
00125     EnableWindow((*b)->hWnd, FALSE);
00126 }
00127 
00128 static void CALLBACK MACRO_EnableButton(LPCSTR id)
00129 {
00130     WINHELP_BUTTON**    b;
00131 
00132     WINE_TRACE("(\"%s\")\n", id);
00133 
00134     b = MACRO_LookupButton(MACRO_CurrentWindow(), id);
00135     if (!*b) {WINE_FIXME("Couldn't find button '%s'\n", id); return;}
00136 
00137     EnableWindow((*b)->hWnd, TRUE);
00138 }
00139 
00140 void CALLBACK MACRO_JumpContents(LPCSTR lpszPath, LPCSTR lpszWindow)
00141 {
00142     HLPFILE*    hlpfile;
00143 
00144     WINE_TRACE("(\"%s\", \"%s\")\n", lpszPath, lpszWindow);
00145     if ((hlpfile = WINHELP_LookupHelpFile(lpszPath)))
00146         WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, 0,
00147                                WINHELP_GetWindowInfo(hlpfile, lpszWindow),
00148                                SW_NORMAL);
00149 }
00150 
00151 
00152 void CALLBACK MACRO_About(void)
00153 {
00154     WCHAR name[256];
00155     HICON icon = LoadImageW( Globals.hInstance, MAKEINTRESOURCEW(IDI_WINHELP),
00156                              IMAGE_ICON, 48, 48, LR_SHARED );
00157     LoadStringW( Globals.hInstance, STID_WINE_HELP, name, sizeof(name)/sizeof(WCHAR) );
00158     ShellAboutW( MACRO_CurrentWindow()->hMainWnd, name, NULL, icon );
00159 }
00160 
00161 static void CALLBACK MACRO_AddAccelerator(LONG u1, LONG u2, LPCSTR str)
00162 {
00163     WINE_FIXME("(%u, %u, \"%s\")\n", u1, u2, str);
00164 }
00165 
00166 static void CALLBACK MACRO_ALink(LPCSTR str1, LONG u, LPCSTR str2)
00167 {
00168     WINE_FIXME("(\"%s\", %u, \"%s\")\n", str1, u, str2);
00169 }
00170 
00171 void CALLBACK MACRO_Annotate(void)
00172 {
00173     WINE_FIXME("()\n");
00174 }
00175 
00176 static void CALLBACK MACRO_AppendItem(LPCSTR str1, LPCSTR str2, LPCSTR str3, LPCSTR str4)
00177 {
00178     WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\")\n", str1, str2, str3, str4);
00179 }
00180 
00181 static void CALLBACK MACRO_Back(void)
00182 {
00183     WINHELP_WINDOW* win = MACRO_CurrentWindow();
00184 
00185     WINE_TRACE("()\n");
00186 
00187     if (win && win->back.index >= 2)
00188         WINHELP_CreateHelpWindow(&win->back.set[--win->back.index - 1], SW_SHOW, FALSE);
00189 }
00190 
00191 static void CALLBACK MACRO_BackFlush(void)
00192 {
00193     WINHELP_WINDOW* win = MACRO_CurrentWindow();
00194 
00195     WINE_TRACE("()\n");
00196 
00197     if (win) WINHELP_DeleteBackSet(win);
00198 }
00199 
00200 void CALLBACK MACRO_BookmarkDefine(void)
00201 {
00202     WINE_FIXME("()\n");
00203 }
00204 
00205 static void CALLBACK MACRO_BookmarkMore(void)
00206 {
00207     WINE_FIXME("()\n");
00208 }
00209 
00210 static void CALLBACK MACRO_BrowseButtons(void)
00211 {
00212     HLPFILE_PAGE*       page = MACRO_CurrentWindow()->page;
00213     ULONG               relative;
00214 
00215     WINE_TRACE("()\n");
00216 
00217     MACRO_CreateButton("BTN_PREV", "&<<", "Prev()");
00218     MACRO_CreateButton("BTN_NEXT", "&>>", "Next()");
00219 
00220     if (!HLPFILE_PageByOffset(page->file, page->browse_bwd, &relative))
00221         MACRO_DisableButton("BTN_PREV");
00222     if (!HLPFILE_PageByOffset(page->file, page->browse_fwd, &relative))
00223         MACRO_DisableButton("BTN_NEXT");
00224 }
00225 
00226 static void CALLBACK MACRO_ChangeButtonBinding(LPCSTR id, LPCSTR macro)
00227 {
00228     WINHELP_WINDOW*     win = MACRO_CurrentWindow();
00229     WINHELP_BUTTON*     button;
00230     WINHELP_BUTTON**    b;
00231     LONG                size;
00232     LPSTR               ptr;
00233 
00234     WINE_TRACE("(\"%s\", \"%s\")\n", id, macro);
00235 
00236     b = MACRO_LookupButton(win, id);
00237     if (!*b) {WINE_FIXME("Couldn't find button '%s'\n", id); return;}
00238 
00239     size = sizeof(WINHELP_BUTTON) + lstrlen(id) +
00240         lstrlen((*b)->lpszName) + lstrlen(macro) + 3;
00241 
00242     button = HeapAlloc(GetProcessHeap(), 0, size);
00243     if (!button) return;
00244 
00245     button->next  = (*b)->next;
00246     button->hWnd  = (*b)->hWnd;
00247     button->wParam = (*b)->wParam;
00248 
00249     ptr = (char*)button + sizeof(WINHELP_BUTTON);
00250 
00251     lstrcpy(ptr, id);
00252     button->lpszID = ptr;
00253     ptr += lstrlen(id) + 1;
00254 
00255     lstrcpy(ptr, (*b)->lpszName);
00256     button->lpszName = ptr;
00257     ptr += lstrlen((*b)->lpszName) + 1;
00258 
00259     lstrcpy(ptr, macro);
00260     button->lpszMacro = ptr;
00261 
00262     *b = button;
00263 
00264     WINHELP_LayoutMainWindow(win);
00265 }
00266 
00267 static void CALLBACK MACRO_ChangeEnable(LPCSTR id, LPCSTR macro)
00268 {
00269     WINE_TRACE("(\"%s\", \"%s\")\n", id, macro);
00270 
00271     MACRO_ChangeButtonBinding(id, macro);
00272     MACRO_EnableButton(id);
00273 }
00274 
00275 static void CALLBACK MACRO_ChangeItemBinding(LPCSTR str1, LPCSTR str2)
00276 {
00277     WINE_FIXME("(\"%s\", \"%s\")\n", str1, str2);
00278 }
00279 
00280 static void CALLBACK MACRO_CheckItem(LPCSTR str)
00281 {
00282     WINE_FIXME("(\"%s\")\n", str);
00283 }
00284 
00285 static void CALLBACK MACRO_CloseSecondarys(void)
00286 {
00287     WINHELP_WINDOW *win;
00288     WINHELP_WINDOW *next;
00289 
00290     WINE_TRACE("()\n");
00291     for (win = Globals.win_list; win; win = next)
00292     {
00293         next = win->next;
00294         if (lstrcmpi(win->info->name, "main"))
00295             WINHELP_ReleaseWindow(win);
00296     }
00297 }
00298 
00299 static void CALLBACK MACRO_CloseWindow(LPCSTR lpszWindow)
00300 {
00301     WINHELP_WINDOW *win;
00302     WINHELP_WINDOW *next;
00303 
00304     WINE_TRACE("(\"%s\")\n", lpszWindow);
00305 
00306     if (!lpszWindow || !lpszWindow[0]) lpszWindow = "main";
00307 
00308     for (win = Globals.win_list; win; win = next)
00309     {
00310         next = win->next;
00311         if (!lstrcmpi(win->info->name, lpszWindow))
00312             WINHELP_ReleaseWindow(win);
00313     }
00314 }
00315 
00316 static void CALLBACK MACRO_Compare(LPCSTR str)
00317 {
00318     WINE_FIXME("(\"%s\")\n", str);
00319 }
00320 
00321 static void CALLBACK MACRO_Contents(void)
00322 {
00323     HLPFILE_PAGE*       page = MACRO_CurrentWindow()->page;
00324 
00325     WINE_TRACE("()\n");
00326 
00327     if (page)
00328         MACRO_JumpContents(page->file->lpszPath, NULL);
00329 }
00330 
00331 static void CALLBACK MACRO_ControlPanel(LPCSTR str1, LPCSTR str2, LONG u)
00332 {
00333     WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1, str2, u);
00334 }
00335 
00336 void CALLBACK MACRO_CopyDialog(void)
00337 {
00338     WINE_FIXME("()\n");
00339 }
00340 
00341 static void CALLBACK MACRO_CopyTopic(void)
00342 {
00343     WINE_FIXME("()\n");
00344 }
00345 
00346 static void CALLBACK MACRO_DeleteItem(LPCSTR str)
00347 {
00348     WINE_FIXME("(\"%s\")\n", str);
00349 }
00350 
00351 static void CALLBACK MACRO_DeleteMark(LPCSTR str)
00352 {
00353     WINE_FIXME("(\"%s\")\n", str);
00354 }
00355 
00356 static void CALLBACK MACRO_DisableItem(LPCSTR str)
00357 {
00358     WINE_FIXME("(\"%s\")\n", str);
00359 }
00360 
00361 static void CALLBACK MACRO_EnableItem(LPCSTR str)
00362 {
00363     WINE_FIXME("(\"%s\")\n", str);
00364 }
00365 
00366 static void CALLBACK MACRO_EndMPrint(void)
00367 {
00368     WINE_FIXME("()\n");
00369 }
00370 
00371 static void CALLBACK MACRO_ExecFile(LPCSTR pgm, LPCSTR args, LONG cmd_show, LPCSTR topic)
00372 {
00373     HINSTANCE ret;
00374 
00375     WINE_TRACE("(%s, %s, %u, %s)\n",
00376                wine_dbgstr_a(pgm), wine_dbgstr_a(args), cmd_show, wine_dbgstr_a(topic));
00377 
00378     ret = ShellExecuteA(Globals.active_win ? Globals.active_win->hMainWnd : NULL, "open",
00379                         pgm, args, ".", cmd_show);
00380     if ((DWORD_PTR)ret < 32)
00381     {
00382         WINE_WARN("Failed with %p\n", ret);
00383         if (topic) MACRO_JumpID(NULL, topic);
00384     }
00385 }
00386 
00387 static void CALLBACK MACRO_ExecProgram(LPCSTR str, LONG u)
00388 {
00389     WINE_FIXME("(\"%s\", %u)\n", str, u);
00390 }
00391 
00392 void CALLBACK MACRO_Exit(void)
00393 {
00394     WINE_TRACE("()\n");
00395 
00396     while (Globals.win_list)
00397         WINHELP_ReleaseWindow(Globals.win_list);
00398 }
00399 
00400 static void CALLBACK MACRO_ExtAbleItem(LPCSTR str, LONG u)
00401 {
00402     WINE_FIXME("(\"%s\", %u)\n", str, u);
00403 }
00404 
00405 static void CALLBACK MACRO_ExtInsertItem(LPCSTR str1, LPCSTR str2, LPCSTR str3, LPCSTR str4, LONG u1, LONG u2)
00406 {
00407     WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u, %u)\n", str1, str2, str3, str4, u1, u2);
00408 }
00409 
00410 static void CALLBACK MACRO_ExtInsertMenu(LPCSTR str1, LPCSTR str2, LPCSTR str3, LONG u1, LONG u2)
00411 {
00412     WINE_FIXME("(\"%s\", \"%s\", \"%s\", %u, %u)\n", str1, str2, str3, u1, u2);
00413 }
00414 
00415 static BOOL CALLBACK MACRO_FileExist(LPCSTR str)
00416 {
00417     WINE_TRACE("(\"%s\")\n", str);
00418     return GetFileAttributes(str) != INVALID_FILE_ATTRIBUTES;
00419 }
00420 
00421 void CALLBACK MACRO_FileOpen(void)
00422 {
00423     char szFile[MAX_PATH];
00424 
00425     if (WINHELP_GetOpenFileName(szFile, MAX_PATH))
00426     {
00427         MACRO_JumpContents(szFile, "main");
00428     }
00429 }
00430 
00431 static void CALLBACK MACRO_Find(void)
00432 {
00433     WINE_FIXME("()\n");
00434 }
00435 
00436 static void CALLBACK MACRO_Finder(void)
00437 {
00438     WINHELP_CreateIndexWindow(FALSE);
00439 }
00440 
00441 static void CALLBACK MACRO_FloatingMenu(void)
00442 {
00443     WINE_FIXME("()\n");
00444 }
00445 
00446 static void CALLBACK MACRO_Flush(void)
00447 {
00448     WINE_FIXME("()\n");
00449 }
00450 
00451 static void CALLBACK MACRO_FocusWindow(LPCSTR lpszWindow)
00452 {
00453     WINHELP_WINDOW *win;
00454 
00455     WINE_TRACE("(\"%s\")\n", lpszWindow);
00456 
00457     if (!lpszWindow || !lpszWindow[0]) lpszWindow = "main";
00458 
00459     for (win = Globals.win_list; win; win = win->next)
00460         if (!lstrcmpi(win->info->name, lpszWindow))
00461             SetFocus(win->hMainWnd);
00462 }
00463 
00464 static void CALLBACK MACRO_Generate(LPCSTR str, LONG w, LONG l)
00465 {
00466     WINE_FIXME("(\"%s\", %x, %x)\n", str, w, l);
00467 }
00468 
00469 static void CALLBACK MACRO_GotoMark(LPCSTR str)
00470 {
00471     WINE_FIXME("(\"%s\")\n", str);
00472 }
00473 
00474 void CALLBACK MACRO_HelpOn(void)
00475 {
00476     WINHELP_WINDOW *win = MACRO_CurrentWindow();
00477     LPCSTR      file = NULL;
00478 
00479     WINE_TRACE("()\n");
00480     if (win && win->page && win->page->file)
00481         file = win->page->file->help_on_file;
00482 
00483     if (!file)
00484         file = (Globals.wVersion > 4) ? "winhlp32.hlp" : "winhelp.hlp";
00485 
00486     MACRO_JumpContents(file, NULL);
00487 }
00488 
00489 void CALLBACK MACRO_HelpOnTop(void)
00490 {
00491     WINE_FIXME("()\n");
00492 }
00493 
00494 void CALLBACK MACRO_History(void)
00495 {
00496     WINE_TRACE("()\n");
00497 
00498     if (Globals.active_win && !Globals.active_win->hHistoryWnd)
00499     {
00500         HWND hWnd = CreateWindow(HISTORY_WIN_CLASS_NAME, "History", WS_OVERLAPPEDWINDOW,
00501                                  0, 0, 0, 0, 0, 0, Globals.hInstance, Globals.active_win);
00502         ShowWindow(hWnd, SW_NORMAL);
00503     }
00504 }
00505 
00506 static void CALLBACK MACRO_IfThen(BOOL b, LPCSTR t)
00507 {
00508     if (b) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t);
00509 }
00510 
00511 static void CALLBACK MACRO_IfThenElse(BOOL b, LPCSTR t, LPCSTR f)
00512 {
00513     if (b) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t);
00514     else MACRO_ExecuteMacro(MACRO_CurrentWindow(), f);
00515 }
00516 
00517 static BOOL CALLBACK MACRO_InitMPrint(void)
00518 {
00519     WINE_FIXME("()\n");
00520     return FALSE;
00521 }
00522 
00523 static void CALLBACK MACRO_InsertItem(LPCSTR str1, LPCSTR str2, LPCSTR str3, LPCSTR str4, LONG u)
00524 {
00525     WINE_FIXME("(\"%s\", \"%s\", \"%s\", \"%s\", %u)\n", str1, str2, str3, str4, u);
00526 }
00527 
00528 static void CALLBACK MACRO_InsertMenu(LPCSTR str1, LPCSTR str2, LONG u)
00529 {
00530     WINE_FIXME("(\"%s\", \"%s\", %u)\n", str1, str2, u);
00531 }
00532 
00533 static BOOL CALLBACK MACRO_IsBook(void)
00534 {
00535     WINE_TRACE("()\n");
00536     return Globals.isBook;
00537 }
00538 
00539 static BOOL CALLBACK MACRO_IsMark(LPCSTR str)
00540 {
00541     WINE_FIXME("(\"%s\")\n", str);
00542     return FALSE;
00543 }
00544 
00545 static BOOL CALLBACK MACRO_IsNotMark(LPCSTR str)
00546 {
00547     WINE_FIXME("(\"%s\")\n", str);
00548     return TRUE;
00549 }
00550 
00551 void CALLBACK MACRO_JumpContext(LPCSTR lpszPath, LPCSTR lpszWindow, LONG context)
00552 {
00553     HLPFILE*    hlpfile;
00554 
00555     WINE_TRACE("(\"%s\", \"%s\", %d)\n", lpszPath, lpszWindow, context);
00556     hlpfile = WINHELP_LookupHelpFile(lpszPath);
00557     /* Some madness: what user calls 'context', hlpfile calls 'map' */
00558     WINHELP_OpenHelpWindow(HLPFILE_PageByMap, hlpfile, context,
00559                            WINHELP_GetWindowInfo(hlpfile, lpszWindow),
00560                            SW_NORMAL);
00561 }
00562 
00563 void CALLBACK MACRO_JumpHash(LPCSTR lpszPath, LPCSTR lpszWindow, LONG lHash)
00564 {
00565     HLPFILE*    hlpfile;
00566 
00567     WINE_TRACE("(\"%s\", \"%s\", %u)\n", lpszPath, lpszWindow, lHash);
00568     if (!lpszPath || !lpszPath[0])
00569         hlpfile = MACRO_CurrentWindow()->page->file;
00570     else
00571         hlpfile = WINHELP_LookupHelpFile(lpszPath);
00572     WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, lHash,
00573                            WINHELP_GetWindowInfo(hlpfile, lpszWindow),
00574                            SW_NORMAL);
00575 }
00576 
00577 static void CALLBACK MACRO_JumpHelpOn(void)
00578 {
00579     WINE_FIXME("()\n");
00580 }
00581 
00582 static void CALLBACK MACRO_JumpID(LPCSTR lpszPathWindow, LPCSTR topic_id)
00583 {
00584     LPSTR       ptr;
00585 
00586     WINE_TRACE("(\"%s\", \"%s\")\n", lpszPathWindow, topic_id);
00587     if ((ptr = strchr(lpszPathWindow, '>')) != NULL)
00588     {
00589         LPSTR   tmp;
00590         size_t  sz;
00591 
00592         tmp = HeapAlloc(GetProcessHeap(), 0, strlen(lpszPathWindow) + 1);
00593         if (tmp)
00594         {
00595             strcpy(tmp, lpszPathWindow);
00596             tmp[ptr - lpszPathWindow] = '\0';
00597             ptr += tmp - lpszPathWindow; /* ptr now points to '>' in tmp buffer */
00598             /* in some cases, we have a trailing space that we need to get rid of */
00599             /* FIXME: check if it has to be done in lexer rather than here */
00600             for (sz = strlen(ptr + 1); sz >= 1 && ptr[sz] == ' '; sz--) ptr[sz] = '\0';
00601             MACRO_JumpHash(tmp, ptr + 1, HLPFILE_Hash(topic_id));
00602             HeapFree(GetProcessHeap(), 0, tmp);
00603         }
00604     }
00605     else
00606         MACRO_JumpHash(lpszPathWindow, NULL, HLPFILE_Hash(topic_id));
00607 }
00608 
00609 /* FIXME: this macros is wrong
00610  * it should only contain 2 strings, path & window are coded as path>window
00611  */
00612 static void CALLBACK MACRO_JumpKeyword(LPCSTR lpszPath, LPCSTR lpszWindow, LPCSTR keyword)
00613 {
00614     WINE_FIXME("(\"%s\", \"%s\", \"%s\")\n", lpszPath, lpszWindow, keyword);
00615 }
00616 
00617 static void CALLBACK MACRO_KLink(LPCSTR str1, LONG u, LPCSTR str2, LPCSTR str3)
00618 {
00619     WINE_FIXME("(\"%s\", %u, \"%s\", \"%s\")\n", str1, u, str2, str3);
00620 }
00621 
00622 static void CALLBACK MACRO_Menu(void)
00623 {
00624     WINE_FIXME("()\n");
00625 }
00626 
00627 static void CALLBACK MACRO_MPrintHash(LONG u)
00628 {
00629     WINE_FIXME("(%u)\n", u);
00630 }
00631 
00632 static void CALLBACK MACRO_MPrintID(LPCSTR str)
00633 {
00634     WINE_FIXME("(\"%s\")\n", str);
00635 }
00636 
00637 static void CALLBACK MACRO_Next(void)
00638 {
00639     WINHELP_WNDPAGE     wp;
00640 
00641     WINE_TRACE("()\n");
00642     wp.page = MACRO_CurrentWindow()->page;
00643     wp.page = HLPFILE_PageByOffset(wp.page->file, wp.page->browse_fwd, &wp.relative);
00644     if (wp.page)
00645     {
00646         wp.page->file->wRefCount++;
00647         wp.wininfo = MACRO_CurrentWindow()->info;
00648         WINHELP_CreateHelpWindow(&wp, SW_NORMAL, TRUE);
00649     }
00650 }
00651 
00652 static void CALLBACK MACRO_NoShow(void)
00653 {
00654     WINE_FIXME("()\n");
00655 }
00656 
00657 void CALLBACK MACRO_PopupContext(LPCSTR str, LONG u)
00658 {
00659     WINE_FIXME("(\"%s\", %u)\n", str, u);
00660 }
00661 
00662 static void CALLBACK MACRO_PopupHash(LPCSTR str, LONG u)
00663 {
00664     WINE_FIXME("(\"%s\", %u)\n", str, u);
00665 }
00666 
00667 static void CALLBACK MACRO_PopupId(LPCSTR str1, LPCSTR str2)
00668 {
00669     WINE_FIXME("(\"%s\", \"%s\")\n", str1, str2);
00670 }
00671 
00672 static void CALLBACK MACRO_PositionWindow(LONG i1, LONG i2, LONG u1, LONG u2, LONG u3, LPCSTR str)
00673 {
00674     WINE_FIXME("(%i, %i, %u, %u, %u, \"%s\")\n", i1, i2, u1, u2, u3, str);
00675 }
00676 
00677 static void CALLBACK MACRO_Prev(void)
00678 {
00679     WINHELP_WNDPAGE     wp;
00680 
00681     WINE_TRACE("()\n");
00682     wp.page = MACRO_CurrentWindow()->page;
00683     wp.page = HLPFILE_PageByOffset(wp.page->file, wp.page->browse_bwd, &wp.relative);
00684     if (wp.page)
00685     {
00686         wp.page->file->wRefCount++;
00687         wp.wininfo = MACRO_CurrentWindow()->info;
00688         WINHELP_CreateHelpWindow(&wp, SW_NORMAL, TRUE);
00689     }
00690 }
00691 
00692 void CALLBACK MACRO_Print(void)
00693 {
00694     PRINTDLG printer;
00695 
00696     WINE_TRACE("()\n");
00697 
00698     printer.lStructSize         = sizeof(printer);
00699     printer.hwndOwner           = MACRO_CurrentWindow()->hMainWnd;
00700     printer.hInstance           = Globals.hInstance;
00701     printer.hDevMode            = 0;
00702     printer.hDevNames           = 0;
00703     printer.hDC                 = 0;
00704     printer.Flags               = 0;
00705     printer.nFromPage           = 0;
00706     printer.nToPage             = 0;
00707     printer.nMinPage            = 0;
00708     printer.nMaxPage            = 0;
00709     printer.nCopies             = 0;
00710     printer.lCustData           = 0;
00711     printer.lpfnPrintHook       = 0;
00712     printer.lpfnSetupHook       = 0;
00713     printer.lpPrintTemplateName = 0;
00714     printer.lpSetupTemplateName = 0;
00715     printer.hPrintTemplate      = 0;
00716     printer.hSetupTemplate      = 0;
00717 
00718     if (PrintDlgA(&printer)) {
00719         WINE_FIXME("Print()\n");
00720     }
00721 }
00722 
00723 void CALLBACK MACRO_PrinterSetup(void)
00724 {
00725     WINE_FIXME("()\n");
00726 }
00727 
00728 static void CALLBACK MACRO_RegisterRoutine(LPCSTR dll_name, LPCSTR proc, LPCSTR args)
00729 {
00730     void               *fn = NULL;
00731     int                 size;
00732     WINHELP_DLL*        dll;
00733 
00734     WINE_TRACE("(\"%s\", \"%s\", \"%s\")\n", dll_name, proc, args);
00735 
00736     /* FIXME: are the registered DLLs global or linked to the current file ???
00737      * We assume globals (as we did for macros, but is this really the case ???)
00738      */
00739     for (dll = Globals.dlls; dll; dll = dll->next)
00740     {
00741         if (!strcmp(dll->name, dll_name)) break;
00742     }
00743     if (!dll)
00744     {
00745         HANDLE hLib = LoadLibrary(dll_name);
00746 
00747         /* FIXME: the library will not be unloaded until exit of program 
00748          * We don't send the DW_TERM message
00749          */
00750         WINE_TRACE("Loading %s\n", dll_name);
00751         /* FIXME: should look in the directory where current hlpfile
00752          * is loaded from
00753          */
00754         if (hLib == NULL)
00755         {
00756             /* FIXME: internationalisation for error messages */
00757             WINE_FIXME("Cannot find dll %s\n", dll_name);
00758         }
00759         else if ((dll = HeapAlloc(GetProcessHeap(), 0, sizeof(*dll))))
00760         {
00761             dll->hLib = hLib;
00762             dll->name = StrDup(dll_name); /* FIXME: never freed */
00763             dll->next = Globals.dlls;
00764             Globals.dlls = dll;
00765             dll->handler = (WINHELP_LDLLHandler)GetProcAddress(dll->hLib, "LDLLHandler");
00766             dll->class = dll->handler ? (dll->handler)(DW_WHATMSG, 0, 0) : DC_NOMSG;
00767             WINE_TRACE("Got class %x for DLL %s\n", dll->class, dll_name);
00768             if (dll->class & DC_INITTERM) dll->handler(DW_INIT, 0, 0);
00769             if (dll->class & DC_CALLBACKS) dll->handler(DW_CALLBACKS, (LONG_PTR)&Callbacks, 0);
00770         }
00771         else WINE_WARN("OOM\n");
00772     }
00773     if (dll && !(fn = GetProcAddress(dll->hLib, proc)))
00774     {
00775         /* FIXME: internationalisation for error messages */
00776         WINE_FIXME("Cannot find proc %s in dll %s\n", dll_name, proc);
00777     }
00778 
00779     size = ++MACRO_NumLoaded * sizeof(struct MacroDesc);
00780     if (!MACRO_Loaded) MACRO_Loaded = HeapAlloc(GetProcessHeap(), 0, size);
00781     else MACRO_Loaded = HeapReAlloc(GetProcessHeap(), 0, MACRO_Loaded, size);
00782     MACRO_Loaded[MACRO_NumLoaded - 1].name      = StrDup(proc); /* FIXME: never freed */
00783     MACRO_Loaded[MACRO_NumLoaded - 1].alias     = NULL;
00784     MACRO_Loaded[MACRO_NumLoaded - 1].isBool    = 0;
00785     MACRO_Loaded[MACRO_NumLoaded - 1].arguments = StrDup(args); /* FIXME: never freed */
00786     MACRO_Loaded[MACRO_NumLoaded - 1].fn        = fn;
00787     WINE_TRACE("Added %s(%s) at %p\n", proc, args, fn);
00788 }
00789 
00790 static void CALLBACK MACRO_RemoveAccelerator(LONG u1, LONG u2)
00791 {
00792     WINE_FIXME("(%u, %u)\n", u1, u2);
00793 }
00794 
00795 static void CALLBACK MACRO_ResetMenu(void)
00796 {
00797     WINE_FIXME("()\n");
00798 }
00799 
00800 static void CALLBACK MACRO_SaveMark(LPCSTR str)
00801 {
00802     WINE_FIXME("(\"%s\")\n", str);
00803 }
00804 
00805 static void CALLBACK MACRO_Search(void)
00806 {
00807     WINHELP_CreateIndexWindow(TRUE);
00808 }
00809 
00810 void CALLBACK MACRO_SetContents(LPCSTR str, LONG u)
00811 {
00812     WINE_FIXME("(\"%s\", %u)\n", str, u);
00813 }
00814 
00815 static void CALLBACK MACRO_SetHelpOnFile(LPCSTR str)
00816 {
00817     HLPFILE_PAGE*       page = MACRO_CurrentWindow()->page;
00818 
00819     WINE_TRACE("(\"%s\")\n", str);
00820 
00821     HeapFree(GetProcessHeap(), 0, page->file->help_on_file);
00822     page->file->help_on_file = HeapAlloc(GetProcessHeap(), 0, strlen(str) + 1);
00823     if (page->file->help_on_file)
00824         strcpy(page->file->help_on_file, str);
00825 }
00826 
00827 static void CALLBACK MACRO_SetPopupColor(LONG r, LONG g, LONG b)
00828 {
00829     HLPFILE_PAGE*       page = MACRO_CurrentWindow()->page;
00830 
00831     WINE_TRACE("(%x, %x, %x)\n", r, g, b);
00832     page->file->has_popup_color = TRUE;
00833     page->file->popup_color = RGB(r, g, b);
00834 }
00835 
00836 static void CALLBACK MACRO_ShellExecute(LPCSTR str1, LPCSTR str2, LONG u1, LONG u2, LPCSTR str3, LPCSTR str4)
00837 {
00838     WINE_FIXME("(\"%s\", \"%s\", %u, %u, \"%s\", \"%s\")\n", str1, str2, u1, u2, str3, str4);
00839 }
00840 
00841 static void CALLBACK MACRO_ShortCut(LPCSTR str1, LPCSTR str2, LONG w, LONG l, LPCSTR str)
00842 {
00843     WINE_FIXME("(\"%s\", \"%s\", %x, %x, \"%s\")\n", str1, str2, w, l, str);
00844 }
00845 
00846 static void CALLBACK MACRO_TCard(LONG u)
00847 {
00848     WINE_FIXME("(%u)\n", u);
00849 }
00850 
00851 static void CALLBACK MACRO_Test(LONG u)
00852 {
00853     WINE_FIXME("(%u)\n", u);
00854 }
00855 
00856 static BOOL CALLBACK MACRO_TestALink(LPCSTR str)
00857 {
00858     WINE_FIXME("(\"%s\")\n", str);
00859     return FALSE;
00860 }
00861 
00862 static BOOL CALLBACK MACRO_TestKLink(LPCSTR str)
00863 {
00864     WINE_FIXME("(\"%s\")\n", str);
00865     return FALSE;
00866 }
00867 
00868 static void CALLBACK MACRO_UncheckItem(LPCSTR str)
00869 {
00870     WINE_FIXME("(\"%s\")\n", str);
00871 }
00872 
00873 static void CALLBACK MACRO_UpdateWindow(LPCSTR str1, LPCSTR str2)
00874 {
00875     WINE_FIXME("(\"%s\", \"%s\")\n", str1, str2);
00876 }
00877 
00878 
00879 /**************************************************/
00880 /*               Macro table                      */
00881 /**************************************************/
00882 
00883 /* types:
00884  *      U:      32 bit unsigned int
00885  *      I:      32 bit signed int
00886  *      S:      string
00887  *      v:      unknown (32 bit entity)
00888  */
00889 
00890 static struct MacroDesc MACRO_Builtins[] = {
00891     {"About",               NULL, 0, "",       MACRO_About},
00892     {"AddAccelerator",      "AA", 0, "UUS",    MACRO_AddAccelerator},
00893     {"ALink",               "AL", 0, "SUS",    MACRO_ALink},
00894     {"Annotate",            NULL, 0, "",       MACRO_Annotate},
00895     {"AppendItem",          NULL, 0, "SSSS",   MACRO_AppendItem},
00896     {"Back",                NULL, 0, "",       MACRO_Back},
00897     {"BackFlush",           "BF", 0, "",       MACRO_BackFlush},
00898     {"BookmarkDefine",      NULL, 0, "",       MACRO_BookmarkDefine},
00899     {"BookmarkMore",        NULL, 0, "",       MACRO_BookmarkMore},
00900     {"BrowseButtons",       NULL, 0, "",       MACRO_BrowseButtons},
00901     {"ChangeButtonBinding", "CBB",0, "SS",     MACRO_ChangeButtonBinding},
00902     {"ChangeEnable",        "CE", 0, "SS",     MACRO_ChangeEnable},
00903     {"ChangeItemBinding",   "CIB",0, "SS",     MACRO_ChangeItemBinding},
00904     {"CheckItem",           "CI", 0, "S",      MACRO_CheckItem},
00905     {"CloseSecondarys",     "CS", 0, "",       MACRO_CloseSecondarys},
00906     {"CloseWindow",         "CW", 0, "S",      MACRO_CloseWindow},
00907     {"Compare",             NULL, 0, "S",      MACRO_Compare},
00908     {"Contents",            NULL, 0, "",       MACRO_Contents},
00909     {"ControlPanel",        NULL, 0, "SSU",    MACRO_ControlPanel},
00910     {"CopyDialog",          NULL, 0, "",       MACRO_CopyDialog},
00911     {"CopyTopic",           "CT", 0, "",       MACRO_CopyTopic},
00912     {"CreateButton",        "CB", 0, "SSS",    MACRO_CreateButton},
00913     {"DeleteItem",          NULL, 0, "S",      MACRO_DeleteItem},
00914     {"DeleteMark",          NULL, 0, "S",      MACRO_DeleteMark},
00915     {"DestroyButton",       NULL, 0, "S",      MACRO_DestroyButton},
00916     {"DisableButton",       "DB", 0, "S",      MACRO_DisableButton},
00917     {"DisableItem",         "DI", 0, "S",      MACRO_DisableItem},
00918     {"EnableButton",        "EB", 0, "S",      MACRO_EnableButton},
00919     {"EnableItem",          "EI", 0, "S",      MACRO_EnableItem},
00920     {"EndMPrint",           NULL, 0, "",       MACRO_EndMPrint},
00921     {"ExecFile",            "EF", 0, "SSUS",   MACRO_ExecFile},
00922     {"ExecProgram",         "EP", 0, "SU",     MACRO_ExecProgram},
00923     {"Exit",                NULL, 0, "",       MACRO_Exit},
00924     {"ExtAbleItem",         NULL, 0, "SU",     MACRO_ExtAbleItem},
00925     {"ExtInsertItem",       NULL, 0, "SSSSUU", MACRO_ExtInsertItem},
00926     {"ExtInsertMenu",       NULL, 0, "SSSUU",  MACRO_ExtInsertMenu},
00927     {"FileExist",           "FE", 1, "S",      MACRO_FileExist},
00928     {"FileOpen",            "FO", 0, "",       MACRO_FileOpen},
00929     {"Find",                NULL, 0, "",       MACRO_Find},
00930     {"Finder",              "FD", 0, "",       MACRO_Finder},
00931     {"FloatingMenu",        NULL, 0, "",       MACRO_FloatingMenu},
00932     {"Flush",               "FH", 0, "",       MACRO_Flush},
00933     {"FocusWindow",         NULL, 0, "S",      MACRO_FocusWindow},
00934     {"Generate",            NULL, 0, "SUU",    MACRO_Generate},
00935     {"GotoMark",            NULL, 0, "S",      MACRO_GotoMark},
00936     {"HelpOn",              NULL, 0, "",       MACRO_HelpOn},
00937     {"HelpOnTop",           NULL, 0, "",       MACRO_HelpOnTop},
00938     {"History",             NULL, 0, "",       MACRO_History},
00939     {"InitMPrint",          NULL, 1, "",       MACRO_InitMPrint},
00940     {"InsertItem",          NULL, 0, "SSSSU",  MACRO_InsertItem},
00941     {"InsertMenu",          NULL, 0, "SSU",    MACRO_InsertMenu},
00942     {"IfThen",              "IF", 0, "BS",     MACRO_IfThen},
00943     {"IfThenElse",          "IE", 0, "BSS",    MACRO_IfThenElse},
00944     {"IsBook",              NULL, 1, "",       MACRO_IsBook},
00945     {"IsMark",              NULL, 1, "S",      MACRO_IsMark},
00946     {"IsNotMark",           "NM", 1, "S",      MACRO_IsNotMark},
00947     {"JumpContents",        NULL, 0, "SS",     MACRO_JumpContents},
00948     {"JumpContext",         "JC", 0, "SSU",    MACRO_JumpContext},
00949     {"JumpHash",            "JH", 0, "SSU",    MACRO_JumpHash},
00950     {"JumpHelpOn",          NULL, 0, "",       MACRO_JumpHelpOn},
00951     {"JumpID",              "JI", 0, "SS",     MACRO_JumpID},
00952     {"JumpKeyword",         "JK", 0, "SSS",    MACRO_JumpKeyword},
00953     {"KLink",               "KL", 0, "SUSS",   MACRO_KLink},
00954     {"Menu",                "MU", 0, "",       MACRO_Menu},
00955     {"MPrintHash",          NULL, 0, "U",      MACRO_MPrintHash},
00956     {"MPrintID",            NULL, 0, "S",      MACRO_MPrintID},
00957     {"Next",                NULL, 0, "",       MACRO_Next},
00958     {"NoShow",              "NS", 0, "",       MACRO_NoShow},
00959     {"PopupContext",        "PC", 0, "SU",     MACRO_PopupContext},
00960     {"PopupHash",           NULL, 0, "SU",     MACRO_PopupHash},
00961     {"PopupId",             "PI", 0, "SS",     MACRO_PopupId},
00962     {"PositionWindow",      "PW", 0, "IIUUUS", MACRO_PositionWindow},
00963     {"Prev",                NULL, 0, "",       MACRO_Prev},
00964     {"Print",               NULL, 0, "",       MACRO_Print},
00965     {"PrinterSetup",        NULL, 0, "",       MACRO_PrinterSetup},
00966     {"RegisterRoutine",     "RR", 0, "SSS",    MACRO_RegisterRoutine},
00967     {"RemoveAccelerator",   "RA", 0, "UU",     MACRO_RemoveAccelerator},
00968     {"ResetMenu",           NULL, 0, "",       MACRO_ResetMenu},
00969     {"SaveMark",            NULL, 0, "S",      MACRO_SaveMark},
00970     {"Search",              NULL, 0, "",       MACRO_Search},
00971     {"SetContents",         NULL, 0, "SU",     MACRO_SetContents},
00972     {"SetHelpOnFile",       NULL, 0, "S",      MACRO_SetHelpOnFile},
00973     {"SetPopupColor",       "SPC",0, "UUU",    MACRO_SetPopupColor},
00974     {"ShellExecute",        "SE", 0, "SSUUSS", MACRO_ShellExecute},
00975     {"ShortCut",            "SH", 0, "SSUUS",  MACRO_ShortCut},
00976     {"TCard",               NULL, 0, "U",      MACRO_TCard},
00977     {"Test",                NULL, 0, "U",      MACRO_Test},
00978     {"TestALink",           NULL, 1, "S",      MACRO_TestALink},
00979     {"TestKLink",           NULL, 1, "S",      MACRO_TestKLink},
00980     {"UncheckItem",         "UI", 0, "S",      MACRO_UncheckItem},
00981     {"UpdateWindow",        "UW", 0, "SS",     MACRO_UpdateWindow},
00982     {NULL,                  NULL, 0, NULL,     NULL}
00983 };
00984 
00985 static int MACRO_DoLookUp(struct MacroDesc* start, const char* name, struct lexret* lr, unsigned len)
00986 {
00987     struct MacroDesc*   md;
00988 
00989     for (md = start; md->name && len != 0; md++, len--)
00990     {
00991         if (strcasecmp(md->name, name) == 0 || (md->alias != NULL && strcasecmp(md->alias, name) == 0))
00992         {
00993             lr->proto = md->arguments;
00994             lr->function = md->fn;
00995             return md->isBool ? BOOL_FUNCTION : VOID_FUNCTION;
00996         }
00997     }
00998     return EMPTY;
00999 }
01000 
01001 int MACRO_Lookup(const char* name, struct lexret* lr)
01002 {
01003     int ret;
01004 
01005     if ((ret = MACRO_DoLookUp(MACRO_Builtins, name, lr, -1)) != EMPTY)
01006         return ret;
01007     if (MACRO_Loaded && (ret = MACRO_DoLookUp(MACRO_Loaded, name, lr, MACRO_NumLoaded)) != EMPTY)
01008         return ret;
01009 
01010     lr->string = name;
01011     return IDENTIFIER;
01012 }

Generated on Sun May 27 2012 04:17:48 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.