/*****************************************************************************
* Copyright (c) 1990-2001 Digi International Inc., All Rights Reserved
* 
* This software contains proprietary and confidential information of Digi
* International Inc.  By accepting transfer of this copy, Recipient agrees
* to retain this software in confidence, to prevent disclosure to others,
* and to make no use of this software other than that for which it was
* delivered.  This is an unpublished copyrighted work of Digi International
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
* prohibited.
* 
* Restricted Rights Legend
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7031 or
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -
* Restricted Rights at 48 CFR 52.227-19, as applicable.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
*
*****************************************************************************/
#ifndef __COMMON_H
#define __COMMON_H

#include "buildctrl.h"

#define NUMBER_OF_LINK_SERVICES	22
#define	MAX_STRING	255
#define MAX_BUFFER	255

#if !NT5_BUILD && !_M_IA64
// NT5 and newer DDKs define these types.  They float (at compile time) from 32 to 64
// bit width depending on the size of pointers in the system being compiled for.
// Define it for NT4.
typedef ULONG        ULONG_PTR, *PULONG_PTR;
typedef LONG         LONG_PTR,  *PLONG_PTR;
typedef int          INT_PTR,   *PINT_PTR;
typedef unsigned int UINT_PTR,  *PUINT_PTR;
#endif

typedef struct _MGSDLCDS           /* Configuration Data */
	{
	char		szInstallPath[MAX_STRING];
	char		szCardString[MAX_STRING]; //
	char		szAdapterServiceString[MAX_STRING]; //
	char		szLineType[MAX_STRING]; //
	char		szRadio4Flag[MAX_STRING]; //
	char		szConstantRTS[MAX_STRING]; //
	char		szDeviceName[MAX_STRING];
	char		szDistributable[MAX_STRING]; //
	BOOL		bBindingsNeeded;
	char		szLinkServiceName[MAX_STRING];
	char		szLinkServiceTitle[MAX_STRING];
	char		szLinkServiceSoftwareRegistryRoot[MAX_STRING];
	char		szLinkServiceServicesRegistryRoot[MAX_STRING];
	char		szLinkServiceLinkServicetype[MAX_STRING];
	char		szDeviceDriverName[MAX_STRING];
	char		szDeviceDriverTitle[MAX_STRING];
	char		szDeviceDriverSoftwareRegistryRoot[MAX_STRING];
	char		szDeviceDriverServicesRegistryRoot[MAX_STRING];
	DWORD		dLineSpeed;
	BOOL		bInternalClock;
	}  MGSDLCDS;

typedef enum _ACTION
{
	NEW,
	EXISTING,
	REMOVING
} ACTION;

typedef struct _MGSDLCREG           /* IBM SDLC Registry Entry */
{
		char	szRegistryKey[MAX_STRING];
		char	szRegistryValue[MAX_STRING];
		char	szRegistryData[MAX_BUFFER];
		DWORD	dType;
		DWORD	dLength;
		BOOL	bInstallThisEntry;
		BOOL	bInstallThisEntryForNT5;
} TYPEMGSDLCREG;

#define MAX_MGATE_LINKS	20
#define DXBPATH		_T("DigiDxbPath")
#define LSPATH		_T("LinkServicePath")
#define INUSE		_T("InUse")
#define CARD		_T("CardString")
#define SNID		_T("Snid")



#define	REGSERVICE			_T("System\\CurrentControlSet\\Services\\")
#define	REGADAPTERPATH_NT4	_T("System\\CurrentControlSet\\Services\\")
#define REGADAPTERPATH_NT5	_T("SYSTEM\\CurrentControlSet\\Control\\Class\\")
#define REGNETCARDGUID_NT5  _T("{4D36E972-E325-11CE-BFC1-08002BE10318}\\")
#define REGSNA				_T("System\\CurrentControlSet\\Services\\" WANLINKS_SNA_NAME_QUOT "\\Parameters")
#define	REGPARAMS			_T("\\Parameters\\ExtraParameters")
#define REGEVENTLOG			_T("System\\CurrentControlSet\\Services\\EventLog\\System")

extern MGSDLCDS gMgsdlc_data;
extern DWORD gdwOSMajorVersion;
 
//
// External Function Prototypes
//

extern BOOL fStringCompare(LPSTR lpszStr1, LPSTR lpszStr2);

extern BOOL fFindAndReplaceString(LPSTR szStringBuffer, 
						   LPSTR szSearchString, 
						   LPSTR szReplaceString);

extern BOOL fConnectRegistry(char * szComputerName);

extern void fDisconnectRegistry();

extern BOOL fAddRegistryEntry (char* szRegistryKey, char* szRegistryName, 
						char* szRegistryData, DWORD dwType, ULONG_PTR dSize );

extern BOOL fRemoveRegistryEntry (char* szRegistryKey);

extern BOOL fRemoveRegistryValue (char* szRegistryKey, char* szRegistryValue);

extern BOOL fRegistryKeyExists(LPSTR szRegistryKey);

extern BOOL fQueryRegistryValue(LPSTR szRegistryKey, LPSTR szRegistryValue, 
						 LPSTR szRegistryData, LPDWORD dSize);

extern BOOL fCanWeAdministerRemoteBox();

extern BOOL bDeleteService(LPSTR szComputerName, LPSTR szServiceName);

extern BOOL bStopService(LPSTR szServiceName, LPSTR szComputer);

extern BOOL bCreateService(LPSTR szComputerName, LPSTR szServiceName, LPSTR szServicePath, 
					LPSTR szServiceDependencies, DWORD dServiceType, DWORD dServiceLoadType);

//
// Function Prototypes
//
extern void fEnumerateEventLogSources(LPSTR szEventLogRegistryKey,
							   LPSTR szValueName);

extern void fAddAllRegistryValues(DWORD dStartIndex);

extern void fRemoveAllRegistryValues(BOOL bRemoveSyncDriver);

extern void fReplaceRegistryKeyName(DWORD dStartIndex, DWORD dEndIndex,
							 LPSTR szOldString, LPSTR szNewString);

extern void fReplaceRegistryData(DWORD dStartIndex, DWORD dEndIndex,
						  LPSTR szOldString, LPSTR szNewString);

extern void fReplaceAllRegistryValues(ACTION eAction);

extern void fAddClassAndBindformRegistries(void);

extern BOOL fSetupGlobalValues(LPSTR szLinkServiceTitle, LPSTR szComputerName, LPSTR szSNALinePath);

extern BOOL bLastDigiLinkService(LPSTR szComputerName);

extern void SetOSGlobals();

extern BOOL bAvailableSNALineNT4(CString& szLinePath);
extern BOOL bAvailableSNALineNT5(CString& szLinePath);

extern BOOL  fRemoveAllLinkServices(LPSTR szComputerName);

extern BOOL fRemoveLinkService(LPSTR szComputerName, LPSTR szLinkServiceTitle);

extern void fAddPerfmonCounters(LPSTR szComputerName);

extern void fInstallService(BOOL bNewLinkService,LPSTR pszComputerName,LPSTR pszSNALinePath);


#endif