mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 06:03:02 +01:00
Allowed Services API for win32 CS (gbak/gfix only). gstat/gsec are not supported yet.
This commit is contained in:
parent
e1a3921e00
commit
c18c6f17bd
@ -473,7 +473,7 @@ SVC SVC_attach(USHORT service_length,
|
|||||||
**************************************
|
**************************************
|
||||||
*
|
*
|
||||||
* Functional description
|
* Functional description
|
||||||
* Connect to an Interbase service.
|
* Connect to a Firebird service.
|
||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
|
|
||||||
@ -1342,13 +1342,10 @@ void SVC_putc(SVC service, UCHAR ch)
|
|||||||
|
|
||||||
if (item == isc_info_svc_line)
|
if (item == isc_info_svc_line)
|
||||||
get_flags = GET_LINE;
|
get_flags = GET_LINE;
|
||||||
else
|
else if (item == isc_info_svc_to_eof)
|
||||||
{
|
|
||||||
if (item == isc_info_svc_to_eof)
|
|
||||||
get_flags = GET_EOF;
|
get_flags = GET_EOF;
|
||||||
else
|
else
|
||||||
get_flags = GET_BINARY;
|
get_flags = GET_BINARY;
|
||||||
}
|
|
||||||
|
|
||||||
service_get(service, info + 3, end - (info + 4), get_flags,
|
service_get(service, info + 3, end - (info + 4), get_flags,
|
||||||
timeout, &length);
|
timeout, &length);
|
||||||
@ -1905,7 +1902,7 @@ void *SVC_start(SVC service, USHORT spb_length, SCHAR * spb)
|
|||||||
**************************************
|
**************************************
|
||||||
*
|
*
|
||||||
* Functional description
|
* Functional description
|
||||||
* Start an InterBase service
|
* Start a Firebird service
|
||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
TDBB tdbb;
|
TDBB tdbb;
|
||||||
@ -1984,7 +1981,8 @@ void *SVC_start(SVC service, USHORT spb_length, SCHAR * spb)
|
|||||||
*spb == isc_action_svc_delete_user ||
|
*spb == isc_action_svc_delete_user ||
|
||||||
*spb == isc_action_svc_modify_user ||
|
*spb == isc_action_svc_modify_user ||
|
||||||
*spb == isc_action_svc_display_user ||
|
*spb == isc_action_svc_display_user ||
|
||||||
*spb == isc_action_svc_db_stats || *spb == isc_action_svc_properties) {
|
*spb == isc_action_svc_db_stats ||
|
||||||
|
*spb == isc_action_svc_properties) {
|
||||||
/* the user issued a username when connecting to the service so
|
/* the user issued a username when connecting to the service so
|
||||||
* add the length of the username and switch to new_spb_length
|
* add the length of the username and switch to new_spb_length
|
||||||
*/
|
*/
|
||||||
@ -2002,9 +2000,10 @@ void *SVC_start(SVC service, USHORT spb_length, SCHAR * spb)
|
|||||||
sizeof(PASSWORD_SWITCH));
|
sizeof(PASSWORD_SWITCH));
|
||||||
|
|
||||||
/* If svc_switches is not used -- call a command-line parsing utility */
|
/* If svc_switches is not used -- call a command-line parsing utility */
|
||||||
if (!service->svc_switches)
|
if (!service->svc_switches) {
|
||||||
conv_switches(spb_length, opt_switch_len, spb,
|
conv_switches(spb_length, opt_switch_len, spb,
|
||||||
&service->svc_switches);
|
&service->svc_switches);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
/* Command line options (isc_spb_options) is used.
|
/* Command line options (isc_spb_options) is used.
|
||||||
* Currently the only case in which it might happen is -- gbak utility
|
* Currently the only case in which it might happen is -- gbak utility
|
||||||
@ -2051,14 +2050,16 @@ void *SVC_start(SVC service, USHORT spb_length, SCHAR * spb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
/* If svc_switches is not used -- call a command-line parsing utility */
|
/* If svc_switches is not used -- call a command-line parsing utility */
|
||||||
if (!service->svc_switches)
|
if (!service->svc_switches) {
|
||||||
conv_switches(spb_length, opt_switch_len, spb,
|
conv_switches(spb_length, opt_switch_len, spb,
|
||||||
&service->svc_switches);
|
&service->svc_switches);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
assert(service->svc_switches == NULL);
|
assert(service->svc_switches == NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* All services except for get_ib_log require switches */
|
/* All services except for get_ib_log require switches */
|
||||||
if (service->svc_switches == NULL && *spb != isc_action_svc_get_ib_log)
|
if (service->svc_switches == NULL && *spb != isc_action_svc_get_ib_log)
|
||||||
ERR_post(isc_bad_spb_form, 0);
|
ERR_post(isc_bad_spb_form, 0);
|
||||||
@ -2243,7 +2244,7 @@ void SVC_read_ib_log(SVC service)
|
|||||||
**************************************
|
**************************************
|
||||||
*
|
*
|
||||||
* Functional description
|
* Functional description
|
||||||
* Service function which reads the InterBase
|
* Service function which reads the Firebird
|
||||||
* log file into the service buffers.
|
* log file into the service buffers.
|
||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
@ -2608,6 +2609,11 @@ static void service_fork(TEXT * service_path, SVC service)
|
|||||||
q++;
|
q++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (q = argv_data; *q; q++) {
|
||||||
|
if (*q == SVC_TRMNTR)
|
||||||
|
*q = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
THREAD_EXIT;
|
THREAD_EXIT;
|
||||||
|
|
||||||
start_crud.cb = sizeof(STARTUPINFO);
|
start_crud.cb = sizeof(STARTUPINFO);
|
||||||
@ -2616,17 +2622,15 @@ static void service_fork(TEXT * service_path, SVC service)
|
|||||||
start_crud.cbReserved2 = 0;
|
start_crud.cbReserved2 = 0;
|
||||||
start_crud.lpDesktop = NULL;
|
start_crud.lpDesktop = NULL;
|
||||||
start_crud.lpTitle = NULL;
|
start_crud.lpTitle = NULL;
|
||||||
start_crud.dwFlags = STARTF_USESTDHANDLES;
|
start_crud.dwFlags = STARTF_USESHOWWINDOW;
|
||||||
start_crud.hStdInput = my_output;
|
start_crud.wShowWindow = SW_HIDE;
|
||||||
start_crud.hStdOutput = my_input;
|
|
||||||
start_crud.hStdError = my_input;
|
|
||||||
|
|
||||||
if (!(ret = CreateProcess(NULL,
|
if (!(ret = CreateProcess(NULL,
|
||||||
argv_data,
|
argv_data,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
TRUE,
|
TRUE,
|
||||||
NORMAL_PRIORITY_CLASS | DETACHED_PROCESS,
|
NORMAL_PRIORITY_CLASS,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
&start_crud, &pi))) status = GetLastError();
|
&start_crud, &pi))) status = GetLastError();
|
||||||
@ -2657,11 +2661,12 @@ static void service_fork(TEXT * service_path, SVC service)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void service_get(
|
static void service_get(SVC service,
|
||||||
SVC service,
|
|
||||||
SCHAR * buffer,
|
SCHAR * buffer,
|
||||||
USHORT length,
|
USHORT length,
|
||||||
USHORT flags, USHORT timeout, USHORT * return_length)
|
USHORT flags,
|
||||||
|
USHORT timeout,
|
||||||
|
USHORT * return_length)
|
||||||
{
|
{
|
||||||
/**************************************
|
/**************************************
|
||||||
*
|
*
|
||||||
@ -2793,9 +2798,7 @@ static void service_put(SVC service, SCHAR * buffer, USHORT length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static USHORT service_read(
|
static USHORT service_read(SVC service, SCHAR * buffer, USHORT length, USHORT flags)
|
||||||
SVC service,
|
|
||||||
SCHAR * buffer, USHORT length, USHORT flags)
|
|
||||||
{
|
{
|
||||||
/**************************************
|
/**************************************
|
||||||
*
|
*
|
||||||
@ -2810,10 +2813,8 @@ static USHORT service_read(
|
|||||||
* special character.
|
* special character.
|
||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
SLONG len, n = 0L;
|
SLONG len, n = 0;
|
||||||
SCHAR *buf;
|
SCHAR *buf = buffer;
|
||||||
|
|
||||||
buf = buffer;
|
|
||||||
|
|
||||||
while (length) {
|
while (length) {
|
||||||
n = 0;
|
n = 0;
|
||||||
@ -2835,6 +2836,9 @@ static USHORT service_read(
|
|||||||
isc_io_read_err, TRUE);
|
isc_io_read_err, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((flags & GET_LINE) && buf[-1] == '\n')
|
||||||
|
buf[-1] = ' ';
|
||||||
|
|
||||||
return buf - buffer;
|
return buf - buffer;
|
||||||
}
|
}
|
||||||
#endif /* ifndef SUPERSERVER */
|
#endif /* ifndef SUPERSERVER */
|
||||||
@ -3611,7 +3615,6 @@ static USHORT process_switches(
|
|||||||
TEXT *p, *sw;
|
TEXT *p, *sw;
|
||||||
ISC_USHORT svc_action;
|
ISC_USHORT svc_action;
|
||||||
BOOLEAN found = FALSE;
|
BOOLEAN found = FALSE;
|
||||||
//BOOLEAN lic_key = FALSE, lic_id = FALSE;
|
|
||||||
|
|
||||||
if (spb_length == 0)
|
if (spb_length == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -3909,22 +3912,33 @@ static void get_action_svc_string(
|
|||||||
* when creating the argc / argv paramters for the service.
|
* when creating the argc / argv paramters for the service.
|
||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
ISC_USHORT l;
|
ISC_USHORT l, l2;
|
||||||
|
|
||||||
l =
|
l = gds__vax_integer(reinterpret_cast < UCHAR * >(*spb),
|
||||||
gds__vax_integer(reinterpret_cast < UCHAR * >(*spb),
|
|
||||||
sizeof(ISC_USHORT));
|
sizeof(ISC_USHORT));
|
||||||
|
|
||||||
|
const char* local_server = "localhost:";
|
||||||
|
#if defined(WIN_NT) && !defined(SUPERSERVER)
|
||||||
|
// dimitr: temporary hack to make Services API available
|
||||||
|
// for the engine without support of local protocol.
|
||||||
|
// Once XNET is implemented in win32 CS, remove this ugly code.
|
||||||
|
TEXT * spb_item = *spb - 1;
|
||||||
|
l2 = (*spb_item == isc_spb_dbname) ? strlen(local_server) : 0;
|
||||||
|
#else
|
||||||
|
l2 = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Do not go beyond the bounds of the spb buffer */
|
/* Do not go beyond the bounds of the spb buffer */
|
||||||
if (l > *len)
|
if (l > *len)
|
||||||
ERR_post(isc_bad_spb_form, 0);
|
ERR_post(isc_bad_spb_form, 0);
|
||||||
|
|
||||||
|
|
||||||
*spb += sizeof(ISC_USHORT);
|
*spb += sizeof(ISC_USHORT);
|
||||||
if (*cmd)
|
if (*cmd)
|
||||||
{
|
{
|
||||||
**cmd = SVC_TRMNTR;
|
**cmd = SVC_TRMNTR;
|
||||||
*cmd += 1;
|
*cmd += 1;
|
||||||
|
MOVE_FASTER(local_server, *cmd, l2);
|
||||||
|
*cmd += l2;
|
||||||
MOVE_FASTER(*spb, *cmd, l);
|
MOVE_FASTER(*spb, *cmd, l);
|
||||||
*cmd += l;
|
*cmd += l;
|
||||||
**cmd = SVC_TRMNTR;
|
**cmd = SVC_TRMNTR;
|
||||||
@ -3933,7 +3947,7 @@ static void get_action_svc_string(
|
|||||||
*cmd += 1;
|
*cmd += 1;
|
||||||
}
|
}
|
||||||
*spb += l;
|
*spb += l;
|
||||||
*total += l + 1 + 2; /* Two SVC_TRMNTR for strings */
|
*total += l + l2 + 1 + 2; /* Two SVC_TRMNTR for strings */
|
||||||
*len -= sizeof(ISC_USHORT) + l;
|
*len -= sizeof(ISC_USHORT) + l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user