8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 22:03:03 +01:00

Don't use the registry, use new config manager instead.

This commit is contained in:
dimitr 2002-11-10 14:06:16 +00:00
parent 011dbe0262
commit 8a376d766b
3 changed files with 7 additions and 103 deletions

View File

@ -30,12 +30,10 @@
#include "../utilities/install_nt.h" #include "../utilities/install_nt.h"
#include "../utilities/servi_proto.h" #include "../utilities/servi_proto.h"
#include "../utilities/registry.h" #include "../utilities/registry.h"
#include "../iscguard/iscguard_utils.cpp" #include "../common/config/config.h"
extern USHORT svc_error(SLONG, TEXT *, SC_HANDLE); extern USHORT svc_error(SLONG, TEXT *, SC_HANDLE);
static void usage(void); static void usage(void);
static USHORT using_guardian (USHORT (*err_handler)(SLONG, TEXT *, SC_HANDLE));
static USHORT guardian_setup (USHORT (*err_handler)(SLONG, TEXT *, SC_HANDLE));
static struct { static struct {
TEXT *name; TEXT *name;
@ -175,10 +173,6 @@ int CLIB_ROUTINE main( int argc, char **argv)
/* Set sw_startup to manual in preparation for install the ib_server service*/ /* Set sw_startup to manual in preparation for install the ib_server service*/
sw_startup = STARTUP_DEMAND; sw_startup = STARTUP_DEMAND;
/* Finally, update the GuardianOptions to 1 so that Guardian
knows it is configured correctly. */
guardian_setup(svc_error);
} }
#endif #endif
@ -249,7 +243,7 @@ int CLIB_ROUTINE main( int argc, char **argv)
case COMMAND_START: case COMMAND_START:
/* Test for use of Guardian. If so, start the guardian else start ib-server */ /* Test for use of Guardian. If so, start the guardian else start ib-server */
if (using_guardian(svc_error) == 1) { if (Config::getGuardianOption() == 1) {
#if (defined SUPERCLIENT || defined SUPERSERVER) #if (defined SUPERCLIENT || defined SUPERSERVER)
status = SERVICES_start(manager, ISCGUARD_SERVICE, ISCGUARD_DISPLAY_NAME, status = SERVICES_start(manager, ISCGUARD_SERVICE, ISCGUARD_DISPLAY_NAME,
sw_mode, svc_error); sw_mode, svc_error);
@ -273,7 +267,7 @@ int CLIB_ROUTINE main( int argc, char **argv)
case COMMAND_STOP: case COMMAND_STOP:
/* Test for use of Guardian. If so, stop the guardian else stop ib-server */ /* Test for use of Guardian. If so, stop the guardian else stop ib-server */
if (using_guardian(svc_error) == 1) { if (Config::getGuardianOption() == 1) {
#if (defined SUPERCLIENT || defined SUPERSERVER) #if (defined SUPERCLIENT || defined SUPERSERVER)
status = SERVICES_stop(manager, ISCGUARD_SERVICE, ISCGUARD_DISPLAY_NAME, status = SERVICES_stop(manager, ISCGUARD_SERVICE, ISCGUARD_DISPLAY_NAME,
svc_error); svc_error);
@ -365,88 +359,3 @@ static void usage(void)
exit(FINI_OK); exit(FINI_OK);
} }
static USHORT using_guardian(USHORT (*err_handler)(SLONG, TEXT *, SC_HANDLE))
{
/**************************************
*
* u s i n g _ g u a r d i a n
*
**************************************
*
* Functional description
* Are we using the guardian?
*
**************************************/
HKEY hkey;
SLONG status;
TEXT *mode;
DWORD buffSize;
mode = "0";
buffSize = 2;
if ((status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
REG_KEY_ROOT_CUR_VER,
0,
KEY_READ,
&hkey)) != ERROR_SUCCESS) {
return (*err_handler)(status, "RegOpenKeyEx", NULL);
}
if ((status = RegQueryValueEx(hkey,
"GuardianOptions",
NULL,
NULL,
reinterpret_cast<UCHAR*>(mode),
&buffSize)) != ERROR_SUCCESS) {
RegCloseKey(hkey);
return (*err_handler)(status, "RegQueryValueEx", NULL);
}
RegCloseKey(hkey);
return atoi(mode);
};
USHORT guardian_setup(USHORT (*err_handler)(SLONG, TEXT *, SC_HANDLE))
{
/*************************************************
*
* g u a r d i a n _ s e t u p
*
*************************************************
*
* Functional description
* Set up the Guardian's registry details
*
*************************************************/
HKEY hkey;
SLONG status;
if ((status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
REG_KEY_ROOT_CUR_VER,
0,
KEY_WRITE,
&hkey)) != ERROR_SUCCESS) {
return (*err_handler)(status, "RegOpenKeyEx", NULL);
}
if (status = RegSetValueEx(hkey,
"GuardianOptions",
0,
REG_SZ,
reinterpret_cast<UCHAR*>("1"),
2) != ERROR_SUCCESS) {
return (*err_handler)(status, "RegSetValueEx",
reinterpret_cast<SC_HANDLE>(hkey));
}
RegCloseKey (hkey);
return SUCCESS;
}

View File

@ -86,6 +86,7 @@ USHORT REGISTRY_install(HKEY hkey_node,
} }
/* We might as well add ServerDirectory here */ /* We might as well add ServerDirectory here */
/*
strcat(path_name, "\\bin"); strcat(path_name, "\\bin");
len = GetFullPathName(path_name, sizeof(path_name), path_name, &p); len = GetFullPathName(path_name, sizeof(path_name), path_name, &p);
if (len && path_name[len - 1] != '/' && path_name[len - 1] != '\\') { if (len && path_name[len - 1] != '/' && path_name[len - 1] != '\\') {
@ -110,7 +111,7 @@ USHORT REGISTRY_install(HKEY hkey_node,
REGISTRY_remove(hkey_node, TRUE, err_handler); REGISTRY_remove(hkey_node, TRUE, err_handler);
return FAILURE; return FAILURE;
} }
*/
RegCloseKey(hkey_kit); RegCloseKey(hkey_kit);
return SUCCESS; return SUCCESS;

View File

@ -25,13 +25,7 @@
#ifndef _REGISTRY_DEFINES_ #ifndef _REGISTRY_DEFINES_
#define _REGISTRY_DEFINES_ #define _REGISTRY_DEFINES_
#define REG_KEY_BOR_ROOT "SOFTWARE\\Borland\\InterBase" #define REG_KEY_ROOT "SOFTWARE\\FirebirdSQL\\Firebird"
#define REG_KEY_BOR_ROOT_CUR_VER "SOFTWARE\\Borland\\InterBase\\CurrentVersion" #define REG_KEY_ROOT_CUR_VER "SOFTWARE\\FirebirdSQL\\Firebird\\CurrentVersion"
#define REG_KEY_FIR_ROOT "SOFTWARE\\FirebirdSQL\\Firebird"
#define REG_KEY_FIR_ROOT_CUR_VER "SOFTWARE\\FirebirdSQL\\Firebird\\CurrentVersion"
#define REG_KEY_ROOT REG_KEY_FIR_ROOT
#define REG_KEY_ROOT_CUR_VER REG_KEY_FIR_ROOT_CUR_VER
#endif /* _REGISTRY_DEFINES_ */ #endif /* _REGISTRY_DEFINES_ */