Leaked source code of windows server 2003
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.

194 lines
3.4 KiB

  1. ///// autoText.cpp - gdiplus text test harness
  2. //
  3. //
  4. #include "precomp.hpp"
  5. #define GLOBALS_HERE 1
  6. #include "global.h"
  7. #include "../gpinit.inc"
  8. /// ProcessCommandLine
  9. //
  10. // -d - Do display regression tests then exit
  11. // -p - Do print regeression tests then exit
  12. //
  13. // ProcessCommandLine returns FALSE if the program should not continue.
  14. void SkipBlanks(const char **p)
  15. {
  16. while (**p && **p == ' ')
  17. {
  18. (*p)++;
  19. }
  20. }
  21. void SkipNonBlank(const char **p)
  22. {
  23. while (**p && **p != ' ')
  24. {
  25. (*p)++;
  26. }
  27. }
  28. void ProcessParameter(const char **p)
  29. {
  30. if ( **p == '-'
  31. || **p == '/')
  32. {
  33. (*p)++;
  34. while (**p && **p != ' ')
  35. {
  36. switch (**p)
  37. {
  38. case 'd':
  39. G.AutoDisplayRegress = TRUE;
  40. break;
  41. case 'p':
  42. G.AutoPrintRegress = TRUE;
  43. break;
  44. case 'h':
  45. default:
  46. G.Help = TRUE;
  47. break;
  48. }
  49. (*p)++;
  50. }
  51. }
  52. else
  53. {
  54. SkipNonBlank(p);
  55. G.Help = TRUE;
  56. }
  57. }
  58. BOOL ProcessCommandLine(const char *command)
  59. {
  60. const char *p = command;
  61. SkipBlanks(&p);
  62. while (*p)
  63. {
  64. ProcessParameter(&p);
  65. SkipBlanks(&p);
  66. }
  67. if (G.Help)
  68. {
  69. MessageBoxA(
  70. NULL,
  71. "-d - Regress display and exit\n\
  72. -p - Regress printing and exit\n\
  73. -h - Help",
  74. "autoText - text regression tests",
  75. MB_OK
  76. );
  77. return FALSE;
  78. }
  79. if (G.AutoDisplayRegress)
  80. {
  81. G.RunAllTests = TRUE;
  82. }
  83. return TRUE;
  84. }
  85. //// WinMain - Application entry point and dispatch loop
  86. //
  87. //
  88. int APIENTRY WinMain(
  89. HINSTANCE hInst,
  90. HINSTANCE hPrevInstance,
  91. char *pCmdLine,
  92. int nCmdShow) {
  93. MSG msg;
  94. HACCEL hAccelTable;
  95. RECT rc;
  96. RECT rcMain;
  97. if (!gGdiplusInitHelper.IsValid())
  98. {
  99. return 0;
  100. }
  101. G.Instance = hInst; // Global hInstance
  102. G.PSLevel2 = TRUE;
  103. G.ghPrinter = 0;
  104. if (!ProcessCommandLine(pCmdLine))
  105. {
  106. return 1;
  107. }
  108. GetInstalledFamilies();
  109. // Create main text window
  110. G.Window = CreateTextWindow();
  111. ShowWindow(G.Window, SW_SHOWNORMAL);
  112. UpdateWindow(G.Window);
  113. // Main message loop
  114. if (G.Unicode)
  115. {
  116. hAccelTable = LoadAcceleratorsW(G.Instance, APPNAMEW);
  117. while (GetMessageW(&msg, (HWND) NULL, 0, 0) > 0)
  118. {
  119. if (!TranslateAcceleratorA(G.Window, hAccelTable, &msg))
  120. {
  121. TranslateMessage(&msg);
  122. DispatchMessageA(&msg);
  123. }
  124. }
  125. }
  126. else
  127. {
  128. hAccelTable = LoadAcceleratorsA(G.Instance, APPNAMEA);
  129. while (GetMessageA(&msg, (HWND) NULL, 0, 0) > 0)
  130. {
  131. if (!TranslateAcceleratorA(G.Window, hAccelTable, &msg))
  132. {
  133. TranslateMessage(&msg);
  134. DispatchMessageA(&msg);
  135. }
  136. }
  137. }
  138. ReleaseInstalledFamilies();
  139. return (int)msg.wParam;
  140. UNREFERENCED_PARAMETER(hPrevInstance);
  141. UNREFERENCED_PARAMETER(pCmdLine);
  142. UNREFERENCED_PARAMETER(nCmdShow);
  143. }