Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

372 lines
9.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1996.
  5. //
  6. // File: help.cxx
  7. //
  8. // Contents: Routines to display help info.
  9. //
  10. // History: 04-04-95 DavidMun Created
  11. //
  12. // Notes: TO CHANGE THE HELP TEXT FOR A COMMAND:
  13. // - edit the command's RCDATA block in jt.rc.
  14. //
  15. // TO ADD HELP FOR A NEW COMMAND:
  16. // - Add a RC_<command_name> identifier to resource.h
  17. // - Add an RCDATA block for RC_<command_name> in jt.rc
  18. // - Add a case statement in the DoHelp() function (below)
  19. // for the new command.
  20. //
  21. //----------------------------------------------------------------------------
  22. #include <headers.hxx>
  23. #pragma hdrstop
  24. #include "jt.hxx"
  25. #include "resource.h"
  26. //+---------------------------------------------------------------------------
  27. //
  28. // Function: DisplayHelp
  29. //
  30. // Synopsis: Print help strings with RCDATA identifier [usResourceID] on
  31. // the console.
  32. //
  33. // Arguments: [usResourceID] - identifier for RCDATA block containing
  34. // printf style string to print.
  35. // [...] - arguments for vprintf
  36. //
  37. // History: 03-11-96 DavidMun Created
  38. //
  39. //----------------------------------------------------------------------------
  40. VOID DisplayHelp(USHORT usResourceID, ...)
  41. {
  42. va_list varArgs;
  43. HRSRC hResource = NULL;
  44. HGLOBAL hgResource = NULL;
  45. LPSTR psz = NULL;
  46. va_start(varArgs, usResourceID);
  47. do
  48. {
  49. hResource = FindResource(NULL, (LPCTSTR) usResourceID, RT_RCDATA);
  50. if (!hResource)
  51. {
  52. g_Log.Write(LOG_ERROR, "FindResource (%u)", GetLastError());
  53. break;
  54. }
  55. hgResource = LoadResource(NULL, hResource);
  56. if (!hgResource)
  57. {
  58. g_Log.Write(LOG_ERROR, "LoadResource (%u)", GetLastError());
  59. break;
  60. }
  61. psz = (LPSTR) LockResource(hgResource);
  62. if (!psz)
  63. {
  64. g_Log.Write(LOG_ERROR, "LockResource (%u)", GetLastError());
  65. break;
  66. }
  67. while (*psz)
  68. {
  69. vprintf(psz, varArgs);
  70. psz += lstrlenA(psz) + 1;
  71. }
  72. } while (0);
  73. va_end(varArgs);
  74. if (hgResource)
  75. {
  76. FreeResource(hgResource);
  77. }
  78. }
  79. //+---------------------------------------------------------------------------
  80. //
  81. // Function: DisplayUsage
  82. //
  83. // Synopsis: Print usage instructions for this exe on the console
  84. //
  85. // History: 02-18-94 DavidMun Created
  86. // 03-31-95 DavidMun Rewrite
  87. //
  88. //----------------------------------------------------------------------------
  89. VOID DisplayUsage()
  90. {
  91. DisplayHelp(
  92. RC_USAGE1,
  93. #if (DBG == 1)
  94. "as a debug build",
  95. #else
  96. "as a retail build",
  97. #endif
  98. #ifdef _CHICAGO_
  99. "Windows 95 or Windows 98"
  100. #else
  101. #ifndef RES_KIT
  102. "Windows NT"
  103. #else
  104. "the Windows NT Resource Kit"
  105. #endif
  106. #endif
  107. );
  108. DisplayHelp(RC_USAGE2, NUM_ENUMERATOR_SLOTS - 1);
  109. }
  110. //+---------------------------------------------------------------------------
  111. //
  112. // Function: DoHelp
  113. //
  114. // Synopsis: Process the HELP command
  115. //
  116. // Arguments: [ppwsz] - token stream
  117. //
  118. // Modifies: *[ppwsz]
  119. //
  120. // History: 04-10-95 DavidMun Created
  121. //
  122. //----------------------------------------------------------------------------
  123. VOID DoHelp(WCHAR **ppwsz)
  124. {
  125. TOKEN tkn;
  126. BOOL fGotToken = FALSE;
  127. do
  128. {
  129. do
  130. {
  131. tkn = GetToken(ppwsz);
  132. } while (tkn != TKN_EOL &&
  133. tkn != TKN_ATSIGN &&
  134. !IsCommandToken(tkn));
  135. #ifdef RES_KIT
  136. if ((tkn == TKN_ADDJOBTOQUEUE) ||
  137. (tkn == TKN_REMOVEJOBFROMQUEUE) ||
  138. (tkn == TKN_SETQUEUE) ||
  139. (tkn == TKN_ABORTQUEUE) ||
  140. (tkn == TKN_CONVERTSAGETASKSTOJOBS) ||
  141. (tkn == TKN_EDITJOB) ||
  142. (tkn == TKN_ENUMCLONE) ||
  143. (tkn == TKN_ENUMNEXT) ||
  144. (tkn == TKN_ENUMRESET) ||
  145. (tkn == TKN_ENUMSKIP) ||
  146. (tkn == TKN_CREATETRIGGERQUEUE) ||
  147. (tkn == TKN_DELETETRIGGERQUEUE) ||
  148. (tkn == TKN_EDITJOBINQUEUE) ||
  149. (tkn == TKN_LOADQUEUE) ||
  150. (tkn == TKN_PRINTQUEUE) ||
  151. (tkn == TKN_PRINTRUNTIMEQUEUE) ||
  152. (tkn == TKN_PRINTSTRINGQUEUE) ||
  153. (tkn == TKN_PRINTTRIGGERQUEUE) ||
  154. (tkn == TKN_RUNQUEUE) ||
  155. (tkn == TKN_SCHEDADDQUEUE) ||
  156. (tkn == TKN_SCHEDCREATEENUM) ||
  157. (tkn == TKN_SCHEDISJOBORQUEUE) ||
  158. (tkn == TKN_SAVEQUEUE) ||
  159. (tkn == TKN_SCHEDNEWQUEUE) ||
  160. (tkn == TKN_SETTRIGGERQUEUE))
  161. {
  162. continue;
  163. }
  164. #endif
  165. if (tkn != TKN_EOL)
  166. {
  167. fGotToken = TRUE;
  168. }
  169. switch (tkn)
  170. {
  171. // case TKN_ADDJOBTOQUEUE:
  172. // case TKN_REMOVEJOBFROMQUEUE:
  173. // case TKN_SETQUEUE:
  174. // DisplayHelp(RC_NOTIMPL);
  175. // break;
  176. case TKN_ABORTJOB:
  177. // case TKN_ABORTQUEUE:
  178. DisplayHelp(RC_ABORT);
  179. break;
  180. case TKN_ATSIGN:
  181. DisplayHelp(RC_ATSIGN);
  182. break;
  183. #ifndef RES_KIT
  184. case TKN_CONVERTSAGETASKSTOJOBS:
  185. DisplayHelp(
  186. RC_CONVERTSAGE,
  187. #ifdef _CHICAGO_
  188. "Win9x"
  189. #else
  190. "Windows NT"
  191. #endif
  192. );
  193. break;
  194. #endif // RES_KIT not defined
  195. case TKN_CREATETRIGGERJOB:
  196. // case TKN_CREATETRIGGERQUEUE:
  197. DisplayHelp(RC_CREATETRIGGER1);
  198. DisplayHelp(RC_TRIGPROPS, TIME_NOW_INCREMENT);
  199. DisplayHelp(RC_CREATETRIGGER2);
  200. break;
  201. case TKN_DELETETRIGGERJOB:
  202. // case TKN_DELETETRIGGERQUEUE:
  203. DisplayHelp(RC_DELETETRIGGER);
  204. break;
  205. #ifndef RES_KIT
  206. case TKN_EDITJOB:
  207. // case TKN_EDITJOBINQUEUE:
  208. DisplayHelp(RC_EDITJOB);
  209. break;
  210. case TKN_ENUMCLONE:
  211. DisplayHelp(RC_ENUMCLONE);
  212. break;
  213. case TKN_ENUMNEXT:
  214. DisplayHelp(RC_ENUMNEXT);
  215. break;
  216. case TKN_ENUMRESET:
  217. DisplayHelp(RC_ENUMRESET);
  218. break;
  219. case TKN_ENUMSKIP:
  220. DisplayHelp(RC_ENUMSKIP);
  221. break;
  222. #endif // RES_KIT not defined
  223. case TKN_GETCREDENTIALS:
  224. DisplayHelp(RC_GETCREDENTIALS);
  225. break;
  226. case TKN_GETMACHINE:
  227. DisplayHelp(RC_GETMACHINE);
  228. break;
  229. #ifndef RES_KIT
  230. case TKN_SCHEDISJOBORQUEUE:
  231. DisplayHelp(RC_ISJOBORQUEUE);
  232. break;
  233. #endif // RES_KIT not defined
  234. case TKN_LOADJOB:
  235. // case TKN_LOADQUEUE:
  236. DisplayHelp(RC_LOAD);
  237. break;
  238. case TKN_PRINTJOB:
  239. // case TKN_PRINTQUEUE:
  240. DisplayHelp(RC_PRINT);
  241. break;
  242. case TKN_PRINTRUNTIMEJOB:
  243. // case TKN_PRINTRUNTIMEQUEUE:
  244. DisplayHelp(RC_PRINTRUNTIME);
  245. break;
  246. case TKN_PRINTSTRINGJOB:
  247. // case TKN_PRINTSTRINGQUEUE:
  248. DisplayHelp(RC_PRINTSTRING);
  249. break;
  250. case TKN_PRINTTRIGGERJOB:
  251. // case TKN_PRINTTRIGGERQUEUE:
  252. DisplayHelp(RC_PRINTTRIGGER);
  253. break;
  254. case TKN_RUNJOB:
  255. // case TKN_RUNQUEUE:
  256. DisplayHelp(RC_RUN);
  257. break;
  258. case TKN_SCHEDACTIVATE:
  259. DisplayHelp(RC_ACTIVATE);
  260. break;
  261. case TKN_SCHEDADDJOB:
  262. // case TKN_SCHEDADDQUEUE:
  263. DisplayHelp(RC_ADD);
  264. break;
  265. #ifndef RES_KIT
  266. case TKN_SCHEDCREATEENUM:
  267. DisplayHelp(
  268. RC_CREATEENUM,
  269. NUM_ENUMERATOR_SLOTS - 1,
  270. NUM_ENUMERATOR_SLOTS,
  271. NUM_ENUMERATOR_SLOTS - 1);
  272. break;
  273. #endif // RES_KIT not defined
  274. case TKN_SCHEDDELETE:
  275. DisplayHelp(RC_DELETE);
  276. break;
  277. case TKN_SCHEDENUM:
  278. DisplayHelp(RC_ENUM);
  279. break;
  280. case TKN_SETCREDENTIALS:
  281. DisplayHelp(RC_SETCREDENTIALS);
  282. break;
  283. case TKN_SETJOB:
  284. DisplayHelp(RC_SETJOB);
  285. break;
  286. case TKN_SAVEJOB:
  287. // case TKN_SAVEQUEUE:
  288. DisplayHelp(RC_SAVE);
  289. break;
  290. case TKN_SETMACHINE:
  291. DisplayHelp(RC_SETMACHINE);
  292. break;
  293. case TKN_SCHEDNEWJOB:
  294. // case TKN_SCHEDNEWQUEUE:
  295. DisplayHelp(RC_NEW);
  296. break;
  297. case TKN_SETTRIGGERJOB:
  298. // case TKN_SETTRIGGERQUEUE:
  299. DisplayHelp(RC_SETTRIGGER1);
  300. DisplayHelp(RC_TRIGPROPS, TIME_NOW_INCREMENT);
  301. DisplayHelp(RC_SETTRIGGER2);
  302. break;
  303. default:
  304. if (!fGotToken)
  305. {
  306. DisplayUsage();
  307. }
  308. break;
  309. }
  310. } while (tkn != TKN_EOL);
  311. }