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.

159 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. spltest.c
  6. Abstract:
  7. Test program for enabling a spooler group.
  8. Author:
  9. Albert Ting (AlbertT) 2-Oct-1996
  10. Revision History:
  11. --*/
  12. #include "precomp.hxx"
  13. #pragma hdrstop
  14. MODULE_DEBUG_INIT( DBG_ERROR|DBG_WARN|DBG_TRACE, DBG_ERROR );
  15. #ifdef __cplusplus
  16. extern "C"
  17. #endif
  18. INT _CRTAPI1
  19. main(
  20. INT argc,
  21. CHAR* argv[]
  22. )
  23. {
  24. if( !bSplLibInit() )
  25. {
  26. return 1;
  27. }
  28. BOOL bOpen = FALSE;
  29. HANDLE hSpooler = NULL;
  30. HANDLE hStdIn = GetStdHandle( STD_INPUT_HANDLE );
  31. SetConsoleMode( hStdIn, ENABLE_PROCESSED_INPUT );
  32. for( ; ; )
  33. {
  34. TCHAR c;
  35. DWORD dwRead;
  36. printf( "SplTest> " );
  37. TStatusB bStatus;
  38. bStatus DBGCHK = ReadConsole( hStdIn,
  39. &c,
  40. 1,
  41. &dwRead,
  42. NULL );
  43. c = TCHAR( CharLower( LPTSTR( c )));
  44. switch( c )
  45. {
  46. case '?':
  47. printf( "Usage: spltest {action}\n"
  48. " Actions: o - Open\n"
  49. " c - Close\n"
  50. " a - IsAlive\n" );
  51. break;
  52. case 'q':
  53. printf( "q: Exiting\n" );
  54. return 0;
  55. case 'o':
  56. {
  57. if( bOpen )
  58. {
  59. printf( "o: Error: already open %x\n", hSpooler );
  60. break;
  61. }
  62. TStatusB bStatus;
  63. bStatus DBGCHK = ClusterSplOpen( NULL,
  64. TEXT( "Spooler" ),
  65. &hSpooler,
  66. TEXT( "alberttc,," ),
  67. TEXT( ",1.2.3.4," ));
  68. if( bStatus )
  69. {
  70. printf( "o: Spooler albertt2 NULL opened %x\n", hSpooler );
  71. bOpen = TRUE;
  72. }
  73. else
  74. {
  75. printf( "o: Error: %d\n", GetLastError() );
  76. }
  77. break;
  78. }
  79. case 'c':
  80. {
  81. if( !bOpen )
  82. {
  83. printf( "c: Error: not open\n" );
  84. break;
  85. }
  86. TStatusB bStatus;
  87. bStatus DBGCHK = ClusterSplClose( hSpooler );
  88. if( bStatus )
  89. {
  90. printf( "c: Spooler closed %x.\n", hSpooler );
  91. }
  92. else
  93. {
  94. printf( "c: Error: closing %x %d\n", hSpooler, GetLastError() );
  95. }
  96. bOpen = FALSE;
  97. break;
  98. }
  99. case 'a':
  100. {
  101. TStatusB bStatus;
  102. bStatus DBGCHK = ClusterSplIsAlive( hSpooler );
  103. if( bStatus )
  104. {
  105. printf( "a: Spooler alive %x.\n", hSpooler );
  106. }
  107. else
  108. {
  109. printf( "a: Error: not alive %x %d (%x)\n",
  110. hSpooler,
  111. GetLastError(),
  112. GetLastError() );
  113. }
  114. break;
  115. }
  116. default:
  117. printf( "%c: Unknown command\n", c );
  118. break;
  119. }
  120. }
  121. return 0;
  122. }