home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / os2db2.zip / COMMAND.CPP next >
Text File  |  1994-09-03  |  5KB  |  107 lines

  1.  /******************************************************
  2. *  COMMAND.CPP - COMMAND CLASS                          *
  3.  ******************************************************/
  4.  
  5. #include "defines.hpp"                                // type defines
  6. #include "command.hpp"                                // command class
  7.  
  8. #define   VERSION "2.0"                               // version number
  9.  
  10. BOOL  COMMAND::clientServer = FALSE;                  // client server
  11. BOOL  COMMAND::managerOnly  = FALSE;                  // manager only
  12. BOOL  COMMAND::doEverything = FALSE;                  // do everything
  13. BOOL  COMMAND::listingFlag  = FALSE;                  // listing flag
  14. BOOL  COMMAND::updateDeamon = FALSE;                  // update deamon
  15. LONG  COMMAND::killProcess  = NOPID;                  // kill process
  16.  
  17.  /******************************************************
  18. *  COMMAND::commandLine - command line                  *
  19.  ******************************************************/
  20.  
  21. NOLINE BOOL COMMAND::commandLine(ULONG argCount, PCHAR argVector[])
  22.  
  23. {
  24.      register LONG  i;                                // arg counter
  25.      register CHAR *c, *p;                            // arg pointer
  26.  
  27.      printf("\nOS/2 Shutdown for DB/2 Version %s\n", VERSION);
  28.      printf("Copyright (c) 1994 SoftFocus Inc. All rights reserved.\n\n");
  29.  
  30.      for (i = 1; i < argCount; i++) {                 // check args
  31.           p = argVector[i]; c = p++;                  // current arg
  32.  
  33.           if ((*c == '-') || (*c == '/')) {           // arg switch
  34.                do {                                   // nested args
  35.                     switch(toupper(*p++)) {           // upper case
  36.                          case 'A':
  37.                               doEverything = TRUE;    // do everything
  38.                               break;                  // continue ok
  39.                          case 'D':
  40.                               managerOnly  = TRUE;    // manager only
  41.                               break;                  // continue ok
  42.                          case 'F':
  43.                               updateDeamon = TRUE;    // update deamon
  44.                               break;                  // continue ok
  45.                          case 'K':
  46.                               clientServer = TRUE;    // client server
  47.                               break;                  // continue ok
  48.                          case 'L':
  49.                               listingFlag  = TRUE;    // listing flag
  50.                               break;                  // continue ok
  51.                          case 'P':
  52.                               killProcess  = atol(p + 1); *p = '\0';
  53.                               break;                  // continue ok
  54.                          default :
  55.                               commandUsage(TRUE);     // print usage
  56.                               return FALSE;           // return error
  57.                     }                                 // end switch
  58.                } while (*p != '\0');                  // nested args
  59.           } else {
  60.                commandUsage(TRUE);                    // print usage
  61.                return FALSE;                          // return error
  62.           }
  63.      }
  64.      if ((clientServer != FALSE) ||                   // client server
  65.          (managerOnly  != FALSE) ||                   // manager only
  66.          (doEverything != FALSE) ||                   // do everything
  67.          (listingFlag  != FALSE) ||                   // listing flag
  68.          (updateDeamon != FALSE) ||                   // update deamon
  69.          (killProcess  != NOPID)) {                   // kill process
  70.           return TRUE;                                // continue ok
  71.      }
  72.      commandUsage(FALSE);                             // print usage
  73.      return FALSE;                                    // return error
  74. }
  75.  
  76.  /******************************************************
  77. *  COMMAND::commandUsage - command usage                *
  78.  ******************************************************/
  79.  
  80. NOLINE VOID COMMAND::commandUsage(BOOL helpFormat)
  81.  
  82. {
  83.      printf("Usage: shutdown [/A] [/D] [/F] [/K] [/L] [/P:pid] [/?]\n");
  84.  
  85.      if (helpFormat == TRUE) {                        // help format
  86.           printf("\n");                               // skip a line
  87.           printf("  [/A]     = same as entering /KFL\n");
  88.           printf("  [/D]     = stop database manager\n");
  89.           printf("  [/F]     = stop OS/2 file system\n");
  90.           printf("  [/K]     = kill DB/2 connections\n");
  91.           printf("  [/L]     = list active processes\n");
  92.           printf("  [/P:pid] = kill process id (dec)\n");
  93.           printf("  [/?]     = display this helptext\n\n");
  94.  
  95.           printf("The /K option attempts to 'kill' all DB/2 client/server\n");
  96.           printf("connections before stopping the database manager.  Use\n");
  97.           printf("this option if you are running shutdown on a database\n");
  98.           printf("server.  The /D option stops the database manager only.\n");
  99.           printf("Use this option if you are running shutdown on a data-\n");
  100.           printf("base client or on a system with a stand alone database.\n");
  101.           printf("The /F option stops the OS/2 file system.  At least one\n");
  102.           printf("option must be specified.  Options may be combined and\n");
  103.           printf("case is insignificant.\n");
  104.      }
  105. }
  106.  
  107.