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"
@ -452,7 +452,8 @@ BOOLEAN TDR_reconnect_multiple(int *handle,
switches |= sw_commit;
else if (switches & sw_two_phase)
switches |= sw_commit;
else if (switches & sw_prompt) {
else if (switches & sw_prompt)
{
ALICE_print(78, reinterpret_cast < char *>(trans->tdr_id), 0,
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. */
@ -470,7 +471,8 @@ BOOLEAN TDR_reconnect_multiple(int *handle,
break;
default:
if (!(switches & (sw_commit | sw_rollback))) {
if (!(switches & (sw_commit | sw_rollback)))
{
ALICE_print(82, reinterpret_cast < char *>(trans->tdr_id), 0,
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. */
@ -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 */
if (switches & (sw_commit | sw_rollback))
{
for (ptr = trans; ptr; ptr = ptr->tdr_next)
{
if (ptr->tdr_state == TRA_limbo)
{
reconnect(reinterpret_cast < int *>(ptr->tdr_db_handle),
ptr->tdr_id, ptr->tdr_filename, switches);
}
}
}
}
else {
else
{
ALICE_print(84, 0, 0, 0, 0, 0); /* msg 84: unexpected end of input */
error = TRUE;
}
@ -514,59 +524,63 @@ static void print_description(TDR trans)
{
TDR ptr;
BOOLEAN prepared_seen;
TGBL tdgbl;
int i;
tdgbl = GET_THREAD_DATA;
#ifdef SUPERSERVER
int i;
#endif
TGBL tdgbl = GET_THREAD_DATA;
if (!trans)
{
return;
}
if (!tdgbl->sw_service_thd)
{
ALICE_print(92, 0, 0, 0, 0, 0); /* msg 92: Multidatabase transaction: */
}
prepared_seen = FALSE;
for (ptr = trans; ptr; ptr = ptr->tdr_next) {
if (ptr->tdr_host_site) {
for (ptr = trans; ptr; ptr = ptr->tdr_next)
{
if (ptr->tdr_host_site)
{
char* pszHostSize =
reinterpret_cast<char*>(ptr->tdr_host_site->str_data);
#ifndef SUPERSERVER
ALICE_print(93,
reinterpret_cast <
char *>(ptr->tdr_host_site->str_data), 0, 0, 0, 0); /* msg 93: Host Site: %s */
/* msg 93: Host Site: %s */
ALICE_print(93, pszHostSize, 0, 0, 0, 0);
#else
const size_t nHostSiteLen = strlen(pszHostSize);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_host_site);
SVC_putc(tdgbl->service_blk,
(UCHAR) strlen(reinterpret_cast <
const char *>(ptr->
tdr_host_site->str_data)));
SVC_putc(tdgbl->service_blk,
(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]);
SVC_putc(tdgbl->service_blk, (UCHAR) nHostSiteLen);
SVC_putc(tdgbl->service_blk, (UCHAR) (nHostSiteLen >> 8 ));
for (i = 0; i < (int) nHostSiteLen; i++)
{
SVC_putc(tdgbl->service_blk, (UCHAR) pszHostSize[i]);
}
#endif
}
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) ptr->tdr_id);
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 >> 24));
}
#endif
}
switch (ptr->tdr_state) {
switch (ptr->tdr_state)
{
case TRA_limbo:
#ifndef SUPERSERVER
ALICE_print(95, 0, 0, 0, 0, 0); /* msg 95: has been prepared. */
@ -607,60 +621,58 @@ static void print_description(TDR trans)
default:
#ifndef SUPERSERVER
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
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
break;
}
if (ptr->tdr_remote_site) {
if (ptr->tdr_remote_site)
{
char* pszRemoteSite =
reinterpret_cast<char*>(ptr->tdr_remote_site->str_data);
#ifndef SUPERSERVER
ALICE_print(101,
reinterpret_cast <
char *>(ptr->tdr_remote_site->str_data), 0, 0, 0, 0); /*msg 101: Remote Site: %s */
/*msg 101: Remote Site: %s */
ALICE_print(101, pszRemoteSite, 0, 0, 0, 0);
#else
const size_t nRemoteSiteLen = strlen(pszRemoteSite);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_remote_site);
SVC_putc(tdgbl->service_blk,
(UCHAR) strlen(reinterpret_cast <
const char *>(ptr->
tdr_remote_site->str_data)));
SVC_putc(tdgbl->service_blk,
(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]);
SVC_putc(tdgbl->service_blk, (UCHAR) nRemoteSiteLen);
SVC_putc(tdgbl->service_blk, (UCHAR) (nRemoteSiteLen >> 8));
for (i = 0; i < (int) nRemoteSiteLen; i++)
{
SVC_putc(tdgbl->service_blk, (UCHAR) nRemoteSiteLen);
}
#endif
}
if (ptr->tdr_fullpath) {
if (ptr->tdr_fullpath)
{
char* pszFullpath =
reinterpret_cast<char*>(ptr->tdr_fullpath->str_data);
#ifndef SUPERSERVER
ALICE_print(102,
reinterpret_cast <
char *>(ptr->tdr_fullpath->str_data), 0, 0, 0, 0); /* msg 102: Database Path: %s */
/* msg 102: Database Path: %s */
ALICE_print(102, pszFullpath, 0, 0, 0, 0);
#else
const size_t nFullpathLen = strlen(pszFullpath);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_db_path);
SVC_putc(tdgbl->service_blk,
(UCHAR) strlen(reinterpret_cast <
const char *>(ptr->
tdr_fullpath->str_data)));
SVC_putc(tdgbl->service_blk,
(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]);
SVC_putc(tdgbl->service_blk, (UCHAR) nFullpathLen);
SVC_putc(tdgbl->service_blk, (UCHAR) (nFullpathLen >> 8));
for (i = 0; i < (int) nFullpathLen; i++)
{
SVC_putc(tdgbl->service_blk, (UCHAR) pszFullpath[i]);
}
#endif
}
@ -668,10 +680,12 @@ static void print_description(TDR trans)
// let the user know what the suggested action is
switch (TDR_analyze(trans)) {
switch (TDR_analyze(trans))
{
case TRA_commit:
#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
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise_commit);
@ -680,7 +694,8 @@ static void print_description(TDR trans)
case TRA_rollback:
#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
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise);
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.
*
**************************************/
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 */
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 */
{
BURP_error(238, NULL, NULL, NULL, NULL, NULL); /* msg 238: System memory exhaused */

View File

@ -23,18 +23,18 @@
#include "../dsql/dsql.h"
BLK ALLD_alloc( /* alloc and init a block from a pool */
PLB pool, UCHAR type, int count);
/* alloc and init a block from a pool */
BLK ALLD_alloc(PLB pool, UCHAR type, int count);
BLK ALLD_extend( /* extend a block by given size */
BLK * pointer, int size);
/* extend a block by given size */
BLK ALLD_extend(BLK* pointer, int size);
int ALLD_fini(); /* get rid of everything */
int ALLD_free(SCHAR * memory); /* give space back to system */
int ALLD_init(); /* initialize pool system */
UCHAR *ALLD_malloc(int size); /* get memory from system */
PLB ALLD_pool(); /* allocate a new pool */
int ALLD_push(BLK object, LLS * stack); /* push object on 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_rlpool(PLB pool); /* release a pool */
int ALLD_fini(); /* get rid of everything */
int ALLD_free(void* memory); /* give space back to system */
int ALLD_init(); /* initialize pool system */
void* ALLD_malloc(int size); /* get memory from system */
PLB ALLD_pool(); /* allocate a new pool */
int ALLD_push(BLK object, LLS * stack); /* push object on 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_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.
*
**************************************/
register UCHAR *memory;
TSQL tdsql;
tdsql = GET_THREAD_DATA;
TSQL tdsql = GET_THREAD_DATA;
if ((memory = gds__alloc((SLONG) size)) != NULL)
#ifdef SUPERSERVER
UCHAR* memory = (UCHAR*)gds__alloc((SLONG) size);
if (memory)
{
#ifdef SUPERSERVER
alld_delta_alloc += size;
#endif
return memory;
}
#else
return memory;
#endif
/* FREE: by ALLD_free, called during DSQL cleanup */
/* NOMEM: post a user level error - if we can */
if (tdsql && tdsql->tsql_setjmp)
{
ERRD_post(gds__sys_request, gds_arg_string, "gds__alloc", gds_arg_gds,
gds__virmemexh, gds_arg_end);
}
/* Commentary: This expands out to a call to ERRD_error - which
* promply depends on tdsql being non-NULL. Knock, knock, anyone home?
@ -711,17 +712,21 @@ void ALLD_rlpool( PLB pool)
* contains pool itself
*/
#ifdef SUPERSERVER
if (trace_pools && pool->plb_blk_type_count) {
if (trace_pools && pool->plb_blk_type_count)
{
int i;
for (i = 0; i < type_MAX; i++)
{
alld_block_type_count[i] -= pool->plb_blk_type_count[i];
}
gds__free(pool->plb_blk_type_count);
}
#endif
for (hunks = pool->plb_hunks; hunk = hunks;) {
for (hunks = pool->plb_hunks; hunk = hunks;)
{
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" {
#endif
extern BLK ALLD_alloc(struct plb *, UCHAR, ULONG);
extern BLK ALLD_extend(struct blk **, ULONG);
extern void ALLD_fini(void);
extern void ALLD_free(SCHAR *);
extern USHORT ALLD_init(void);
extern UCHAR *ALLD_malloc(ULONG);
extern PLB ALLD_pool(void);
extern BLK ALLD_pop(register struct lls **);
extern void ALLD_push(struct blk *, register struct lls **);
extern void ALLD_release(register struct frb *);
extern void ALLD_rlpool(struct plb *);
BLK ALLD_alloc(struct plb*, UCHAR, ULONG);
BLK ALLD_extend(struct blk**, ULONG);
void ALLD_fini(void);
void ALLD_free(void*);
USHORT ALLD_init(void);
void* ALLD_malloc(ULONG);
PLB ALLD_pool(void);
BLK ALLD_pop(register struct lls**);
void ALLD_push(struct blk*, register struct lls**);
void ALLD_release(register struct frb*);
void ALLD_rlpool(struct plb*);
#ifdef __cplusplus
} /* extern "C" */

View File

@ -21,7 +21,7 @@
* 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.
@ -2255,32 +2255,40 @@ static STATUS execute_request(REQ 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;
s = isc_start_request(tdsql->tsql_status,
reinterpret_cast <
void **>(&request->req_handle),
reinterpret_cast <
void **>(&request->req_trans), 0);
reinterpret_cast<void**>(&request->req_handle),
reinterpret_cast<void**>(&request->req_trans),
0);
THREAD_ENTER;
if (s)
punt();
}
else {
map_in_out(request, message, in_blr_length, in_blr, in_msg_length,
in_msg);
else
{
map_in_out( request,
message,
in_blr_length,
in_blr,
in_msg_length,
in_msg);
THREAD_EXIT;
s = isc_start_and_send(tdsql->tsql_status,
reinterpret_cast <
void **>(&request->req_handle),
reinterpret_cast <
void **>(&request->req_trans),
message->msg_number, message->msg_length,
message->msg_buffer, 0);
reinterpret_cast<void**>(&request->req_handle),
reinterpret_cast<void**>(&request->req_trans),
message->msg_number,
message->msg_length,
message->msg_buffer,
0);
THREAD_ENTER;
if (s)
{
punt();
}
}
if (out_msg_length && (message = (MSG) request->req_receive)) {
@ -2293,9 +2301,11 @@ static STATUS execute_request(REQ request,
THREAD_EXIT;
s = isc_receive(tdsql->tsql_status,
reinterpret_cast < void **>(&request->req_handle),
reinterpret_cast<void**>(&request->req_handle),
message->msg_number,
message->msg_length, message->msg_buffer, 0);
message->msg_length,
message->msg_buffer,
0);
THREAD_ENTER;
if (s)
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 (singleton) {
UCHAR *message_buffer;
if (singleton)
{
USHORT counter;
/* 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.
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;
THREAD_EXIT;
for (counter = 0; counter < 2 && !s; counter++) {
for (counter = 0; counter < 2 && !s; counter++)
{
s = isc_receive(local_status,
reinterpret_cast <
void **>(&request->req_handle),
message->msg_number, message->msg_length,
message_buffer, 0);
reinterpret_cast<void**>(&request->req_handle),
message->msg_number,
message->msg_length,
message_buffer,
0);
}
THREAD_ENTER;
ALLD_free(reinterpret_cast < SCHAR * >(message_buffer));
ALLD_free(message_buffer);
/* two successful receives means more than one record
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 */
if (!s) {
if (!s)
{
tdsql->tsql_status[0] = gds_arg_gds;
tdsql->tsql_status[1] = gds_sing_select_err;
tdsql->tsql_status[2] = gds_arg_end;
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[1] = gds_stream_eof;
tdsql->tsql_status[2] = gds_arg_end;
return_status = gds_stream_eof;
}
else if (s != gds_req_sync)
{
punt();
}
}
}
if (!(request->req_dbb->dbb_flags & DBB_v3)) {
if (request->req_type == REQ_UPDATE_CURSOR) {
if (!(request->req_dbb->dbb_flags & DBB_v3))
{
if (request->req_type == REQ_UPDATE_CURSOR)
{
GDS_DSQL_SQL_INFO(local_status, &request,
sizeof(sql_records_info),
const_cast < char *>(sql_records_info),
sizeof(buffer), buffer);
if (!request->req_updates)
{
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 913,
isc_arg_gds, isc_deadlock, isc_arg_gds,
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,
sizeof(sql_records_info),
const_cast < char *>(sql_records_info),
sizeof(buffer), buffer);
if (!request->req_deletes)
{
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 913,
isc_arg_gds, isc_deadlock, isc_arg_gds,
isc_update_conflict, 0);
}
}
}
return return_status;

View File

@ -149,12 +149,13 @@ void HSHD_fini(void)
* 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;
}
ALLD_free(reinterpret_cast < SCHAR * >(hash_table));
ALLD_free(hash_table);
hash_table = NULL;
}

View File

@ -20,7 +20,7 @@
//
// All Rights Reserved.
// 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
// Added new switch -verbose to gpre that will dump
// 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
@ -238,9 +238,9 @@ static struct ext_table_t dml_ext_table[] =
//____________________________________________________________
//
// Main line routine for C preprocessor. Initializes
// system, performs pass 1 and pass 2. Interprets
// command line.
// Main line routine for C preprocessor. Initializes
// system, performs pass 1 and pass 2. Interprets
// command line.
//
int main(int argc, char* argv[])

View File

@ -26,53 +26,38 @@
#include "../ipserver/ipc.h"
#define BLKDEF(type, root, tail) sizeof (struct root), tail,
static struct {
static struct
{
SSHORT typ_root_length;
SSHORT typ_tail_length;
} PIPE_block_sizes[] = {
0, 0,
#include "../ipserver/blk.h"
0};
0
};
#include "../jrd/gds_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);
}
//____________________________________________________________
//
// 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)
{
/**************************************
*
* 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)
@ -82,53 +67,42 @@ if (type <= (SCHAR) type_MIN || type >= (SCHAR) type_MAX)
/* 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)
size += count * tail;
BLK block = (BLK) ALLI_alloc((SLONG) size);
block = (BLK) ALLI_alloc((SLONG) size);
if (!block)
return block;
block->blk_type = type;
block->blk_length = size;
if (block)
{
block->blk_type = type;
block->blk_length = size;
if (size -= sizeof(struct blk))
memset((SCHAR *) block + sizeof(struct blk), 0, size);
size -= sizeof(struct blk);
if (size)
{
memset((SCHAR *) block + sizeof(struct blk), 0, size);
}
}
return block;
}
void ALLI_free( UCHAR * block)
//____________________________________________________________
//
// Free a block.
//
void ALLI_free(void* block)
{
/**************************************
*
* A L L I _ f r e e
*
**************************************
*
* Functional description
* Free a block.
*
**************************************/
gds__free((ULONG *) block);
gds__free(block);
}
void ALLI_release( BLK block)
//____________________________________________________________
//
// Release a structured block.
//
void ALLI_release(BLK block)
{
/**************************************
*
* A L L I _ r e l e a s e
*
**************************************
*
* Functional description
* Release a structured block.
*
**************************************/
ALLI_free((UCHAR *) block);
ALLI_free(block);
}

View File

@ -24,9 +24,9 @@
#ifndef _ALLI_PROTO_H_
#define _ALLI_PROTO_H_
extern UCHAR *ALLI_alloc(ULONG);
extern BLK ALLI_block(UCHAR, int);
extern void ALLI_free(UCHAR *);
extern void ALLI_release(BLK);
void* ALLI_alloc(ULONG);
BLK ALLI_block(UCHAR, int);
void ALLI_free(void*);
void ALLI_release(BLK);
#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)
gds__sys_free(comm->ips_buffers[n].ips_sv_buffer);
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 */
@ -2021,7 +2021,7 @@ static void get_slice( ICC icc)
slice_length = ips_data->ips_cl_size;
if (slice_length)
{
slice = gds__sys_alloc(slice_length);
slice = (UCHAR*)gds__sys_alloc(slice_length);
NOT_NULL(slice, TRUE);
memset(slice, 0, slice_length);
}
@ -2699,7 +2699,7 @@ static void put_slice( ICC icc)
slice_length = ips_data->ips_cl_size;
if (slice_length)
{
slice = gds__sys_alloc(slice_length);
slice = (UCHAR*)gds__sys_alloc(slice_length);
NOT_NULL(slice, TRUE);
memset(slice, 0, slice_length);
}

View File

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

View File

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

View File

@ -19,7 +19,7 @@
*
* All Rights Reserved.
* 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;
UCHAR *p1, *p2, *temp1, *temp2, *buffer;
#endif
SSHORT l1, l2, l;
SSHORT l1, l2;
USHORT type1, xtype1;
STR match_str = NULL;
SSHORT ret_val;

View File

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

View File

@ -21,7 +21,7 @@
* 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"
@ -104,13 +104,17 @@ const char* dirname(const char* fname)
if (strlen(fname) == 0)
return ".";
strcpy(result, fname);
while (*fname) {
while (*fname)
{
i++;
if (*fname == '/')
{
last = i;
}
fname++;
}
if (last == 0) {
if (last == 0)
{
last = 1;
result[0] = '.';
}
@ -120,6 +124,18 @@ const char* dirname(const char* fname)
#endif
static void terminate_at_space(char* psz)
{
while (*psz && *psz != ' ')
{
++psz;
}
if (*psz) {
*psz = '\0';
}
}
/* DG specific stuff */
#ifdef DGUX
@ -176,22 +192,20 @@ MOD FLU_lookup_module(TEXT* module)
* Lookup external function module descriptor.
*
**************************************/
MOD mod;
USHORT length;
#ifndef WIN_NT
TEXT *p;
for (p = module; *p && *p != ' '; p++)
;
if (*p)
*p = 0;
#ifndef WIN_NT
terminate_at_space(module);
#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))
{
return mod;
}
}
return 0;
}
@ -220,10 +234,13 @@ void FLU_unregister_module(MOD module)
/* Unlink from list of active modules, unload it, and release memory. */
for (mod = &FLU_modules; *mod; mod = &(*mod)->mod_next)
if (*mod == module) {
{
if (*mod == module)
{
*mod = module->mod_next;
break;
}
}
#if (defined HP700 || defined HP10)
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);
for (p = name; *p && *p != ' '; p++);
p = name;
while (*p && *p != ' ')
{
++p;
}
ISC_make_desc(name, &nam_desc, p - name);
VAXC$ESTABLISH(condition_handler);
@ -300,8 +321,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
*/
#if (defined OLD_AIX || defined OLD_AIX_PPC)
#define LOOKUP
FPTR_INT ISC_lookup_entrypoint(TEXT * module,
TEXT * name, TEXT * ib_path_env_var)
FPTR_INT ISC_lookup_entrypoint(TEXT* module,
TEXT* name,
TEXT* ib_path_env_var)
{
/**************************************
*
@ -317,19 +339,28 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
TEXT *p;
TEXT absolute_module[MAXPATHLEN];
if (function = FUNCTIONS_entrypoint(module, name))
function = FUNCTIONS_entrypoint(module, name);
if (function)
{
return function;
}
for (p = module; *p && *p != ' '; p++);
if (*p)
*p = 0;
terminate_at_space(module);
if (ib_path_env_var == NULL)
{
strcpy(absolute_module, module);
}
else
if (!gds__validate_lib_path
(module, ib_path_env_var, absolute_module,
sizeof(absolute_module))) return NULL;
{
if (!gds__validate_lib_path(module,
ib_path_env_var,
absolute_module,
sizeof(absolute_module)))
{
return NULL;
}
}
REPLACE THIS COMPILER ERROR WITH CODE TO VERIFY THAT THE MODULE IS FOUND
EITHER IN $INTERBASE / UDF, OR $INTERBASE / intl,
@ -358,49 +389,61 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
**************************************/
FPTR_INT function;
TEXT *p;
MOD mod;
TEXT absolute_module[MAXPATHLEN];
if (function = FUNCTIONS_entrypoint(module, name))
function = FUNCTIONS_entrypoint(module, name);
if (function)
{
return function;
}
for (p = module; *p && *p != ' '; p++);
if (*p)
*p = 0;
for (p = name; *p && *p != ' '; p++);
if (*p)
*p = 0;
terminate_at_space(module);
terminate_at_space(name);
if (!*module || !*name)
{
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))) {
USHORT length;
if (!mod)
{
TEXT absolute_module[MAXPATHLEN];
#ifdef EXT_LIB_PATH
if (ib_path_env_var == NULL)
{
strcpy(absolute_module, module);
}
else
if (!gds__validate_lib_path
(module, ib_path_env_var, absolute_module,
sizeof(absolute_module))) return NULL;
{
if (!gds__validate_lib_path(module,
ib_path_env_var,
absolute_module,
sizeof(absolute_module)))
{
return NULL;
}
}
#else
strcpy(absolute_module, module);
#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, then with <name>.sl . */
mod = search_for_module(absolute_module, name);
if (!mod) {
if (!mod)
{
strcat(absolute_module, ".sl");
mod = search_for_module(absolute_module, name);
}
if (!mod)
{
return NULL;
}
assert(mod->mod_handle); /* assert that we found the module */
mod->mod_use_count = 0;
@ -445,45 +488,56 @@ static MOD search_for_module(TEXT * module, TEXT * name)
strlen(absolute_module)))) return NULL;
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. */
gds__prefix(ib_lib_path, IB_UDF_DIR);
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. */
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);
return NULL;
}
}
else {
else
{
gds__prefix(ib_lib_path, IB_INTL_DIR);
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 international character set directory:
load it. */
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);
return NULL;
}
}
else {
else
{
/* The module is not in a default directory, so ...
* use the EXTERNAL_FUNCTION_DIRECTORY lines from isc_config.
*/
dir_list = DLS_get_func_dirs();
found_module = FALSE;
while (dir_list && !found_module) {
while (dir_list && !found_module)
{
strcpy(ib_lib_path, dir_list->fdls_directory);
strcat(ib_lib_path, "/");
strncat(ib_lib_path, module,
MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!access(ib_lib_path, R_OK | X_OK)) {
if (!(mod->mod_handle = shl_load(ib_lib_path,
BIND_DEFERRED, 0))) {
if (!access(ib_lib_path, R_OK | X_OK))
{
mod->mod_handle = shl_load(ib_lib_path,
BIND_DEFERRED, 0);
if (!mod->mod_handle)
{
gds__free(mod);
return NULL;
}
@ -491,34 +545,39 @@ static MOD search_for_module(TEXT * module, TEXT * name)
}
dir_list = dir_list->fdls_next;
}
if (!found_module) {
if (!found_module)
{
gds__free(mod);
return NULL;
}
} /* else module is not in the INTL directory */
} /* else module is not in the default UDF directory, so ... */
} /* if dirname is "." */
else {
else
{
/* The module name includes a directory path.
* 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,
* and the module must be accessible in that directory.
*/
gds__prefix(ib_lib_path, IB_UDF_DIR);
ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing "/" */
found_module = !strcmp(ib_lib_path, dirp);
if (!found_module) {
if (!found_module)
{
gds__prefix(ib_lib_path, IB_INTL_DIR);
ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing / */
found_module = !strcmp(ib_lib_path, dirp);
}
if (!found_module) {
if (!found_module)
{
/* It's not the default directory, so try the ones listed
* in EXTERNAL_FUNCTION_DIRECTORY lines in isc_config.
*/
dir_list = DLS_get_func_dirs();
while (dir_list && !found_module) {
while (dir_list && !found_module)
{
if (!strcmp(dir_list->fdls_directory, dirp))
found_module = TRUE;
dir_list = dir_list->fdls_next;
@ -527,7 +586,8 @@ static MOD search_for_module(TEXT * module, TEXT * name)
if (found_module)
found_module = (!access(module, R_OK | X_OK)) &&
(0 != (mod->mod_handle = shl_load(module, BIND_DEFERRED, 0)));
if (!found_module) {
if (!found_module)
{
gds__free(mod);
return NULL;
}
@ -553,7 +613,6 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
*
**************************************/
FPTR_INT function;
TEXT *p;
shl_t handle;
TEXT buffer[256];
TEXT absolute_module[MAXPATHLEN];
@ -561,10 +620,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
if (function = FUNCTIONS_entrypoint(module, name))
return function;
for (p = module; *p && *p != ' '; p++);
if (*p)
*p = 0;
p = buffer;
terminate_at_space(module);
TEXT* p = buffer;
*p++ = '_';
for (; (*p = *name) && *name != ' '; p++, name++);
*p = 0;
@ -580,9 +638,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
EITHER IN $INTERBASE / UDF, OR $INTERBASE / intl,
OR IN ONE OF THE DIRECTORIES NAMED IN EXTERNAL_FUNCTION_DIRECTORY
LINES IN
ISC_CONFIG.if (!
(handle = shl_load(absolute_module, BIND_DEFERRED, 0L))
|| shl_findsym(&handle, buffer, TYPE_PROCEDURE, &function))
ISC_CONFIG.
if (!(handle = shl_load(absolute_module, BIND_DEFERRED, 0L)) ||
shl_findsym(&handle, buffer, TYPE_PROCEDURE, &function))
return NULL;
return function;
@ -592,8 +650,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
#ifdef DYNAMIC_SHARED_LIBRARIES
#define LOOKUP
FPTR_INT ISC_lookup_entrypoint(TEXT * module,
TEXT * name, TEXT * ib_path_env_var)
FPTR_INT ISC_lookup_entrypoint(TEXT* module,
TEXT* name,
TEXT* ib_path_env_var)
{
/**************************************
*
@ -607,52 +666,65 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
**************************************/
FPTR_INT function;
TEXT *p;
MOD mod;
TEXT absolute_module[MAXPATHLEN];
if (function = FUNCTIONS_entrypoint(module, name))
function = FUNCTIONS_entrypoint(module, name);
if (function)
{
return function;
}
#ifdef NON_DL_COMPATIBLE
return NULL;
#else
for (p = module; *p && *p != ' '; p++);
if (*p)
*p = 0;
for (p = name; *p && *p != ' '; p++);
if (*p)
*p = 0;
terminate_at_space(module);
terminate_at_space(name);
if (!*module || !*name)
{
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))) {
USHORT length;
if (!mod)
{
TEXT absolute_module[MAXPATHLEN];
#ifdef EXT_LIB_PATH
if (ib_path_env_var == NULL)
{
strcpy(absolute_module, module);
}
else
if (!gds__validate_lib_path
(module, ib_path_env_var, absolute_module,
sizeof(absolute_module))) return NULL;
{
if (!gds__validate_lib_path(module,
ib_path_env_var,
absolute_module,
sizeof(absolute_module)))
{
return NULL;
}
}
#else
strcpy(absolute_module, module);
#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, then with <name>.so . */
mod = search_for_module(absolute_module, name);
if (!mod) {
if (!mod)
{
strcat(absolute_module, ".so");
mod = search_for_module(absolute_module, name);
}
if (!mod)
{
return NULL;
}
assert(mod->mod_handle); /* assert that we found the module */
mod->mod_use_count = 0;
@ -682,8 +754,6 @@ static MOD search_for_module(TEXT * module, TEXT * name)
* statement.
*
**************************************/
MOD mod;
char *dirp;
TEXT ib_lib_path[MAXPATHLEN];
TEXT absolute_module[MAXPATHLEN]; /* for _access() ??? */
FDLS *dir_list;
@ -691,46 +761,63 @@ static MOD search_for_module(TEXT * module, TEXT * name)
strcpy(absolute_module, module);
if (!(mod = (MOD) gds__alloc(sizeof(struct mod) +
strlen(absolute_module)))) return NULL;
dirp = dirname(absolute_module);
if (('.' == dirp[0]) && ('\0' == dirp[1])) {
MOD mod = (MOD) gds__alloc(sizeof(struct mod) + strlen(absolute_module));
if (!mod)
{
return NULL;
}
char* dirp = dirname(absolute_module);
if (('.' == dirp[0]) && ('\0' == dirp[1]))
{
/* We have a simple module name without a directory. */
gds__prefix(ib_lib_path, IB_UDF_DIR);
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. */
if (!(mod->mod_handle = dlopen(ib_lib_path, RTLD_LAZY))) {
if (!(mod->mod_handle = dlopen(ib_lib_path, RTLD_LAZY)))
{
gds__free(mod);
return NULL;
}
}
else {
else
{
gds__prefix(ib_lib_path, IB_INTL_DIR);
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 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);
return NULL;
}
}
else {
else
{
/* The module is not in the default directory, so ...
* use the EXTERNAL_FUNCTION_DIRECTORY lines from isc_config.
*/
dir_list = DLS_get_func_dirs();
found_module = FALSE;
while (dir_list && !found_module) {
while (dir_list && !found_module)
{
strcpy(ib_lib_path, dir_list->fdls_directory);
strcat(ib_lib_path, "/");
strncat(ib_lib_path, module,
MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!access(ib_lib_path, R_OK)) {
if (!(mod->mod_handle = dlopen(ib_lib_path,
RTLD_LAZY))) {
if (!access(ib_lib_path, R_OK))
{
mod->mod_handle = dlopen(ib_lib_path, RTLD_LAZY);
if (!mod->mod_handle)
{
gds__free(mod);
return NULL;
}
@ -738,14 +825,16 @@ static MOD search_for_module(TEXT * module, TEXT * name)
}
dir_list = dir_list->fdls_next;
}
if (!found_module) {
if (!found_module)
{
gds__free(mod);
return NULL;
}
} /* else module is not in the INTL directory */
} /* else module is not in the default directory, so ... */
} /* if *dirp is "." */
else {
else
{
/* The module name includes a directory path.
* The directory must be the standard UDF directory, or the
* 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);
ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing "/" */
found_module = !strcmp(ib_lib_path, dirp);
if (!found_module) {
if (!found_module)
{
gds__prefix(ib_lib_path, IB_INTL_DIR);
ib_lib_path[strlen(ib_lib_path) - 1] = '\0'; /* drop trailing / */
found_module = !strcmp(ib_lib_path, dirp);
}
if (!found_module) {
if (!found_module)
{
/* It's not the default directory, so try the ones listed
* in EXTERNAL_FUNCTION_DIRECTORY lines in isc_config.
*/
dir_list = DLS_get_func_dirs();
while (dir_list && !found_module) {
while (dir_list && !found_module)
{
if (!strcmp(dir_list->fdls_directory, dirp))
found_module = TRUE;
dir_list = dir_list->fdls_next;
}
}
if (found_module)
{
found_module = (!access(module, R_OK)) &&
(0 != (mod->mod_handle = dlopen(module, RTLD_LAZY)));
if (!found_module) {
}
if (!found_module)
{
gds__free(mod);
return NULL;
}
@ -786,8 +882,9 @@ static MOD search_for_module(TEXT * module, TEXT * name)
#ifdef DGUX
#define LOOKUP
FPTR_INT ISC_lookup_entrypoint(TEXT * module,
TEXT * name, TEXT * ib_path_env_var)
FPTR_INT ISC_lookup_entrypoint(TEXT* module,
TEXT* name,
TEXT* ib_path_env_var)
{
/**************************************
*
@ -811,29 +908,36 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
#ifdef NON_DL_COMPATIBLE
return NULL;
#else
for (p = module; *p && *p != ' '; p++);
if (*p)
*p = 0;
for (p = name; *p && *p != ' '; p++);
if (*p)
*p = 0;
terminate_at_space(module);
terminate_at_space(name);
if (!*module || stat(module, &stdbuf))
{
return NULL;
}
if (ib_path_env_var == NULL)
{
strcpy(absolute_module, module);
}
else
if (!gds__validate_lib_path
(module, ib_path_env_var, absolute_module,
sizeof(absolute_module))) return NULL;
{
if (!gds__validate_lib_path(module,
ib_path_env_var,
absolute_module,
sizeof(absolute_module)))
{
return NULL;
}
}
REPLACE THIS COMPILER ERROR WITH CODE TO VERIFY THAT THE MODULE IS FOUND
EITHER IN $INTERBASE / UDF, OR $INTERBASE / intl,
OR IN ONE OF THE DIRECTORIES NAMED IN EXTERNAL_FUNCTION_DIRECTORY
LINES IN
ISC_CONFIG.if (!(handle = dlopen(absolute_module, RTLD_LAZY))) return
NULL;
ISC_CONFIG.
if (!(handle = dlopen(absolute_module, RTLD_LAZY)))
return NULL;
return dlsym(handle, name);
#endif
@ -843,8 +947,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
#ifdef WIN_NT
#define LOOKUP
FPTR_INT ISC_lookup_entrypoint(TEXT * module,
TEXT * name, TEXT * ib_path_env_var)
FPTR_INT ISC_lookup_entrypoint(TEXT* module,
TEXT* name,
TEXT* ib_path_env_var)
{
/**************************************
*
@ -861,46 +966,59 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
**************************************/
FPTR_INT function;
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;
}
for (p = name; *p && *p != ' '; p++);
if (*p)
*p = 0;
terminate_at_space(name);
/* 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))) {
USHORT length;
if (!mod)
{
TEXT absolute_module[MAXPATHLEN]; // for _access()
#ifdef EXT_LIB_PATH
if (ib_path_env_var == NULL)
{
strcpy(absolute_module, module);
}
else
if (!gds__validate_lib_path
(module, ib_path_env_var, absolute_module,
sizeof(absolute_module))) return NULL;
{
if (!gds__validate_lib_path(module,
ib_path_env_var,
absolute_module,
sizeof(absolute_module)))
{
return NULL;
}
}
#else
strcpy(absolute_module, module);
#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,
then with <name>.DLL (if the name did not have a trailing "."). */
mod = search_for_module(absolute_module, name);
if (!mod) {
if (!mod)
{
if ((absolute_module[length - 1] != '.') &&
stricmp(absolute_module + length - 4, ".DLL")) {
stricmp(absolute_module + length - 4, ".DLL"))
{
strcat(absolute_module, ".DLL");
mod = search_for_module(absolute_module, name);
}
}
if (!mod)
{
return NULL;
}
assert(mod->mod_handle); /* assert that we found the module */
mod->mod_use_count = 0;
@ -912,15 +1030,16 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
++mod->mod_use_count;
/* The Borland compiler prefixes an '_' for functions compiled
with the __cdecl calling convention. */
// The Borland compiler prefixes an '_' for functions compiled
// 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];
p = buffer;
*p++ = '_';
while (*p++ = *name++);
buffer[0] = '_';
strcpy(&buffer[1], name);
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.
*
**************************************/
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
* .DLL to the supplied name and access does not. We need to control
* 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 dir_buf[_MAX_DIR];
FDLS *dir_list;
USHORT length;
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;
}
/* Set absolute_module to the drive and directory prefix part of
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);
strcat(absolute_module, dir_buf);
if (0 == absolute_module[0]) {
if (0 == absolute_module[0])
{
/* We have a simple module name without a directory. */
gds__prefix(ib_lib_path, IB_UDF_DIR);
strncat(ib_lib_path, module, MAXPATHLEN - strlen(ib_lib_path) - 1);
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. */
if (!(mod->mod_handle = LoadLibrary(loadlib_name))) {
mod->mod_handle = LoadLibrary(loadlib_name);
if (!mod->mod_handle)
{
gds__free(mod);
return NULL;
}
}
else {
else
{
gds__prefix(ib_lib_path, IB_INTL_DIR);
strncat(ib_lib_path, module,
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 */
if (!(mod->mod_handle = LoadLibrary(ib_lib_path))) {
mod->mod_handle = LoadLibrary(ib_lib_path);
if (!mod->mod_handle)
{
gds__free(mod);
return NULL;
}
}
else {
else
{
/* The module is not in the default directory, so ...
* use the EXTERNAL_FUNCTION_DIRECTORY lines from isc_config.
*/
dir_list = DLS_get_func_dirs();
found_module = FALSE;
while (dir_list && !found_module) {
while (dir_list && !found_module)
{
strcpy(ib_lib_path, dir_list->fdls_directory);
strcat(ib_lib_path, "\\");
strncat(ib_lib_path, module,
MAXPATHLEN - strlen(ib_lib_path) - 1);
if (!_access(ib_lib_path, 4 /* read permission */ )) {
if (!(mod->mod_handle = LoadLibrary(ib_lib_path))) {
if (!_access(ib_lib_path, 4 /* read permission */ ))
{
mod->mod_handle = LoadLibrary(ib_lib_path);
if (!mod->mod_handle)
{
gds__free(mod);
return NULL;
}
@ -1012,14 +1147,16 @@ static MOD search_for_module(TEXT * module, TEXT * name)
}
dir_list = dir_list->fdls_next;
}
if (!found_module) {
if (!found_module)
{
gds__free(mod);
return NULL;
}
} /* else module is not in the INTL directory */
} /* else module is not in the default UDF directory, so ... */
} /* if path part of name is empty */
else {
else
{
/* The module name includes a directory path.
* The directory must be either $INTERBASE/UDF, or $INTERBASE/intl
* 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);
found_module = !stricmp(ib_lib_path, absolute_module);
if (!found_module) {
if (!found_module)
{
gds__prefix(ib_lib_path, IB_INTL_DIR);
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
* in EXTERNAL_FUNCTION_DIRECTORY lines in isc_config.
*/
dir_list = DLS_get_func_dirs();
while (dir_list && !found_module) {
while (dir_list && !found_module)
{
if (!stricmp(dir_list->fdls_directory, absolute_module))
found_module = TRUE;
dir_list = dir_list->fdls_next;
}
}
if (found_module)
found_module = (!_access(module, 4 /* read ok? */ )) &&
{
found_module =
(!_access(module, 4 /* read ok? */ )) &&
(0 != (mod->mod_handle = LoadLibrary(module)));
if (!found_module) {
}
if (!found_module)
{
gds__free(mod);
return NULL;
}
@ -1069,9 +1213,7 @@ static void adjust_loadlib_name(TEXT * access_path, TEXT * load_path)
*
**************************************/
USHORT length;
length = strlen(access_path);
const USHORT length = strlen(access_path);
strcpy(load_path, access_path);
/* 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.dll foo.dll foo.dll foo.dll
*/
if (stricmp(access_path + length - 4, ".dll")) {
if ('.' == access_path[length - 1]) {
if (stricmp(access_path + length - 4, ".dll"))
{
if ('.' == access_path[length - 1])
{
access_path[length - 1] = '\0';
}
else {
else
{
load_path[length] = '.';
load_path[length + 1] = '\0';
}
@ -1097,8 +1242,9 @@ static void adjust_loadlib_name(TEXT * access_path, TEXT * load_path)
#ifndef LOOKUP
FPTR_INT ISC_lookup_entrypoint(TEXT * module,
TEXT * name, TEXT * ib_path_env_var)
FPTR_INT ISC_lookup_entrypoint(TEXT* module,
TEXT* name,
TEXT* ib_path_env_var)
{
/**************************************
*
@ -1110,12 +1256,9 @@ FPTR_INT ISC_lookup_entrypoint(TEXT * module,
* Lookup entrypoint of function.
*
**************************************/
FPTR_INT function;
if (function = FUNCTIONS_entrypoint(module, name))
return function;
return NULL;
FPTR_INT function = FUNCTIONS_entrypoint(module, name);
return function;
}
#endif

View File

@ -572,69 +572,73 @@ static JMP_BUF env; /* Error return environment */
static const UCHAR
/* generic print formats */
zero[] = { op_line, 0 },
one[] = { op_line, op_verb, 0},
two[] = { op_line, 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},
byte[] = { op_byte, op_line, 0},
zero[] = { op_line, 0 },
one[] = { op_line, op_verb, 0},
two[] = { op_line, 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},
byte[] = { op_byte, op_line, 0},
byte_args[] = { op_byte, op_line, op_args, 0},
byte_byte[] = { op_byte, op_byte, op_line, 0},
byte_verb[] = { op_byte, op_line, 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_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},
parm3[] = { op_byte, op_word, 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},
/* formats specific to a verb */
begin[] = { op_line, op_begin, op_verb, 0},
literal[] = { op_dtype, op_literal, op_line, 0},
message[] = { op_byte, op_word, op_line, op_message, 0},
rse[] = { op_byte, op_line, op_begin, op_verb, 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,
op_byte, op_line, 0},
aggregate[] = { op_byte, op_line, op_verb, op_verb, op_verb, 0},
rid[] = { op_word, op_byte, op_line, 0},
rid2[] = { op_word, op_byte, op_literal, op_pad, op_byte, op_line, 0},
begin[] = { op_line, op_begin, op_verb, 0},
literal[] = { op_dtype, op_literal, op_line, 0},
message[] = { op_byte, op_word, op_line, op_message, 0},
rse[] = { op_byte, op_line, op_begin, op_verb, 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, op_byte, op_line, 0},
aggregate[] = { op_byte, op_line, op_verb, op_verb, op_verb, 0},
rid[] = { op_word, 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},
map[] = { op_word, op_line, op_map, 0},
function[] = { op_byte, op_literal, op_byte, op_line, op_args, 0},
gen_id[] = { op_byte, op_literal, op_line, op_verb, 0},
declare[] = { op_word, op_dtype, op_line, 0},
variable[] = { op_word, op_line, 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},
seek[] = { op_line, op_verb, op_verb, 0},
join[] = { op_join, op_line, 0},
exec_proc[] = { op_byte, op_literal, op_line, op_indent, op_word, op_line, 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,
op_line, op_parameters, 0},
pid[] = { op_word, op_pad, op_byte, op_line, op_indent, op_word, op_line,
op_parameters, 0},
map[] = { op_word, op_line, op_map, 0},
function[] = { op_byte, op_literal, op_byte, op_line, op_args, 0},
gen_id[] = { op_byte, op_literal, op_line, op_verb, 0},
declare[] = { op_word, op_dtype, op_line, 0},
variable[] = { op_word, op_line, 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},
seek[] = { op_line, op_verb, op_verb, 0},
join[] = { op_join, op_line, 0},
exec_proc[] = { op_byte, op_literal, op_line, op_indent, op_word, op_line,
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, op_line, op_parameters, 0},
pid[] = { op_word, op_pad, op_byte, op_line, op_indent, op_word,
op_line, op_parameters, 0},
error_handler[] = { op_word, op_line, op_error_handler, 0},
set_error[] = { op_set_error, op_line, 0},
cast[] = { op_dtype, op_line, op_verb, 0},
indices[] = { op_byte, op_line, op_literals, 0},
cast[] = { op_dtype, op_line, op_verb, 0},
indices[] = { op_byte, op_line, op_literals, 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},
extract[] = { op_line, op_byte, op_verb, 0};
extract[] = { op_line, op_byte, op_verb, 0};
static const struct
{
const char *blr_string;
const UCHAR *blr_operators;
} FAR_VARIABLE blr_table[] = {
} FAR_VARIABLE blr_table[] =
{
#pragma FB_COMPILER_MESSAGE("Fix this!")
#include "../jrd/blp.h"
0, 0
};
#define ISC_ENV "INTERBASE"
#define ISC_ENV "INTERBASE"
#define ISC_LOCK_ENV "INTERBASE_LOCK"
#define ISC_MSG_ENV "INTERBASE_MSG"
@ -680,12 +684,12 @@ void gds_print_delta_counters(IB_FILE *);
#ifdef DEBUG_GDS_ALLOC
UCHAR *API_ROUTINE gds__alloc_debug(
SLONG size_request,
TEXT * filename, ULONG lineno)
void* API_ROUTINE gds__alloc_debug(SLONG size_request,
TEXT* filename,
ULONG lineno)
#else
UCHAR *API_ROUTINE gds__alloc(SLONG size_request)
void* API_ROUTINE gds__alloc(SLONG size_request)
#endif
{
/**************************************
@ -748,9 +752,12 @@ UCHAR *API_ROUTINE gds__alloc(SLONG size_request)
*/
factor = 1;
if (!(size_request & (1024 - 1)))
{
factor = size_request / 1024;
}
size = size_request + ALLOC_OVERHEAD * factor;
size = ROUNDUP(size, GDS_ALLOC_ALIGNMENT);
#ifdef DEV_BUILD
gds_delta_alloc += size;
#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)
{
return SUCCESS;
else if (code & ISC_MASK != ISC_MASK)
}
if (code & ISC_MASK != ISC_MASK)
{
/* not an ISC error message */
return code;
}
*fac = GET_FACILITY(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((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
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");
}
if (!errors
&& strncmp(p->alloc_magic1, ALLOC_HEADER1_MAGIC_ALLOCATED,
sizeof(p->alloc_magic1))) {
if (!errors &&
strncmp(p->alloc_magic1,
ALLOC_HEADER1_MAGIC_ALLOCATED,
sizeof(p->alloc_magic1)))
{
errors++;
DEV_REPORT("gds_alloc_validate: Header marker1 mismatch\n");
}
if (!errors
&& strncmp(p->alloc_magic2, ALLOC_HEADER2_MAGIC,
sizeof(p->alloc_magic2))) {
if (!errors &&
strncmp(p->alloc_magic2,
ALLOC_HEADER2_MAGIC,
sizeof(p->alloc_magic2)))
{
errors++;
DEV_REPORT("gds_alloc_validate: Header marker2 mismatch\n");
}
if (!errors
&& memcmp(((BLOB_PTR *) p) + ALLOC_HEADER_SIZE +
p->alloc_requested_length, ALLOC_TAILER_MAGIC,
ALLOC_TAILER_SIZE)) {
if (!errors &&
memcmp(((BLOB_PTR*) p) + ALLOC_HEADER_SIZE + p->alloc_requested_length,
ALLOC_TAILER_MAGIC,
ALLOC_TAILER_SIZE))
{
errors++;
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++;
DEV_REPORT
("gds_alloc_validate: Header has been trashed (smaller than req)\n");
DEV_REPORT("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++;
DEV_REPORT
("gds_alloc_validate: Header has been trashed (smaller than min)\n");
}
if (errors) {
if (errors)
{
char buffer[150];
sprintf(buffer,
"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_lineno,
p->alloc_callno,
gds_alloc_call_count, gds_free_call_count, NEWLINE);
gds_alloc_call_count,
gds_free_call_count,
NEWLINE);
DEV_REPORT(buffer);
BREAKPOINT(__LINE__);
}
@ -1384,8 +1405,7 @@ static void gds_alloc_validate(ALLOC p)
#ifdef DEBUG_GDS_ALLOC
static BOOLEAN gds_alloc_validate_free_pattern(
register UCHAR * ptr,
static BOOLEAN gds_alloc_validate_free_pattern(register UCHAR* ptr,
register ULONG len)
{
/**************************************
@ -1403,7 +1423,9 @@ static BOOLEAN gds_alloc_validate_free_pattern(
*
**************************************/
while (len--)
if (*ptr++ != ALLOC_FREED_PATTERN) {
{
if (*ptr++ != ALLOC_FREED_PATTERN)
{
char buffer[100];
sprintf(buffer,
"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__);
return FALSE;
}
}
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 */
if (!p) {
if (!p)
{
errors++;
DEV_REPORT("gds_alloc_validate_freed: pointer doesn't look right\n");
}
/* Now look at the space, is it all the same pattern? */
if (!errors) {
if (!errors)
{
register UCHAR *ptr;
register ULONG len;
ptr = ((UCHAR *) p) + sizeof(struct free);
len = p->alloc_status.alloc_freed.free_length - sizeof(struct free);
if (!gds_alloc_validate_free_pattern(ptr, len))
{
errors++;
}
}
if (errors) {
if (errors)
{
char buffer[150];
sprintf(buffer,
"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
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++;
/* 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_watch_call_count = 1;
}
/* If we have a watchpoint, check that it's still valid */
if (gds_alloc_watchpoint)
{
gds_alloc_validate(gds_alloc_watchpoint);
}
}
#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
*
**************************************/
ALLOC p;
/* 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 */
gds_alloc_validate(p);
@ -1526,7 +1556,7 @@ void API_ROUTINE gds_alloc_flag_unfreed(void *blk)
#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;
if (flags & ALLOC_check_each_call)
{
gds_alloc_state = gds_alloc_call_count;
}
if (flags & ALLOC_dont_check)
{
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);
if ((!(p->alloc_flags & ALLOC_dont_report) &&
!(flags & ALLOC_silent)) ||
@ -1569,14 +1604,25 @@ void API_ROUTINE gds_alloc_report(ULONG flags, char *filename, int lineno)
ib_fflush(ib_stderr);
sprintf(buffer,
"%sgds_alloc_report: flags %ld file %15.15s lineno %ld alloc=%ld free=%ld%s%s",
NEWLINE, flags, filename ? filename : "?", lineno,
gds_alloc_call_count, gds_free_call_count, NEWLINE,
NEWLINE,
flags,
filename ? filename : "?",
lineno,
gds_alloc_call_count,
gds_free_call_count,
NEWLINE,
NEWLINE);
if (getenv("NO_GDS_ALLOC_REPORT"))
{
stderr_reporting = FALSE;
}
if (stderr_reporting)
{
DEV_REPORT(buffer);
if (f) {
}
if (f)
{
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_filename,
p->alloc_lineno, p->alloc_callno, NEWLINE);
if (stderr_reporting) {
if (stderr_reporting)
{
DEV_REPORT(buffer);
}
if (f) {
if (f)
{
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 */
for (p = (ALLOC) pool; p;
p = (ALLOC) p->alloc_status.alloc_freed.free_next)
for (p = (ALLOC)pool; p; p = (ALLOC)p->alloc_status.alloc_freed.free_next)
{
gds_alloc_validate_freed(p);
}
if (f) {
if (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.
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;
/* FREE: at procedure exit */
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
#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
#define gds__alloc(s) gds__alloc_debug ((s),(TEXT *)__FILE__,(ULONG)__LINE__)
extern UCHAR *API_ROUTINE gds__alloc_debug(SLONG, TEXT *, ULONG);
extern void API_ROUTINE gds_alloc_flag_unfreed(void *);
extern void API_ROUTINE gds_alloc_report(ULONG, char *, int);
#define gds__alloc(s) gds__alloc_debug ((s),(TEXT*)__FILE__,(ULONG)__LINE__)
void* API_ROUTINE gds__alloc_debug(SLONG, TEXT*, ULONG);
void API_ROUTINE gds_alloc_flag_unfreed(void*);
void API_ROUTINE gds_alloc_report(ULONG, char*, int);
#define ALLOC_dont_report (1L << 0) /* Don't report this block */
#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 */
extern UCHAR *API_ROUTINE gds__alloc(SLONG);
extern void* API_ROUTINE gds__alloc(SLONG);
#endif /* DEBUG_GDS_ALLOC */
@ -70,73 +70,73 @@ extern UCHAR *API_ROUTINE gds__alloc(SLONG);
typedef GDS_QUAD GDS__QUAD;
#endif
extern STATUS API_ROUTINE gds__decode(STATUS, USHORT *, USHORT *);
extern void API_ROUTINE isc_decode_date(GDS_QUAD *, void *);
extern void API_ROUTINE isc_decode_sql_date(GDS_DATE *, void *);
extern void API_ROUTINE isc_decode_sql_time(GDS_TIME *, void *);
extern void API_ROUTINE isc_decode_timestamp(GDS_TIMESTAMP *, void *);
extern STATUS API_ROUTINE gds__encode(STATUS, USHORT);
extern void API_ROUTINE isc_encode_date(void *, GDS_QUAD *);
extern void API_ROUTINE isc_encode_sql_date(void *, GDS_DATE *);
extern void API_ROUTINE isc_encode_sql_time(void *, GDS_TIME *);
extern void API_ROUTINE isc_encode_timestamp(void *, GDS_TIMESTAMP *);
extern ULONG API_ROUTINE gds__free(void *);
extern SLONG API_ROUTINE gds__interprete(char *, STATUS **);
extern void API_ROUTINE gds__interprete_a(SCHAR *, SSHORT *, STATUS *,
SSHORT *);
extern void API_ROUTINE gds__log(TEXT *, ...);
extern void API_ROUTINE gds__log_status(TEXT *, STATUS *);
extern int API_ROUTINE gds__msg_close(void *);
extern SSHORT API_ROUTINE gds__msg_format(void *, USHORT, USHORT, USHORT,
TEXT *, TEXT *, TEXT *, TEXT *,
TEXT *, TEXT *);
extern SSHORT API_ROUTINE gds__msg_lookup(void *, USHORT, USHORT, USHORT,
TEXT *, USHORT *);
extern int API_ROUTINE gds__msg_open(void **, TEXT *);
extern void API_ROUTINE gds__msg_put(void *, USHORT, USHORT, TEXT *, TEXT *,
TEXT *, TEXT *, TEXT *);
STATUS API_ROUTINE gds__decode(STATUS, USHORT*, USHORT*);
void API_ROUTINE isc_decode_date(GDS_QUAD*, void*);
void API_ROUTINE isc_decode_sql_date(GDS_DATE*, void*);
void API_ROUTINE isc_decode_sql_time(GDS_TIME*, void*);
void API_ROUTINE isc_decode_timestamp(GDS_TIMESTAMP*, void*);
STATUS API_ROUTINE gds__encode(STATUS, USHORT);
void API_ROUTINE isc_encode_date(void*, GDS_QUAD*);
void API_ROUTINE isc_encode_sql_date(void*, GDS_DATE*);
void API_ROUTINE isc_encode_sql_time(void*, GDS_TIME*);
void API_ROUTINE isc_encode_timestamp(void*, GDS_TIMESTAMP*);
ULONG API_ROUTINE gds__free(void*);
SLONG API_ROUTINE gds__interprete(char*, STATUS**);
void API_ROUTINE gds__interprete_a(SCHAR*, SSHORT*, STATUS*, SSHORT*);
void API_ROUTINE gds__log(TEXT*, ...);
void API_ROUTINE gds__log_status(TEXT*, STATUS*);
int API_ROUTINE gds__msg_close(void*);
SSHORT API_ROUTINE gds__msg_format(void*, USHORT, USHORT, USHORT,
TEXT*, TEXT*, TEXT*, TEXT*,
TEXT*, TEXT*);
SSHORT API_ROUTINE gds__msg_lookup(void*, USHORT, USHORT, USHORT,
TEXT*, USHORT*);
int API_ROUTINE gds__msg_open(void**, TEXT*);
void API_ROUTINE gds__msg_put(void*, USHORT, USHORT, TEXT*, TEXT*,
TEXT*, TEXT*, TEXT*);
#ifdef NETWARE_386
extern void API_ROUTINE gds__prefix(TEXT *, void *);
extern void API_ROUTINE gds__prefix_lock(TEXT *, void *);
void API_ROUTINE gds__prefix(TEXT*, void*);
void API_ROUTINE gds__prefix_lock(TEXT*, void*);
#else
extern void API_ROUTINE gds__prefix(TEXT *, TEXT *);
extern void API_ROUTINE gds__prefix_lock(TEXT *, TEXT *);
extern void API_ROUTINE gds__prefix_msg(TEXT *, TEXT *);
void API_ROUTINE gds__prefix(TEXT*, TEXT*);
void API_ROUTINE gds__prefix_lock(TEXT*, TEXT*);
void API_ROUTINE gds__prefix_msg(TEXT*, TEXT*);
#endif
extern SLONG API_ROUTINE gds__get_prefix(SSHORT, TEXT *);
extern STATUS API_ROUTINE gds__print_status(STATUS *);
extern USHORT API_ROUTINE gds__parse_bpb(USHORT, UCHAR *, USHORT *, USHORT *);
extern USHORT API_ROUTINE gds__parse_bpb2(USHORT, UCHAR *, USHORT *, USHORT *,
USHORT *, USHORT *);
extern SLONG API_ROUTINE gds__ftof(SCHAR *, USHORT GDS_VAL(length1), SCHAR *,
USHORT GDS_VAL(length2));
extern int API_ROUTINE gds__print_blr(UCHAR *, FPTR_VOID, SCHAR *, SSHORT);
extern void API_ROUTINE gds__put_error(TEXT *);
extern void API_ROUTINE gds__qtoq(void *, void *);
extern void API_ROUTINE gds__register_cleanup(FPTR_VOID_PTR, void *);
extern SLONG API_ROUTINE gds__sqlcode(STATUS *);
extern void API_ROUTINE gds__sqlcode_s(STATUS *, ULONG *);
extern UCHAR *API_ROUTINE gds__sys_alloc(SLONG);
extern SLONG API_ROUTINE gds__sys_free(void *);
extern void *API_ROUTINE gds__temp_file(BOOLEAN, TEXT *, TEXT *);
extern void API_ROUTINE gds__unregister_cleanup(FPTR_VOID_PTR, void *);
extern BOOLEAN API_ROUTINE gds__validate_lib_path(TEXT *, TEXT *, TEXT *,
SLONG);
extern SLONG API_ROUTINE gds__vax_integer(UCHAR *, SSHORT);
extern void API_ROUTINE gds__vtof(SCHAR *, SCHAR *, USHORT);
extern void API_ROUTINE gds__vtov(CONST SCHAR *, SCHAR *, SSHORT);
extern void API_ROUTINE isc_print_sqlerror(SSHORT, STATUS *);
extern void API_ROUTINE isc_sql_interprete(SSHORT, TEXT *, SSHORT);
extern void *gds__tmp_file2(BOOLEAN, TEXT *, TEXT *, TEXT *);
extern SINT64 API_ROUTINE isc_portable_integer(UCHAR *, SSHORT);
extern void gds__cleanup(void);
SLONG API_ROUTINE gds__get_prefix(SSHORT, TEXT*);
STATUS API_ROUTINE gds__print_status(STATUS*);
USHORT API_ROUTINE gds__parse_bpb(USHORT, UCHAR*, USHORT*, USHORT*);
USHORT API_ROUTINE gds__parse_bpb2(USHORT, UCHAR*, USHORT*, USHORT*,
USHORT*, USHORT*);
SLONG API_ROUTINE gds__ftof(SCHAR*, USHORT GDS_VAL(length1), SCHAR*,
USHORT GDS_VAL(length2));
int API_ROUTINE gds__print_blr(UCHAR*, FPTR_VOID, SCHAR*, SSHORT);
void API_ROUTINE gds__put_error(TEXT*);
void API_ROUTINE gds__qtoq(void*, void*);
void API_ROUTINE gds__register_cleanup(FPTR_VOID_PTR, void*);
SLONG API_ROUTINE gds__sqlcode(STATUS*);
void API_ROUTINE gds__sqlcode_s(STATUS*, ULONG*);
void* API_ROUTINE gds__sys_alloc(SLONG);
SLONG API_ROUTINE gds__sys_free(void*);
void* API_ROUTINE gds__temp_file(BOOLEAN, TEXT*, TEXT*);
void API_ROUTINE gds__unregister_cleanup(FPTR_VOID_PTR, void*);
BOOLEAN API_ROUTINE gds__validate_lib_path(TEXT*, TEXT*, TEXT*,
SLONG);
SLONG API_ROUTINE gds__vax_integer(UCHAR*, SSHORT);
void API_ROUTINE gds__vtof(SCHAR*, SCHAR*, USHORT);
void API_ROUTINE gds__vtov(CONST SCHAR*, SCHAR*, SSHORT);
void API_ROUTINE isc_print_sqlerror(SSHORT, STATUS*);
void API_ROUTINE isc_sql_interprete(SSHORT, TEXT*, SSHORT);
void* gds__tmp_file2(BOOLEAN, TEXT*, TEXT*, TEXT*);
SINT64 API_ROUTINE isc_portable_integer(UCHAR*, SSHORT);
void gds__cleanup(void);
#ifdef NETWARE_386
extern SCHAR *mktemp(SCHAR *);
SCHAR* mktemp(SCHAR*);
#endif
#ifdef VMS
extern int unlink(SCHAR *);
int unlink(SCHAR*);
#endif

View File

@ -244,9 +244,10 @@ UCHAR *DLL_EXPORT SDL_prepare_slice(UCHAR * sdl, USHORT sdl_length)
* blr_d_float to blr_double.
*
**************************************/
UCHAR *new_sdl, *old_sdl;
DSC junk;
USHORT n;
UCHAR* new_sdl;
UCHAR* old_sdl;
DSC junk;
USHORT n;
new_sdl = old_sdl = sdl;
@ -254,14 +255,20 @@ UCHAR *DLL_EXPORT SDL_prepare_slice(UCHAR * sdl, USHORT sdl_length)
return old_sdl;
while ((SCHAR) * sdl != gds_sdl_eoc)
switch (*sdl++) {
{
switch (*sdl++)
{
case gds_sdl_struct:
for (n = *sdl++; n; --n) {
if (*sdl == blr_d_float) {
if (new_sdl == old_sdl) {
new_sdl = gds__alloc((SLONG) sdl_length);
for (n = *sdl++; n; --n)
{
if (*sdl == blr_d_float)
{
if (new_sdl == old_sdl)
{
new_sdl = (UCHAR*)gds__alloc((SLONG) sdl_length);
/* FREE: apparently never freed */
if (!new_sdl) { /* NOMEM: ignore operation */
if (!new_sdl)
{ /* NOMEM: ignore operation */
assert(FALSE); /* no real error handling */
return old_sdl;
}
@ -290,6 +297,7 @@ UCHAR *DLL_EXPORT SDL_prepare_slice(UCHAR * sdl, USHORT sdl_length)
default:
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)
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() */
if (!service->svc_stdout) /* NOMEM: */
{
ERR_post(isc_virmemexh, 0);
}
if (serv->serv_thd) {
SLONG count;
#pragma FB_COMPILER_MESSAGE("Fix! Probable bug!")
EVENT evnt_ptr =
reinterpret_cast < EVENT > (&(service->svc_start_event));
reinterpret_cast<EVENT> (&(service->svc_start_event));
THREAD_EXIT;
/* 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)
return (1);
else
return (0);
return 1;
return 0;
}
@ -2888,24 +2890,27 @@ static void service_fork(void (*service_executable) (), SVC service)
}
*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() */
if (!service->svc_stdout) /* NOMEM: */
ERR_post(isc_virmemexh, 0);
THREAD_EXIT;
gds__thread_start(reinterpret_cast < FPTR_INT_VOID_PTR >
(service_executable), service, 0, 0,
(void *) &service->svc_handle);
gds__thread_start(reinterpret_cast<FPTR_INT_VOID_PTR>(service_executable),
service,
0,
0,
(void*)&service->svc_handle);
THREAD_ENTER;
}
static void service_get(
SVC service,
SCHAR * buffer,
USHORT length,
USHORT flags, USHORT timeout, USHORT * return_length)
static void service_get(SVC service,
SCHAR* buffer,
USHORT length,
USHORT flags,
USHORT timeout,
USHORT* return_length)
{
/**************************************
*
@ -3772,7 +3777,8 @@ static void get_action_svc_string(
*spb += sizeof(ISC_USHORT);
if (*cmd) {
if (*cmd)
{
**cmd = SVC_TRMNTR;
*cmd += 1;
MOVE_FASTER(*spb, *cmd, l);

View File

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

View File

@ -30,40 +30,45 @@
extern "C" {
#endif
extern int API_ROUTINE gds__thread_start(FPTR_INT_VOID_PTR, void *, int, int,
void *);
extern long THD_get_thread_id(void);
extern struct thdd *DLL_EXPORT THD_get_specific(void);
extern void THD_getspecific_data(void **t_data);
extern void DLL_EXPORT THD_init(void);
extern void DLL_EXPORT THD_cleanup(void);
extern int DLL_EXPORT THD_mutex_destroy(struct mutx_t *);
extern int THD_mutex_init(struct mutx_t *);
extern int THD_mutex_lock(struct mutx_t *);
extern int THD_mutex_unlock(struct mutx_t *);
extern int THD_mutex_destroy_n(struct mutx_t *, USHORT);
extern int THD_mutex_init_n(struct mutx_t *, USHORT);
extern int THD_mutex_lock_global(void);
extern int THD_mutex_unlock_global(void);
extern void DLL_EXPORT THD_put_specific(struct thdd *);
extern void THD_putspecific_data(void *t_data);
int API_ROUTINE gds__thread_start(FPTR_INT_VOID_PTR, void*, int, int,
void*);
struct thdd* DLL_EXPORT THD_get_specific(void);
void DLL_EXPORT THD_init(void);
void DLL_EXPORT THD_cleanup(void);
int DLL_EXPORT THD_mutex_destroy(struct mutx_t*);
void DLL_EXPORT THD_put_specific(struct thdd*);
int DLL_EXPORT THD_wlck_destroy(struct wlck_t*);
int DLL_EXPORT THD_wlck_init(struct wlck_t*);
int DLL_EXPORT THD_wlck_lock(struct wlck_t*, USHORT);
int DLL_EXPORT THD_wlck_unlock(struct wlck_t*);
long THD_get_thread_id(void);
void THD_getspecific_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
extern int THD_rec_mutex_destroy(struct rec_mutx_t *);
extern int THD_rec_mutex_init(struct rec_mutx_t *);
extern int THD_rec_mutex_lock(struct rec_mutx_t *);
extern int THD_rec_mutex_unlock(struct rec_mutx_t *);
int THD_rec_mutex_destroy(struct rec_mutx_t*);
int THD_rec_mutex_init(struct rec_mutx_t*);
int THD_rec_mutex_lock(struct rec_mutx_t*);
int THD_rec_mutex_unlock(struct rec_mutx_t*);
#endif
extern struct thdd *DLL_EXPORT THD_restore_specific(void);
extern int THD_resume(THD_T);
extern void THD_sleep(ULONG);
extern int THD_suspend(THD_T);
extern int DLL_EXPORT THD_wlck_destroy(struct wlck_t *);
extern int DLL_EXPORT THD_wlck_init(struct wlck_t *);
extern int DLL_EXPORT THD_wlck_lock(struct wlck_t *, USHORT);
extern int DLL_EXPORT THD_wlck_unlock(struct wlck_t *);
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);
struct thdd* DLL_EXPORT THD_restore_specific(void);
int THD_resume(THD_T);
void THD_sleep(ULONG);
int THD_suspend(THD_T);
void THD_wlck_destroy_n(struct wlck_t*, USHORT);
void THD_wlck_init_n(struct wlck_t*, USHORT);
void THD_yield(void);
#ifdef __cplusplus
} /* 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)
{
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++;
} else {
int ret = THD_mutex_lock(rec_mutex->rec_mutx_mtx);
if (ret) {
} else
{
const int ret = THD_mutex_lock(rec_mutex->rec_mutx_mtx);
if (ret)
{
return ret;
}
rec_mutex->rec_mutx_id = THD_get_thread_id();

View File

@ -68,7 +68,9 @@
#if defined(WIN_NT) && defined(_MSC_VER)
#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
#define DYN_MSG_FAC 8
@ -79,7 +81,8 @@
#define EVENT_FLAG 15
static CONST SCHAR lock_types[] = {
static CONST SCHAR lock_types[] =
{
0,
LCK$K_NLMODE,
LCK$K_CRMODE,
@ -2883,50 +2886,54 @@ static BOOLEAN start_sweeper(TDBB tdbb, DBB dbb)
* Start a thread to sweep the database.
*
**************************************/
struct lck temp_lock;
UCHAR *database;
if (dbb->dbb_flags & DBB_sweep_in_progress)
{
return FALSE;
}
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_dbb = dbb;
temp_lock.lck_type = LCK_sweep;
temp_lock.lck_owner_handle =
LCK_get_owner_handle(tdbb, temp_lock.lck_type);
temp_lock.lck_owner_handle = LCK_get_owner_handle(tdbb, temp_lock.lck_type);
temp_lock.lck_parent = dbb->dbb_lock;
temp_lock.lck_length = sizeof(SLONG);
if (!LCK_lock(tdbb, &temp_lock, LCK_EX, FALSE))
{
return FALSE;
}
LCK_release(tdbb, &temp_lock);
/* allocate space for the string and a null at the end */
database =
gds__alloc(strlen
(reinterpret_cast <
const char *>(dbb->dbb_filename->str_data)) +1);
if (database) {
strcpy(reinterpret_cast < char *>(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 {
/* allocate space for the string and a null at the end */
const char* pszFilename =
reinterpret_cast<const char*>(dbb->dbb_filename->str_data);
char* database = (char*)gds__alloc(strlen(pszFilename) + 1);
if (!database)
{
ERR_log(0, 0, "cannot start sweep thread, Out of Memory");
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;
}
@ -2943,18 +2950,13 @@ static void THREAD_ROUTINE sweep_database(UCHAR * database)
* Sweep database.
*
**************************************/
isc_db_handle db_handle;
IHNDL ihandle;
STATUS status_vector[ISC_STATUS_LENGTH];
UCHAR* dpb;
SSHORT dpb_length;
char* q;
STATUS status_vector[ISC_STATUS_LENGTH];
char* q;
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_user_name;
@ -2976,9 +2978,11 @@ static void THREAD_ROUTINE sweep_database(UCHAR * database)
*dpb++ = gds_dpb_sweep;
*dpb++ = 1;
*dpb++ = gds_dpb_records;
dpb_length = dpb - sweep_dpb;
const SSHORT dpb_length = dpb - sweep_dpb;
/* Register as internal database handle */
IHNDL ihandle;
THREAD_ENTER;
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.
*
**************************************/
SSHORT length, new_dpb_length;
UCHAR *new_dpb;
char *p;
char *q;
va_list args;
USHORT type;
SSHORT length;
SSHORT new_dpb_length;
UCHAR* new_dpb;
char* p;
char* q;
va_list args;
USHORT type;
/* calculate length of database parameter block,
setting initial length to include version */
if (!*dpb || !(new_dpb_length = *dpb_size))
{
new_dpb_length = 1;
}
VA_START(args, dpb_size);
while (type = va_arg(args, int))
switch (type) {
{
switch (type)
{
case gds_dpb_user_name:
case gds_dpb_password:
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 isc_dpb_reserved:
p = va_arg(args, char *);
if (p) {
if (p)
{
length = strlen(p);
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);
break;
}
}
/* if items have been added, allocate space
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 */
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);
/* 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");
return; /* NOMEM: not really handled */
}
q = *dpb;
for (length = *dpb_size; length; length--)
{
*p++ = *q++;
}
}
else {
else
{
new_dpb = (UCHAR *) * dpb;
p = reinterpret_cast < char *>(new_dpb + *dpb_size);
p = reinterpret_cast<char*>(new_dpb + *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);
while (type = va_arg(args, int))
switch (type) {
{
switch (type)
{
case gds_dpb_user_name:
case gds_dpb_password:
case isc_dpb_sql_role_name:
case gds_dpb_lc_messages:
case gds_dpb_lc_ctype:
case isc_dpb_reserved:
if (q = va_arg(args, char *)) {
if (q = va_arg(args, char *))
{
length = strlen(q);
assert(type <= CHAR_MAX);
*p++ = (char) type;
@ -499,16 +514,18 @@ void API_ROUTINE_VARARG isc_expand_dpb(SCHAR ** dpb, SSHORT * dpb_size, ...)
(void) va_arg(args, int);
break;
}
}
*dpb_size = p - reinterpret_cast < char *>(new_dpb);
*dpb = (SCHAR *) new_dpb;
*dpb_size = p - reinterpret_cast<char*>(new_dpb);
*dpb = (SCHAR*) new_dpb;
}
int API_ROUTINE isc_modify_dpb(
SCHAR ** dpb,
SSHORT * dpb_size,
USHORT type, SCHAR * str, SSHORT str_len)
int API_ROUTINE isc_modify_dpb(SCHAR** dpb,
SSHORT* dpb_size,
USHORT type,
SCHAR* str,
SSHORT str_len)
{
/**************************************
*
@ -544,9 +561,12 @@ int API_ROUTINE isc_modify_dpb(
setting initial length to include version */
if (!*dpb || !(new_dpb_length = *dpb_size))
{
new_dpb_length = 1;
}
switch (type) {
switch (type)
{
case gds_dpb_user_name:
case gds_dpb_password:
case isc_dpb_sql_role_name:
@ -563,46 +583,59 @@ int API_ROUTINE isc_modify_dpb(
/* if items have been added, allocate space
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 */
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 */
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");
return FAILURE; /* NOMEM: not really handled */
}
q = (UCHAR *) * dpb;
p = new_dpb;
q = (UCHAR*) *dpb;
for (length = *dpb_size; length; length--)
{
*p++ = *q++;
}
}
else {
else
{
new_dpb = (UCHAR *) * dpb;
p = new_dpb + *dpb_size;
}
if (!*dpb_size)
{
*p++ = gds_dpb_version1;
}
/* copy in the new runtime items */
switch (type) {
switch (type)
{
case gds_dpb_user_name:
case gds_dpb_password:
case isc_dpb_sql_role_name:
case gds_dpb_lc_messages:
case gds_dpb_lc_ctype:
case isc_dpb_reserved:
if (q = (UCHAR *) str) {
if (q = (UCHAR *) str)
{
length = str_len;
assert(type <= MAX_UCHAR);
*p++ = (UCHAR) type;
assert(length <= MAX_UCHAR);
*p++ = (UCHAR) length;
while (length--)
{
*p++ = *q++;
}
}
break;
@ -612,12 +645,13 @@ int API_ROUTINE isc_modify_dpb(
*dpb_size = p - new_dpb;
*dpb = (SCHAR *) new_dpb;
return SUCCESS;
}
#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";
#else
if (!(editor = getenv("EDITOR")))
editor = "mep";
editor = "Notepad";
#endif
statistics(file_name, &before);
@ -647,8 +681,8 @@ int API_ROUTINE GDS_EDIT(TEXT * file_name, USHORT type)
statistics(file_name, &after);
return (before.st_mtime != after.st_mtime
|| before.st_size != after.st_size);
return (before.st_mtime != after.st_mtime ||
before.st_size != after.st_size);
}
#endif

View File

@ -72,7 +72,7 @@ SLONG allr_delta_alloc = 0;
//
UCHAR* DLL_EXPORT ALLR_alloc(ULONG size)
{
UCHAR* block = gds__alloc((SLONG) size);
UCHAR* block = (UCHAR*)gds__alloc((SLONG) size);
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.
*
**************************************/
RDB rdb;
PORT port;
USHORT length, user_verification, new_dpb_length, result;
STATUS *v;
UCHAR expanded_name[MAXPATHLEN], new_dpb[MAXPATHLEN], *new_dpb_ptr;
TEXT user_string[256], *us;
TEXT node_name[MAXPATHLEN];
JMP_BUF env;
struct trdb thd_context, *trdb;
RDB rdb;
PORT port;
USHORT length;
USHORT user_verification;
USHORT new_dpb_length;
USHORT result;
UCHAR expanded_name[MAXPATHLEN];
UCHAR new_dpb[MAXPATHLEN];
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);
v = user_status;
STATUS* v = user_status;
*v++ = gds_arg_gds;
*v++ = gds_unavailable;
*v = gds_arg_end;
#ifdef UNIX
/* If single user, return */
// If single user, return
if (get_single_user(dpb_length, dpb))
{
return gds_unavailable;
}
#endif
SET_THREAD_DATA;
@ -302,12 +310,13 @@ STATUS GDS_ATTACH_DATABASE(STATUS* user_status,
length = strlen((char *) expanded_name);
new_dpb_ptr = new_dpb;
if ((dpb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH +
MAX_OTHER_PARAMS) > sizeof(new_dpb))
{
new_dpb_ptr =
gds__alloc(dpb_length + MAX_USER_LENGTH +
MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS);
(UCHAR*)gds__alloc(dpb_length + MAX_USER_LENGTH +
MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS);
/* FREE: by return(s) from this procedure */
@ -830,16 +839,18 @@ STATUS GDS_CREATE_DATABASE(STATUS * user_status,
length = strlen((char *) expanded_name);
new_dpb_ptr = new_dpb;
if (
(dpb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH +
MAX_OTHER_PARAMS) > sizeof(new_dpb)) {
if ((dpb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH +
MAX_OTHER_PARAMS) > sizeof(new_dpb))
{
new_dpb_ptr =
gds__alloc(dpb_length + MAX_USER_LENGTH +
MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS);
(UCHAR*)gds__alloc(dpb_length + MAX_USER_LENGTH +
MAX_PASSWORD_ENC_LENGTH + MAX_OTHER_PARAMS);
/* 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;
return error(user_status);
}
@ -3541,16 +3552,17 @@ STATUS GDS_SERVICE_ATTACH(STATUS * user_status,
*v = gds_arg_end;
new_spb_ptr = new_spb;
if (
(spb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH +
MAX_OTHER_PARAMS) > sizeof(new_spb)) {
if ((spb_length + MAX_USER_LENGTH + MAX_PASSWORD_ENC_LENGTH +
MAX_OTHER_PARAMS) > sizeof(new_spb))
{
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);
/* 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;
return error(user_status);
}

View File

@ -27,6 +27,7 @@
#include "../jrd/common.h"
#include "../remote/remote_def.h"
#include "../jrd/ibsetjmp.h"
#include "../jrd/thd_proto.h"
/* 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 encrypted2[MAX_PASSWORD_LENGTH + 2];
TEXT buff[MSG_LENGTH];
STATUS tmp_status[20];
void *gds__trans;
BOOLEAN found;
@ -283,7 +282,7 @@ SSHORT SECURITY_exec_line(STATUS * isc_status,
strcpy(user_data->first_name, U.FIRST_NAME);
strcpy(user_data->middle_name, U.MIDDLE_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;
END_FOR
@ -302,7 +301,7 @@ SSHORT SECURITY_exec_line(STATUS * isc_status,
strcpy(user_data->first_name, U.FIRST_NAME);
strcpy(user_data->middle_name, U.MIDDLE_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;
END_FOR