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.

188 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. TODO: cmntool.c
  5. Abstract:
  6. <TODO: fill in abstract>
  7. Author:
  8. TODO: <full name> (<alias>) <date>
  9. Revision History:
  10. <full name> (<alias>) <date> <comments>
  11. --*/
  12. #include "pch.h"
  13. HANDLE g_hHeap;
  14. HINSTANCE g_hInst;
  15. BOOL WINAPI MigUtil_Entry (HINSTANCE, DWORD, PVOID);
  16. BOOL
  17. pCallEntryPoints (
  18. DWORD Reason
  19. )
  20. {
  21. HINSTANCE Instance;
  22. //
  23. // Simulate DllMain
  24. //
  25. Instance = g_hInst;
  26. //
  27. // Initialize the common libs
  28. //
  29. if (!MigUtil_Entry (Instance, Reason, NULL)) {
  30. return FALSE;
  31. }
  32. //
  33. // TODO: Add others here if needed (don't forget to prototype above)
  34. //
  35. return TRUE;
  36. }
  37. BOOL
  38. Init (
  39. VOID
  40. )
  41. {
  42. g_hHeap = GetProcessHeap();
  43. g_hInst = GetModuleHandle (NULL);
  44. return pCallEntryPoints (DLL_PROCESS_ATTACH);
  45. }
  46. VOID
  47. Terminate (
  48. VOID
  49. )
  50. {
  51. pCallEntryPoints (DLL_PROCESS_DETACH);
  52. }
  53. VOID
  54. HelpAndExit (
  55. VOID
  56. )
  57. {
  58. //
  59. // This routine is called whenever command line args are wrong
  60. //
  61. _ftprintf (
  62. stderr,
  63. TEXT("Command Line Syntax:\n\n")
  64. //
  65. // TODO: Describe command line syntax(es), indent 2 spaces
  66. //
  67. TEXT(" cmntool [/F:file]\n")
  68. TEXT("\nDescription:\n\n")
  69. //
  70. // TODO: Describe tool, indent 2 spaces
  71. //
  72. TEXT(" cmntool is a stub!\n")
  73. TEXT("\nArguments:\n\n")
  74. //
  75. // TODO: Describe args, indent 2 spaces, say optional if necessary
  76. //
  77. TEXT(" /F Specifies optional file name\n")
  78. );
  79. exit (1);
  80. }
  81. INT
  82. __cdecl
  83. _tmain (
  84. INT argc,
  85. PCTSTR argv[]
  86. )
  87. {
  88. INT i;
  89. PCTSTR FileArg;
  90. //
  91. // TODO: Parse command line here
  92. //
  93. for (i = 1 ; i < argc ; i++) {
  94. if (argv[i][0] == TEXT('/') || argv[i][0] == TEXT('-')) {
  95. switch (_totlower (_tcsnextc (&argv[i][1]))) {
  96. case TEXT('f'):
  97. //
  98. // Sample option - /f:file
  99. //
  100. if (argv[i][2] == TEXT(':')) {
  101. FileArg = &argv[i][3];
  102. } else if (i + 1 < argc) {
  103. FileArg = argv[++i];
  104. } else {
  105. HelpAndExit();
  106. }
  107. break;
  108. default:
  109. HelpAndExit();
  110. }
  111. } else {
  112. //
  113. // Parse other args that don't require / or -
  114. //
  115. // None
  116. HelpAndExit();
  117. }
  118. }
  119. //
  120. // Begin processing
  121. //
  122. if (!Init()) {
  123. return 0;
  124. }
  125. //
  126. // TODO: Do work here
  127. //
  128. //
  129. // End of processing
  130. //
  131. Terminate();
  132. return 0;
  133. }