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

ongoing cleanup

This commit is contained in:
tamlin 2001-05-24 14:54:26 +00:00
parent 9a776a604e
commit 9587c717b3
29 changed files with 1072 additions and 783 deletions

View File

@ -24,7 +24,7 @@
// //
//____________________________________________________________ //____________________________________________________________
// //
// $Id: tdr.cpp,v 1.1.1.1 2001-05-23 13:25:33 tamlin Exp $ // $Id: tdr.cpp,v 1.2 2001-05-24 14:54:25 tamlin Exp $
// //
#include "../jrd/ib_stdio.h" #include "../jrd/ib_stdio.h"
@ -452,7 +452,8 @@ BOOLEAN TDR_reconnect_multiple(int *handle,
switches |= sw_commit; switches |= sw_commit;
else if (switches & sw_two_phase) else if (switches & sw_two_phase)
switches |= sw_commit; switches |= sw_commit;
else if (switches & sw_prompt) { else if (switches & sw_prompt)
{
ALICE_print(78, reinterpret_cast < char *>(trans->tdr_id), 0, ALICE_print(78, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 78: Transaction %ld has been partially committed. */ 0, 0, 0); /* msg 78: Transaction %ld has been partially committed. */
ALICE_print(79, 0, 0, 0, 0, 0); /* msg 79: A commit is necessary to preserve the two-phase commit. */ ALICE_print(79, 0, 0, 0, 0, 0); /* msg 79: A commit is necessary to preserve the two-phase commit. */
@ -470,7 +471,8 @@ BOOLEAN TDR_reconnect_multiple(int *handle,
break; break;
default: default:
if (!(switches & (sw_commit | sw_rollback))) { if (!(switches & (sw_commit | sw_rollback)))
{
ALICE_print(82, reinterpret_cast < char *>(trans->tdr_id), 0, ALICE_print(82, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 82: Transaction %ld: All subtransactions have been prepared. */ 0, 0, 0); /* msg 82: Transaction %ld: All subtransactions have been prepared. */
ALICE_print(83, 0, 0, 0, 0, 0); /* msg 83: Either commit or rollback is possible. */ ALICE_print(83, 0, 0, 0, 0, 0); /* msg 83: Either commit or rollback is possible. */
@ -480,16 +482,24 @@ BOOLEAN TDR_reconnect_multiple(int *handle,
} }
} }
if (switches != (ULONG) - 1) { if (switches != (ULONG) - 1)
{
/* now do the required operation with all the subtransactions */ /* now do the required operation with all the subtransactions */
if (switches & (sw_commit | sw_rollback)) if (switches & (sw_commit | sw_rollback))
{
for (ptr = trans; ptr; ptr = ptr->tdr_next) for (ptr = trans; ptr; ptr = ptr->tdr_next)
{
if (ptr->tdr_state == TRA_limbo) if (ptr->tdr_state == TRA_limbo)
{
reconnect(reinterpret_cast < int *>(ptr->tdr_db_handle), reconnect(reinterpret_cast < int *>(ptr->tdr_db_handle),
ptr->tdr_id, ptr->tdr_filename, switches); ptr->tdr_id, ptr->tdr_filename, switches);
}
}
}
} }
else { else
{
ALICE_print(84, 0, 0, 0, 0, 0); /* msg 84: unexpected end of input */ ALICE_print(84, 0, 0, 0, 0, 0); /* msg 84: unexpected end of input */
error = TRUE; error = TRUE;
} }
@ -514,59 +524,63 @@ static void print_description(TDR trans)
{ {
TDR ptr; TDR ptr;
BOOLEAN prepared_seen; BOOLEAN prepared_seen;
TGBL tdgbl;
int i;
tdgbl = GET_THREAD_DATA; #ifdef SUPERSERVER
int i;
#endif
TGBL tdgbl = GET_THREAD_DATA;
if (!trans) if (!trans)
{
return; return;
}
if (!tdgbl->sw_service_thd) if (!tdgbl->sw_service_thd)
{
ALICE_print(92, 0, 0, 0, 0, 0); /* msg 92: Multidatabase transaction: */ ALICE_print(92, 0, 0, 0, 0, 0); /* msg 92: Multidatabase transaction: */
}
prepared_seen = FALSE; prepared_seen = FALSE;
for (ptr = trans; ptr; ptr = ptr->tdr_next) { for (ptr = trans; ptr; ptr = ptr->tdr_next)
if (ptr->tdr_host_site) { {
if (ptr->tdr_host_site)
{
char* pszHostSize =
reinterpret_cast<char*>(ptr->tdr_host_site->str_data);
#ifndef SUPERSERVER #ifndef SUPERSERVER
ALICE_print(93, /* msg 93: Host Site: %s */
reinterpret_cast < ALICE_print(93, pszHostSize, 0, 0, 0, 0);
char *>(ptr->tdr_host_site->str_data), 0, 0, 0, 0); /* msg 93: Host Site: %s */
#else #else
const size_t nHostSiteLen = strlen(pszHostSize);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_host_site); SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_host_site);
SVC_putc(tdgbl->service_blk, SVC_putc(tdgbl->service_blk, (UCHAR) nHostSiteLen);
(UCHAR) strlen(reinterpret_cast < SVC_putc(tdgbl->service_blk, (UCHAR) (nHostSiteLen >> 8 ));
const char *>(ptr-> for (i = 0; i < (int) nHostSiteLen; i++)
tdr_host_site->str_data))); {
SVC_putc(tdgbl->service_blk, SVC_putc(tdgbl->service_blk, (UCHAR) pszHostSize[i]);
(UCHAR) (strlen }
(reinterpret_cast <
const char *>(ptr->
tdr_host_site->str_data)) >> 8));
for (i = 0;
i < (int) strlen(reinterpret_cast <
const char *>(ptr->
tdr_host_site->str_data));
i++);
SVC_putc(tdgbl->service_blk,
(UCHAR) ptr->tdr_host_site->str_data[i]);
#endif #endif
} }
if (ptr->tdr_id) if (ptr->tdr_id)
#ifndef SUPERSERVER
ALICE_print(94, reinterpret_cast < char *>(ptr->tdr_id), 0, 0, 0, 0); /* msg 94: Transaction %ld */
#else
{ {
#ifndef SUPERSERVER
/* msg 94: Transaction %ld */
ALICE_print(94, reinterpret_cast<char*>(ptr->tdr_id), 0, 0, 0, 0);
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_id); SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_id);
SVC_putc(tdgbl->service_blk, (UCHAR) ptr->tdr_id); SVC_putc(tdgbl->service_blk, (UCHAR) ptr->tdr_id);
SVC_putc(tdgbl->service_blk, (UCHAR) (ptr->tdr_id >> 8)); SVC_putc(tdgbl->service_blk, (UCHAR) (ptr->tdr_id >> 8));
SVC_putc(tdgbl->service_blk, (UCHAR) (ptr->tdr_id >> 16)); SVC_putc(tdgbl->service_blk, (UCHAR) (ptr->tdr_id >> 16));
SVC_putc(tdgbl->service_blk, (UCHAR) (ptr->tdr_id >> 24)); SVC_putc(tdgbl->service_blk, (UCHAR) (ptr->tdr_id >> 24));
}
#endif #endif
}
switch (ptr->tdr_state) { switch (ptr->tdr_state)
{
case TRA_limbo: case TRA_limbo:
#ifndef SUPERSERVER #ifndef SUPERSERVER
ALICE_print(95, 0, 0, 0, 0, 0); /* msg 95: has been prepared. */ ALICE_print(95, 0, 0, 0, 0, 0); /* msg 95: has been prepared. */
@ -607,60 +621,58 @@ static void print_description(TDR trans)
default: default:
#ifndef SUPERSERVER #ifndef SUPERSERVER
if (prepared_seen) if (prepared_seen)
ALICE_print(99, 0, 0, 0, 0, 0); /* msg 99: is not found, assumed not prepared. */ {
/* msg 99: is not found, assumed not prepared. */
ALICE_print(99, 0, 0, 0, 0, 0);
}
else else
ALICE_print(100, 0, 0, 0, 0, 0); /* msg 100: is not found, assumed to be committed. */ {
/* msg 100: is not found, assumed to be committed. */
ALICE_print(100, 0, 0, 0, 0, 0);
}
#endif #endif
break; break;
} }
if (ptr->tdr_remote_site) { if (ptr->tdr_remote_site)
{
char* pszRemoteSite =
reinterpret_cast<char*>(ptr->tdr_remote_site->str_data);
#ifndef SUPERSERVER #ifndef SUPERSERVER
ALICE_print(101, /*msg 101: Remote Site: %s */
reinterpret_cast < ALICE_print(101, pszRemoteSite, 0, 0, 0, 0);
char *>(ptr->tdr_remote_site->str_data), 0, 0, 0, 0); /*msg 101: Remote Site: %s */
#else #else
const size_t nRemoteSiteLen = strlen(pszRemoteSite);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_remote_site); SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_remote_site);
SVC_putc(tdgbl->service_blk, SVC_putc(tdgbl->service_blk, (UCHAR) nRemoteSiteLen);
(UCHAR) strlen(reinterpret_cast < SVC_putc(tdgbl->service_blk, (UCHAR) (nRemoteSiteLen >> 8));
const char *>(ptr-> for (i = 0; i < (int) nRemoteSiteLen; i++)
tdr_remote_site->str_data))); {
SVC_putc(tdgbl->service_blk, SVC_putc(tdgbl->service_blk, (UCHAR) nRemoteSiteLen);
(UCHAR) (strlen }
(reinterpret_cast <
const char *>(ptr->
tdr_remote_site->str_data)) >>
8));
for (i = 0;
i < (int) strlen(reinterpret_cast <
const char *>(ptr->
tdr_remote_site->str_data));
i++) SVC_putc(tdgbl->service_blk,
(UCHAR) ptr->tdr_remote_site->str_data[i]);
#endif #endif
} }
if (ptr->tdr_fullpath) { if (ptr->tdr_fullpath)
{
char* pszFullpath =
reinterpret_cast<char*>(ptr->tdr_fullpath->str_data);
#ifndef SUPERSERVER #ifndef SUPERSERVER
ALICE_print(102, /* msg 102: Database Path: %s */
reinterpret_cast < ALICE_print(102, pszFullpath, 0, 0, 0, 0);
char *>(ptr->tdr_fullpath->str_data), 0, 0, 0, 0); /* msg 102: Database Path: %s */
#else #else
const size_t nFullpathLen = strlen(pszFullpath);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_db_path); SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_db_path);
SVC_putc(tdgbl->service_blk, SVC_putc(tdgbl->service_blk, (UCHAR) nFullpathLen);
(UCHAR) strlen(reinterpret_cast < SVC_putc(tdgbl->service_blk, (UCHAR) (nFullpathLen >> 8));
const char *>(ptr-> for (i = 0; i < (int) nFullpathLen; i++)
tdr_fullpath->str_data))); {
SVC_putc(tdgbl->service_blk, SVC_putc(tdgbl->service_blk, (UCHAR) pszFullpath[i]);
(UCHAR) (strlen }
(reinterpret_cast <
const char *>(ptr->
tdr_fullpath->str_data)) >> 8));
for (i = 0;
i < (int) strlen(reinterpret_cast <
const char *>(ptr->tdr_fullpath->str_data));
i++) SVC_putc(tdgbl->service_blk,
(UCHAR) ptr->tdr_fullpath->str_data[i]);
#endif #endif
} }
@ -668,10 +680,12 @@ static void print_description(TDR trans)
// let the user know what the suggested action is // let the user know what the suggested action is
switch (TDR_analyze(trans)) { switch (TDR_analyze(trans))
{
case TRA_commit: case TRA_commit:
#ifndef SUPERSERVER #ifndef SUPERSERVER
ALICE_print(103, 0, 0, 0, 0, 0); /* msg 103: Automated recovery would commit this transaction. */ /* msg 103: Automated recovery would commit this transaction. */
ALICE_print(103, 0, 0, 0, 0, 0);
#else #else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise); SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise_commit); SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise_commit);
@ -680,7 +694,8 @@ static void print_description(TDR trans)
case TRA_rollback: case TRA_rollback:
#ifndef SUPERSERVER #ifndef SUPERSERVER
ALICE_print(104, 0, 0, 0, 0, 0); /* msg 104: Automated recovery would rollback this transaction. */ /* msg 104: Automated recovery would rollback this transaction. */
ALICE_print(104, 0, 0, 0, 0, 0);
#else #else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise); SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise_rollback); SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise_rollback);

View File

@ -52,15 +52,15 @@ UCHAR *MISC_alloc_burp(ULONG size)
* This could be optimized. * This could be optimized.
* *
**************************************/ **************************************/
UCHAR *block;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA; TGBL tdgbl = GET_THREAD_DATA;
/* Add some header space to store a list of blocks allocated for this gbak */ /* Add some header space to store a list of blocks allocated for this gbak */
size += ROUNDUP(sizeof(UCHAR *), ALIGNMENT); size += ROUNDUP(sizeof(UCHAR *), ALIGNMENT);
if (!(block = gds__alloc(size))) UCHAR* block = (UCHAR*)gds__alloc(size);
if (!block)
/* NOMEM: message & abort FREE: all items freed at gbak exit */ /* NOMEM: message & abort FREE: all items freed at gbak exit */
{ {
BURP_error(238, NULL, NULL, NULL, NULL, NULL); /* msg 238: System memory exhaused */ BURP_error(238, NULL, NULL, NULL, NULL, NULL); /* msg 238: System memory exhaused */

View File

@ -23,18 +23,18 @@
#include "../dsql/dsql.h" #include "../dsql/dsql.h"
BLK ALLD_alloc( /* alloc and init a block from a pool */ /* alloc and init a block from a pool */
PLB pool, UCHAR type, int count); BLK ALLD_alloc(PLB pool, UCHAR type, int count);
BLK ALLD_extend( /* extend a block by given size */ /* extend a block by given size */
BLK * pointer, int size); BLK ALLD_extend(BLK* pointer, int size);
int ALLD_fini(); /* get rid of everything */ int ALLD_fini(); /* get rid of everything */
int ALLD_free(SCHAR * memory); /* give space back to system */ int ALLD_free(void* memory); /* give space back to system */
int ALLD_init(); /* initialize pool system */ int ALLD_init(); /* initialize pool system */
UCHAR *ALLD_malloc(int size); /* get memory from system */ void* ALLD_malloc(int size); /* get memory from system */
PLB ALLD_pool(); /* allocate a new pool */ PLB ALLD_pool(); /* allocate a new pool */
int ALLD_push(BLK object, LLS * stack); /* push object on LLS stack */ int ALLD_push(BLK object, LLS * stack); /* push object on LLS stack */
BLK ALLD_pop(LLS * stack); /* pop object off LLS stack */ BLK ALLD_pop(LLS* stack); /* pop object off LLS stack */
int ALLD_release(FRB block); /* release a block to its pool */ int ALLD_release(FRB block); /* release a block to its pool */
int ALLD_rlpool(PLB pool); /* release a pool */ int ALLD_rlpool(PLB pool); /* release a pool */

View File

@ -350,7 +350,7 @@ void ALLD_fini(void)
} }
void ALLD_free( SCHAR * memory) void ALLD_free(void* memory)
{ {
/************************************** /**************************************
* *
@ -412,7 +412,7 @@ USHORT ALLD_init(void)
} }
UCHAR *ALLD_malloc(ULONG size) void* ALLD_malloc(ULONG size)
{ {
/************************************** /**************************************
* *
@ -424,26 +424,27 @@ UCHAR *ALLD_malloc(ULONG size)
* Get memory from system. * Get memory from system.
* *
**************************************/ **************************************/
register UCHAR *memory;
TSQL tdsql;
tdsql = GET_THREAD_DATA; TSQL tdsql = GET_THREAD_DATA;
if ((memory = gds__alloc((SLONG) size)) != NULL) UCHAR* memory = (UCHAR*)gds__alloc((SLONG) size);
#ifdef SUPERSERVER
if (memory)
{ {
#ifdef SUPERSERVER
alld_delta_alloc += size; alld_delta_alloc += size;
#endif
return memory; return memory;
} }
#else
return memory;
#endif
/* FREE: by ALLD_free, called during DSQL cleanup */ /* FREE: by ALLD_free, called during DSQL cleanup */
/* NOMEM: post a user level error - if we can */ /* NOMEM: post a user level error - if we can */
if (tdsql && tdsql->tsql_setjmp) if (tdsql && tdsql->tsql_setjmp)
{
ERRD_post(gds__sys_request, gds_arg_string, "gds__alloc", gds_arg_gds, ERRD_post(gds__sys_request, gds_arg_string, "gds__alloc", gds_arg_gds,
gds__virmemexh, gds_arg_end); gds__virmemexh, gds_arg_end);
}
/* Commentary: This expands out to a call to ERRD_error - which /* Commentary: This expands out to a call to ERRD_error - which
* promply depends on tdsql being non-NULL. Knock, knock, anyone home? * promply depends on tdsql being non-NULL. Knock, knock, anyone home?
@ -711,17 +712,21 @@ void ALLD_rlpool( PLB pool)
* contains pool itself * contains pool itself
*/ */
#ifdef SUPERSERVER #ifdef SUPERSERVER
if (trace_pools && pool->plb_blk_type_count) { if (trace_pools && pool->plb_blk_type_count)
{
int i; int i;
for (i = 0; i < type_MAX; i++) for (i = 0; i < type_MAX; i++)
{
alld_block_type_count[i] -= pool->plb_blk_type_count[i]; alld_block_type_count[i] -= pool->plb_blk_type_count[i];
}
gds__free(pool->plb_blk_type_count); gds__free(pool->plb_blk_type_count);
} }
#endif #endif
for (hunks = pool->plb_hunks; hunk = hunks;) { for (hunks = pool->plb_hunks; hunk = hunks;)
{
hunks = hunk->hnk_next; hunks = hunk->hnk_next;
ALLD_free(reinterpret_cast < char *>(hunk->hnk_address)); ALLD_free(hunk->hnk_address);
} }
} }

View File

@ -28,17 +28,17 @@
extern "C" { extern "C" {
#endif #endif
extern BLK ALLD_alloc(struct plb *, UCHAR, ULONG); BLK ALLD_alloc(struct plb*, UCHAR, ULONG);
extern BLK ALLD_extend(struct blk **, ULONG); BLK ALLD_extend(struct blk**, ULONG);
extern void ALLD_fini(void); void ALLD_fini(void);
extern void ALLD_free(SCHAR *); void ALLD_free(void*);
extern USHORT ALLD_init(void); USHORT ALLD_init(void);
extern UCHAR *ALLD_malloc(ULONG); void* ALLD_malloc(ULONG);
extern PLB ALLD_pool(void); PLB ALLD_pool(void);
extern BLK ALLD_pop(register struct lls **); BLK ALLD_pop(register struct lls**);
extern void ALLD_push(struct blk *, register struct lls **); void ALLD_push(struct blk*, register struct lls**);
extern void ALLD_release(register struct frb *); void ALLD_release(register struct frb*);
extern void ALLD_rlpool(struct plb *); void ALLD_rlpool(struct plb*);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View File

@ -21,7 +21,7 @@
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
*/ */
/* /*
$Id: dsql.cpp,v 1.1.1.1 2001-05-23 13:25:36 tamlin Exp $ $Id: dsql.cpp,v 1.2 2001-05-24 14:54:25 tamlin Exp $
*/ */
/************************************************************** /**************************************************************
V4 Multi-threading changes. V4 Multi-threading changes.
@ -2255,32 +2255,40 @@ static STATUS execute_request(REQ request,
/* If there is no data required, just start the request */ /* If there is no data required, just start the request */
if (!(message = (MSG) request->req_send)) { message = (MSG) request->req_send;
if (!message)
{
THREAD_EXIT; THREAD_EXIT;
s = isc_start_request(tdsql->tsql_status, s = isc_start_request(tdsql->tsql_status,
reinterpret_cast < reinterpret_cast<void**>(&request->req_handle),
void **>(&request->req_handle), reinterpret_cast<void**>(&request->req_trans),
reinterpret_cast < 0);
void **>(&request->req_trans), 0);
THREAD_ENTER; THREAD_ENTER;
if (s) if (s)
punt(); punt();
} }
else { else
map_in_out(request, message, in_blr_length, in_blr, in_msg_length, {
in_msg); map_in_out( request,
message,
in_blr_length,
in_blr,
in_msg_length,
in_msg);
THREAD_EXIT; THREAD_EXIT;
s = isc_start_and_send(tdsql->tsql_status, s = isc_start_and_send(tdsql->tsql_status,
reinterpret_cast < reinterpret_cast<void**>(&request->req_handle),
void **>(&request->req_handle), reinterpret_cast<void**>(&request->req_trans),
reinterpret_cast < message->msg_number,
void **>(&request->req_trans), message->msg_length,
message->msg_number, message->msg_length, message->msg_buffer,
message->msg_buffer, 0); 0);
THREAD_ENTER; THREAD_ENTER;
if (s) if (s)
{
punt(); punt();
}
} }
if (out_msg_length && (message = (MSG) request->req_receive)) { if (out_msg_length && (message = (MSG) request->req_receive)) {
@ -2293,9 +2301,11 @@ static STATUS execute_request(REQ request,
THREAD_EXIT; THREAD_EXIT;
s = isc_receive(tdsql->tsql_status, s = isc_receive(tdsql->tsql_status,
reinterpret_cast < void **>(&request->req_handle), reinterpret_cast<void**>(&request->req_handle),
message->msg_number, message->msg_number,
message->msg_length, message->msg_buffer, 0); message->msg_length,
message->msg_buffer,
0);
THREAD_ENTER; THREAD_ENTER;
if (s) if (s)
punt(); punt();
@ -2304,8 +2314,8 @@ static STATUS execute_request(REQ request,
/* if this is a singleton select, make sure there's in fact one record */ /* if this is a singleton select, make sure there's in fact one record */
if (singleton) { if (singleton)
UCHAR *message_buffer; {
USHORT counter; USHORT counter;
/* Create a temp message buffer and try two more receives. /* Create a temp message buffer and try two more receives.
@ -2313,60 +2323,75 @@ static STATUS execute_request(REQ request,
second is either another record or the end of record message. second is either another record or the end of record message.
In either case, there's more than one record. */ In either case, there's more than one record. */
message_buffer = ALLD_malloc((ULONG) message->msg_length); UCHAR* message_buffer =
(UCHAR*)ALLD_malloc((ULONG) message->msg_length);
s = 0; s = 0;
THREAD_EXIT; THREAD_EXIT;
for (counter = 0; counter < 2 && !s; counter++) { for (counter = 0; counter < 2 && !s; counter++)
{
s = isc_receive(local_status, s = isc_receive(local_status,
reinterpret_cast < reinterpret_cast<void**>(&request->req_handle),
void **>(&request->req_handle), message->msg_number,
message->msg_number, message->msg_length, message->msg_length,
message_buffer, 0); message_buffer,
0);
} }
THREAD_ENTER; THREAD_ENTER;
ALLD_free(reinterpret_cast < SCHAR * >(message_buffer)); ALLD_free(message_buffer);
/* two successful receives means more than one record /* two successful receives means more than one record
a req_sync error on the first pass above means no records a req_sync error on the first pass above means no records
a non-req_sync error on any of the passes above is an error */ a non-req_sync error on any of the passes above is an error */
if (!s) { if (!s)
{
tdsql->tsql_status[0] = gds_arg_gds; tdsql->tsql_status[0] = gds_arg_gds;
tdsql->tsql_status[1] = gds_sing_select_err; tdsql->tsql_status[1] = gds_sing_select_err;
tdsql->tsql_status[2] = gds_arg_end; tdsql->tsql_status[2] = gds_arg_end;
return_status = gds_sing_select_err; return_status = gds_sing_select_err;
} }
else if (s == gds_req_sync && counter == 1) { else if (s == gds_req_sync && counter == 1)
{
tdsql->tsql_status[0] = gds_arg_gds; tdsql->tsql_status[0] = gds_arg_gds;
tdsql->tsql_status[1] = gds_stream_eof; tdsql->tsql_status[1] = gds_stream_eof;
tdsql->tsql_status[2] = gds_arg_end; tdsql->tsql_status[2] = gds_arg_end;
return_status = gds_stream_eof; return_status = gds_stream_eof;
} }
else if (s != gds_req_sync) else if (s != gds_req_sync)
{
punt(); punt();
}
} }
} }
if (!(request->req_dbb->dbb_flags & DBB_v3)) { if (!(request->req_dbb->dbb_flags & DBB_v3))
if (request->req_type == REQ_UPDATE_CURSOR) { {
if (request->req_type == REQ_UPDATE_CURSOR)
{
GDS_DSQL_SQL_INFO(local_status, &request, GDS_DSQL_SQL_INFO(local_status, &request,
sizeof(sql_records_info), sizeof(sql_records_info),
const_cast < char *>(sql_records_info), const_cast < char *>(sql_records_info),
sizeof(buffer), buffer); sizeof(buffer), buffer);
if (!request->req_updates) if (!request->req_updates)
{
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 913, ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 913,
isc_arg_gds, isc_deadlock, isc_arg_gds, isc_arg_gds, isc_deadlock, isc_arg_gds,
isc_update_conflict, 0); isc_update_conflict, 0);
}
} }
else if (request->req_type == REQ_DELETE_CURSOR) { else if (request->req_type == REQ_DELETE_CURSOR)
{
GDS_DSQL_SQL_INFO(local_status, &request, GDS_DSQL_SQL_INFO(local_status, &request,
sizeof(sql_records_info), sizeof(sql_records_info),
const_cast < char *>(sql_records_info), const_cast < char *>(sql_records_info),
sizeof(buffer), buffer); sizeof(buffer), buffer);
if (!request->req_deletes) if (!request->req_deletes)
{
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 913, ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 913,
isc_arg_gds, isc_deadlock, isc_arg_gds, isc_arg_gds, isc_deadlock, isc_arg_gds,
isc_update_conflict, 0); isc_update_conflict, 0);
}
} }
} }
return return_status; return return_status;

View File

@ -149,12 +149,13 @@ void HSHD_fini(void)
* symbols are deallocated with their pools. * symbols are deallocated with their pools.
* *
**************************************/ **************************************/
SSHORT i;
for (i = 0; i < HASH_SIZE; i++) for (SSHORT i = 0; i < HASH_SIZE; i++)
{
hash_table[i] = NULL; hash_table[i] = NULL;
}
ALLD_free(reinterpret_cast < SCHAR * >(hash_table)); ALLD_free(hash_table);
hash_table = NULL; hash_table = NULL;
} }

View File

@ -20,7 +20,7 @@
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// $Id: gpre.cpp,v 1.1.1.1 2001-05-23 13:25:29 tamlin Exp $ // $Id: gpre.cpp,v 1.2 2001-05-24 14:54:26 tamlin Exp $
// Revision 1.2 2000/11/16 15:54:29 fsg // Revision 1.2 2000/11/16 15:54:29 fsg
// Added new switch -verbose to gpre that will dump // Added new switch -verbose to gpre that will dump
// parsed lines to stderr // parsed lines to stderr
@ -38,7 +38,7 @@
// //
//____________________________________________________________ //____________________________________________________________
// //
// $Id: gpre.cpp,v 1.1.1.1 2001-05-23 13:25:29 tamlin Exp $ // $Id: gpre.cpp,v 1.2 2001-05-24 14:54:26 tamlin Exp $
// //
#define GPRE_MAIN #define GPRE_MAIN
@ -237,11 +237,11 @@ static struct ext_table_t dml_ext_table[] =
//____________________________________________________________ //____________________________________________________________
// //
// Main line routine for C preprocessor. Initializes // Main line routine for C preprocessor. Initializes
// system, performs pass 1 and pass 2. Interprets // system, performs pass 1 and pass 2. Interprets
// command line. // command line.
// //
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {

View File

@ -26,53 +26,38 @@
#include "../ipserver/ipc.h" #include "../ipserver/ipc.h"
#define BLKDEF(type, root, tail) sizeof (struct root), tail, #define BLKDEF(type, root, tail) sizeof (struct root), tail,
static struct { static struct
{
SSHORT typ_root_length; SSHORT typ_root_length;
SSHORT typ_tail_length; SSHORT typ_tail_length;
} PIPE_block_sizes[] = { } PIPE_block_sizes[] = {
0, 0, 0, 0,
#include "../ipserver/blk.h" #include "../ipserver/blk.h"
0}; 0
};
#include "../jrd/gds_proto.h" #include "../jrd/gds_proto.h"
#include "../ipserver/alli_proto.h" #include "../ipserver/alli_proto.h"
//____________________________________________________________
UCHAR *ALLI_alloc(ULONG size) //
// Allocate a block.
//
void* ALLI_alloc(ULONG size)
{ {
/**************************************
*
* A L L I _ a l l o c
*
**************************************
*
* Functional description
* Allocate a block.
*
**************************************/
return gds__alloc(size); return gds__alloc(size);
} }
//____________________________________________________________
//
// Allocate a block from a given pool and initialize the block.
// This is the primary block allocation routine.
//
BLK ALLI_block(UCHAR type, int count) BLK ALLI_block(UCHAR type, int count)
{ {
/**************************************
*
* A L L I _ b l o c k
*
**************************************
*
* Functional description
* Allocate a block from a given pool and initialize the block.
* This is the primary block allocation routine.
*
**************************************/
register BLK block;
register USHORT size;
USHORT tail;
/* /*
if (type <= (SCHAR) type_MIN || type >= (SCHAR) type_MAX) if (type <= (SCHAR) type_MIN || type >= (SCHAR) type_MAX)
@ -82,53 +67,42 @@ if (type <= (SCHAR) type_MIN || type >= (SCHAR) type_MAX)
/* Compute block length */ /* Compute block length */
size = PIPE_block_sizes[type].typ_root_length; const USHORT tail = PIPE_block_sizes[type].typ_tail_length;
USHORT size = PIPE_block_sizes[type].typ_root_length + count * tail;
if (tail = PIPE_block_sizes[type].typ_tail_length) BLK block = (BLK) ALLI_alloc((SLONG) size);
size += count * tail;
block = (BLK) ALLI_alloc((SLONG) size); if (block)
if (!block) {
return block; block->blk_type = type;
block->blk_type = type; block->blk_length = size;
block->blk_length = size;
if (size -= sizeof(struct blk)) size -= sizeof(struct blk);
memset((SCHAR *) block + sizeof(struct blk), 0, size); if (size)
{
memset((SCHAR *) block + sizeof(struct blk), 0, size);
}
}
return block; return block;
} }
void ALLI_free( UCHAR * block) //____________________________________________________________
//
// Free a block.
//
void ALLI_free(void* block)
{ {
/************************************** gds__free(block);
*
* A L L I _ f r e e
*
**************************************
*
* Functional description
* Free a block.
*
**************************************/
gds__free((ULONG *) block);
} }
void ALLI_release( BLK block) //____________________________________________________________
//
// Release a structured block.
//
void ALLI_release(BLK block)
{ {
/************************************** ALLI_free(block);
*
* A L L I _ r e l e a s e
*
**************************************
*
* Functional description
* Release a structured block.
*
**************************************/
ALLI_free((UCHAR *) block);
} }

View File

@ -24,9 +24,9 @@
#ifndef _ALLI_PROTO_H_ #ifndef _ALLI_PROTO_H_
#define _ALLI_PROTO_H_ #define _ALLI_PROTO_H_
extern UCHAR *ALLI_alloc(ULONG); void* ALLI_alloc(ULONG);
extern BLK ALLI_block(UCHAR, int); BLK ALLI_block(UCHAR, int);
extern void ALLI_free(UCHAR *); void ALLI_free(void*);
extern void ALLI_release(BLK); void ALLI_release(BLK);
#endif /* _ALLI_PROTO_H_ */ #endif /* _ALLI_PROTO_H_ */

View File

@ -1887,7 +1887,7 @@ static UCHAR *get_buffer( IPS comm, USHORT length, USHORT n)
if (comm->ips_buffers[n].ips_sv_buffer) if (comm->ips_buffers[n].ips_sv_buffer)
gds__sys_free(comm->ips_buffers[n].ips_sv_buffer); gds__sys_free(comm->ips_buffers[n].ips_sv_buffer);
comm->ips_buffers[n].ips_sv_alloced = length; comm->ips_buffers[n].ips_sv_alloced = length;
comm->ips_buffers[n].ips_sv_buffer = gds__sys_alloc((SLONG) length); comm->ips_buffers[n].ips_sv_buffer = (UCHAR*)gds__sys_alloc((SLONG) length);
} }
/* Make sure that the buffer returned is empty */ /* Make sure that the buffer returned is empty */
@ -2021,7 +2021,7 @@ static void get_slice( ICC icc)
slice_length = ips_data->ips_cl_size; slice_length = ips_data->ips_cl_size;
if (slice_length) if (slice_length)
{ {
slice = gds__sys_alloc(slice_length); slice = (UCHAR*)gds__sys_alloc(slice_length);
NOT_NULL(slice, TRUE); NOT_NULL(slice, TRUE);
memset(slice, 0, slice_length); memset(slice, 0, slice_length);
} }
@ -2699,7 +2699,7 @@ static void put_slice( ICC icc)
slice_length = ips_data->ips_cl_size; slice_length = ips_data->ips_cl_size;
if (slice_length) if (slice_length)
{ {
slice = gds__sys_alloc(slice_length); slice = (UCHAR*)gds__sys_alloc(slice_length);
NOT_NULL(slice, TRUE); NOT_NULL(slice, TRUE);
memset(slice, 0, slice_length); memset(slice, 0, slice_length);
} }

View File

@ -16,7 +16,7 @@
* All Rights Reserved. * All Rights Reserved.
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
*/ */
NULL, NULL, NULL, NULL,
"assignment", two, "assignment", two,
"begin", begin, "begin", begin,
"declare", declare, "declare", declare,

View File

@ -1038,16 +1038,18 @@ static void deliver_request(REQ request)
for (next = request->req_interests; for (next = request->req_interests;
next && (interest = (RINT) ABS_PTR(next)); next && (interest = (RINT) ABS_PTR(next));
next = interest->rint_next) { next = interest->rint_next)
{
interest = (RINT) ABS_PTR(next); interest = (RINT) ABS_PTR(next);
event = (EVNT) ABS_PTR(interest->rint_event); event = (EVNT) ABS_PTR(interest->rint_event);
if (end < p + event->evnt_length + 5) { if (end < p + event->evnt_length + 5)
UCHAR *new_buffer; {
/* Running out of space - allocate some more and copy it over */ /* Running out of space - allocate some more and copy it over */
assert(event_buffer == buffer); /* we're in this block only once */ assert(event_buffer == buffer); /* we're in this block only once */
new_buffer = gds__alloc((SLONG) MAX_EVENT_BUFFER); UCHAR* new_buffer = (UCHAR*)gds__alloc((SLONG) MAX_EVENT_BUFFER);
/* FREE: at procedure exit */ /* FREE: at procedure exit */
if (!new_buffer) { /* NOMEM: */ if (!new_buffer)
{ /* NOMEM: */
gds__log("failed to post all events"); gds__log("failed to post all events");
break; /* exit loop and send what we have */ break; /* exit loop and send what we have */
} }
@ -1068,10 +1070,11 @@ static void deliver_request(REQ request)
delete_request(request); delete_request(request);
RELEASE; RELEASE;
reinterpret_cast < void (*) (...) > (*ast) (arg, p - event_buffer, reinterpret_cast<void(*)(...)>(*ast)(arg, p - event_buffer, event_buffer);
event_buffer);
if (event_buffer != buffer) if (event_buffer != buffer)
{
gds__free(event_buffer); gds__free(event_buffer);
}
ACQUIRE; ACQUIRE;
} }

View File

@ -19,7 +19,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
* $Id: evl.cpp,v 1.1.1.1 2001-05-23 13:26:09 tamlin Exp $ * $Id: evl.cpp,v 1.2 2001-05-24 14:54:26 tamlin Exp $
*/ */
/* /*
@ -4675,7 +4675,7 @@ static SSHORT string_boolean(TDBB tdbb, NOD node, DSC * desc1, DSC * desc2)
STR temp_str; STR temp_str;
UCHAR *p1, *p2, *temp1, *temp2, *buffer; UCHAR *p1, *p2, *temp1, *temp2, *buffer;
#endif #endif
SSHORT l1, l2, l; SSHORT l1, l2;
USHORT type1, xtype1; USHORT type1, xtype1;
STR match_str = NULL; STR match_str = NULL;
SSHORT ret_val; SSHORT ret_val;

View File

@ -207,7 +207,6 @@ int EXT_get(RSB rsb)
FLD field, *field_ptr; FLD field, *field_ptr;
SSHORT c, l, offset, i; SSHORT c, l, offset, i;
UCHAR *p; UCHAR *p;
SLONG currec;
tdbb = GET_THREAD_DATA; tdbb = GET_THREAD_DATA;

View File

@ -21,7 +21,7 @@
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
*/ */
/* /*
$Id: flu.cpp,v 1.1.1.1 2001-05-23 13:26:12 tamlin Exp $ $Id: flu.cpp,v 1.2 2001-05-24 14:54:26 tamlin Exp $
*/ */
#include "../jrd/common.h" #include "../jrd/common.h"
@ -104,13 +104,17 @@ const char* dirname(const char* fname)
if (strlen(fname) == 0) if (strlen(fname) == 0)
return "."; return ".";
strcpy(result, fname); strcpy(result, fname);
while (*fname) { while (*fname)
{
i++; i++;
if (*fname == '/') if (*fname == '/')
{
last = i; last = i;
}
fname++; fname++;
} }
if (last == 0) { if (last == 0)
{
last = 1; last = 1;
result[0] = '.'; result[0] = '.';
} }
@ -120,6 +124,18 @@ const char* dirname(const char* fname)
#endif #endif
static void terminate_at_space(char* psz)
{
while (*psz && *psz != ' ')
{
++psz;
}
if (*psz) {
*psz = '\0';
}
}
/* DG specific stuff */ /* DG specific stuff */
#ifdef DGUX #ifdef DGUX
@ -176,22 +192,20 @@ MOD FLU_lookup_module(TEXT* module)
* Lookup external function module descriptor. * Lookup external function module descriptor.
* *
**************************************/ **************************************/
MOD mod;
USHORT length;
#ifndef WIN_NT
TEXT *p;
for (p = module; *p && *p != ' '; p++) #ifndef WIN_NT
; terminate_at_space(module);
if (*p)
*p = 0;
#endif #endif
length = strlen(module); const USHORT length = strlen(module);
for (mod = FLU_modules; mod; mod = mod->mod_next) for (MOD mod = FLU_modules; mod; mod = mod->mod_next)
{
if (mod->mod_length == length && !strcmp(mod->mod_name, module)) if (mod->mod_length == length && !strcmp(mod->mod_name, module))
{
return mod; return mod;
}
}
return 0; return 0;
} }
@ -220,10 +234,13 @@ void FLU_unregister_module(MOD module)
/* Unlink from list of active modules, unload it, and release memory. */ /* Unlink from list of active modules, unload it, and release memory. */
for (mod = &FLU_modules; *mod; mod = &(*mod)->mod_next) for (mod = &FLU_modules; *mod; mod = &(*mod)->mod_next)
if (*mod == module) { {
if (*mod == module)
{
*mod = module->mod_next; *mod = module->mod_next;
break; break;
} }
}
#if (defined HP700 || defined HP10) #if (defined HP700 || defined HP10)
shl_unload(module->mod_handle); shl_unload(module->mod_handle);
@ -277,7 +294,11 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
ISC_make_desc(absolute_module, &mod_desc, p - absolute_module); ISC_make_desc(absolute_module, &mod_desc, p - absolute_module);
for (p = name; *p && *p != ' '; p++); p = name;
while (*p && *p != ' ')
{
++p;
}
ISC_make_desc(name, &nam_desc, p - name); ISC_make_desc(name, &nam_desc, p - name);
VAXC$ESTABLISH(condition_handler); VAXC$ESTABLISH(condition_handler);
@ -300,8 +321,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
*/ */
#if (defined OLD_AIX || defined OLD_AIX_PPC) #if (defined OLD_AIX || defined OLD_AIX_PPC)
#define LOOKUP #define LOOKUP
FPTR_INT ISC_lookup_entrypoint(TEXT * module, FPTR_INT ISC_lookup_entrypoint(TEXT* module,
TEXT * name, TEXT * ib_path_env_var) TEXT* name,
TEXT* ib_path_env_var)
{ {
/************************************** /**************************************
* *
@ -317,19 +339,28 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
TEXT *p; TEXT *p;
TEXT absolute_module[MAXPATHLEN]; TEXT absolute_module[MAXPATHLEN];
if (function = FUNCTIONS_entrypoint(module, name)) function = FUNCTIONS_entrypoint(module, name);
if (function)
{
return function; return function;
}
for (p = module; *p && *p != ' '; p++); terminate_at_space(module);
if (*p)
*p = 0;
if (ib_path_env_var == NULL) if (ib_path_env_var == NULL)
{
strcpy(absolute_module, module); strcpy(absolute_module, module);
}
else else
if (!gds__validate_lib_path {
(module, ib_path_env_var, absolute_module, if (!gds__validate_lib_path(module,
sizeof(absolute_module))) return NULL; ib_path_env_var,
absolute_module,
sizeof(absolute_module)))
{
return NULL;
}
}
REPLACE THIS COMPILER ERROR WITH CODE TO VERIFY THAT THE MODULE IS FOUND REPLACE THIS COMPILER ERROR WITH CODE TO VERIFY THAT THE MODULE IS FOUND
EITHER IN $INTERBASE / UDF, OR $INTERBASE / intl, EITHER IN $INTERBASE / UDF, OR $INTERBASE / intl,
@ -358,49 +389,61 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
**************************************/ **************************************/
FPTR_INT function; FPTR_INT function;
TEXT *p; TEXT *p;
MOD mod;
TEXT absolute_module[MAXPATHLEN];
if (function = FUNCTIONS_entrypoint(module, name)) function = FUNCTIONS_entrypoint(module, name);
if (function)
{
return function; return function;
}
for (p = module; *p && *p != ' '; p++); terminate_at_space(module);
if (*p) terminate_at_space(name);
*p = 0;
for (p = name; *p && *p != ' '; p++);
if (*p)
*p = 0;
if (!*module || !*name) if (!*module || !*name)
{
return NULL; return NULL;
}
/* Check if external function module has already been loaded */ // Check if external function module has already been loaded
MOD mod = FLU_lookup_module(module);
if (!(mod = FLU_lookup_module(module))) { if (!mod)
USHORT length; {
TEXT absolute_module[MAXPATHLEN];
#ifdef EXT_LIB_PATH #ifdef EXT_LIB_PATH
if (ib_path_env_var == NULL) if (ib_path_env_var == NULL)
{
strcpy(absolute_module, module); strcpy(absolute_module, module);
}
else else
if (!gds__validate_lib_path {
(module, ib_path_env_var, absolute_module, if (!gds__validate_lib_path(module,
sizeof(absolute_module))) return NULL; ib_path_env_var,
absolute_module,
sizeof(absolute_module)))
{
return NULL;
}
}
#else #else
strcpy(absolute_module, module); strcpy(absolute_module, module);
#endif /* EXT_LIB_PATH */ #endif /* EXT_LIB_PATH */
length = strlen(absolute_module); const USHORT length = strlen(absolute_module);
/* call search_for_module with the supplied name, /* call search_for_module with the supplied name,
and if unsuccessful, then with <name>.sl . */ and if unsuccessful, then with <name>.sl . */
mod = search_for_module(absolute_module, name); mod = search_for_module(absolute_module, name);
if (!mod) { if (!mod)
{
strcat(absolute_module, ".sl"); strcat(absolute_module, ".sl");
mod = search_for_module(absolute_module, name); mod = search_for_module(absolute_module, name);
} }
if (!mod) if (!mod)
{
return NULL; return NULL;
}
assert(mod->mod_handle); /* assert that we found the module */ assert(mod->mod_handle); /* assert that we found the module */
mod->mod_use_count = 0; mod->mod_use_count = 0;
@ -445,45 +488,56 @@ static MOD search_for_module(TEXT * module, TEXT * name)
strlen(absolute_module)))) return NULL; strlen(absolute_module)))) return NULL;
dirp = dirname(absolute_module); dirp = dirname(absolute_module);
if (('.' == dirp[0]) && ('\0' == dirp[1])) { if (('.' == dirp[0]) && ('\0' == dirp[1]))
{
/* We have a simple module name, without a directory. */ /* We have a simple module name, without a directory. */
gds__prefix(ib_lib_path, IB_UDF_DIR); gds__prefix(ib_lib_path, IB_UDF_DIR);
strncat(ib_lib_path, module, MAXPATHLEN - strlen(ib_lib_path) - 1); strncat(ib_lib_path, module, MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!access(ib_lib_path, R_OK | X_OK)) { if (!access(ib_lib_path, R_OK | X_OK))
{
/* Module is in the default UDF directory: load it. */ /* Module is in the default UDF directory: load it. */
if (!(mod->mod_handle = shl_load(ib_lib_path, BIND_DEFERRED, 0))) { if (!(mod->mod_handle = shl_load(ib_lib_path, BIND_DEFERRED, 0)))
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
} }
else { else
{
gds__prefix(ib_lib_path, IB_INTL_DIR); gds__prefix(ib_lib_path, IB_INTL_DIR);
strncat(ib_lib_path, module, strncat(ib_lib_path, module,
MAXPATHLEN - strlen(ib_lib_path) - 1); MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!access(ib_lib_path, R_OK | X_OK)) { if (!access(ib_lib_path, R_OK | X_OK))
{
/* Module is in the international character set directory: /* Module is in the international character set directory:
load it. */ load it. */
if (!(mod->mod_handle = shl_load(ib_lib_path, mod->mod_handle = shl_load(ib_lib_path, BIND_DEFERRED, 0);
BIND_DEFERRED, 0))) { if (!mod->mod_handle)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
} }
else { else
{
/* The module is not in a default directory, so ... /* The module is not in a default directory, so ...
* use the EXTERNAL_FUNCTION_DIRECTORY lines from isc_config. * use the EXTERNAL_FUNCTION_DIRECTORY lines from isc_config.
*/ */
dir_list = DLS_get_func_dirs(); dir_list = DLS_get_func_dirs();
found_module = FALSE; found_module = FALSE;
while (dir_list && !found_module) { while (dir_list && !found_module)
{
strcpy(ib_lib_path, dir_list->fdls_directory); strcpy(ib_lib_path, dir_list->fdls_directory);
strcat(ib_lib_path, "/"); strcat(ib_lib_path, "/");
strncat(ib_lib_path, module, strncat(ib_lib_path, module,
MAXPATHLEN - strlen(ib_lib_path) - 1); MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!access(ib_lib_path, R_OK | X_OK)) { if (!access(ib_lib_path, R_OK | X_OK))
if (!(mod->mod_handle = shl_load(ib_lib_path, {
BIND_DEFERRED, 0))) { mod->mod_handle = shl_load(ib_lib_path,
BIND_DEFERRED, 0);
if (!mod->mod_handle)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
@ -491,34 +545,39 @@ static MOD search_for_module(TEXT * module, TEXT * name)
} }
dir_list = dir_list->fdls_next; dir_list = dir_list->fdls_next;
} }
if (!found_module) { if (!found_module)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
} /* else module is not in the INTL directory */ } /* else module is not in the INTL directory */
} /* else module is not in the default UDF directory, so ... */ } /* else module is not in the default UDF directory, so ... */
} /* if dirname is "." */ } /* if dirname is "." */
else { else
{
/* The module name includes a directory path. /* The module name includes a directory path.
* The directory must be the standard UDF directory, or the * The directory must be the standard UDF directory, or the
* the standard international directory, or listed in * standard international directory, or listed in
* an EXTERNAL_FUNCTION_DIRECTORY line in isc_config, * an EXTERNAL_FUNCTION_DIRECTORY line in isc_config,
* and the module must be accessible in that directory. * and the module must be accessible in that directory.
*/ */
gds__prefix(ib_lib_path, IB_UDF_DIR); gds__prefix(ib_lib_path, IB_UDF_DIR);
ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing "/" */ ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing "/" */
found_module = !strcmp(ib_lib_path, dirp); found_module = !strcmp(ib_lib_path, dirp);
if (!found_module) { if (!found_module)
{
gds__prefix(ib_lib_path, IB_INTL_DIR); gds__prefix(ib_lib_path, IB_INTL_DIR);
ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing / */ ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing / */
found_module = !strcmp(ib_lib_path, dirp); found_module = !strcmp(ib_lib_path, dirp);
} }
if (!found_module) { if (!found_module)
{
/* It's not the default directory, so try the ones listed /* It's not the default directory, so try the ones listed
* in EXTERNAL_FUNCTION_DIRECTORY lines in isc_config. * in EXTERNAL_FUNCTION_DIRECTORY lines in isc_config.
*/ */
dir_list = DLS_get_func_dirs(); dir_list = DLS_get_func_dirs();
while (dir_list && !found_module) { while (dir_list && !found_module)
{
if (!strcmp(dir_list->fdls_directory, dirp)) if (!strcmp(dir_list->fdls_directory, dirp))
found_module = TRUE; found_module = TRUE;
dir_list = dir_list->fdls_next; dir_list = dir_list->fdls_next;
@ -527,7 +586,8 @@ static MOD search_for_module(TEXT * module, TEXT * name)
if (found_module) if (found_module)
found_module = (!access(module, R_OK | X_OK)) && found_module = (!access(module, R_OK | X_OK)) &&
(0 != (mod->mod_handle = shl_load(module, BIND_DEFERRED, 0))); (0 != (mod->mod_handle = shl_load(module, BIND_DEFERRED, 0)));
if (!found_module) { if (!found_module)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
@ -553,7 +613,6 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
* *
**************************************/ **************************************/
FPTR_INT function; FPTR_INT function;
TEXT *p;
shl_t handle; shl_t handle;
TEXT buffer[256]; TEXT buffer[256];
TEXT absolute_module[MAXPATHLEN]; TEXT absolute_module[MAXPATHLEN];
@ -561,10 +620,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
if (function = FUNCTIONS_entrypoint(module, name)) if (function = FUNCTIONS_entrypoint(module, name))
return function; return function;
for (p = module; *p && *p != ' '; p++); terminate_at_space(module);
if (*p)
*p = 0; TEXT* p = buffer;
p = buffer;
*p++ = '_'; *p++ = '_';
for (; (*p = *name) && *name != ' '; p++, name++); for (; (*p = *name) && *name != ' '; p++, name++);
*p = 0; *p = 0;
@ -580,9 +638,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
EITHER IN $INTERBASE / UDF, OR $INTERBASE / intl, EITHER IN $INTERBASE / UDF, OR $INTERBASE / intl,
OR IN ONE OF THE DIRECTORIES NAMED IN EXTERNAL_FUNCTION_DIRECTORY OR IN ONE OF THE DIRECTORIES NAMED IN EXTERNAL_FUNCTION_DIRECTORY
LINES IN LINES IN
ISC_CONFIG.if (! ISC_CONFIG.
(handle = shl_load(absolute_module, BIND_DEFERRED, 0L)) if (!(handle = shl_load(absolute_module, BIND_DEFERRED, 0L)) ||
|| shl_findsym(&handle, buffer, TYPE_PROCEDURE, &function)) shl_findsym(&handle, buffer, TYPE_PROCEDURE, &function))
return NULL; return NULL;
return function; return function;
@ -592,8 +650,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
#ifdef DYNAMIC_SHARED_LIBRARIES #ifdef DYNAMIC_SHARED_LIBRARIES
#define LOOKUP #define LOOKUP
FPTR_INT ISC_lookup_entrypoint(TEXT * module, FPTR_INT ISC_lookup_entrypoint(TEXT* module,
TEXT * name, TEXT * ib_path_env_var) TEXT* name,
TEXT* ib_path_env_var)
{ {
/************************************** /**************************************
* *
@ -607,52 +666,65 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
**************************************/ **************************************/
FPTR_INT function; FPTR_INT function;
TEXT *p; TEXT *p;
MOD mod;
TEXT absolute_module[MAXPATHLEN];
if (function = FUNCTIONS_entrypoint(module, name)) function = FUNCTIONS_entrypoint(module, name);
if (function)
{
return function; return function;
}
#ifdef NON_DL_COMPATIBLE #ifdef NON_DL_COMPATIBLE
return NULL; return NULL;
#else #else
for (p = module; *p && *p != ' '; p++);
if (*p) terminate_at_space(module);
*p = 0; terminate_at_space(name);
for (p = name; *p && *p != ' '; p++);
if (*p)
*p = 0;
if (!*module || !*name) if (!*module || !*name)
{
return NULL; return NULL;
}
/* Check if external function module has already been loaded */ // Check if external function module has already been loaded
MOD mod = FLU_lookup_module(module);
if (!(mod = FLU_lookup_module(module))) { if (!mod)
USHORT length; {
TEXT absolute_module[MAXPATHLEN];
#ifdef EXT_LIB_PATH #ifdef EXT_LIB_PATH
if (ib_path_env_var == NULL) if (ib_path_env_var == NULL)
{
strcpy(absolute_module, module); strcpy(absolute_module, module);
}
else else
if (!gds__validate_lib_path {
(module, ib_path_env_var, absolute_module, if (!gds__validate_lib_path(module,
sizeof(absolute_module))) return NULL; ib_path_env_var,
absolute_module,
sizeof(absolute_module)))
{
return NULL;
}
}
#else #else
strcpy(absolute_module, module); strcpy(absolute_module, module);
#endif /* EXT_LIB_PATH */ #endif /* EXT_LIB_PATH */
length = strlen(absolute_module); const USHORT length = strlen(absolute_module);
/* call search_for_module with the supplied name, /* call search_for_module with the supplied name,
and if unsuccessful, then with <name>.so . */ and if unsuccessful, then with <name>.so . */
mod = search_for_module(absolute_module, name); mod = search_for_module(absolute_module, name);
if (!mod) { if (!mod)
{
strcat(absolute_module, ".so"); strcat(absolute_module, ".so");
mod = search_for_module(absolute_module, name); mod = search_for_module(absolute_module, name);
} }
if (!mod) if (!mod)
{
return NULL; return NULL;
}
assert(mod->mod_handle); /* assert that we found the module */ assert(mod->mod_handle); /* assert that we found the module */
mod->mod_use_count = 0; mod->mod_use_count = 0;
@ -682,8 +754,6 @@ static MOD search_for_module(TEXT * module, TEXT * name)
* statement. * statement.
* *
**************************************/ **************************************/
MOD mod;
char *dirp;
TEXT ib_lib_path[MAXPATHLEN]; TEXT ib_lib_path[MAXPATHLEN];
TEXT absolute_module[MAXPATHLEN]; /* for _access() ??? */ TEXT absolute_module[MAXPATHLEN]; /* for _access() ??? */
FDLS *dir_list; FDLS *dir_list;
@ -691,46 +761,63 @@ static MOD search_for_module(TEXT * module, TEXT * name)
strcpy(absolute_module, module); strcpy(absolute_module, module);
if (!(mod = (MOD) gds__alloc(sizeof(struct mod) + MOD mod = (MOD) gds__alloc(sizeof(struct mod) + strlen(absolute_module));
strlen(absolute_module)))) return NULL;
dirp = dirname(absolute_module); if (!mod)
if (('.' == dirp[0]) && ('\0' == dirp[1])) { {
return NULL;
}
char* dirp = dirname(absolute_module);
if (('.' == dirp[0]) && ('\0' == dirp[1]))
{
/* We have a simple module name without a directory. */ /* We have a simple module name without a directory. */
gds__prefix(ib_lib_path, IB_UDF_DIR); gds__prefix(ib_lib_path, IB_UDF_DIR);
strncat(ib_lib_path, module, MAXPATHLEN - strlen(ib_lib_path) - 1); strncat(ib_lib_path, module, MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!access(ib_lib_path, R_OK)) { if (!access(ib_lib_path, R_OK))
{
/* Module is in the standard UDF directory: load it. */ /* Module is in the standard UDF directory: load it. */
if (!(mod->mod_handle = dlopen(ib_lib_path, RTLD_LAZY))) { if (!(mod->mod_handle = dlopen(ib_lib_path, RTLD_LAZY)))
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
} }
else { else
{
gds__prefix(ib_lib_path, IB_INTL_DIR); gds__prefix(ib_lib_path, IB_INTL_DIR);
strncat(ib_lib_path, module, strncat(ib_lib_path, module,
MAXPATHLEN - strlen(ib_lib_path) - 1); MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!access(ib_lib_path, R_OK)) { if (!access(ib_lib_path, R_OK))
{
/* Module is in the default directory: load it. */ /* Module is in the default directory: load it. */
if (!(mod->mod_handle = dlopen(ib_lib_path, RTLD_LAZY))) { mod->mod_handle = dlopen(ib_lib_path, RTLD_LAZY);
if (!mod->mod_handle)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
} }
else { else
{
/* The module is not in the default directory, so ... /* The module is not in the default directory, so ...
* use the EXTERNAL_FUNCTION_DIRECTORY lines from isc_config. * use the EXTERNAL_FUNCTION_DIRECTORY lines from isc_config.
*/ */
dir_list = DLS_get_func_dirs(); dir_list = DLS_get_func_dirs();
found_module = FALSE; found_module = FALSE;
while (dir_list && !found_module) { while (dir_list && !found_module)
{
strcpy(ib_lib_path, dir_list->fdls_directory); strcpy(ib_lib_path, dir_list->fdls_directory);
strcat(ib_lib_path, "/"); strcat(ib_lib_path, "/");
strncat(ib_lib_path, module, strncat(ib_lib_path, module,
MAXPATHLEN - strlen(ib_lib_path) - 1); MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!access(ib_lib_path, R_OK)) { if (!access(ib_lib_path, R_OK))
if (!(mod->mod_handle = dlopen(ib_lib_path, {
RTLD_LAZY))) { mod->mod_handle = dlopen(ib_lib_path, RTLD_LAZY);
if (!mod->mod_handle)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
@ -738,14 +825,16 @@ static MOD search_for_module(TEXT * module, TEXT * name)
} }
dir_list = dir_list->fdls_next; dir_list = dir_list->fdls_next;
} }
if (!found_module) { if (!found_module)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
} /* else module is not in the INTL directory */ } /* else module is not in the INTL directory */
} /* else module is not in the default directory, so ... */ } /* else module is not in the default directory, so ... */
} /* if *dirp is "." */ } /* if *dirp is "." */
else { else
{
/* The module name includes a directory path. /* The module name includes a directory path.
* The directory must be the standard UDF directory, or the * The directory must be the standard UDF directory, or the
* standard international directory, or listed in * standard international directory, or listed in
@ -754,27 +843,34 @@ static MOD search_for_module(TEXT * module, TEXT * name)
*/ */
gds__prefix(ib_lib_path, IB_UDF_DIR); gds__prefix(ib_lib_path, IB_UDF_DIR);
ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing "/" */ ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing "/" */
found_module = !strcmp(ib_lib_path, dirp); found_module = !strcmp(ib_lib_path, dirp);
if (!found_module) { if (!found_module)
{
gds__prefix(ib_lib_path, IB_INTL_DIR); gds__prefix(ib_lib_path, IB_INTL_DIR);
ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing / */ ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing / */
found_module = !strcmp(ib_lib_path, dirp); found_module = !strcmp(ib_lib_path, dirp);
} }
if (!found_module) { if (!found_module)
{
/* It's not the default directory, so try the ones listed /* It's not the default directory, so try the ones listed
* in EXTERNAL_FUNCTION_DIRECTORY lines in isc_config. * in EXTERNAL_FUNCTION_DIRECTORY lines in isc_config.
*/ */
dir_list = DLS_get_func_dirs(); dir_list = DLS_get_func_dirs();
while (dir_list && !found_module) { while (dir_list && !found_module)
{
if (!strcmp(dir_list->fdls_directory, dirp)) if (!strcmp(dir_list->fdls_directory, dirp))
found_module = TRUE; found_module = TRUE;
dir_list = dir_list->fdls_next; dir_list = dir_list->fdls_next;
} }
} }
if (found_module) if (found_module)
{
found_module = (!access(module, R_OK)) && found_module = (!access(module, R_OK)) &&
(0 != (mod->mod_handle = dlopen(module, RTLD_LAZY))); (0 != (mod->mod_handle = dlopen(module, RTLD_LAZY)));
if (!found_module) { }
if (!found_module)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
@ -786,8 +882,9 @@ static MOD search_for_module(TEXT * module, TEXT * name)
#ifdef DGUX #ifdef DGUX
#define LOOKUP #define LOOKUP
FPTR_INT ISC_lookup_entrypoint(TEXT * module, FPTR_INT ISC_lookup_entrypoint(TEXT* module,
TEXT * name, TEXT * ib_path_env_var) TEXT* name,
TEXT* ib_path_env_var)
{ {
/************************************** /**************************************
* *
@ -811,29 +908,36 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
#ifdef NON_DL_COMPATIBLE #ifdef NON_DL_COMPATIBLE
return NULL; return NULL;
#else #else
for (p = module; *p && *p != ' '; p++); terminate_at_space(module);
if (*p) terminate_at_space(name);
*p = 0;
for (p = name; *p && *p != ' '; p++);
if (*p)
*p = 0;
if (!*module || stat(module, &stdbuf)) if (!*module || stat(module, &stdbuf))
{
return NULL; return NULL;
}
if (ib_path_env_var == NULL) if (ib_path_env_var == NULL)
{
strcpy(absolute_module, module); strcpy(absolute_module, module);
}
else else
if (!gds__validate_lib_path {
(module, ib_path_env_var, absolute_module, if (!gds__validate_lib_path(module,
sizeof(absolute_module))) return NULL; ib_path_env_var,
absolute_module,
sizeof(absolute_module)))
{
return NULL;
}
}
REPLACE THIS COMPILER ERROR WITH CODE TO VERIFY THAT THE MODULE IS FOUND REPLACE THIS COMPILER ERROR WITH CODE TO VERIFY THAT THE MODULE IS FOUND
EITHER IN $INTERBASE / UDF, OR $INTERBASE / intl, EITHER IN $INTERBASE / UDF, OR $INTERBASE / intl,
OR IN ONE OF THE DIRECTORIES NAMED IN EXTERNAL_FUNCTION_DIRECTORY OR IN ONE OF THE DIRECTORIES NAMED IN EXTERNAL_FUNCTION_DIRECTORY
LINES IN LINES IN
ISC_CONFIG.if (!(handle = dlopen(absolute_module, RTLD_LAZY))) return ISC_CONFIG.
NULL; if (!(handle = dlopen(absolute_module, RTLD_LAZY)))
return NULL;
return dlsym(handle, name); return dlsym(handle, name);
#endif #endif
@ -843,8 +947,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
#ifdef WIN_NT #ifdef WIN_NT
#define LOOKUP #define LOOKUP
FPTR_INT ISC_lookup_entrypoint(TEXT * module, FPTR_INT ISC_lookup_entrypoint(TEXT* module,
TEXT * name, TEXT * ib_path_env_var) TEXT* name,
TEXT* ib_path_env_var)
{ {
/************************************** /**************************************
* *
@ -861,46 +966,59 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
**************************************/ **************************************/
FPTR_INT function; FPTR_INT function;
TEXT *p; TEXT *p;
MOD mod;
TEXT absolute_module[MAXPATHLEN]; /* for _access() */
if (function = FUNCTIONS_entrypoint(module, name)) function = FUNCTIONS_entrypoint(module, name);
if (function)
{
return function; return function;
}
for (p = name; *p && *p != ' '; p++); terminate_at_space(name);
if (*p)
*p = 0;
/* Check if external function module has already been loaded */ // Check if external function module has already been loaded
MOD mod = FLU_lookup_module(module);
if (!(mod = FLU_lookup_module(module))) { if (!mod)
USHORT length; {
TEXT absolute_module[MAXPATHLEN]; // for _access()
#ifdef EXT_LIB_PATH #ifdef EXT_LIB_PATH
if (ib_path_env_var == NULL) if (ib_path_env_var == NULL)
{
strcpy(absolute_module, module); strcpy(absolute_module, module);
}
else else
if (!gds__validate_lib_path {
(module, ib_path_env_var, absolute_module, if (!gds__validate_lib_path(module,
sizeof(absolute_module))) return NULL; ib_path_env_var,
absolute_module,
sizeof(absolute_module)))
{
return NULL;
}
}
#else #else
strcpy(absolute_module, module); strcpy(absolute_module, module);
#endif /* EXT_LIB_PATH */ #endif /* EXT_LIB_PATH */
length = strlen(absolute_module); const USHORT length = strlen(absolute_module);
/* call search_for_module with the supplied name, and if unsuccessful, /* call search_for_module with the supplied name, and if unsuccessful,
then with <name>.DLL (if the name did not have a trailing "."). */ then with <name>.DLL (if the name did not have a trailing "."). */
mod = search_for_module(absolute_module, name); mod = search_for_module(absolute_module, name);
if (!mod) { if (!mod)
{
if ((absolute_module[length - 1] != '.') && if ((absolute_module[length - 1] != '.') &&
stricmp(absolute_module + length - 4, ".DLL")) { stricmp(absolute_module + length - 4, ".DLL"))
{
strcat(absolute_module, ".DLL"); strcat(absolute_module, ".DLL");
mod = search_for_module(absolute_module, name); mod = search_for_module(absolute_module, name);
} }
} }
if (!mod) if (!mod)
{
return NULL; return NULL;
}
assert(mod->mod_handle); /* assert that we found the module */ assert(mod->mod_handle); /* assert that we found the module */
mod->mod_use_count = 0; mod->mod_use_count = 0;
@ -912,15 +1030,16 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
++mod->mod_use_count; ++mod->mod_use_count;
/* The Borland compiler prefixes an '_' for functions compiled // The Borland compiler prefixes an '_' for functions compiled
with the __cdecl calling convention. */ // with the __cdecl calling convention.
// TMN: Doesn't all_ ompilers do that?
if (!(function = (FPTR_INT) GetProcAddress(mod->mod_handle, name))) { function = (FPTR_INT) GetProcAddress(mod->mod_handle, name);
if (!function)
{
TEXT buffer[128]; TEXT buffer[128];
buffer[0] = '_';
p = buffer; strcpy(&buffer[1], name);
*p++ = '_';
while (*p++ = *name++);
function = (FPTR_INT) GetProcAddress(mod->mod_handle, buffer); function = (FPTR_INT) GetProcAddress(mod->mod_handle, buffer);
} }
@ -928,7 +1047,7 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
} }
static MOD search_for_module(TEXT * module, TEXT * name) static MOD search_for_module(TEXT* module, TEXT* name)
{ {
/************************************** /**************************************
* *
@ -942,8 +1061,8 @@ static MOD search_for_module(TEXT * module, TEXT * name)
* _access() and LoadLibrary() w.r.t. implicit .DLL suffix. * _access() and LoadLibrary() w.r.t. implicit .DLL suffix.
* *
**************************************/ **************************************/
MOD mod;
/* We need different versions of the file name to pass to _access() /* We need different versions of the file name to pass to _access()
* and to LoadLibrary(), because LoadLibrary() implicitly appends * and to LoadLibrary(), because LoadLibrary() implicitly appends
* .DLL to the supplied name and access does not. We need to control * .DLL to the supplied name and access does not. We need to control
* exactly what name is being used by each routine. * exactly what name is being used by each routine.
@ -954,57 +1073,73 @@ static MOD search_for_module(TEXT * module, TEXT * name)
TEXT drive_buf[_MAX_DRIVE]; TEXT drive_buf[_MAX_DRIVE];
TEXT dir_buf[_MAX_DIR]; TEXT dir_buf[_MAX_DIR];
FDLS *dir_list; FDLS *dir_list;
USHORT length;
BOOLEAN found_module; BOOLEAN found_module;
length = strlen(module); const USHORT length = strlen(module);
if (!(mod = (MOD) gds__alloc(sizeof(struct mod) + length))) MOD mod = (MOD) gds__alloc(sizeof(struct mod) + length);
if (!mod)
{
return NULL; return NULL;
}
/* Set absolute_module to the drive and directory prefix part of /* Set absolute_module to the drive and directory prefix part of
module, like dirname() under Unix. */ module, like dirname() under Unix. */
_splitpath(module, drive_buf, dir_buf, (char *) 0, (char *) 0); _splitpath(module, drive_buf, dir_buf, 0, 0);
strcpy(absolute_module, drive_buf); strcpy(absolute_module, drive_buf);
strcat(absolute_module, dir_buf); strcat(absolute_module, dir_buf);
if (0 == absolute_module[0]) { if (0 == absolute_module[0])
{
/* We have a simple module name without a directory. */ /* We have a simple module name without a directory. */
gds__prefix(ib_lib_path, IB_UDF_DIR); gds__prefix(ib_lib_path, IB_UDF_DIR);
strncat(ib_lib_path, module, MAXPATHLEN - strlen(ib_lib_path) - 1); strncat(ib_lib_path, module, MAXPATHLEN - strlen(ib_lib_path) - 1);
adjust_loadlib_name(ib_lib_path, loadlib_name); adjust_loadlib_name(ib_lib_path, loadlib_name);
if (!_access(ib_lib_path, 4 /* read permission */ )) { if (!_access(ib_lib_path, 4 /* read permission */ ))
{
/* Module is in the default UDF directory: load it. */ /* Module is in the default UDF directory: load it. */
if (!(mod->mod_handle = LoadLibrary(loadlib_name))) { mod->mod_handle = LoadLibrary(loadlib_name);
if (!mod->mod_handle)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
} }
else { else
{
gds__prefix(ib_lib_path, IB_INTL_DIR); gds__prefix(ib_lib_path, IB_INTL_DIR);
strncat(ib_lib_path, module, strncat(ib_lib_path, module,
MAXPATHLEN - strlen(ib_lib_path) - 1); MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!_access(ib_lib_path, 4 /* read permission */ )) { if (!_access(ib_lib_path, 4 /* read permission */ ))
{
/* Module is in the default international library: load it */ /* Module is in the default international library: load it */
if (!(mod->mod_handle = LoadLibrary(ib_lib_path))) { mod->mod_handle = LoadLibrary(ib_lib_path);
if (!mod->mod_handle)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
} }
else { else
{
/* The module is not in the default directory, so ... /* The module is not in the default directory, so ...
* use the EXTERNAL_FUNCTION_DIRECTORY lines from isc_config. * use the EXTERNAL_FUNCTION_DIRECTORY lines from isc_config.
*/ */
dir_list = DLS_get_func_dirs(); dir_list = DLS_get_func_dirs();
found_module = FALSE; found_module = FALSE;
while (dir_list && !found_module) { while (dir_list && !found_module)
{
strcpy(ib_lib_path, dir_list->fdls_directory); strcpy(ib_lib_path, dir_list->fdls_directory);
strcat(ib_lib_path, "\\"); strcat(ib_lib_path, "\\");
strncat(ib_lib_path, module, strncat(ib_lib_path, module,
MAXPATHLEN - strlen(ib_lib_path) - 1); MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!_access(ib_lib_path, 4 /* read permission */ )) { if (!_access(ib_lib_path, 4 /* read permission */ ))
if (!(mod->mod_handle = LoadLibrary(ib_lib_path))) { {
mod->mod_handle = LoadLibrary(ib_lib_path);
if (!mod->mod_handle)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
@ -1012,14 +1147,16 @@ static MOD search_for_module(TEXT * module, TEXT * name)
} }
dir_list = dir_list->fdls_next; dir_list = dir_list->fdls_next;
} }
if (!found_module) { if (!found_module)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
} /* else module is not in the INTL directory */ } /* else module is not in the INTL directory */
} /* else module is not in the default UDF directory, so ... */ } /* else module is not in the default UDF directory, so ... */
} /* if path part of name is empty */ } /* if path part of name is empty */
else { else
{
/* The module name includes a directory path. /* The module name includes a directory path.
* The directory must be either $INTERBASE/UDF, or $INTERBASE/intl * The directory must be either $INTERBASE/UDF, or $INTERBASE/intl
* or listed in an EXTERNAL_FUNCTION_DIRECTORY line in isc_config, * or listed in an EXTERNAL_FUNCTION_DIRECTORY line in isc_config,
@ -1027,25 +1164,32 @@ static MOD search_for_module(TEXT * module, TEXT * name)
*/ */
gds__prefix(ib_lib_path, IB_UDF_DIR); gds__prefix(ib_lib_path, IB_UDF_DIR);
found_module = !stricmp(ib_lib_path, absolute_module); found_module = !stricmp(ib_lib_path, absolute_module);
if (!found_module) { if (!found_module)
{
gds__prefix(ib_lib_path, IB_INTL_DIR); gds__prefix(ib_lib_path, IB_INTL_DIR);
found_module = !stricmp(ib_lib_path, absolute_module); found_module = !stricmp(ib_lib_path, absolute_module);
} }
if (!found_module) { if (!found_module)
{
/* It's not the default directory, so try the ones listed /* It's not the default directory, so try the ones listed
* in EXTERNAL_FUNCTION_DIRECTORY lines in isc_config. * in EXTERNAL_FUNCTION_DIRECTORY lines in isc_config.
*/ */
dir_list = DLS_get_func_dirs(); dir_list = DLS_get_func_dirs();
while (dir_list && !found_module) { while (dir_list && !found_module)
{
if (!stricmp(dir_list->fdls_directory, absolute_module)) if (!stricmp(dir_list->fdls_directory, absolute_module))
found_module = TRUE; found_module = TRUE;
dir_list = dir_list->fdls_next; dir_list = dir_list->fdls_next;
} }
} }
if (found_module) if (found_module)
found_module = (!_access(module, 4 /* read ok? */ )) && {
found_module =
(!_access(module, 4 /* read ok? */ )) &&
(0 != (mod->mod_handle = LoadLibrary(module))); (0 != (mod->mod_handle = LoadLibrary(module)));
if (!found_module) { }
if (!found_module)
{
gds__free(mod); gds__free(mod);
return NULL; return NULL;
} }
@ -1069,9 +1213,7 @@ static void adjust_loadlib_name(TEXT * access_path, TEXT * load_path)
* *
**************************************/ **************************************/
USHORT length; const USHORT length = strlen(access_path);
length = strlen(access_path);
strcpy(load_path, access_path); strcpy(load_path, access_path);
/* Adjust the names to be passed to _access() and LoadLibrary(), /* Adjust the names to be passed to _access() and LoadLibrary(),
@ -1083,11 +1225,14 @@ static void adjust_loadlib_name(TEXT * access_path, TEXT * load_path)
* foo foo foo. foo * foo foo foo. foo
* foo.dll foo.dll foo.dll foo.dll * foo.dll foo.dll foo.dll foo.dll
*/ */
if (stricmp(access_path + length - 4, ".dll")) { if (stricmp(access_path + length - 4, ".dll"))
if ('.' == access_path[length - 1]) { {
if ('.' == access_path[length - 1])
{
access_path[length - 1] = '\0'; access_path[length - 1] = '\0';
} }
else { else
{
load_path[length] = '.'; load_path[length] = '.';
load_path[length + 1] = '\0'; load_path[length + 1] = '\0';
} }
@ -1097,8 +1242,9 @@ static void adjust_loadlib_name(TEXT * access_path, TEXT * load_path)
#ifndef LOOKUP #ifndef LOOKUP
FPTR_INT ISC_lookup_entrypoint(TEXT * module, FPTR_INT ISC_lookup_entrypoint(TEXT* module,
TEXT * name, TEXT * ib_path_env_var) TEXT* name,
TEXT* ib_path_env_var)
{ {
/************************************** /**************************************
* *
@ -1110,12 +1256,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
* Lookup entrypoint of function. * Lookup entrypoint of function.
* *
**************************************/ **************************************/
FPTR_INT function;
if (function = FUNCTIONS_entrypoint(module, name)) FPTR_INT function = FUNCTIONS_entrypoint(module, name);
return function; return function;
return NULL;
} }
#endif #endif

View File

@ -572,69 +572,73 @@ static JMP_BUF env; /* Error return environment */
static const UCHAR static const UCHAR
/* generic print formats */ /* generic print formats */
zero[] = { op_line, 0 }, zero[] = { op_line, 0 },
one[] = { op_line, op_verb, 0}, one[] = { op_line, op_verb, 0},
two[] = { op_line, op_verb, op_verb, 0}, two[] = { op_line, op_verb, op_verb, 0},
three[] = { op_line, op_verb, op_verb, op_verb, 0}, three[] = { op_line, op_verb, op_verb, op_verb, 0},
field[] = { op_byte, op_byte, op_literal, op_pad, op_line, 0}, field[] = { op_byte, op_byte, op_literal, op_pad, op_line, 0},
byte[] = { op_byte, op_line, 0}, byte[] = { op_byte, op_line, 0},
byte_args[] = { op_byte, op_line, op_args, 0}, byte_args[] = { op_byte, op_line, op_args, 0},
byte_byte[] = { op_byte, op_byte, op_line, 0}, byte_byte[] = { op_byte, op_byte, op_line, 0},
byte_verb[] = { op_byte, op_line, op_verb, 0}, byte_verb[] = { op_byte, op_line, op_verb, 0},
byte_verb_verb[] = { op_byte, op_line, op_verb, op_verb, 0}, byte_verb_verb[] = { op_byte, op_line, op_verb, op_verb, 0},
byte_literal[] = { op_byte, op_literal, op_line, 0}, byte_literal[] = { op_byte, op_literal, op_line, 0},
byte_byte_verb[] = { op_byte, op_byte, op_line, op_verb, 0}, byte_byte_verb[] = { op_byte, op_byte, op_line, op_verb, 0},
parm[] = { op_byte, op_word, op_line, 0}, /* also field id */ parm[] = { op_byte, op_word, op_line, 0}, /* also field id */
parm2[] = { op_byte, op_word, op_word, op_line, 0}, parm2[] = { op_byte, op_word, op_word, op_line, 0},
parm3[] = { op_byte, op_word, op_word, op_word, op_line, 0}, parm3[] = { op_byte, op_word, op_word, op_word, op_line, 0},
/* formats specific to a verb */ /* formats specific to a verb */
begin[] = { op_line, op_begin, op_verb, 0}, begin[] = { op_line, op_begin, op_verb, 0},
literal[] = { op_dtype, op_literal, op_line, 0}, literal[] = { op_dtype, op_literal, op_line, 0},
message[] = { op_byte, op_word, op_line, op_message, 0}, message[] = { op_byte, op_word, op_line, op_message, 0},
rse[] = { op_byte, op_line, op_begin, op_verb, 0}, rse[] = { op_byte, op_line, op_begin, op_verb, 0},
relation[] = { op_byte, op_literal, op_pad, op_byte, op_line, 0}, relation[] = { op_byte, op_literal, op_pad, op_byte, op_line, 0},
relation2[] = { op_byte, op_literal, op_line, op_indent, op_byte, op_literal, op_pad, relation2[] = { op_byte, op_literal, op_line, op_indent, op_byte,
op_byte, op_line, 0}, op_literal, op_pad, op_byte, op_line, 0},
aggregate[] = { op_byte, op_line, op_verb, op_verb, op_verb, 0}, aggregate[] = { op_byte, op_line, op_verb, op_verb, op_verb, 0},
rid[] = { op_word, op_byte, op_line, 0}, rid[] = { op_word, op_byte, op_line, 0},
rid2[] = { op_word, op_byte, op_literal, op_pad, op_byte, op_line, 0}, rid2[] = { op_word, op_byte, op_literal, op_pad, op_byte, op_line, 0},
union_ops[] = { op_byte, op_byte, op_line, op_union, 0}, union_ops[] = { op_byte, op_byte, op_line, op_union, 0},
map[] = { op_word, op_line, op_map, 0}, map[] = { op_word, op_line, op_map, 0},
function[] = { op_byte, op_literal, op_byte, op_line, op_args, 0}, function[] = { op_byte, op_literal, op_byte, op_line, op_args, 0},
gen_id[] = { op_byte, op_literal, op_line, op_verb, 0}, gen_id[] = { op_byte, op_literal, op_line, op_verb, 0},
declare[] = { op_word, op_dtype, op_line, 0}, declare[] = { op_word, op_dtype, op_line, 0},
variable[] = { op_word, op_line, 0}, variable[] = { op_word, op_line, 0},
indx[] = { op_line, op_verb, op_indent, op_byte, op_line, op_args, 0}, indx[] = { op_line, op_verb, op_indent, op_byte, op_line, op_args, 0},
find[] = { op_byte, op_verb, op_verb, op_indent, op_byte, op_line, op_args, 0}, find[] = { op_byte, op_verb, op_verb, op_indent, op_byte, op_line, op_args, 0},
seek[] = { op_line, op_verb, op_verb, 0}, seek[] = { op_line, op_verb, op_verb, 0},
join[] = { op_join, op_line, 0}, join[] = { op_join, op_line, 0},
exec_proc[] = { op_byte, op_literal, op_line, op_indent, op_word, op_line, op_parameters, exec_proc[] = { op_byte, op_literal, op_line, op_indent, op_word, op_line,
op_indent, op_word, op_line, op_parameters, 0}, op_parameters, op_indent, op_word, op_line, op_parameters, 0},
procedure[] = { op_byte, op_literal, op_pad, op_byte, op_line, op_indent, op_word, procedure[] = { op_byte, op_literal, op_pad, op_byte, op_line, op_indent,
op_line, op_parameters, 0}, op_word, op_line, op_parameters, 0},
pid[] = { op_word, op_pad, op_byte, op_line, op_indent, op_word, op_line, pid[] = { op_word, op_pad, op_byte, op_line, op_indent, op_word,
op_parameters, 0}, op_line, op_parameters, 0},
error_handler[] = { op_word, op_line, op_error_handler, 0}, error_handler[] = { op_word, op_line, op_error_handler, 0},
set_error[] = { op_set_error, op_line, 0}, set_error[] = { op_set_error, op_line, 0},
cast[] = { op_dtype, op_line, op_verb, 0}, cast[] = { op_dtype, op_line, op_verb, 0},
indices[] = { op_byte, op_line, op_literals, 0}, indices[] = { op_byte, op_line, op_literals, 0},
lock_relation[] = { op_line, op_indent, op_relation, op_line, op_verb, 0}, lock_relation[] = { op_line, op_indent, op_relation, op_line, op_verb, 0},
range_relation[] = { op_line, op_verb, op_indent, op_relation, op_line, 0}, range_relation[] = { op_line, op_verb, op_indent, op_relation, op_line, 0},
extract[] = { op_line, op_byte, op_verb, 0}; extract[] = { op_line, op_byte, op_verb, 0};
static const struct static const struct
{ {
const char *blr_string; const char *blr_string;
const UCHAR *blr_operators; const UCHAR *blr_operators;
} FAR_VARIABLE blr_table[] = { } FAR_VARIABLE blr_table[] =
{
#pragma FB_COMPILER_MESSAGE("Fix this!")
#include "../jrd/blp.h" #include "../jrd/blp.h"
0, 0 0, 0
}; };
#define ISC_ENV "INTERBASE" #define ISC_ENV "INTERBASE"
#define ISC_LOCK_ENV "INTERBASE_LOCK" #define ISC_LOCK_ENV "INTERBASE_LOCK"
#define ISC_MSG_ENV "INTERBASE_MSG" #define ISC_MSG_ENV "INTERBASE_MSG"
@ -680,12 +684,12 @@ void gds_print_delta_counters(IB_FILE *);
#ifdef DEBUG_GDS_ALLOC #ifdef DEBUG_GDS_ALLOC
UCHAR *API_ROUTINE gds__alloc_debug( void* API_ROUTINE gds__alloc_debug(SLONG size_request,
SLONG size_request, TEXT* filename,
TEXT * filename, ULONG lineno) ULONG lineno)
#else #else
UCHAR *API_ROUTINE gds__alloc(SLONG size_request) void* API_ROUTINE gds__alloc(SLONG size_request)
#endif #endif
{ {
/************************************** /**************************************
@ -748,9 +752,12 @@ UCHAR *API_ROUTINE gds__alloc(SLONG size_request)
*/ */
factor = 1; factor = 1;
if (!(size_request & (1024 - 1))) if (!(size_request & (1024 - 1)))
{
factor = size_request / 1024; factor = size_request / 1024;
}
size = size_request + ALLOC_OVERHEAD * factor; size = size_request + ALLOC_OVERHEAD * factor;
size = ROUNDUP(size, GDS_ALLOC_ALIGNMENT); size = ROUNDUP(size, GDS_ALLOC_ALIGNMENT);
#ifdef DEV_BUILD #ifdef DEV_BUILD
gds_delta_alloc += size; gds_delta_alloc += size;
#endif #endif
@ -917,7 +924,7 @@ UCHAR *API_ROUTINE gds__alloc(SLONG size_request)
} }
STATUS API_ROUTINE gds__decode(STATUS code, USHORT * fac, USHORT * class_) STATUS API_ROUTINE gds__decode(STATUS code, USHORT* fac, USHORT* class_)
{ {
/************************************** /**************************************
* *
@ -932,10 +939,15 @@ STATUS API_ROUTINE gds__decode(STATUS code, USHORT * fac, USHORT * class_)
**************************************/ **************************************/
if (!code) if (!code)
{
return SUCCESS; return SUCCESS;
else if (code & ISC_MASK != ISC_MASK) }
if (code & ISC_MASK != ISC_MASK)
{
/* not an ISC error message */ /* not an ISC error message */
return code; return code;
}
*fac = GET_FACILITY(code); *fac = GET_FACILITY(code);
*class_ = GET_CLASS(code); *class_ = GET_CLASS(code);
@ -944,7 +956,7 @@ STATUS API_ROUTINE gds__decode(STATUS code, USHORT * fac, USHORT * class_)
} }
void API_ROUTINE isc_decode_date(GDS_QUAD * date, void *times_arg) void API_ROUTINE isc_decode_date(GDS_QUAD* date, void* times_arg)
{ {
/************************************** /**************************************
* *
@ -959,11 +971,11 @@ void API_ROUTINE isc_decode_date(GDS_QUAD * date, void *times_arg)
* isc_decode_timestamp * isc_decode_timestamp
* *
**************************************/ **************************************/
isc_decode_timestamp((GDS_TIMESTAMP *) date, times_arg); isc_decode_timestamp((GDS_TIMESTAMP*) date, times_arg);
} }
void API_ROUTINE isc_decode_sql_date(GDS_DATE * date, void *times_arg) void API_ROUTINE isc_decode_sql_date(GDS_DATE* date, void* times_arg)
{ {
/************************************** /**************************************
* *
@ -1150,7 +1162,7 @@ void API_ROUTINE isc_encode_timestamp(void *times_arg, GDS_TIMESTAMP * date)
} }
ULONG API_ROUTINE gds__free(void *blk) ULONG API_ROUTINE gds__free(void* blk)
{ {
/************************************** /**************************************
* *
@ -1249,7 +1261,7 @@ void GDS_breakpoint(int parameter)
#endif #endif
SINT64 API_ROUTINE isc_portable_integer(UCHAR * ptr, SSHORT length) SINT64 API_ROUTINE isc_portable_integer(UCHAR* ptr, SSHORT length)
{ {
/************************************** /**************************************
* *
@ -1332,41 +1344,48 @@ static void gds_alloc_validate(ALLOC p)
DEV_REPORT("gds_alloc_validate: pointer doesn't look right\n"); DEV_REPORT("gds_alloc_validate: pointer doesn't look right\n");
} }
if (!errors if (!errors &&
&& strncmp(p->alloc_magic1, ALLOC_HEADER1_MAGIC_ALLOCATED, strncmp(p->alloc_magic1,
sizeof(p->alloc_magic1))) { ALLOC_HEADER1_MAGIC_ALLOCATED,
sizeof(p->alloc_magic1)))
{
errors++; errors++;
DEV_REPORT("gds_alloc_validate: Header marker1 mismatch\n"); DEV_REPORT("gds_alloc_validate: Header marker1 mismatch\n");
} }
if (!errors if (!errors &&
&& strncmp(p->alloc_magic2, ALLOC_HEADER2_MAGIC, strncmp(p->alloc_magic2,
sizeof(p->alloc_magic2))) { ALLOC_HEADER2_MAGIC,
sizeof(p->alloc_magic2)))
{
errors++; errors++;
DEV_REPORT("gds_alloc_validate: Header marker2 mismatch\n"); DEV_REPORT("gds_alloc_validate: Header marker2 mismatch\n");
} }
if (!errors if (!errors &&
&& memcmp(((BLOB_PTR *) p) + ALLOC_HEADER_SIZE + memcmp(((BLOB_PTR*) p) + ALLOC_HEADER_SIZE + p->alloc_requested_length,
p->alloc_requested_length, ALLOC_TAILER_MAGIC, ALLOC_TAILER_MAGIC,
ALLOC_TAILER_SIZE)) { ALLOC_TAILER_SIZE))
{
errors++; errors++;
DEV_REPORT("gds_alloc_validate: tailer marker mismatch\n"); DEV_REPORT("gds_alloc_validate: tailer marker mismatch\n");
} }
if (!errors && p->alloc_status.alloc_length < p->alloc_requested_length) { if (!errors && p->alloc_status.alloc_length < p->alloc_requested_length)
{
errors++; errors++;
DEV_REPORT DEV_REPORT("gds_alloc_validate: Header has been trashed (smaller than req)\n");
("gds_alloc_validate: Header has been trashed (smaller than req)\n");
} }
if (!errors && p->alloc_status.alloc_length < ALLOC_OVERHEAD) { if (!errors && p->alloc_status.alloc_length < ALLOC_OVERHEAD)
{
errors++; errors++;
DEV_REPORT DEV_REPORT
("gds_alloc_validate: Header has been trashed (smaller than min)\n"); ("gds_alloc_validate: Header has been trashed (smaller than min)\n");
} }
if (errors) { if (errors)
{
char buffer[150]; char buffer[150];
sprintf(buffer, sprintf(buffer,
"gds_alloc_validate: %lx len=%5ld file=%15.30s line=%4ld call=%ld alloc=%ld free=%ld%s", "gds_alloc_validate: %lx len=%5ld file=%15.30s line=%4ld call=%ld alloc=%ld free=%ld%s",
@ -1375,7 +1394,9 @@ static void gds_alloc_validate(ALLOC p)
p->alloc_filename, p->alloc_filename,
p->alloc_lineno, p->alloc_lineno,
p->alloc_callno, p->alloc_callno,
gds_alloc_call_count, gds_free_call_count, NEWLINE); gds_alloc_call_count,
gds_free_call_count,
NEWLINE);
DEV_REPORT(buffer); DEV_REPORT(buffer);
BREAKPOINT(__LINE__); BREAKPOINT(__LINE__);
} }
@ -1384,8 +1405,7 @@ static void gds_alloc_validate(ALLOC p)
#ifdef DEBUG_GDS_ALLOC #ifdef DEBUG_GDS_ALLOC
static BOOLEAN gds_alloc_validate_free_pattern( static BOOLEAN gds_alloc_validate_free_pattern(register UCHAR* ptr,
register UCHAR * ptr,
register ULONG len) register ULONG len)
{ {
/************************************** /**************************************
@ -1403,7 +1423,9 @@ static BOOLEAN gds_alloc_validate_free_pattern(
* *
**************************************/ **************************************/
while (len--) while (len--)
if (*ptr++ != ALLOC_FREED_PATTERN) { {
if (*ptr++ != ALLOC_FREED_PATTERN)
{
char buffer[100]; char buffer[100];
sprintf(buffer, sprintf(buffer,
"gds_alloc_validate_free_pattern: Write to freed memory at %lx\n", "gds_alloc_validate_free_pattern: Write to freed memory at %lx\n",
@ -1412,6 +1434,7 @@ static BOOLEAN gds_alloc_validate_free_pattern(
BREAKPOINT(__LINE__); BREAKPOINT(__LINE__);
return FALSE; return FALSE;
} }
}
return TRUE; return TRUE;
} }
@ -1435,22 +1458,27 @@ static void gds_alloc_validate_freed(ALLOC p)
/* This might be a garbage pointer, so try and validate it first */ /* This might be a garbage pointer, so try and validate it first */
if (!p) { if (!p)
{
errors++; errors++;
DEV_REPORT("gds_alloc_validate_freed: pointer doesn't look right\n"); DEV_REPORT("gds_alloc_validate_freed: pointer doesn't look right\n");
} }
/* Now look at the space, is it all the same pattern? */ /* Now look at the space, is it all the same pattern? */
if (!errors) { if (!errors)
{
register UCHAR *ptr; register UCHAR *ptr;
register ULONG len; register ULONG len;
ptr = ((UCHAR *) p) + sizeof(struct free); ptr = ((UCHAR *) p) + sizeof(struct free);
len = p->alloc_status.alloc_freed.free_length - sizeof(struct free); len = p->alloc_status.alloc_freed.free_length - sizeof(struct free);
if (!gds_alloc_validate_free_pattern(ptr, len)) if (!gds_alloc_validate_free_pattern(ptr, len))
{
errors++; errors++;
}
} }
if (errors) { if (errors)
{
char buffer[150]; char buffer[150];
sprintf(buffer, sprintf(buffer,
"gds_alloc_validate_freed: %lx len=%5ld alloc=%ld free=%ld%s", "gds_alloc_validate_freed: %lx len=%5ld alloc=%ld free=%ld%s",
@ -1466,7 +1494,7 @@ static void gds_alloc_validate_freed(ALLOC p)
#ifdef DEBUG_GDS_ALLOC #ifdef DEBUG_GDS_ALLOC
void gds_alloc_watch(void *p) void gds_alloc_watch(void* p)
{ {
/************************************** /**************************************
* *
@ -1482,14 +1510,17 @@ void gds_alloc_watch(void *p)
gds_alloc_watch_call_count++; gds_alloc_watch_call_count++;
/* Do we have a new place to watch? If so, set our watcher */ /* Do we have a new place to watch? If so, set our watcher */
if (p) { if (p)
{
gds_alloc_watchpoint = (ALLOC) ((UCHAR *) p - ALLOC_HEADER_SIZE); gds_alloc_watchpoint = (ALLOC) ((UCHAR *) p - ALLOC_HEADER_SIZE);
gds_alloc_watch_call_count = 1; gds_alloc_watch_call_count = 1;
} }
/* If we have a watchpoint, check that it's still valid */ /* If we have a watchpoint, check that it's still valid */
if (gds_alloc_watchpoint) if (gds_alloc_watchpoint)
{
gds_alloc_validate(gds_alloc_watchpoint); gds_alloc_validate(gds_alloc_watchpoint);
}
} }
#endif /* DEBUG_GDS_ALLOC */ #endif /* DEBUG_GDS_ALLOC */
@ -1509,10 +1540,9 @@ void API_ROUTINE gds_alloc_flag_unfreed(void *blk)
* don't report it in gds_alloc_report * don't report it in gds_alloc_report
* *
**************************************/ **************************************/
ALLOC p;
/* Point to the start of the block */ /* Point to the start of the block */
p = (ALLOC) (((UCHAR *) blk) - ALLOC_HEADER_SIZE); ALLOC p = (ALLOC) (((UCHAR *) blk) - ALLOC_HEADER_SIZE);
/* Might as well validate it while we're here */ /* Might as well validate it while we're here */
gds_alloc_validate(p); gds_alloc_validate(p);
@ -1526,7 +1556,7 @@ void API_ROUTINE gds_alloc_flag_unfreed(void *blk)
#ifdef DEBUG_GDS_ALLOC #ifdef DEBUG_GDS_ALLOC
void API_ROUTINE gds_alloc_report(ULONG flags, char *filename, int lineno) void API_ROUTINE gds_alloc_report(ULONG flags, char* filename, int lineno)
{ {
/************************************** /**************************************
* *
@ -1546,11 +1576,16 @@ void API_ROUTINE gds_alloc_report(ULONG flags, char *filename, int lineno)
BOOLEAN stderr_reporting = TRUE; BOOLEAN stderr_reporting = TRUE;
if (flags & ALLOC_check_each_call) if (flags & ALLOC_check_each_call)
{
gds_alloc_state = gds_alloc_call_count; gds_alloc_state = gds_alloc_call_count;
}
if (flags & ALLOC_dont_check) if (flags & ALLOC_dont_check)
{
gds_alloc_state = ~0; gds_alloc_state = ~0;
}
for (p = gds_alloc_chain; p; p = p->alloc_next) { for (p = gds_alloc_chain; p; p = p->alloc_next)
{
gds_alloc_validate(p); gds_alloc_validate(p);
if ((!(p->alloc_flags & ALLOC_dont_report) && if ((!(p->alloc_flags & ALLOC_dont_report) &&
!(flags & ALLOC_silent)) || !(flags & ALLOC_silent)) ||
@ -1569,14 +1604,25 @@ void API_ROUTINE gds_alloc_report(ULONG flags, char *filename, int lineno)
ib_fflush(ib_stderr); ib_fflush(ib_stderr);
sprintf(buffer, sprintf(buffer,
"%sgds_alloc_report: flags %ld file %15.15s lineno %ld alloc=%ld free=%ld%s%s", "%sgds_alloc_report: flags %ld file %15.15s lineno %ld alloc=%ld free=%ld%s%s",
NEWLINE, flags, filename ? filename : "?", lineno, NEWLINE,
gds_alloc_call_count, gds_free_call_count, NEWLINE, flags,
filename ? filename : "?",
lineno,
gds_alloc_call_count,
gds_free_call_count,
NEWLINE,
NEWLINE); NEWLINE);
if (getenv("NO_GDS_ALLOC_REPORT")) if (getenv("NO_GDS_ALLOC_REPORT"))
{
stderr_reporting = FALSE; stderr_reporting = FALSE;
}
if (stderr_reporting) if (stderr_reporting)
{
DEV_REPORT(buffer); DEV_REPORT(buffer);
if (f) { }
if (f)
{
ib_fprintf(f, buffer); ib_fprintf(f, buffer);
} }
} }
@ -1586,10 +1632,12 @@ void API_ROUTINE gds_alloc_report(ULONG flags, char *filename, int lineno)
p->alloc_requested_length, p->alloc_requested_length,
p->alloc_filename, p->alloc_filename,
p->alloc_lineno, p->alloc_callno, NEWLINE); p->alloc_lineno, p->alloc_callno, NEWLINE);
if (stderr_reporting) { if (stderr_reporting)
{
DEV_REPORT(buffer); DEV_REPORT(buffer);
} }
if (f) { if (f)
{
ib_fprintf(f, buffer); ib_fprintf(f, buffer);
} }
} }
@ -1599,13 +1647,13 @@ void API_ROUTINE gds_alloc_report(ULONG flags, char *filename, int lineno)
} }
/* Walk the list of free blocks and validate they haven't been referenced */ /* Walk the list of free blocks and validate they haven't been referenced */
for (p = (ALLOC) pool; p; for (p = (ALLOC)pool; p; p = (ALLOC)p->alloc_status.alloc_freed.free_next)
p = (ALLOC) p->alloc_status.alloc_freed.free_next)
{ {
gds_alloc_validate_freed(p); gds_alloc_validate_freed(p);
} }
if (f) { if (f)
{
ib_fclose(f); ib_fclose(f);
} }
} }
@ -1671,7 +1719,7 @@ SLONG API_ROUTINE gds__interprete(char *s, STATUS ** vector)
/* We need a temporary buffer when cstrings are involved. /* We need a temporary buffer when cstrings are involved.
Give up if we can't get one. */ Give up if we can't get one. */
p = temp = (TEXT *) gds__alloc((SLONG) BUFFER_SMALL); p = temp = (TEXT*) gds__alloc((SLONG) BUFFER_SMALL);
temp_len = (SSHORT) BUFFER_SMALL; temp_len = (SSHORT) BUFFER_SMALL;
/* FREE: at procedure exit */ /* FREE: at procedure exit */
if (!temp) /* NOMEM: */ if (!temp) /* NOMEM: */
@ -3048,7 +3096,7 @@ void API_ROUTINE gds__sqlcode_s(STATUS * status_vector, ULONG * sqlcode)
} }
UCHAR *API_ROUTINE gds__sys_alloc(SLONG size) void* API_ROUTINE gds__sys_alloc(SLONG size)
{ {
/************************************** /**************************************
* *
@ -3151,7 +3199,7 @@ UCHAR *API_ROUTINE gds__sys_alloc(SLONG size)
} }
SLONG API_ROUTINE gds__sys_free(void *blk) SLONG API_ROUTINE gds__sys_free(void* blk)
{ {
/************************************** /**************************************
* *
@ -4951,7 +4999,7 @@ static void sanitize(TEXT * locale)
#ifdef DEBUG_GDS_ALLOC #ifdef DEBUG_GDS_ALLOC
#undef gds__alloc #undef gds__alloc
UCHAR *API_ROUTINE gds__alloc(SLONG size) void* API_ROUTINE gds__alloc(SLONG size)
{ {
/************************************** /**************************************
* *

View File

@ -48,10 +48,10 @@ extern "C" {
#ifdef DEBUG_GDS_ALLOC #ifdef DEBUG_GDS_ALLOC
#define gds__alloc(s) gds__alloc_debug ((s),(TEXT *)__FILE__,(ULONG)__LINE__) #define gds__alloc(s) gds__alloc_debug ((s),(TEXT*)__FILE__,(ULONG)__LINE__)
extern UCHAR *API_ROUTINE gds__alloc_debug(SLONG, TEXT *, ULONG); void* API_ROUTINE gds__alloc_debug(SLONG, TEXT*, ULONG);
extern void API_ROUTINE gds_alloc_flag_unfreed(void *); void API_ROUTINE gds_alloc_flag_unfreed(void*);
extern void API_ROUTINE gds_alloc_report(ULONG, char *, int); void API_ROUTINE gds_alloc_report(ULONG, char*, int);
#define ALLOC_dont_report (1L << 0) /* Don't report this block */ #define ALLOC_dont_report (1L << 0) /* Don't report this block */
#define ALLOC_silent (1L << 1) /* Don't report new leaks */ #define ALLOC_silent (1L << 1) /* Don't report new leaks */
@ -62,7 +62,7 @@ extern void API_ROUTINE gds_alloc_report(ULONG, char *, int);
#else /* DEBUG_GDS_ALLOC */ #else /* DEBUG_GDS_ALLOC */
extern UCHAR *API_ROUTINE gds__alloc(SLONG); extern void* API_ROUTINE gds__alloc(SLONG);
#endif /* DEBUG_GDS_ALLOC */ #endif /* DEBUG_GDS_ALLOC */
@ -70,73 +70,73 @@ extern UCHAR *API_ROUTINE gds__alloc(SLONG);
typedef GDS_QUAD GDS__QUAD; typedef GDS_QUAD GDS__QUAD;
#endif #endif
extern STATUS API_ROUTINE gds__decode(STATUS, USHORT *, USHORT *); STATUS API_ROUTINE gds__decode(STATUS, USHORT*, USHORT*);
extern void API_ROUTINE isc_decode_date(GDS_QUAD *, void *); void API_ROUTINE isc_decode_date(GDS_QUAD*, void*);
extern void API_ROUTINE isc_decode_sql_date(GDS_DATE *, void *); void API_ROUTINE isc_decode_sql_date(GDS_DATE*, void*);
extern void API_ROUTINE isc_decode_sql_time(GDS_TIME *, void *); void API_ROUTINE isc_decode_sql_time(GDS_TIME*, void*);
extern void API_ROUTINE isc_decode_timestamp(GDS_TIMESTAMP *, void *); void API_ROUTINE isc_decode_timestamp(GDS_TIMESTAMP*, void*);
extern STATUS API_ROUTINE gds__encode(STATUS, USHORT); STATUS API_ROUTINE gds__encode(STATUS, USHORT);
extern void API_ROUTINE isc_encode_date(void *, GDS_QUAD *); void API_ROUTINE isc_encode_date(void*, GDS_QUAD*);
extern void API_ROUTINE isc_encode_sql_date(void *, GDS_DATE *); void API_ROUTINE isc_encode_sql_date(void*, GDS_DATE*);
extern void API_ROUTINE isc_encode_sql_time(void *, GDS_TIME *); void API_ROUTINE isc_encode_sql_time(void*, GDS_TIME*);
extern void API_ROUTINE isc_encode_timestamp(void *, GDS_TIMESTAMP *); void API_ROUTINE isc_encode_timestamp(void*, GDS_TIMESTAMP*);
extern ULONG API_ROUTINE gds__free(void *); ULONG API_ROUTINE gds__free(void*);
extern SLONG API_ROUTINE gds__interprete(char *, STATUS **); SLONG API_ROUTINE gds__interprete(char*, STATUS**);
extern void API_ROUTINE gds__interprete_a(SCHAR *, SSHORT *, STATUS *, void API_ROUTINE gds__interprete_a(SCHAR*, SSHORT*, STATUS*, SSHORT*);
SSHORT *); void API_ROUTINE gds__log(TEXT*, ...);
extern void API_ROUTINE gds__log(TEXT *, ...); void API_ROUTINE gds__log_status(TEXT*, STATUS*);
extern void API_ROUTINE gds__log_status(TEXT *, STATUS *); int API_ROUTINE gds__msg_close(void*);
extern int API_ROUTINE gds__msg_close(void *); SSHORT API_ROUTINE gds__msg_format(void*, USHORT, USHORT, USHORT,
extern SSHORT API_ROUTINE gds__msg_format(void *, USHORT, USHORT, USHORT, TEXT*, TEXT*, TEXT*, TEXT*,
TEXT *, TEXT *, TEXT *, TEXT *, TEXT*, TEXT*);
TEXT *, TEXT *); SSHORT API_ROUTINE gds__msg_lookup(void*, USHORT, USHORT, USHORT,
extern SSHORT API_ROUTINE gds__msg_lookup(void *, USHORT, USHORT, USHORT, TEXT*, USHORT*);
TEXT *, USHORT *); int API_ROUTINE gds__msg_open(void**, TEXT*);
extern int API_ROUTINE gds__msg_open(void **, TEXT *); void API_ROUTINE gds__msg_put(void*, USHORT, USHORT, TEXT*, TEXT*,
extern void API_ROUTINE gds__msg_put(void *, USHORT, USHORT, TEXT *, TEXT *, TEXT*, TEXT*, TEXT*);
TEXT *, TEXT *, TEXT *);
#ifdef NETWARE_386 #ifdef NETWARE_386
extern void API_ROUTINE gds__prefix(TEXT *, void *); void API_ROUTINE gds__prefix(TEXT*, void*);
extern void API_ROUTINE gds__prefix_lock(TEXT *, void *); void API_ROUTINE gds__prefix_lock(TEXT*, void*);
#else #else
extern void API_ROUTINE gds__prefix(TEXT *, TEXT *); void API_ROUTINE gds__prefix(TEXT*, TEXT*);
extern void API_ROUTINE gds__prefix_lock(TEXT *, TEXT *); void API_ROUTINE gds__prefix_lock(TEXT*, TEXT*);
extern void API_ROUTINE gds__prefix_msg(TEXT *, TEXT *); void API_ROUTINE gds__prefix_msg(TEXT*, TEXT*);
#endif #endif
extern SLONG API_ROUTINE gds__get_prefix(SSHORT, TEXT *);
extern STATUS API_ROUTINE gds__print_status(STATUS *); SLONG API_ROUTINE gds__get_prefix(SSHORT, TEXT*);
extern USHORT API_ROUTINE gds__parse_bpb(USHORT, UCHAR *, USHORT *, USHORT *); STATUS API_ROUTINE gds__print_status(STATUS*);
extern USHORT API_ROUTINE gds__parse_bpb2(USHORT, UCHAR *, USHORT *, USHORT *, USHORT API_ROUTINE gds__parse_bpb(USHORT, UCHAR*, USHORT*, USHORT*);
USHORT *, USHORT *); USHORT API_ROUTINE gds__parse_bpb2(USHORT, UCHAR*, USHORT*, USHORT*,
extern SLONG API_ROUTINE gds__ftof(SCHAR *, USHORT GDS_VAL(length1), SCHAR *, USHORT*, USHORT*);
USHORT GDS_VAL(length2)); SLONG API_ROUTINE gds__ftof(SCHAR*, USHORT GDS_VAL(length1), SCHAR*,
extern int API_ROUTINE gds__print_blr(UCHAR *, FPTR_VOID, SCHAR *, SSHORT); USHORT GDS_VAL(length2));
extern void API_ROUTINE gds__put_error(TEXT *); int API_ROUTINE gds__print_blr(UCHAR*, FPTR_VOID, SCHAR*, SSHORT);
extern void API_ROUTINE gds__qtoq(void *, void *); void API_ROUTINE gds__put_error(TEXT*);
extern void API_ROUTINE gds__register_cleanup(FPTR_VOID_PTR, void *); void API_ROUTINE gds__qtoq(void*, void*);
extern SLONG API_ROUTINE gds__sqlcode(STATUS *); void API_ROUTINE gds__register_cleanup(FPTR_VOID_PTR, void*);
extern void API_ROUTINE gds__sqlcode_s(STATUS *, ULONG *); SLONG API_ROUTINE gds__sqlcode(STATUS*);
extern UCHAR *API_ROUTINE gds__sys_alloc(SLONG); void API_ROUTINE gds__sqlcode_s(STATUS*, ULONG*);
extern SLONG API_ROUTINE gds__sys_free(void *); void* API_ROUTINE gds__sys_alloc(SLONG);
extern void *API_ROUTINE gds__temp_file(BOOLEAN, TEXT *, TEXT *); SLONG API_ROUTINE gds__sys_free(void*);
extern void API_ROUTINE gds__unregister_cleanup(FPTR_VOID_PTR, void *); void* API_ROUTINE gds__temp_file(BOOLEAN, TEXT*, TEXT*);
extern BOOLEAN API_ROUTINE gds__validate_lib_path(TEXT *, TEXT *, TEXT *, void API_ROUTINE gds__unregister_cleanup(FPTR_VOID_PTR, void*);
SLONG); BOOLEAN API_ROUTINE gds__validate_lib_path(TEXT*, TEXT*, TEXT*,
extern SLONG API_ROUTINE gds__vax_integer(UCHAR *, SSHORT); SLONG);
extern void API_ROUTINE gds__vtof(SCHAR *, SCHAR *, USHORT); SLONG API_ROUTINE gds__vax_integer(UCHAR*, SSHORT);
extern void API_ROUTINE gds__vtov(CONST SCHAR *, SCHAR *, SSHORT); void API_ROUTINE gds__vtof(SCHAR*, SCHAR*, USHORT);
extern void API_ROUTINE isc_print_sqlerror(SSHORT, STATUS *); void API_ROUTINE gds__vtov(CONST SCHAR*, SCHAR*, SSHORT);
extern void API_ROUTINE isc_sql_interprete(SSHORT, TEXT *, SSHORT); void API_ROUTINE isc_print_sqlerror(SSHORT, STATUS*);
extern void *gds__tmp_file2(BOOLEAN, TEXT *, TEXT *, TEXT *); void API_ROUTINE isc_sql_interprete(SSHORT, TEXT*, SSHORT);
extern SINT64 API_ROUTINE isc_portable_integer(UCHAR *, SSHORT); void* gds__tmp_file2(BOOLEAN, TEXT*, TEXT*, TEXT*);
extern void gds__cleanup(void); SINT64 API_ROUTINE isc_portable_integer(UCHAR*, SSHORT);
void gds__cleanup(void);
#ifdef NETWARE_386 #ifdef NETWARE_386
extern SCHAR *mktemp(SCHAR *); SCHAR* mktemp(SCHAR*);
#endif #endif
#ifdef VMS #ifdef VMS
extern int unlink(SCHAR *); int unlink(SCHAR*);
#endif #endif

View File

@ -244,9 +244,10 @@ UCHAR *DLL_EXPORT SDL_prepare_slice(UCHAR * sdl, USHORT sdl_length)
* blr_d_float to blr_double. * blr_d_float to blr_double.
* *
**************************************/ **************************************/
UCHAR *new_sdl, *old_sdl; UCHAR* new_sdl;
DSC junk; UCHAR* old_sdl;
USHORT n; DSC junk;
USHORT n;
new_sdl = old_sdl = sdl; new_sdl = old_sdl = sdl;
@ -254,14 +255,20 @@ UCHAR *DLL_EXPORT SDL_prepare_slice(UCHAR * sdl, USHORT sdl_length)
return old_sdl; return old_sdl;
while ((SCHAR) * sdl != gds_sdl_eoc) while ((SCHAR) * sdl != gds_sdl_eoc)
switch (*sdl++) { {
switch (*sdl++)
{
case gds_sdl_struct: case gds_sdl_struct:
for (n = *sdl++; n; --n) { for (n = *sdl++; n; --n)
if (*sdl == blr_d_float) { {
if (new_sdl == old_sdl) { if (*sdl == blr_d_float)
new_sdl = gds__alloc((SLONG) sdl_length); {
if (new_sdl == old_sdl)
{
new_sdl = (UCHAR*)gds__alloc((SLONG) sdl_length);
/* FREE: apparently never freed */ /* FREE: apparently never freed */
if (!new_sdl) { /* NOMEM: ignore operation */ if (!new_sdl)
{ /* NOMEM: ignore operation */
assert(FALSE); /* no real error handling */ assert(FALSE); /* no real error handling */
return old_sdl; return old_sdl;
} }
@ -290,6 +297,7 @@ UCHAR *DLL_EXPORT SDL_prepare_slice(UCHAR * sdl, USHORT sdl_length)
default: default:
return new_sdl; return new_sdl;
} }
}
return new_sdl; return new_sdl;
} }

View File

@ -2085,16 +2085,18 @@ void *SVC_start(SVC service, USHORT spb_length, SCHAR * spb)
if (service->svc_stdout) if (service->svc_stdout)
gds__free(service->svc_stdout); gds__free(service->svc_stdout);
service->svc_stdout = gds__alloc((SLONG) SVC_STDOUT_BUFFER_SIZE + 1); service->svc_stdout = (UCHAR*)gds__alloc((SLONG) SVC_STDOUT_BUFFER_SIZE + 1);
/* FREE: at SVC_detach() */ /* FREE: at SVC_detach() */
if (!service->svc_stdout) /* NOMEM: */ if (!service->svc_stdout) /* NOMEM: */
{
ERR_post(isc_virmemexh, 0); ERR_post(isc_virmemexh, 0);
}
if (serv->serv_thd) { if (serv->serv_thd) {
SLONG count; SLONG count;
#pragma FB_COMPILER_MESSAGE("Fix! Probable bug!") #pragma FB_COMPILER_MESSAGE("Fix! Probable bug!")
EVENT evnt_ptr = EVENT evnt_ptr =
reinterpret_cast < EVENT > (&(service->svc_start_event)); reinterpret_cast<EVENT> (&(service->svc_start_event));
THREAD_EXIT; THREAD_EXIT;
/* create an event for the service. The event will be signaled once the /* create an event for the service. The event will be signaled once the
@ -2769,9 +2771,9 @@ static USHORT service_empty(SVC service)
* *
**************************************/ **************************************/
if (service_add_one(service->svc_stdout_tail) == service->svc_stdout_head) if (service_add_one(service->svc_stdout_tail) == service->svc_stdout_head)
return (1); return 1;
else
return (0); return 0;
} }
@ -2888,24 +2890,27 @@ static void service_fork(void (*service_executable) (), SVC service)
} }
*arg = NULL; *arg = NULL;
service->svc_stdout = gds__alloc((SLONG) SVC_STDOUT_BUFFER_SIZE + 1); service->svc_stdout = (UCHAR*)gds__alloc((SLONG) SVC_STDOUT_BUFFER_SIZE + 1);
/* FREE: at SVC_detach() */ /* FREE: at SVC_detach() */
if (!service->svc_stdout) /* NOMEM: */ if (!service->svc_stdout) /* NOMEM: */
ERR_post(isc_virmemexh, 0); ERR_post(isc_virmemexh, 0);
THREAD_EXIT; THREAD_EXIT;
gds__thread_start(reinterpret_cast < FPTR_INT_VOID_PTR > gds__thread_start(reinterpret_cast<FPTR_INT_VOID_PTR>(service_executable),
(service_executable), service, 0, 0, service,
(void *) &service->svc_handle); 0,
0,
(void*)&service->svc_handle);
THREAD_ENTER; THREAD_ENTER;
} }
static void service_get( static void service_get(SVC service,
SVC service, SCHAR* buffer,
SCHAR * buffer, USHORT length,
USHORT length, USHORT flags,
USHORT flags, USHORT timeout, USHORT * return_length) USHORT timeout,
USHORT* return_length)
{ {
/************************************** /**************************************
* *
@ -3772,7 +3777,8 @@ static void get_action_svc_string(
*spb += sizeof(ISC_USHORT); *spb += sizeof(ISC_USHORT);
if (*cmd) { if (*cmd)
{
**cmd = SVC_TRMNTR; **cmd = SVC_TRMNTR;
*cmd += 1; *cmd += 1;
MOVE_FASTER(*spb, *cmd, l); MOVE_FASTER(*spb, *cmd, l);

View File

@ -40,17 +40,17 @@ extern "C" {
#define SVC_STDOUT_BUFFER_SIZE 1024 #define SVC_STDOUT_BUFFER_SIZE 1024
/* Flag of capabilities supported by the server */ /* Flag of capabilities supported by the server */
#define WAL_SUPPORT 0x1L /* Write Ahead Log */ #define WAL_SUPPORT 0x1L /* Write Ahead Log */
#define MULTI_CLIENT_SUPPORT 0x2L /* SuperServer model (vs. multi-inet) */ #define MULTI_CLIENT_SUPPORT 0x2L /* SuperServer model (vs. multi-inet) */
#define REMOTE_HOP_SUPPORT 0x4L /* Server can connect to other server */ #define REMOTE_HOP_SUPPORT 0x4L /* Server can connect to other server */
#define NO_SVR_STATS_SUPPORT 0x8L /* Does not support statistics */ #define NO_SVR_STATS_SUPPORT 0x8L /* Does not support statistics */
#define NO_DB_STATS_SUPPORT 0x10L /* Does not support statistics */ #define NO_DB_STATS_SUPPORT 0x10L /* Does not support statistics */
#define LOCAL_ENGINE_SUPPORT 0x20L /* The local 16 bit engine */ #define LOCAL_ENGINE_SUPPORT 0x20L /* The local 16 bit engine */
#define NO_FORCED_WRITE_SUPPORT 0x40L /* Can not configure sync writes */ #define NO_FORCED_WRITE_SUPPORT 0x40L /* Can not configure sync writes */
#define NO_SHUTDOWN_SUPPORT 0x80L /* Can not shutdown/restart databases */ #define NO_SHUTDOWN_SUPPORT 0x80L /* Can not shutdown/restart databases */
#define NO_SERVER_SHUTDOWN_SUPPORT 0x100L /* Can not shutdown server */ #define NO_SERVER_SHUTDOWN_SUPPORT 0x100L /* Can not shutdown server */
#define SERVER_CONFIG_SUPPORT 0x200L /* Can configure server */ #define SERVER_CONFIG_SUPPORT 0x200L /* Can configure server */
#define QUOTED_FILENAME_SUPPORT 0x400L /* Can pass quoted filenames in */ #define QUOTED_FILENAME_SUPPORT 0x400L /* Can pass quoted filenames in */
/* Range definitions for service actions. Any action outside of /* Range definitions for service actions. Any action outside of
this range is not supported */ this range is not supported */
@ -100,8 +100,10 @@ extern "C" {
inline SVC_STATUS_ARG(STATUS * &status, USHORT type, void *value) inline SVC_STATUS_ARG(STATUS * &status, USHORT type, void *value)
{ {
if (value) { if (value)
switch (type) { {
switch (type)
{
case isc_arg_number: case isc_arg_number:
*status++ = type; *status++ = type;
*status++ = reinterpret_cast < STATUS > (value); *status++ = reinterpret_cast < STATUS > (value);
@ -148,51 +150,53 @@ inline SVC_STATUS_ARG(STATUS * &status, USHORT type, void *value)
}}} }}}
/* Service manager block */ /* Service manager block */
typedef struct svc { typedef struct svc
{
struct blk svc_header; struct blk svc_header;
SLONG svc_handle; /* "handle" of process/thread running service */ SLONG svc_handle; /* "handle" of process/thread running service */
STATUS *svc_status; /* status vector for svc_handle */ STATUS* svc_status; /* status vector for svc_handle */
void *svc_input; /* input to service */ void* svc_input; /* input to service */
void *svc_output; /* output from service */ void* svc_output; /* output from service */
ULONG svc_stdout_head; ULONG svc_stdout_head;
ULONG svc_stdout_tail; ULONG svc_stdout_tail;
UCHAR *svc_stdout; UCHAR* svc_stdout;
TEXT **svc_argv; TEXT** svc_argv;
ULONG svc_argc; ULONG svc_argc;
EVENT_T svc_start_event[1]; /* fired once service has started successfully */ EVENT_T svc_start_event[1]; /* fired once service has started successfully */
CONST struct serv *svc_service; CONST struct serv* svc_service;
UCHAR *svc_resp_buf; UCHAR* svc_resp_buf;
UCHAR *svc_resp_ptr; UCHAR* svc_resp_ptr;
USHORT svc_resp_buf_len; USHORT svc_resp_buf_len;
USHORT svc_resp_len; USHORT svc_resp_len;
USHORT svc_flags; USHORT svc_flags;
USHORT svc_user_flag; USHORT svc_user_flag;
USHORT svc_spb_version; USHORT svc_spb_version;
BOOLEAN svc_do_shutdown; BOOLEAN svc_do_shutdown;
TEXT svc_username[33]; TEXT svc_username[33];
TEXT svc_enc_password[MAX_PASSWORD_ENC_LENGTH]; TEXT svc_enc_password[MAX_PASSWORD_ENC_LENGTH];
TEXT svc_reserved[1]; TEXT svc_reserved[1];
TEXT *svc_switches; TEXT* svc_switches;
} *SVC; } *SVC;
typedef struct serv { typedef struct serv
USHORT serv_action; {
CONST TEXT *serv_name; USHORT serv_action;
CONST TEXT *serv_std_switches; CONST TEXT* serv_name;
CONST TEXT *serv_executable; CONST TEXT* serv_std_switches;
CONST TEXT* serv_executable;
CONST void (*serv_thd) (); CONST void (*serv_thd) ();
BOOLEAN *in_use; BOOLEAN* in_use;
} *SERV; } *SERV;
/* Bitmask values for the svc_flags variable */ /* Bitmask values for the svc_flags variable */
#define SVC_eof 1 #define SVC_eof 1
#define SVC_timeout 2 #define SVC_timeout 2
#define SVC_forked 4 #define SVC_forked 4
#define SVC_detached 8 #define SVC_detached 8
#define SVC_finished 16 #define SVC_finished 16
#define SVC_thd_running 32 #define SVC_thd_running 32
#define SVC_evnt_fired 64 #define SVC_evnt_fired 64
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -30,40 +30,45 @@
extern "C" { extern "C" {
#endif #endif
extern int API_ROUTINE gds__thread_start(FPTR_INT_VOID_PTR, void *, int, int, int API_ROUTINE gds__thread_start(FPTR_INT_VOID_PTR, void*, int, int,
void *); void*);
extern long THD_get_thread_id(void);
extern struct thdd *DLL_EXPORT THD_get_specific(void); struct thdd* DLL_EXPORT THD_get_specific(void);
extern void THD_getspecific_data(void **t_data); void DLL_EXPORT THD_init(void);
extern void DLL_EXPORT THD_init(void); void DLL_EXPORT THD_cleanup(void);
extern void DLL_EXPORT THD_cleanup(void); int DLL_EXPORT THD_mutex_destroy(struct mutx_t*);
extern int DLL_EXPORT THD_mutex_destroy(struct mutx_t *); void DLL_EXPORT THD_put_specific(struct thdd*);
extern int THD_mutex_init(struct mutx_t *); int DLL_EXPORT THD_wlck_destroy(struct wlck_t*);
extern int THD_mutex_lock(struct mutx_t *); int DLL_EXPORT THD_wlck_init(struct wlck_t*);
extern int THD_mutex_unlock(struct mutx_t *); int DLL_EXPORT THD_wlck_lock(struct wlck_t*, USHORT);
extern int THD_mutex_destroy_n(struct mutx_t *, USHORT); int DLL_EXPORT THD_wlck_unlock(struct wlck_t*);
extern int THD_mutex_init_n(struct mutx_t *, USHORT);
extern int THD_mutex_lock_global(void); long THD_get_thread_id(void);
extern int THD_mutex_unlock_global(void); void THD_getspecific_data(void** t_data);
extern void DLL_EXPORT THD_put_specific(struct thdd *);
extern void THD_putspecific_data(void *t_data); int THD_mutex_init(struct mutx_t*);
int THD_mutex_lock(struct mutx_t*);
int THD_mutex_unlock(struct mutx_t*);
int THD_mutex_destroy_n(struct mutx_t*, USHORT);
int THD_mutex_init_n(struct mutx_t*, USHORT);
int THD_mutex_lock_global(void);
int THD_mutex_unlock_global(void);
void THD_putspecific_data(void* t_data);
#ifdef SUPERSERVER #ifdef SUPERSERVER
extern int THD_rec_mutex_destroy(struct rec_mutx_t *); int THD_rec_mutex_destroy(struct rec_mutx_t*);
extern int THD_rec_mutex_init(struct rec_mutx_t *); int THD_rec_mutex_init(struct rec_mutx_t*);
extern int THD_rec_mutex_lock(struct rec_mutx_t *); int THD_rec_mutex_lock(struct rec_mutx_t*);
extern int THD_rec_mutex_unlock(struct rec_mutx_t *); int THD_rec_mutex_unlock(struct rec_mutx_t*);
#endif #endif
extern struct thdd *DLL_EXPORT THD_restore_specific(void);
extern int THD_resume(THD_T); struct thdd* DLL_EXPORT THD_restore_specific(void);
extern void THD_sleep(ULONG); int THD_resume(THD_T);
extern int THD_suspend(THD_T); void THD_sleep(ULONG);
extern int DLL_EXPORT THD_wlck_destroy(struct wlck_t *); int THD_suspend(THD_T);
extern int DLL_EXPORT THD_wlck_init(struct wlck_t *); void THD_wlck_destroy_n(struct wlck_t*, USHORT);
extern int DLL_EXPORT THD_wlck_lock(struct wlck_t *, USHORT); void THD_wlck_init_n(struct wlck_t*, USHORT);
extern int DLL_EXPORT THD_wlck_unlock(struct wlck_t *); void THD_yield(void);
extern void THD_wlck_destroy_n(struct wlck_t *, USHORT);
extern void THD_wlck_init_n(struct wlck_t *, USHORT);
extern void THD_yield(void);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View File

@ -372,11 +372,14 @@ int THD_rec_mutex_init(REC_MUTX_T * rec_mutex)
// //
int THD_rec_mutex_lock(REC_MUTX_T * rec_mutex) int THD_rec_mutex_lock(REC_MUTX_T * rec_mutex)
{ {
if (rec_mutex->rec_mutx_id == THD_get_thread_id()) { if (rec_mutex->rec_mutx_id == THD_get_thread_id())
{
rec_mutex->rec_mutx_count++; rec_mutex->rec_mutx_count++;
} else { } else
int ret = THD_mutex_lock(rec_mutex->rec_mutx_mtx); {
if (ret) { const int ret = THD_mutex_lock(rec_mutex->rec_mutx_mtx);
if (ret)
{
return ret; return ret;
} }
rec_mutex->rec_mutx_id = THD_get_thread_id(); rec_mutex->rec_mutx_id = THD_get_thread_id();

View File

@ -68,7 +68,9 @@
#if defined(WIN_NT) && defined(_MSC_VER) #if defined(WIN_NT) && defined(_MSC_VER)
#pragma FB_COMPILER_MESSAGE("Fix! warnings turned off!") #pragma FB_COMPILER_MESSAGE("Fix! warnings turned off!")
#pragma warning(disable: 4244 4018) // 4018 - signed/unsigned mismatch
// 4244 - conversion from 'type1' to 'type2', possible loss of data
#pragma warning(disable: 4018 4244)
#endif #endif
#define DYN_MSG_FAC 8 #define DYN_MSG_FAC 8
@ -79,7 +81,8 @@
#define EVENT_FLAG 15 #define EVENT_FLAG 15
static CONST SCHAR lock_types[] = { static CONST SCHAR lock_types[] =
{
0, 0,
LCK$K_NLMODE, LCK$K_NLMODE,
LCK$K_CRMODE, LCK$K_CRMODE,
@ -2883,50 +2886,54 @@ static BOOLEAN start_sweeper(TDBB tdbb, DBB dbb)
* Start a thread to sweep the database. * Start a thread to sweep the database.
* *
**************************************/ **************************************/
struct lck temp_lock;
UCHAR *database;
if (dbb->dbb_flags & DBB_sweep_in_progress) if (dbb->dbb_flags & DBB_sweep_in_progress)
{
return FALSE; return FALSE;
}
SET_TDBB(tdbb); SET_TDBB(tdbb);
/* fill out a lock block, zeroing it out first */
MOVE_CLEAR(&temp_lock, sizeof(struct lck)); /* fill out the lock block */
struct lck temp_lock = { 0 };
temp_lock.lck_header.blk_type = type_lck; temp_lock.lck_header.blk_type = type_lck;
temp_lock.lck_dbb = dbb; temp_lock.lck_dbb = dbb;
temp_lock.lck_type = LCK_sweep; temp_lock.lck_type = LCK_sweep;
temp_lock.lck_owner_handle = temp_lock.lck_owner_handle = LCK_get_owner_handle(tdbb, temp_lock.lck_type);
LCK_get_owner_handle(tdbb, temp_lock.lck_type);
temp_lock.lck_parent = dbb->dbb_lock; temp_lock.lck_parent = dbb->dbb_lock;
temp_lock.lck_length = sizeof(SLONG); temp_lock.lck_length = sizeof(SLONG);
if (!LCK_lock(tdbb, &temp_lock, LCK_EX, FALSE)) if (!LCK_lock(tdbb, &temp_lock, LCK_EX, FALSE))
{
return FALSE; return FALSE;
}
LCK_release(tdbb, &temp_lock); LCK_release(tdbb, &temp_lock);
/* allocate space for the string and a null at the end */ /* allocate space for the string and a null at the end */
database = const char* pszFilename =
gds__alloc(strlen reinterpret_cast<const char*>(dbb->dbb_filename->str_data);
(reinterpret_cast <
const char *>(dbb->dbb_filename->str_data)) +1); char* database = (char*)gds__alloc(strlen(pszFilename) + 1);
if (database) {
strcpy(reinterpret_cast < char *>(database), if (!database)
reinterpret_cast < const char *>(dbb->dbb_filename->str_data)); {
if (gds__thread_start
(reinterpret_cast < FPTR_INT_VOID_PTR > (sweep_database),
database, THREAD_low, 0, 0)) {
gds__free(database);
ERR_log(0, 0, "cannot start sweep thread");
}
}
else {
ERR_log(0, 0, "cannot start sweep thread, Out of Memory"); ERR_log(0, 0, "cannot start sweep thread, Out of Memory");
return FALSE; return FALSE;
} }
strcpy(database, pszFilename);
if (gds__thread_start(reinterpret_cast<FPTR_INT_VOID_PTR>(sweep_database),
database,
THREAD_low,
0,
0))
{
gds__free(database);
ERR_log(0, 0, "cannot start sweep thread");
}
return TRUE; return TRUE;
} }
@ -2943,18 +2950,13 @@ static void THREAD_ROUTINE sweep_database(UCHAR * database)
* Sweep database. * Sweep database.
* *
**************************************/ **************************************/
isc_db_handle db_handle; STATUS status_vector[ISC_STATUS_LENGTH];
IHNDL ihandle; char* q;
STATUS status_vector[ISC_STATUS_LENGTH];
UCHAR* dpb;
SSHORT dpb_length;
char* q;
UCHAR sweep_dpb[100]; UCHAR sweep_dpb[100];
TEXT password_enc[100];
db_handle = NULL; isc_db_handle db_handle = NULL;
dpb = sweep_dpb; UCHAR* dpb = sweep_dpb;
*dpb++ = gds_dpb_version1; *dpb++ = gds_dpb_version1;
*dpb++ = gds_dpb_user_name; *dpb++ = gds_dpb_user_name;
@ -2976,9 +2978,11 @@ static void THREAD_ROUTINE sweep_database(UCHAR * database)
*dpb++ = gds_dpb_sweep; *dpb++ = gds_dpb_sweep;
*dpb++ = 1; *dpb++ = 1;
*dpb++ = gds_dpb_records; *dpb++ = gds_dpb_records;
dpb_length = dpb - sweep_dpb;
const SSHORT dpb_length = dpb - sweep_dpb;
/* Register as internal database handle */ /* Register as internal database handle */
IHNDL ihandle;
THREAD_ENTER; THREAD_ENTER;
for (ihandle = internal_db_handles; ihandle; ihandle = ihandle->ihndl_next) for (ihandle = internal_db_handles; ihandle; ihandle = ihandle->ihndl_next)

View File

@ -410,23 +410,28 @@ void API_ROUTINE_VARARG isc_expand_dpb(SCHAR ** dpb, SSHORT * dpb_size, ...)
* use than the natural alternative. * use than the natural alternative.
* *
**************************************/ **************************************/
SSHORT length, new_dpb_length; SSHORT length;
UCHAR *new_dpb; SSHORT new_dpb_length;
char *p; UCHAR* new_dpb;
char *q; char* p;
va_list args; char* q;
USHORT type; va_list args;
USHORT type;
/* calculate length of database parameter block, /* calculate length of database parameter block,
setting initial length to include version */ setting initial length to include version */
if (!*dpb || !(new_dpb_length = *dpb_size)) if (!*dpb || !(new_dpb_length = *dpb_size))
{
new_dpb_length = 1; new_dpb_length = 1;
}
VA_START(args, dpb_size); VA_START(args, dpb_size);
while (type = va_arg(args, int)) while (type = va_arg(args, int))
switch (type) { {
switch (type)
{
case gds_dpb_user_name: case gds_dpb_user_name:
case gds_dpb_password: case gds_dpb_password:
case isc_dpb_sql_role_name: case isc_dpb_sql_role_name:
@ -434,7 +439,8 @@ void API_ROUTINE_VARARG isc_expand_dpb(SCHAR ** dpb, SSHORT * dpb_size, ...)
case gds_dpb_lc_ctype: case gds_dpb_lc_ctype:
case isc_dpb_reserved: case isc_dpb_reserved:
p = va_arg(args, char *); p = va_arg(args, char *);
if (p) { if (p)
{
length = strlen(p); length = strlen(p);
new_dpb_length += 2 + length; new_dpb_length += 2 + length;
} }
@ -444,29 +450,35 @@ void API_ROUTINE_VARARG isc_expand_dpb(SCHAR ** dpb, SSHORT * dpb_size, ...)
(void) va_arg(args, int); (void) va_arg(args, int);
break; break;
} }
}
/* if items have been added, allocate space /* if items have been added, allocate space
for the new dpb and copy the old one over */ for the new dpb and copy the old one over */
if (new_dpb_length > *dpb_size) { if (new_dpb_length > *dpb_size)
{
/* Note: gds__free done by GPRE generated code */ /* Note: gds__free done by GPRE generated code */
new_dpb = gds__alloc((SLONG) (sizeof(UCHAR) * new_dpb_length)); new_dpb = (UCHAR*)gds__alloc((SLONG)(sizeof(UCHAR) * new_dpb_length));
p = reinterpret_cast < char *>(new_dpb); p = reinterpret_cast < char *>(new_dpb);
/* FREE: done by client process in GPRE generated code */ /* FREE: done by client process in GPRE generated code */
if (!new_dpb) { /* NOMEM: don't trash existing dpb */ if (!new_dpb)
{ /* NOMEM: don't trash existing dpb */
DEV_REPORT("isc_extend_dpb: out of memory"); DEV_REPORT("isc_extend_dpb: out of memory");
return; /* NOMEM: not really handled */ return; /* NOMEM: not really handled */
} }
q = *dpb; q = *dpb;
for (length = *dpb_size; length; length--) for (length = *dpb_size; length; length--)
{
*p++ = *q++; *p++ = *q++;
}
} }
else { else
{
new_dpb = (UCHAR *) * dpb; new_dpb = (UCHAR *) * dpb;
p = reinterpret_cast < char *>(new_dpb + *dpb_size); p = reinterpret_cast<char*>(new_dpb + *dpb_size);
} }
if (!*dpb_size) if (!*dpb_size)
@ -477,14 +489,17 @@ void API_ROUTINE_VARARG isc_expand_dpb(SCHAR ** dpb, SSHORT * dpb_size, ...)
VA_START(args, dpb_size); VA_START(args, dpb_size);
while (type = va_arg(args, int)) while (type = va_arg(args, int))
switch (type) { {
switch (type)
{
case gds_dpb_user_name: case gds_dpb_user_name:
case gds_dpb_password: case gds_dpb_password:
case isc_dpb_sql_role_name: case isc_dpb_sql_role_name:
case gds_dpb_lc_messages: case gds_dpb_lc_messages:
case gds_dpb_lc_ctype: case gds_dpb_lc_ctype:
case isc_dpb_reserved: case isc_dpb_reserved:
if (q = va_arg(args, char *)) { if (q = va_arg(args, char *))
{
length = strlen(q); length = strlen(q);
assert(type <= CHAR_MAX); assert(type <= CHAR_MAX);
*p++ = (char) type; *p++ = (char) type;
@ -499,16 +514,18 @@ void API_ROUTINE_VARARG isc_expand_dpb(SCHAR ** dpb, SSHORT * dpb_size, ...)
(void) va_arg(args, int); (void) va_arg(args, int);
break; break;
} }
}
*dpb_size = p - reinterpret_cast < char *>(new_dpb); *dpb_size = p - reinterpret_cast<char*>(new_dpb);
*dpb = (SCHAR *) new_dpb; *dpb = (SCHAR*) new_dpb;
} }
int API_ROUTINE isc_modify_dpb( int API_ROUTINE isc_modify_dpb(SCHAR** dpb,
SCHAR ** dpb, SSHORT* dpb_size,
SSHORT * dpb_size, USHORT type,
USHORT type, SCHAR * str, SSHORT str_len) SCHAR* str,
SSHORT str_len)
{ {
/************************************** /**************************************
* *
@ -544,9 +561,12 @@ int API_ROUTINE isc_modify_dpb(
setting initial length to include version */ setting initial length to include version */
if (!*dpb || !(new_dpb_length = *dpb_size)) if (!*dpb || !(new_dpb_length = *dpb_size))
{
new_dpb_length = 1; new_dpb_length = 1;
}
switch (type) { switch (type)
{
case gds_dpb_user_name: case gds_dpb_user_name:
case gds_dpb_password: case gds_dpb_password:
case isc_dpb_sql_role_name: case isc_dpb_sql_role_name:
@ -563,46 +583,59 @@ int API_ROUTINE isc_modify_dpb(
/* if items have been added, allocate space /* if items have been added, allocate space
for the new dpb and copy the old one over */ for the new dpb and copy the old one over */
if (new_dpb_length > *dpb_size) { if (new_dpb_length > *dpb_size)
{
/* Note: gds__free done by GPRE generated code */ /* Note: gds__free done by GPRE generated code */
p = new_dpb = gds__alloc((SLONG) (sizeof(UCHAR) * new_dpb_length)); new_dpb = (UCHAR*)gds__alloc((SLONG)(sizeof(UCHAR) * new_dpb_length));
/* FREE: done by client process in GPRE generated code */ /* FREE: done by client process in GPRE generated code */
if (!new_dpb) { /* NOMEM: don't trash existing dpb */ if (!new_dpb)
{ /* NOMEM: don't trash existing dpb */
DEV_REPORT("isc_extend_dpb: out of memory"); DEV_REPORT("isc_extend_dpb: out of memory");
return FAILURE; /* NOMEM: not really handled */ return FAILURE; /* NOMEM: not really handled */
} }
q = (UCHAR *) * dpb; p = new_dpb;
q = (UCHAR*) *dpb;
for (length = *dpb_size; length; length--) for (length = *dpb_size; length; length--)
{
*p++ = *q++; *p++ = *q++;
}
} }
else { else
{
new_dpb = (UCHAR *) * dpb; new_dpb = (UCHAR *) * dpb;
p = new_dpb + *dpb_size; p = new_dpb + *dpb_size;
} }
if (!*dpb_size) if (!*dpb_size)
{
*p++ = gds_dpb_version1; *p++ = gds_dpb_version1;
}
/* copy in the new runtime items */ /* copy in the new runtime items */
switch (type) { switch (type)
{
case gds_dpb_user_name: case gds_dpb_user_name:
case gds_dpb_password: case gds_dpb_password:
case isc_dpb_sql_role_name: case isc_dpb_sql_role_name:
case gds_dpb_lc_messages: case gds_dpb_lc_messages:
case gds_dpb_lc_ctype: case gds_dpb_lc_ctype:
case isc_dpb_reserved: case isc_dpb_reserved:
if (q = (UCHAR *) str) { if (q = (UCHAR *) str)
{
length = str_len; length = str_len;
assert(type <= MAX_UCHAR); assert(type <= MAX_UCHAR);
*p++ = (UCHAR) type; *p++ = (UCHAR) type;
assert(length <= MAX_UCHAR); assert(length <= MAX_UCHAR);
*p++ = (UCHAR) length; *p++ = (UCHAR) length;
while (length--) while (length--)
{
*p++ = *q++; *p++ = *q++;
}
} }
break; break;
@ -612,12 +645,13 @@ int API_ROUTINE isc_modify_dpb(
*dpb_size = p - new_dpb; *dpb_size = p - new_dpb;
*dpb = (SCHAR *) new_dpb; *dpb = (SCHAR *) new_dpb;
return SUCCESS; return SUCCESS;
} }
#ifdef GDS_EDIT #ifdef GDS_EDIT
int API_ROUTINE GDS_EDIT(TEXT * file_name, USHORT type) int API_ROUTINE GDS_EDIT(TEXT* file_name, USHORT type)
{ {
/************************************** /**************************************
* *
@ -637,7 +671,7 @@ int API_ROUTINE GDS_EDIT(TEXT * file_name, USHORT type)
editor = "vi"; editor = "vi";
#else #else
if (!(editor = getenv("EDITOR"))) if (!(editor = getenv("EDITOR")))
editor = "mep"; editor = "Notepad";
#endif #endif
statistics(file_name, &before); statistics(file_name, &before);
@ -647,8 +681,8 @@ int API_ROUTINE GDS_EDIT(TEXT * file_name, USHORT type)
statistics(file_name, &after); statistics(file_name, &after);
return (before.st_mtime != after.st_mtime return (before.st_mtime != after.st_mtime ||
|| before.st_size != after.st_size); before.st_size != after.st_size);
} }
#endif #endif

View File

@ -72,7 +72,7 @@ SLONG allr_delta_alloc = 0;
// //
UCHAR* DLL_EXPORT ALLR_alloc(ULONG size) UCHAR* DLL_EXPORT ALLR_alloc(ULONG size)
{ {
UCHAR* block = gds__alloc((SLONG) size); UCHAR* block = (UCHAR*)gds__alloc((SLONG) size);
if (block) if (block)
{ {

View File

@ -270,28 +270,36 @@ STATUS GDS_ATTACH_DATABASE(STATUS* user_status,
* Connect to an old, grungy database, corrupted by user data. * Connect to an old, grungy database, corrupted by user data.
* *
**************************************/ **************************************/
RDB rdb; RDB rdb;
PORT port; PORT port;
USHORT length, user_verification, new_dpb_length, result; USHORT length;
STATUS *v; USHORT user_verification;
UCHAR expanded_name[MAXPATHLEN], new_dpb[MAXPATHLEN], *new_dpb_ptr; USHORT new_dpb_length;
TEXT user_string[256], *us; USHORT result;
TEXT node_name[MAXPATHLEN]; UCHAR expanded_name[MAXPATHLEN];
JMP_BUF env; UCHAR new_dpb[MAXPATHLEN];
struct trdb thd_context, *trdb; UCHAR* new_dpb_ptr;
TEXT user_string[256];
TEXT* us;
TEXT node_name[MAXPATHLEN];
JMP_BUF env;
struct trdb thd_context;
struct trdb* trdb;
(void) memset((void *) node_name, 0, (size_t) MAXPATHLEN); (void) memset((void *) node_name, 0, (size_t) MAXPATHLEN);
v = user_status; STATUS* v = user_status;
*v++ = gds_arg_gds; *v++ = gds_arg_gds;
*v++ = gds_unavailable; *v++ = gds_unavailable;
*v = gds_arg_end; *v = gds_arg_end;
#ifdef UNIX #ifdef UNIX
/* If single user, return */ // If single user, return
if (get_single_user(dpb_length, dpb)) if (get_single_user(dpb_length, dpb))
{
return gds_unavailable; return gds_unavailable;
}
#endif #endif
SET_THREAD_DATA; SET_THREAD_DATA;
@ -302,12 +310,13 @@ STATUS GDS_ATTACH_DATABASE(STATUS* user_status,
length = strlen((char *) expanded_name); length = strlen((char *) expanded_name);
new_dpb_ptr = new_dpb; new_dpb_ptr = new_dpb;
if ((dpb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH + if ((dpb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH +
MAX_OTHER_PARAMS) > sizeof(new_dpb)) MAX_OTHER_PARAMS) > sizeof(new_dpb))
{ {
new_dpb_ptr = new_dpb_ptr =
gds__alloc(dpb_length + MAX_USER_LENGTH + (UCHAR*)gds__alloc(dpb_length + MAX_USER_LENGTH +
MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS); MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS);
/* FREE: by return(s) from this procedure */ /* FREE: by return(s) from this procedure */
@ -830,16 +839,18 @@ STATUS GDS_CREATE_DATABASE(STATUS * user_status,
length = strlen((char *) expanded_name); length = strlen((char *) expanded_name);
new_dpb_ptr = new_dpb; new_dpb_ptr = new_dpb;
if (
(dpb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH + if ((dpb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH +
MAX_OTHER_PARAMS) > sizeof(new_dpb)) { MAX_OTHER_PARAMS) > sizeof(new_dpb))
{
new_dpb_ptr = new_dpb_ptr =
gds__alloc(dpb_length + MAX_USER_LENGTH + (UCHAR*)gds__alloc(dpb_length + MAX_USER_LENGTH +
MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS); MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS);
/* FREE: by return(s) in this routine */ /* FREE: by return(s) in this routine */
if (!new_dpb_ptr) { /* NOMEM: return error to client */ if (!new_dpb_ptr)
{ /* NOMEM: return error to client */
user_status[1] = gds_virmemexh; user_status[1] = gds_virmemexh;
return error(user_status); return error(user_status);
} }
@ -3541,16 +3552,17 @@ STATUS GDS_SERVICE_ATTACH(STATUS * user_status,
*v = gds_arg_end; *v = gds_arg_end;
new_spb_ptr = new_spb; new_spb_ptr = new_spb;
if ( if ((spb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH +
(spb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS) > sizeof(new_spb))
MAX_OTHER_PARAMS) > sizeof(new_spb)) { {
new_spb_ptr = new_spb_ptr =
gds__alloc(spb_length + MAX_USER_LENGTH + (UCHAR*)gds__alloc(spb_length + MAX_USER_LENGTH +
MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS); MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS);
/* FREE: by return(s) in this routine */ /* FREE: by return(s) in this routine */
if (!new_spb_ptr) { /* NOMEM: return error to client */ if (!new_spb_ptr)
{ /* NOMEM: return error to client */
user_status[1] = gds_virmemexh; user_status[1] = gds_virmemexh;
return error(user_status); return error(user_status);
} }

View File

@ -27,6 +27,7 @@
#include "../jrd/common.h" #include "../jrd/common.h"
#include "../remote/remote_def.h" #include "../remote/remote_def.h"
#include "../jrd/ibsetjmp.h" #include "../jrd/ibsetjmp.h"
#include "../jrd/thd_proto.h"
/* Include some apollo include files for tasking */ /* Include some apollo include files for tasking */

View File

@ -107,7 +107,6 @@ SSHORT SECURITY_exec_line(STATUS * isc_status,
**************************************/ **************************************/
SCHAR encrypted1[MAX_PASSWORD_LENGTH + 2]; SCHAR encrypted1[MAX_PASSWORD_LENGTH + 2];
SCHAR encrypted2[MAX_PASSWORD_LENGTH + 2]; SCHAR encrypted2[MAX_PASSWORD_LENGTH + 2];
TEXT buff[MSG_LENGTH];
STATUS tmp_status[20]; STATUS tmp_status[20];
void *gds__trans; void *gds__trans;
BOOLEAN found; BOOLEAN found;
@ -283,7 +282,7 @@ SSHORT SECURITY_exec_line(STATUS * isc_status,
strcpy(user_data->first_name, U.FIRST_NAME); strcpy(user_data->first_name, U.FIRST_NAME);
strcpy(user_data->middle_name, U.MIDDLE_NAME); strcpy(user_data->middle_name, U.MIDDLE_NAME);
strcpy(user_data->last_name, U.LAST_NAME); strcpy(user_data->last_name, U.LAST_NAME);
display_func(callback_arg, user_data, !found); display_func(callback_arg, user_data, (BOOLEAN)!found);
found = TRUE; found = TRUE;
END_FOR END_FOR
@ -302,7 +301,7 @@ SSHORT SECURITY_exec_line(STATUS * isc_status,
strcpy(user_data->first_name, U.FIRST_NAME); strcpy(user_data->first_name, U.FIRST_NAME);
strcpy(user_data->middle_name, U.MIDDLE_NAME); strcpy(user_data->middle_name, U.MIDDLE_NAME);
strcpy(user_data->last_name, U.LAST_NAME); strcpy(user_data->last_name, U.LAST_NAME);
display_func(callback_arg, user_data, !found); display_func(callback_arg, user_data, (BOOLEAN)!found);
found = TRUE; found = TRUE;
END_FOR END_FOR