home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CMSTOP.ZIP / CMSTOP / CMSTOP_C / CMSTOP.C < prev    next >
Text File  |  1991-12-05  |  6KB  |  120 lines

  1. /************************************************************************/
  2. /*                                                                      */
  3. /*   MODULE NAME: CMSTOP.C                                              */
  4. /*                                                                      */
  5. /*   DESCRIPTIVE NAME: SAMPLE PROGRAM TO STOP COMMUNICATIONS MANAGER    */
  6. /*                     OS/2 EXTENDED SERVICES Version 1.0               */
  7. /*                                                                      */
  8. /*   COPYRIGHT:  (C) COPYRIGHT IBM CORP. 1991                           */
  9. /*               LICENSED MATERIAL - PROGRAM PROPERTY OF IBM            */
  10. /*               ALL RIGHTS RESERVED                                    */
  11. /*                                                                      */
  12. /*   FUNCTION: The sample program will use the API interface to stop    */
  13. /*             the IBM Communications Manager.  It will call the        */
  14. /*             CmkDeactivateService entry point with the stop type      */
  15. /*             selected.                                                */
  16. /*                                                                      */
  17. /*              Uses the following Communication Manager Verb:          */
  18. /*                                                                      */
  19. /*                CmkDeactivateService                                  */
  20. /*                                                                      */
  21. /*   NOTE:     The program assumes a SOFT stop unless a parameter       */
  22. /*             is included that starts with an 'H',  and then a         */
  23. /*             HARD stop is issued.   A successful return code          */
  24. /*             from CmkDeactivate does not mean that CM is stopped,     */
  25. /*             only that the request has been received.                 */
  26. /*                                                                      */
  27. /*   MODULE TYPE = IBM Personal Computer C/2 Compiler Version 1.1       */
  28. /*                 (Compiler options - /AL /Zd /Od)                     */
  29. /*                                                                      */
  30. /*   PREREQS = Requires CM DLL file "REMAPI.DLL" at runtime.            */
  31. /*                                                                      */
  32. /************************************************************************/
  33. #include <os2def.h>
  34. #define INCL_DOS
  35. #include <bsedos.h>
  36.  
  37.   /****  CmkDeactivateService - Deactivate the Communication Manager  */
  38.   /*                                                                  */
  39.   /*     This command will stop the IBM Communications Manager        */
  40.   /*                                                                  */
  41.   /********************************************************************/
  42.  
  43. USHORT APIENTRY CmkKernelReg(USHORT,          /* Reserved                 */
  44.                              PSZ,             /* Reserved                 */
  45.                              PSZ);            /* Application Name         */
  46.  
  47. USHORT APIENTRY CmkDeactivateService(USHORT,  /* type of stop             */
  48.                                      ULONG,   /* service to deactivate    */
  49.                                      PVOID,   /* Reserved                 */
  50.                                      USHORT); /* Reserved                 */
  51.  
  52. #define CMK_ALL_FEATURES     1                /* autostartable features   */
  53.  
  54. /* StopType codes */
  55. #define CMK_SOFT             0                /* soft stop                */
  56. #define CMK_HARD             1                /* hard stop                */
  57.  
  58. #define CMK_SUCCESSFUL                  0
  59. #define CMK_ERR_INVALID_SERVICE        22
  60. #define CMK_ERR_SYSTEM_ERROR           23
  61. #define CMK_ERR_CM_NOT_ACTIVE          37
  62. #define CMK_ERR_NOT_REGISTERED         41
  63.  
  64. #define CMKDEACTIVATESERVICE_ERROR "ERROR in CmkDeactivateService.\r\n"
  65.  
  66.  
  67.  
  68. main(argc, argv)
  69.    int argc;
  70.    char *argv[];
  71. {
  72.  
  73.   unsigned short int rc;
  74.   unsigned short int stop_type;
  75.   unsigned short dummy;
  76.  
  77.  
  78.      /***********************************************************/
  79.      /*                                                         */
  80.      /*    Determine if parameter starts with an 'H'            */
  81.      /*    If yes then we will stop HARD                        */
  82.      /*                                                         */
  83.      /***********************************************************/
  84.  
  85.   stop_type = CMK_SOFT;
  86.   if (argc >= 2) {                            // Is there a parameter ?
  87.     if (toupper(argv[1][0]) == 'H') {         // Is first char 'h' or 'H'
  88.       stop_type = CMK_HARD;                   // Yes then HARD STOP
  89.     } /* endif */
  90.   } /* endif */
  91.  
  92.      /***********************************************************/
  93.      /**                                                        */
  94.      /**   Call API to Stop Communication Manager               */
  95.      /**                                                        */
  96.      /***********************************************************/
  97.   rc = 0;
  98.   if (!CmkKernelReg((USHORT)NULL, (PSZ)NULL, "cmstop")) {
  99.      rc = CmkDeactivateService (stop_type, (ULONG)CMK_ALL_FEATURES, 0L, 0);
  100.   } /* endif */
  101.  
  102.      /************************************************************/
  103.      /*    If return code is non zero then and error occured     */
  104.      /*                                                          */
  105.      /*    If a Zero is returned the command request was accepted*/
  106.      /*    but it does not mean Communications have stopped      */
  107.      /************************************************************/
  108.  
  109.   if (rc)
  110.   {
  111.     DosWrite (2,CMKDEACTIVATESERVICE_ERROR,
  112.                 sizeof(CMKDEACTIVATESERVICE_ERROR),
  113.                 &dummy);
  114.     return rc;
  115.   }
  116.  
  117. }
  118.  
  119.  
  120.