.ad 8
.bm 8
.fm 4
.bt $Copyright by   Software AG, 1994$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VOS94CC$
.tt 2 $$$
.tt 3 $R.Roedling$NT Server Configuration$1997-05-07$
***********************************************************
.nf


    ========== licence begin LGPL
    Copyright (C) 2002 SAP AG

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    ========== licence end

.fo
.nf
.sp
Module  :       NT_Server_Configuration
=========
.sp
Purpose :
    This small utility creates and removes
    entries in the Service Control database.
    These entries are needed by Windows NT for server
    processes which should not be killed at logout.
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :

.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :

.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :

.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : Raphael Molle, R.Rdling
.sp
.cp 3
Created : 1994-01-27
.sp
.cp 3
Version :
.sp
.cp 3
Release :  6.2 	 Date : 1997-05-07
.br
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:

.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:

.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:

.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
/* PRETTY */

/*
 * INCLUDE FILES
 */
#include           <stdarg.h>

/*
 *  DEFINES
 */
#define MOD__  "VOS94CC : "
#define MF__   MOD__"UNDEFINED"

#define OPTION_STRING             "d:raun:R:qsAg"



/*
 *  MACROS
 */


/*
 *  LOCAL TYPE AND STRUCT DEFINITIONS
 */


/*
 * EXTERNAL VARIABLES
 */
extern int        sql80_OptInd;
extern int        sql80_OptErr;
extern char*      sql80_OptArg;


/*
 *  EXPORTED VARIABLES
 */


/*
 * LOCAL VARIABLES
 */


/*
 * LOCAL FUNCTION PROTOTYPES
 */

/*
 * ========================== GLOBAL FUNCTIONS ================================
 */

INT _CDECL  main (INT     argc, CHAR   *argv[])
  {
  #undef  MF__
  #define MF__ MOD__"main"
  INT                   OptionChar;
  PSZ                   pszDBRoot     = NULL;
  APIRET                rc            = NO_ERROR;
  PSZ                   pszServerDB   = NULL;
  BOOL                  fCommandError = FALSE;
  BOOL                  fAutoStart    = FALSE;
  BOOL                  fGateway      = FALSE;
  BOOL                  fAddGroup     = FALSE;
  ULONG                 ulRequest     = CREATE_ADABAS_SERVICE;
  PCHAR                 pszNodeName   = NULL;
  ULONG                 ulKernelType  = KERNEL_TYPE_FAST;

  DBGIN;
  //
  //
  // --- check the platform id first
  //
  //
  if ( sql02_get_platform_id() != VER_PLATFORM_WIN32_NT )
    {
    // --- Windows 95 - nothing to do !!!!!!!
    DBGOUT;
    return ( NO_ERROR );
    }

  while ( (OptionChar = sql80_GetOpt ( argc, argv, OPTION_STRING )) != -1 )
    {
    switch ( OptionChar )
      {
      case 'd' :
              pszServerDB   = sql80_OptArg;
              break;
      case 'A' :
              fAddGroup     = TRUE;
              break;
      case 'g' :
              fGateway      = TRUE;
              break;
      case 'n' :
              pszNodeName   = sql80_OptArg;
              break;
      case 'R' :
              pszDBRoot     = sql80_OptArg;
              break;
      case 'r' :
              ulRequest     = REMOVE_ADABAS_SERVICE;
              break;
      case 'a' :
              fAutoStart    = TRUE;
              break;
      case 'u' :
              ulRequest     = UPDATE_ADABAS_SERVICE;
              break;
      case 'q' :
              ulKernelType  = KERNEL_TYPE_QUICK;
              break;
      case 's' :
              ulKernelType  = KERNEL_TYPE_SLOW;
              break;
      default :
              fCommandError = TRUE;
      }
    }

  if ( fGateway )
    {
    switch ( ulKernelType )
      {
      case KERNEL_TYPE_FAST :
        ulKernelType  = KERNEL_TYPE_FAST_ORA_GW;
        break;
      case KERNEL_TYPE_SLOW :
        ulKernelType  = KERNEL_TYPE_SLOW_ORA_GW;
        break;
      default:
        fCommandError = TRUE;
        break;
      }
    }

  if ( (argc - sql80_OptInd) || (fCommandError == TRUE) )
    {
    printf (SERVICE_USAGE);
    EXITPROCESS(0);
    }

  if ( pszServerDB == NULL)
    {
    if ( sql01c_get_serverdb ( &pszServerDB  ) == FALSE )
      {
      printf (SERVICE_USAGE);
      DBGOUT;
      EXITPROCESS(2);
      }
    }

  if ( pszDBRoot == NULL )
    {
    /*
     * get DBROOT from Environment
     */
    if ( sql01c_get_dbroot (&pszDBRoot) == FALSE )
      {
      MSGCD ((ERR_DBROOT_NOT_SET));
      DBGOUT;
      EXITPROCESS(2);
      }
    }

  sql94_service_entry ( ulRequest, ulKernelType, fAutoStart,
                        pszNodeName, pszDBRoot,
                        pszServerDB, NULL );

  if ( fAddGroup )
    sql03c_add_ADABAS_operators_group ();

  DBGOUT;
  EXITPROCESS(0);
  }

/*
 * ========================== LOCAL FUNCTIONS =================================
 */


/*
 * =============================== END ========================================
 */

.CM *-END-* code ----------------------------------------
.SP 2
***********************************************************
.PA
