home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winbase / winnt / pop3 / pop3srv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-05  |  4.0 KB  |  166 lines

  1.  
  2. /******************************************************************************\
  3. *       This is a part of the Microsoft Source Code Samples.
  4. *       Copyright (C) 1992-1997 Microsoft Corporation.
  5. *       All rights reserved. 
  6. *       This source code is only intended as a supplement to 
  7. *       Microsoft Development Tools and/or WinHelp documentation.
  8. *       See these sources for detailed information regarding the 
  9. *       Microsoft samples programs.
  10. \******************************************************************************/
  11.  
  12. //+---------------------------------------------------------------------------
  13. //
  14. //  File:       pop3svr.c
  15. //
  16. //  Contents:
  17. //
  18. //  Classes:
  19. //
  20. //  Functions:
  21. //
  22. //----------------------------------------------------------------------------
  23.  
  24. #include "pop3srvp.h"
  25. #pragma hdrstop
  26.  
  27.  
  28. BOOL    fService = TRUE;
  29. BOOL    fTestMode = FALSE;
  30.  
  31. //
  32. // This table is the service dispatch table.  It lists the services in
  33. // this process by name, and the entry point to invoke to start them.  This
  34. // example has but one service, but this could be extended to include, for
  35. // instance, an SMTP server.  Be sure to have the prototype for your entry
  36. // point in a global header file, so that you don't get a compiler complaint.
  37. //
  38. SERVICE_TABLE_ENTRY Pop3SrvTable[] = {
  39.             {APPLICATION_NAME, Pop3SrvMain},
  40.             {NULL, NULL } };
  41.  
  42.  
  43.  
  44. //+---------------------------------------------------------------------------
  45. //
  46. //  Function:   DoArgs
  47. //
  48. //  Synopsis:   This parses the process's start arguments, basically just to
  49. //              see if we have a -noservice flag so that we don't talk to the
  50. //              service controller.
  51. //
  52. //  Arguments:  [argc] --
  53. //              [argv] --
  54. //
  55. //  History:    1-09-95   RichardW   Created
  56. //
  57. //  Notes:
  58. //
  59. //----------------------------------------------------------------------------
  60. void
  61. DoArgs(
  62.     int argc,
  63.     char * argv[])
  64. {
  65.     int i;
  66.     char * arg;
  67.  
  68.     for (i = 1; i < argc ; i++)
  69.     {
  70.         arg = argv[i];
  71.  
  72.         if (*arg == '-')
  73.         {
  74.             //
  75.             // Ooo, an option.
  76.             //
  77.             if (_stricmp(arg, "-noservice") == 0)
  78.             {
  79.                 fService = FALSE;
  80.                 continue;
  81.             }
  82.             if (_stricmp(arg, "-testmode") == 0)
  83.             {
  84.                 fTestMode = TRUE;
  85.                 continue;
  86.             }
  87.         }
  88.     }
  89. }
  90.  
  91. //+---------------------------------------------------------------------------
  92. //
  93. //  Function:   DoServiceController
  94. //
  95. //  Synopsis:   This calls into the service controller, and is never heard
  96. //              from again.
  97. //
  98. //  Arguments:  (none)
  99. //
  100. //  Requires:
  101. //
  102. //  Returns:
  103. //
  104. //  History:    1-09-95   RichardW   Created
  105. //
  106. //  Notes:
  107. //
  108. //----------------------------------------------------------------------------
  109. void
  110. DoServiceController(void)
  111. {
  112.     StartServiceCtrlDispatcher(Pop3SrvTable);
  113. }
  114.  
  115.  
  116.  
  117. //+---------------------------------------------------------------------------
  118. //
  119. //  Function:   main
  120. //
  121. //  Synopsis:   Process entry point.  Unless we're told to start without
  122. //              the service controller, we quickly wait for a service start
  123. //              command.
  124. //
  125. //  Arguments:  [argc] --
  126. //              [argv] --
  127. //
  128. //  Requires:
  129. //
  130. //  Returns:
  131. //
  132. //  History:    1-09-95   RichardW   Created
  133. //
  134. //  Notes:
  135. //
  136. //----------------------------------------------------------------------------
  137. void
  138. main (int argc, char *argv[])
  139. {
  140.  
  141.     //
  142.     // Initialize the debug support, by reading our debug level from the
  143.     // registry.
  144.     //
  145.     InitDebugSupport();
  146.  
  147.     //
  148.     // Parse the arguments
  149.     //
  150.     DoArgs(argc, argv);
  151.  
  152.     //
  153.     // If we're a service, go to the service controller, otherwise start
  154.     // the service immediately.
  155.     //
  156.     if (fService)
  157.     {
  158.         DoServiceController();
  159.     }
  160.     else
  161.     {
  162.         Pop3SrvMain(argc, NULL);
  163.     }
  164.  
  165. }
  166.