/*----------------------------------------------------------------------------*/
/*                                                                            */
/*  Copyright (c) 1996 -  2001 by                                             */
/*  blaxxun interactive Inc, San Francisco, California, USA                   */
/*  All rights reserved                                                       */
/*                                                                            */
/*  This software is furnished under a license  and may be  used and  copied  */
/*  only in  accordance of the  terms of such license and with the inclusion  */
/*  of the above copyright notice.  This software or any other copies therof  */
/*  may not be provided or otherwise made available to any other person.  No  */
/*  title to and ownership of the software is hereby transferred.             */
/*                                                                            */
/*  The information in this software is subject to change without notice and  */
/*  should not be construed as a commitment by blaxxun interactive Inc.       */
/*                                                                            */
/*----------------------------------------------------------------------------*/

/*
--------------------------------------------------------------------------------

  MODULE NAME:  $RCSfile: ivntserv.h,v $
  REVISION:     $Revision: 1.16 $
  DATE:         $Date: 2001/02/15 18:36:57 $
  AUTHOR:       $Author: peter $
  STATE:        $State: Exp $

  CREATION DATE:       Jul 11, 1996

  =DocStart= Module ivntserv.h

  PROJECT:            VWP         - blaxxun virtual worlds platform
  SYSTEM:             server      - server processes
  COMPONENT:          apserver    - Community Server API server

  DESCRIPTION:
      include file for NT services stuff

  =DocEnd=

--------------------------------------------------------------------------------
*/

#ifndef _IVNTSERV_H_
#define _IVNTSERV_H_

/*
 * make it an extern C declararation for CPLUSPLUS
 */
#ifdef __cplusplus
extern "C" {
#endif

static char * _IVNTSERV_H_rcsid = "$Id: ivntserv.h,v 1.16 2001/02/15 18:36:57 peter Exp $";

/*
 * the following function is needed to suppress compiler warnings, don't call it
 */
static void _IVNTSERV_H_rcsid_fkt()
{
    if( ! *_IVNTSERV_H_rcsid )
        *_IVNTSERV_H_rcsid = 0;
    if( 0 )
        _IVNTSERV_H_rcsid_fkt();
}

/*----------------------------------------------------------------------------*/
/*             SYSTEM INCLUDE FILES                                           */
/*----------------------------------------------------------------------------*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <winsvc.h>

/*----------------------------------------------------------------------------*/
/*             MACROS/CONSTANTS                                               */
/*----------------------------------------------------------------------------*/

/*
 * Registry keys we use
 */
#define IVNT_REGKEY_COMPANY     "blaxxun interactive"
#define IVNT_REGVAL_INSTALLDIR  "InstallDirectory"
#define IVNT_REGVAL_UNINSTARG   "UninstArg"

/*
 * the following define together with the service name has to yield
 * the port variable of the service
 * e.g. idserver + Port == idserverPort
 */
#define IVNT_REGVAL_PORT        "Port"

/*
 * if other products need the name of the CommServ service, they get it from
 * here
 */
#define IVNT_REGKEY_PRODUCT     "Community Server"

/*----------------------------------------------------------------------------*/
/*             VARIABLE DECLARATIONS                                          */
/*----------------------------------------------------------------------------*/
extern int  (*ntserviceInitFunction)( int, char ** );
extern void (*ntserviceRunFunction)( );
extern void (*ntservicePauseFunction)( int );
extern void (*ntserviceExitProc)( int );

/*----------------------------------------------------------------------------*/
/*             FUNCTION PROTOTYPES                                            */
/*----------------------------------------------------------------------------*/

extern VOID ivntserv_CloseSCManager( VOID );

extern SC_HANDLE ivntserv_OpenSCManager(
DWORD fwdDesiredAccess
);

extern int ivntserv_CreateService(
char * servicename,                     /* unique name of service to create */
char * displayname,                     /* name displayed in SC manager win */
char * exepath,                         /* full pathname of exe of service  */
char * startmode                        /* start mode of service            */
);

extern LONG WINAPI ivntserv_InstallService(
HWND hwndDummy,
LONG *longdummy,
char * servicename,                     /* unique name of service to create */
char * displayname,                     /* name displayed in SC manager win */
char * exepath,                         /* full pathname of exe of service  */
char * startmode                        /* start mode of service            */
);

extern SC_HANDLE ivntserv_OpenService(
char * servicename,                     /* unique name of service to create */
DWORD fwdDesiredAccess
);

extern int ivntserv_StartService(
char * servicename,             /* unique name of service to start          */
int argc,                       /* arguments for service start              */
char * argv[]
);

extern int ivntserv_StopService(
char * servicename              /* unique name of service to stop           */
);

extern int ivntserv_DeleteService(
char * servicename              /* unique name of service to delete         */
);

extern int ivntserv_RegCreateKeyByName(
char * product,                 /* r: product to create key for              */
char * name,                    /* r: name of value to create                */
char * value,                   /* r: buffer for value                       */
int    len                      /* r: length of that value                   */
);

extern int ivntserv_RegQueryKeyByName(
char * product,                 /* r: product to query key for               */
char * name,                    /* r: name of value to request               */
char * value,                   /* w: buffer for value read                  */
long * valuelen                 /* rw: length of that buffer                 */
);

extern char * ivntserv_RegGetKeyByName(
char * service,         /* r: service to get value for               */
char * name             /* r: name of value to request               */
);

extern int ivntserv_RegDeleteKeyByName(
char * product,                 /* r: product to query key for               */
char * name                     /* r: name of value to request               */
);

extern int ivntserv_QueryService(
char * servicename                      /* unique name of service to query  */
);

extern int ivntserv_QueryStatus(
char * servicename,                     /* r  name of service to query        */
char * pprocessname,                    /*  w name of process                 */
int  * ppid,                            /*  w pid of process if found         */
char * ptime                            /*  w start or stop time of process   */
);

extern void WINAPI ivntserv_ServiceStart(
DWORD   argc,
LPTSTR  *argv
);

extern int ivntserv_RegListServices(
);

#ifdef __cplusplus
}
#endif

#endif

