home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Source / tokens.cpp < prev    next >
C/C++ Source or Header  |  2004-01-30  |  22KB  |  360 lines

  1. #include "Platform.h"
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. #include "build.h"
  6. #include "tokens.h"
  7.  
  8. // token placement
  9. #define TP_SEC    1
  10. #define TP_FUNC   2
  11. #define TP_CODE   (TP_SEC | TP_FUNC)
  12. #define TP_GLOBAL 4
  13. #define TP_PAGEEX 8
  14. #define TP_PG     (TP_GLOBAL | TP_PAGEEX)
  15. #define TP_ALL    (TP_CODE | TP_PG)
  16.  
  17. typedef struct 
  18. {
  19.   int id;
  20.   char *name;
  21.   int num_parms; // minimum number of parameters
  22.   int opt_parms; // optional parmaters, usually 0, can be -1 for unlimited.
  23.   char *usage_str;
  24.   int placement; // where the token can be placed
  25. } tokenType;
  26.  
  27.  
  28. static tokenType tokenlist[TOK__LAST] =
  29. {
  30. {TOK_ABORT,"Abort",0,1,"[message]",TP_CODE},
  31. {TOK_ADDBRANDINGIMAGE,"AddBrandingImage",2,1,"(top|left|bottom|right) (height|width) [padding]",TP_GLOBAL},
  32. {TOK_ADDSIZE,"AddSize",1,0,"size_to_add_to_section_in_kb",TP_SEC},
  33. {TOK_AUTOCLOSE,"AutoCloseWindow",1,0,"(false|true)",TP_GLOBAL},
  34. {TOK_BGGRADIENT,"BGGradient",0,3,"(off | [top_color [bottom_color [text_color]]])",TP_GLOBAL},
  35. {TOK_BRANDINGTEXT,"BrandingText",1,1,"[/TRIM(LEFT|RIGHT|CENTER)] installer_text",TP_GLOBAL},
  36. {TOK_BRINGTOFRONT,"BringToFront",0,0,"",TP_CODE},
  37. {TOK_CALL,"Call",1,0,"function_name | [:label_name]",TP_CODE},
  38. {TOK_CALLINSTDLL,"CallInstDLL",2,1,"dll_path_on_target.dll [/NOUNLOAD] function",TP_CODE},
  39. {TOK_CAPTION,"Caption",1,0,"installer_caption",TP_GLOBAL|TP_PAGEEX},
  40. {TOK_CHANGEUI,"ChangeUI",1,1,"[/RTL] (all|dlg_id) ui_file.exe",TP_GLOBAL},
  41. {TOK_CLEARERRORS,"ClearErrors",0,0,"",TP_CODE},
  42. {TOK_COMPTEXT,"ComponentText",0,3,"[component_page_description] [component_subtext1] [component_subtext2]",TP_PG},
  43. {TOK_GETDLLVERSION,"GetDLLVersion",3,0,"filename $(user_var: high output) $(user_var: low output)",TP_CODE},
  44. {TOK_GETDLLVERSIONLOCAL,"GetDLLVersionLocal",3,0,"localfilename $(user_var: high output) $(user_var: low output)",TP_CODE},
  45. {TOK_GETFILETIME,"GetFileTime",3,0,"file $(user_var: high output) $(user_var: low output)",TP_CODE},
  46. {TOK_GETFILETIMELOCAL,"GetFileTimeLocal",3,0,"localfile $(user_var: high output) $(user_var: low output)",TP_CODE},
  47. {TOK_COPYFILES,"CopyFiles",2,3,"[/SILENT] [/FILESONLY] source_path destination_path [total_size_in_kb]",TP_CODE},
  48. {TOK_CRCCHECK,"CRCCheck",1,0,"(on|force|off)",TP_GLOBAL},
  49. {TOK_CREATEDIR,"CreateDirectory",1,0,"directory_name",TP_CODE},
  50. {TOK_CREATEFONT,"CreateFont",2,5,"$(user_var: handle output) face_name [height wieght /ITALIC /UNDERLINE /STRIKE]",TP_CODE},
  51. {TOK_CREATESHORTCUT,"CreateShortCut",2,6,"shortcut_name.lnk shortcut_target [parameters [icon_file [icon index [showmode [hotkey [comment]]]]]]\n    showmode=(SW_SHOWNORMAL|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED)\n    hotkey=(ALT|CONTROL|EXT|SHIFT)|(F1-F24|A-Z)",TP_CODE},
  52. {TOK_DBOPTIMIZE,"SetDatablockOptimize",1,0,"(off|on)",TP_ALL},
  53. {TOK_DELETEINISEC,"DeleteINISec",2,0,"ini_file section_name",TP_CODE},
  54. {TOK_DELETEINISTR,"DeleteINIStr",3,0,"ini_file section_name entry_name",TP_CODE},
  55. {TOK_DELETEREGKEY,"DeleteRegKey",2,1,"[/ifempty] root_key subkey\n    root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_CODE},
  56. {TOK_DELETEREGVALUE,"DeleteRegValue",3,0,"root_key subkey entry_name\n    root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_CODE},
  57. {TOK_DELETE,"Delete",1,1,"[/REBOOTOK] filespec",TP_CODE},
  58. {TOK_DETAILPRINT,"DetailPrint",1,0,"message",TP_CODE},
  59. {TOK_DIRTEXT,"DirText",0,4,"[directory_page_description] [directory_page_subtext] [browse_button_text] [browse_dlg_text]",TP_PG},
  60. //{TOK_DIRSHOW,"DirShow",1,0,"(show|hide)",TP_PG},
  61. {TOK_DIRSHOW,"DirShow",0,0,"doesn't currently work",TP_ALL},
  62. {TOK_DIRVAR,"DirVar",1,0,"$(user_var: dir in/out))",TP_PAGEEX},
  63. {TOK_DIRVERIFY,"DirVerify",1,0,"auto|leave",TP_PAGEEX},
  64. {TOK_GETINSTDIRERROR,"GetInstDirError",1,0,"$(user_var: error output)",TP_CODE},
  65. {TOK_ROOTDIRINST,"AllowRootDirInstall",1,0,"(true|false)",TP_GLOBAL},
  66. {TOK_CHECKBITMAP,"CheckBitmap",1,0,"local_bitmap.bmp",TP_GLOBAL},
  67. {TOK_ENABLEWINDOW,"EnableWindow",2,0,"hwnd (1|0)",TP_CODE},
  68. {TOK_ENUMREGKEY,"EnumRegKey",4,0,"$(user_var: output) rootkey subkey index\n    root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_CODE},
  69. {TOK_ENUMREGVAL,"EnumRegValue",4,0,"$(user_var: output) rootkey subkey index\n    root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_CODE},
  70. {TOK_EXCH,"Exch",0,1,"[$(user_var)] | [stack_item_index]",TP_CODE},
  71. {TOK_EXEC,"Exec",1,0,"command_line",TP_CODE},
  72. {TOK_EXECWAIT,"ExecWait",1,1,"command_line [$(user_var: return value)]",TP_CODE},
  73. {TOK_EXECSHELL,"ExecShell",2,2,"(open|print|etc) command_line [parameters [showmode]]\n   showmode=(SW_SHOWNORMAL|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED)",TP_CODE},
  74. {TOK_EXPANDENVSTRS,"ExpandEnvStrings",2,0,"$(user_var: output) string",TP_CODE},
  75. {TOK_FINDWINDOW,"FindWindow",2,3,"$(user_var: handle output) WindowClass [WindowTitle] [Window_Parent] [Child_After]",TP_CODE},
  76. {TOK_FINDCLOSE,"FindClose",1,0,"$(user_var: handle input)",TP_CODE},
  77. {TOK_FINDFIRST,"FindFirst",3,0,"$(user_var: handle output) $(user_var: filename output) filespec",TP_CODE},
  78. {TOK_FINDNEXT,"FindNext",2,0,"$(user_var: handle input) $(user_var: filename output)",TP_CODE},
  79. {TOK_FILE,"File",1,-1,"[/nonfatal] [/a] ([/r] filespec [...]|/oname=outfile one_file_only)",TP_CODE},
  80. {TOK_FILEBUFSIZE,"FileBufSize",1,0,"buf_size_mb",TP_ALL},
  81. {TOK_FLUSHINI,"FlushINI",1,0,"ini_file",TP_CODE},
  82. {TOK_RESERVEFILE,"ReserveFile",1,-1,"[/nonfatal] [/r] file [file...]",TP_ALL},
  83. {TOK_FILECLOSE,"FileClose",1,0,"$(user_var: handle input)",TP_CODE},
  84. {TOK_FILEERRORTEXT,"FileErrorText",0,2,"[text (can contain $0)] [text without ignore (can contain $0)]",TP_GLOBAL},
  85. {TOK_FILEOPEN,"FileOpen",3,0,"$(user_var: handle output) filename openmode\n   openmode=r|w|a",TP_CODE},
  86. {TOK_FILEREAD,"FileRead",2,1,"$(user_var: handle input) $(user_var: text output) [maxlen]",TP_CODE},
  87. {TOK_FILEWRITE,"FileWrite",2,0,"$(user_var: handle input) text",TP_CODE},
  88. {TOK_FILEREADBYTE,"FileReadByte",2,0,"$(user_var: handle input) $(user_var: bytevalue output)",TP_CODE},
  89. {TOK_FILEWRITEBYTE,"FileWriteByte",2,0,"$(user_var: handle input) bytevalue",TP_CODE},
  90. {TOK_FILESEEK,"FileSeek",2,2,"$(user_var: handle input) offset [mode] [$(user_var: new position output)]\n    mode=SET|CUR|END",TP_CODE},
  91. {TOK_FUNCTION,"Function",1,0,"function_name",TP_GLOBAL},
  92. {TOK_FUNCTIONEND,"FunctionEnd",0,0,"",TP_FUNC},
  93. {TOK_GETDLGITEM,"GetDlgItem",3,0,"$(user_var: handle output) dialog item_id",TP_CODE},
  94. {TOK_GETFULLPATHNAME,"GetFullPathName",2,1,"[/SHORT] $(user_var: result) path_or_file",TP_CODE},
  95. {TOK_GETTEMPFILENAME,"GetTempFileName",1,1,"$(user_var: name output) [base_dir]",TP_CODE},
  96. {TOK_HIDEWINDOW,"HideWindow",0,0,"",TP_CODE},
  97. {TOK_ICON,"Icon",1,0,"local_icon.ico",TP_GLOBAL},
  98. {TOK_IFABORT,"IfAbort",1,1,"label_to_goto_if_abort [label_to_goto_if_no_abort]",TP_CODE},
  99. {TOK_IFERRORS,"IfErrors",1,1,"label_to_goto_if_errors [label_to_goto_if_no_errors]",TP_CODE},
  100. {TOK_IFFILEEXISTS,"IfFileExists",2,1,"filename label_to_goto_if_file_exists [label_to_goto_otherwise]",TP_CODE},
  101. {TOK_IFREBOOTFLAG,"IfRebootFlag",1,1,"jump_if_set [jump_if_not_set]",TP_CODE},
  102. {TOK_IFSILENT,"IfSilent",1,1,"jump_if_silent [jump_if_not_silent]",TP_CODE},
  103. {TOK_INSTALLDIRREGKEY,"InstallDirRegKey",3,0,"root_key subkey entry_name\n    root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_GLOBAL},
  104. {TOK_INSTCOLORS,"InstallColors",1,1,"(/windows | (foreground_color background_color))",TP_GLOBAL},
  105. {TOK_INSTDIR,"InstallDir",1,0,"default_install_directory",TP_GLOBAL},
  106. {TOK_INSTPROGRESSFLAGS,"InstProgressFlags",0,-1,"[flag [...]]\n    flag={smooth|colored}",TP_GLOBAL},
  107. {TOK_INSTTYPE,"InstType",1,0,"[un.]install_type_name | /NOCUSTOM | /CUSTOMSTRING=str | /COMPONENTSONLYONCUSTOM",TP_GLOBAL},
  108. {TOK_INTOP,"IntOp",3,1,"$(user_var: result) val1 OP [val2]\n    OP=(+ - * / % | & ^ ~ ! || &&)",TP_CODE},
  109. {TOK_INTCMP,"IntCmp",3,2,"val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more]",TP_CODE},
  110. {TOK_INTCMPU,"IntCmpU",3,2,"val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more]",TP_CODE},
  111. {TOK_INTFMT,"IntFmt",3,0,"$(user_var: output) format_string input",TP_CODE},
  112. {TOK_ISWINDOW,"IsWindow",2,1,"hwnd jump_if_window [jump_if_not_window]",TP_CODE},
  113. {TOK_GOTO,"Goto",1,0,"label",TP_CODE},
  114. {TOK_LANGSTRING,"LangString",3,0,"[un.]name lang_id string",TP_GLOBAL},
  115. {TOK_LANGSTRINGUP,"LangStringUP",0,0,"obsolete, use LangString.",TP_ALL},
  116. {TOK_LICENSEDATA,"LicenseData",1,0,"local_file_that_has_license_text | license_lang_string",TP_PG},
  117. {TOK_LICENSEFORCESELECTION,"LicenseForceSelection",1,2,"(checkbox [accept_text] | radiobuttons [accept_text] [decline_text] | off)",TP_PG},
  118. {TOK_LICENSELANGSTRING,"LicenseLangString",3,0,"name lang_id license_path",TP_GLOBAL},
  119. {TOK_LICENSETEXT,"LicenseText",1,1,"license_page_description [license_button_text]",TP_PG},
  120. {TOK_LICENSEBKCOLOR,"LicenseBkColor",1,0,"background_color",TP_GLOBAL},
  121. {TOK_LOADNLF,"LoadLanguageFile",1,0,"language.nlf",TP_GLOBAL},
  122. {TOK_LOGSET,"LogSet",1,0,"on|off",TP_CODE},
  123. {TOK_LOGTEXT,"LogText",1,0,"text",TP_CODE},
  124. {TOK_MESSAGEBOX,"MessageBox",2,6,"mode messagebox_text [/SD return] [return_check label_to_goto_if_equal [return_check2 label2]]\n    mode=modeflag[|modeflag[|modeflag[...]]]\n    "
  125.                                 "modeflag=(MB_ABORTRETRYIGNORE|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_YESNO|MB_YESNOCANCEL|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND|MB_RIGHT",TP_CODE},
  126. {TOK_NOP,"Nop",0,0,"",TP_CODE},
  127. {TOK_NAME,"Name",1,1,"installer_name installer_name_doubled_ampersands",TP_GLOBAL},
  128. {TOK_OUTFILE,"OutFile",1,0,"install_output.exe",TP_GLOBAL},
  129. #ifdef NSIS_SUPPORT_CODECALLBACKS
  130. {TOK_PAGE,"Page",1,4,"((custom [creator_function] [leave_function] [caption]) | ((license|components|directory|instfiles|uninstConfirm) [pre_function] [show_function] [leave_function]))",TP_GLOBAL},
  131. #else
  132. {TOK_PAGE,"Page",1,1,"license|components|directory|instfiles|uninstConfirm",TP_GLOBAL},
  133. #endif
  134. {TOK_PAGECALLBACKS,"PageCallbacks",0,3,"([creator_function] [leave_function]) | ([pre_function] [show_function] [leave_function])",TP_PAGEEX},
  135. {TOK_PAGEEX,"PageEx",1,0,"[un.](custom|uninstConfirm|license|components|directory|instfiles)",TP_GLOBAL},
  136. {TOK_PAGEEXEND,"PageExEnd",0,0,"",TP_PAGEEX},
  137. {TOK_POP,"Pop",1,0,"$(user_var: output)",TP_CODE},
  138. {TOK_PUSH,"Push",1,0,"string",TP_CODE},
  139. {TOK_QUIT,"Quit",0,0,"",TP_CODE},
  140. {TOK_READINISTR,"ReadINIStr",4,0,"$(user_var: output) ini_file section entry_name",TP_CODE},
  141. {TOK_READREGDWORD,"ReadRegDWORD",4,0,"$(user_var: output) rootkey subkey entry\n   root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_CODE},
  142. {TOK_READREGSTR,"ReadRegStr",4,0,"$(user_var: output) rootkey subkey entry\n   root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_CODE},
  143. {TOK_READENVSTR,"ReadEnvStr",2,0,"$(user_var: output) name",TP_CODE},
  144. {TOK_REBOOT,"Reboot",0,0,"",TP_CODE},
  145. {TOK_REGDLL,"RegDLL",1,1,"dll_path_on_target.dll [entrypoint_symbol]",TP_CODE},
  146. {TOK_RENAME,"Rename",2,1,"[/REBOOTOK] source_file destination_file",TP_CODE},
  147. {TOK_RET,"Return",0,0,"",TP_CODE},
  148. {TOK_RMDIR,"RMDir",1,1,"[/r|/REBOOTOK] directory_name",TP_CODE},
  149. {TOK_SECTION,"Section",0,3,"[/0] [-][un.][section_name] [section index output]",TP_GLOBAL},
  150. {TOK_SECTIONEND,"SectionEnd",0,0,"",TP_SEC},
  151. {TOK_SECTIONIN,"SectionIn",1,-1,"InstTypeIdx [InstTypeIdx [...]]",TP_SEC},
  152. {TOK_SUBSECTION,"SubSection",1,2,"[/e] [un.]subsection_name [section index output]",TP_GLOBAL},
  153. {TOK_SUBSECTIONEND,"SubSectionEnd",0,0,"",TP_GLOBAL},
  154. {TOK_SEARCHPATH,"SearchPath",2,0,"$(user_var: result) filename",TP_CODE},
  155. {TOK_SECTIONSETFLAGS,"SectionSetFlags",2,0,"section_index flags",TP_CODE},
  156. {TOK_SECTIONGETFLAGS,"SectionGetFlags",2,0,"section_index $(user_var: output flags)",TP_CODE},
  157. {TOK_SECTIONSETINSTTYPES,"SectionSetInstTypes",2,0,"section_index inst_types",TP_CODE},
  158. {TOK_SECTIONGETINSTTYPES,"SectionGetInstTypes",2,0,"section_index $(user_var: output inst_types)",TP_CODE},
  159. {TOK_SECTIONGETTEXT,"SectionGetText",2,0,"section_index $(user_var: output text)",TP_CODE},
  160. {TOK_SECTIONSETTEXT,"SectionSetText",2,0,"section_index text_string",TP_CODE},
  161. {TOK_SECTIONGETSIZE,"SectionGetSize",2,0,"section_index $(user_var: output size)",TP_CODE},
  162. {TOK_SECTIONSETSIZE,"SectionSetSize",2,0,"section_index new_size",TP_CODE},
  163. {TOK_GETCURINSTTYPE,"GetCurInstType",1,0,"$(user_var: output inst_type_idx)",TP_CODE},
  164. {TOK_SETCURINSTTYPE,"SetCurInstType",1,0,"inst_type_idx",TP_CODE},
  165. {TOK_INSTTYPESETTEXT,"InstTypeSetText",2,0,"insttype_index flags",TP_CODE},
  166. {TOK_INSTTYPEGETTEXT,"InstTypeGetText",2,0,"insttype_index $(user_var: output flags)",TP_CODE},
  167. {TOK_SENDMESSAGE,"SendMessage",4,2,"hwnd message [wparam|STR:wParam] [lparam|STR:lParam] [$(user_var: return value)] [/TIMEOUT=X]",TP_CODE},
  168. {TOK_SETAUTOCLOSE,"SetAutoClose",1,0,"(false|true)",TP_CODE},
  169. {TOK_SETCTLCOLORS,"SetCtlColors",2,2,"hwnd [/BRANDING] [text_color] [transparent|bg_color]",TP_CODE},
  170. {TOK_SETBRANDINGIMAGE,"SetBrandingImage",1,2,"[/IMGID=image_item_id_in_dialog] [/RESIZETOFIT] bitmap.bmp",TP_CODE},
  171. {TOK_SETCOMPRESS,"SetCompress",1,0,"(off|auto|force)",TP_ALL},
  172. {TOK_SETCOMPRESSOR,"SetCompressor",1,1,"[/FINAL] (zlib|bzip2|lzma)",TP_GLOBAL},
  173. {TOK_SETCOMPRESSORDICTSIZE,"SetCompressorDictSize",1,0,"dict_size_mb",TP_ALL},
  174. {TOK_SETCOMPRESSIONLEVEL,"SetCompressionLevel",1,0,"level_0-9",TP_ALL},
  175. {TOK_SETDATESAVE,"SetDateSave",1,0,"(off|on)",TP_ALL},
  176. {TOK_SETDETAILSVIEW,"SetDetailsView",1,0,"(hide|show)",TP_CODE},
  177. {TOK_SETDETAILSPRINT,"SetDetailsPrint",1,0,"(none|listonly|textonly|both)",TP_CODE},
  178. {TOK_SETERRORS,"SetErrors",0,0,"",TP_CODE},
  179. {TOK_SETFILEATTRIBUTES,"SetFileAttributes",2,0,"file attribute[|attribute[...]]\n    attribute=(NORMAL|ARCHIVE|HIDDEN|OFFLINE|READONLY|SYSTEM|TEMPORARY|0)",TP_CODE},
  180. {TOK_SETFONT,"SetFont",2,1,"[/LANG=lang_id] font_face_name font_size",TP_GLOBAL},
  181. {TOK_SETOUTPATH,"SetOutPath",1,0,"output_path",TP_CODE},
  182. {TOK_SETOVERWRITE,"SetOverwrite",1,0,"on|off|try|ifnewer|ifdiff",TP_ALL},
  183. {TOK_SETPLUGINUNLOAD,"SetPluginUnload",1,0,"(manual|alwaysoff)",TP_ALL},
  184. {TOK_SETREBOOTFLAG,"SetRebootFlag",1,0,"true|false",TP_CODE},
  185. {TOK_SETSHELLVARCONTEXT,"SetShellVarContext",1,0,"all|current",TP_CODE},
  186. {TOK_SETSILENT,"SetSilent",1,0,"silent|normal",TP_CODE},
  187. {TOK_SHOWDETAILS,"ShowInstDetails",1,0,"(hide|show|nevershow)",TP_GLOBAL},
  188. {TOK_SHOWDETAILSUNINST,"ShowUninstDetails",1,0,"(hide|show|nevershow)",TP_GLOBAL},
  189. {TOK_SHOWWINDOW,"ShowWindow",2,0,"hwnd show_state",TP_CODE},
  190. {TOK_SILENTINST,"SilentInstall",1,0,"(normal|silent|silentlog)",TP_GLOBAL},
  191. {TOK_SILENTUNINST,"SilentUnInstall",1,0,"(normal|silent)",TP_GLOBAL},
  192. {TOK_SLEEP,"Sleep",1,0,"sleep_time_in_ms",TP_CODE},
  193. {TOK_STRCMP,"StrCmp",3,1,"str1 str2 label_to_goto_if_equal [label_to_goto_if_not]",TP_CODE},
  194. {TOK_STRCPY,"StrCpy",2,2,"$(user_var: output) str [maxlen] [startoffset]",TP_CODE},
  195. {TOK_STRLEN,"StrLen",2,0,"$(user_var: length output) str",TP_CODE},
  196. {TOK_SUBCAPTION,"SubCaption",2,0,"page_number(0-4) new_subcaption",TP_GLOBAL},
  197. {TOK_UNINSTALLEXENAME,"UninstallExeName",0,0,"no longer supported, use WriteUninstaller from section.",TP_ALL},
  198. {TOK_UNINSTCAPTION,"UninstallCaption",1,0,"uninstaller_caption",TP_GLOBAL},
  199. {TOK_UNINSTICON,"UninstallIcon",1,0,"icon_on_local_system.ico",TP_GLOBAL},
  200. #ifdef NSIS_SUPPORT_CODECALLBACKS
  201. {TOK_UNINSTPAGE,"UninstPage",1,4,"((custom [creator_function] [leave_function] [caption]) | ((license|components|directory|instfiles|uninstConfirm) [pre_function] [show_function] [leave_function]))",TP_GLOBAL},
  202. #else
  203. {TOK_UNINSTPAGE,"UninstPage",1,1,"license|components|directory|instfiles|uninstConfirm",TP_GLOBAL},
  204. #endif
  205. {TOK_UNINSTTEXT,"UninstallText",1,1,"Text_to_go_on_uninstall_page [subtext]",TP_PG},
  206. {TOK_UNINSTSUBCAPTION,"UninstallSubCaption",2,0,"page_number(0-2) new_subcaption",TP_GLOBAL},
  207. {TOK_UNREGDLL,"UnRegDLL",1,0,"dll_path_on_target.dll",TP_CODE},
  208. {TOK_WINDOWICON,"WindowIcon",1,0,"on|off",TP_GLOBAL},
  209. {TOK_WRITEINISTR,"WriteINIStr",4,0,"ini_file section_name entry_name new_value",TP_CODE},
  210. {TOK_WRITEREGBIN,"WriteRegBin",4,0,"rootkey subkey entry_name hex_string_like_12848412AB\n    root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_CODE},
  211. {TOK_WRITEREGDWORD,"WriteRegDWORD",4,0,"rootkey subkey entry_name new_value_dword\n    root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_CODE},
  212. {TOK_WRITEREGSTR,"WriteRegStr",4,0,"rootkey subkey entry_name new_value_string\n    root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_CODE},
  213. {TOK_WRITEREGEXPANDSTR,"WriteRegExpandStr",4,0,"rootkey subkey entry_name new_value_string\n    root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)",TP_CODE},
  214. {TOK_WRITEUNINSTALLER,"WriteUninstaller",1,0,"uninstall_exe_name",TP_CODE},
  215. {TOK_XPSTYLE, "XPStyle",1,0,"(on|off)",TP_GLOBAL},
  216. {TOK_P_PACKEXEHEADER,"!packhdr",2,0,"temp_file_name command_line_to_compress_that_temp_file",TP_ALL},
  217. {TOK_P_SYSTEMEXEC,"!system",1,2,"command [<|>|<>|=) retval]",TP_ALL},
  218. {TOK_P_ADDINCLUDEDIR,"!AddIncludeDir",1,0,"dir",TP_ALL},
  219. {TOK_P_INCLUDE,"!include",1,0,"filename.nsi",TP_ALL},
  220. {TOK_P_CD,"!cd",1,0,"absolute_or_relative_new_directory",TP_ALL},
  221. {TOK_P_IFDEF,"!ifdef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]",TP_ALL},
  222. {TOK_P_IFNDEF,"!ifndef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]",TP_ALL},
  223. {TOK_P_ENDIF,"!endif",0,0,"",TP_ALL},
  224. {TOK_P_DEFINE,"!define",1,1,"symbol [value]",TP_ALL},
  225. {TOK_P_UNDEF,"!undef",1,1,"symbol [value]",TP_ALL},
  226. {TOK_P_ELSE,"!else",0,-1,"[ifdef|ifndef symbol [|symbol2 [& symbol3 [...]]]]",TP_ALL},
  227. {TOK_P_ECHO,"!echo",1,0,"message",TP_ALL},
  228. {TOK_P_WARNING,"!warning",0,1,"[warning_message]",TP_ALL},
  229. {TOK_P_ERROR,"!error",0,1,"[error_message]",TP_ALL},
  230.  
  231. {TOK_P_VERBOSE,"!verbose",1,0,"verbose_level | push | pop",TP_ALL},
  232.  
  233. {TOK_P_MACRO,"!macro",1,-1,"macroname [parms ...]",TP_ALL},
  234. {TOK_P_MACROEND,"!macroend",0,0,"",TP_ALL},
  235. {TOK_P_INSERTMACRO,"!insertmacro",1,-1,"macroname [parms ...]",TP_ALL},
  236. {TOK_P_IFMACRODEF,"!ifmacrodef",1,-1,"macro [| macro2 [& macro3 [...]]]",TP_ALL},
  237. {TOK_P_IFMACRONDEF,"!ifmacrondef",1,-1,"macro [| macro2 [& macro3 [...]]]",TP_ALL},
  238.  
  239. {TOK_MISCBUTTONTEXT,"MiscButtonText",0,4,"[back button text] [next button text] [cancel button text] [close button text]",TP_GLOBAL},
  240. {TOK_DETAILSBUTTONTEXT,"DetailsButtonText",0,1,"[details button text]",TP_PG},
  241. {TOK_UNINSTBUTTONTEXT,"UninstallButtonText",0,1,"[uninstall button text]",TP_GLOBAL},
  242. {TOK_INSTBUTTONTEXT,"InstallButtonText",0,1,"[install button text]",TP_GLOBAL},
  243. {TOK_SPACETEXTS,"SpaceTexts",0,2,"none | ([space required text] [space available text])",TP_GLOBAL},
  244. {TOK_COMPLETEDTEXT,"CompletedText",0,2,"[completed text]",TP_PG},
  245.  
  246. {TOK_GETFUNCTIONADDR,"GetFunctionAddress",2,0,"output function",TP_CODE},
  247. {TOK_GETLABELADDR,"GetLabelAddress",2,0,"output label",TP_CODE},
  248. {TOK_GETCURRENTADDR,"GetCurrentAddress",1,0,"output",TP_CODE},
  249.  
  250. {TOK_PLUGINDIR,"!AddPluginDir",1,0,"new_plugin_directory",TP_ALL},
  251. {TOK_INITPLUGINSDIR,"InitPluginsDir",0,0,"",TP_CODE},
  252. // Added by ramon 23 May 2003
  253. {TOK_ALLOWSKIPFILES,"AllowSkipFiles",1,0,"(off|on)",TP_ALL},
  254. // Added by ramon 3 jun 2003
  255. {TOK_DEFVAR,"Var",1,0,"VarName",TP_GLOBAL},
  256. // Added by ramon 6 jun 2003
  257. {TOK_VI_ADDKEY,"VIAddVersionKey",2,1,"/LANG=lang_id keyname value",TP_GLOBAL},
  258. {TOK_VI_SETPRODUCTVERSION,"VIProductVersion",1,0,"[version_string_X.X.X.X]",TP_GLOBAL},
  259. {TOK_LOCKWINDOW,"LockWindow",1,0,"(on|off)",TP_CODE},
  260. };
  261.  
  262. void CEXEBuild::print_help(char *commandname)
  263. {
  264.   int x;
  265.   for (x = 0; x < TOK__LAST; x ++)
  266.   {
  267.     if (!commandname || !stricmp(tokenlist[x].name,commandname))
  268.     {
  269.       ERROR_MSG("%s%s %s\n",commandname?"Usage: ":"",tokenlist[x].name,tokenlist[x].usage_str);
  270.       if (commandname) break;
  271.     }
  272.   }
  273.   if (x == TOK__LAST && commandname)
  274.   {
  275.     ERROR_MSG("Invalid command \"%s\"\n",commandname);
  276.   }
  277.  
  278. }
  279.  
  280. int CEXEBuild::get_commandtoken(char *s, int *np, int *op, int *pos)
  281. {
  282.   int x;
  283.   for (x = 0; x < TOK__LAST; x ++)
  284.     if (!stricmp(tokenlist[x].name,s)) 
  285.     {
  286.       *np=tokenlist[x].num_parms;
  287.       *op=tokenlist[x].opt_parms;
  288.       *pos=x;
  289.       return tokenlist[x].id;
  290.     }
  291.   return -1;
  292. }
  293.  
  294. int CEXEBuild::IsTokenPlacedRight(int pos, char *tok)
  295. {
  296.   if ((unsigned int) pos > (sizeof(tokenlist) / sizeof(tokenType)))
  297.     return PS_OK;
  298.  
  299.   int tp = tokenlist[pos].placement;
  300.   if (build_cursection && !build_cursection_isfunc)
  301.   {
  302.     // section
  303.     if (tp & TP_SEC)
  304.       return PS_OK;
  305.     ERROR_MSG("Error: command %s not valid in section\n", tok);
  306.     return PS_ERROR;
  307.   }
  308.   else if (build_cursection && build_cursection_isfunc)
  309.   {
  310.     // function
  311.     if (tp & TP_FUNC)
  312.       return PS_OK;
  313.     ERROR_MSG("Error: command %s not valid in function\n", tok);
  314.     return PS_ERROR;
  315.   }
  316.   else if (cur_page)
  317.   {
  318.     // pageex
  319.     if (tp & TP_PAGEEX)
  320.       return PS_OK;
  321.     ERROR_MSG("Error: command %s not valid in PageEx\n", tok);
  322.     return PS_ERROR;
  323.   }
  324.   else
  325.   {
  326.     // global
  327.     if (tp & TP_GLOBAL)
  328.       return PS_OK;
  329.     char err[1024];
  330.     strcpy(err, "Error: command %s not valid outside ");
  331.     if (tp & TP_SEC)
  332.       strcat(err, "section");
  333.     if (tp & TP_FUNC)
  334.     {
  335.       if (tp & TP_SEC)
  336.       {
  337.         if (tp & TP_PAGEEX)
  338.         {
  339.           strcat(err, ", ");
  340.         }
  341.         else
  342.         {
  343.           strcat(err, " or ");
  344.         }
  345.       }
  346.       strcat(err, "function");
  347.     }
  348.     if (tp & TP_PAGEEX)
  349.     {
  350.       if (tp & TP_CODE)
  351.       {
  352.         strcat(err, " or ");
  353.       }
  354.       strcat(err, "PageEx");
  355.     }
  356.     strcat(err, "\n");
  357.     ERROR_MSG(err, tok);
  358.     return PS_ERROR;
  359.   }
  360. }