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

Cleanup, const correctness, variables in scope, etc.

Having done my best to merge everyone else's changes, I hope the tree can be build with whatever other tools != MSVC6.
This commit is contained in:
robocop 2003-09-25 11:49:12 +00:00
parent af9399585a
commit 484c6ec372
99 changed files with 4391 additions and 4804 deletions

View File

@ -24,7 +24,7 @@
//
//____________________________________________________________
//
// $Id: alice.cpp,v 1.36 2003-09-22 14:11:14 brodsom Exp $
// $Id: alice.cpp,v 1.37 2003-09-25 11:48:56 robocop Exp $
//
// 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
// conditionals, as the engine now fully supports
@ -105,7 +105,7 @@ static bool fAnsiCP = false;
static void ALICE_error(USHORT number); // overloaded to keep down param count
static inline void translate_cp(TEXT* sz);
static void expand_filename(TEXT*, TEXT*);
static void expand_filename(const TEXT*, TEXT*);
#ifndef SUPERSERVER
static int output_main(SLONG, UCHAR*);
#endif
@ -182,12 +182,6 @@ int common_main(int argc,
pfn_svc_output output_proc,
SLONG output_data)
{
IN_SW_TAB table = alice_in_sw_table;
bool error;
TEXT* database;
TEXT string[512];
ULONG switches;
#ifdef SERVICE_REDIRECT
SLONG redir_in;
SLONG redir_out;
@ -226,7 +220,7 @@ int common_main(int argc,
tdgbl->sw_service_thd = false;
tdgbl->service_blk = NULL;
tdgbl->status =
/* TMN: cast away volatile */
// TMN: cast away volatile
(long *) tdgbl->status_vector;
if (argc > 1 && !strcmp(argv[1], "-svc")) {
@ -287,18 +281,23 @@ int common_main(int argc,
// Start by parsing switches
error = false;
switches = 0;
bool error = false;
ULONG switches = 0;
tdgbl->ALICE_data.ua_shutdown_delay = 0;
database = NULL;
TEXT* database = NULL;
TEXT string[512];
argv++;
// tested outside the loop
const in_sw_tab_t* table = alice_in_sw_table;
while (--argc > 0)
{
if ((*argv)[0] != '-')
{
if (database) {
ALICE_error(1, database, 0, 0, 0, 0); /* msg 1: "data base file name (%s) already given", */
ALICE_error(1, database, 0, 0, 0, 0);
// msg 1: "data base file name (%s) already given",
}
database = *argv++;
@ -314,7 +313,7 @@ int common_main(int argc,
#endif
continue;
}
ALICE_down_case(*argv++, string);
ALICE_down_case(*argv++, string, sizeof(string));
if (!string[1]) {
continue;
}
@ -322,7 +321,7 @@ int common_main(int argc,
{
const TEXT* p = (TEXT*) table->in_sw_name;
if (!p) {
ALICE_print(2, *--argv, 0, 0, 0, 0); /* msg 2: invalid switch %s */
ALICE_print(2, *--argv, 0, 0, 0, 0); // msg 2: invalid switch %s
error = true;
break;
}
@ -342,11 +341,11 @@ int common_main(int argc,
tdgbl->ALICE_data.ua_debug++;
}
if (table->in_sw_value == sw_z) {
ALICE_print(3, GDS_VERSION, 0, 0, 0, 0); /* msg 3: gfix version %s */
ALICE_print(3, GDS_VERSION, 0, 0, 0, 0); // msg 3: gfix version %s
}
if ((table->in_sw_incompatibilities & switches) ||
(table->in_sw_requires && !(table->in_sw_requires & switches))) {
ALICE_print(4, 0, 0, 0, 0, 0); /* msg 4: incompatible switch combination */
ALICE_print(4, 0, 0, 0, 0, 0); // msg 4: incompatible switch combination
error = true;
break;
}
@ -354,53 +353,53 @@ int common_main(int argc,
if (table->in_sw_value & sw_begin_log) {
if (--argc <= 0) {
ALICE_error(5); /* msg 5: replay log pathname required */
ALICE_error(5); // msg 5: replay log pathname required
}
expand_filename(*argv++, /* TMN: cast away volatile */
expand_filename(*argv++, // TMN: cast away volatile
(TEXT *) tdgbl->ALICE_data.ua_log_file);
}
if (table->in_sw_value & (sw_buffers)) {
if (--argc <= 0) {
ALICE_error(6); /* msg 6: number of page buffers for cache required */
ALICE_error(6); // msg 6: number of page buffers for cache required
}
ALICE_down_case(*argv++, string);
ALICE_down_case(*argv++, string, sizeof(string));
if ((!(tdgbl->ALICE_data.ua_page_buffers = atoi(string)))
&& (strcmp(string, "0")))
{
ALICE_error(7); /* msg 7: numeric value required */
ALICE_error(7); // msg 7: numeric value required
}
if (tdgbl->ALICE_data.ua_page_buffers < 0) {
ALICE_error(8); /* msg 8: positive numeric value required */
ALICE_error(8); // msg 8: positive numeric value required
}
}
if (table->in_sw_value & (sw_housekeeping)) {
if (--argc <= 0) {
ALICE_error(113); /* msg 113: dialect number required */
ALICE_error(113); // msg 113: dialect number required
}
ALICE_down_case(*argv++, string);
ALICE_down_case(*argv++, string, sizeof(string));
if ((!(tdgbl->ALICE_data.ua_sweep_interval = atoi(string)))
&& (strcmp(string, "0")))
{
ALICE_error(7); /* msg 7: numeric value required */
ALICE_error(7); // msg 7: numeric value required
}
if (tdgbl->ALICE_data.ua_sweep_interval < 0) {
ALICE_error(8); /* msg 8: positive numeric value required */
ALICE_error(8); // msg 8: positive numeric value required
}
}
if (table->in_sw_value & (sw_set_db_dialect)) {
if (--argc <= 0) {
ALICE_error(113); /* msg 113: dialect info is required XXX */
ALICE_error(113); // msg 113: dialect info is required XXX
}
ALICE_down_case(*argv++, string);
ALICE_down_case(*argv++, string, sizeof(string));
if ((!(tdgbl->ALICE_data.ua_db_SQL_dialect = atoi(string))) &&
(strcmp(string, "0")))
{
ALICE_error(7); /* msg 7: numeric value required */
ALICE_error(7); // msg 7: numeric value required
}
// JMB: Removed because tdgbl->ALICE_data.ua_db_SQL_dialect is
@ -416,7 +415,7 @@ int common_main(int argc,
if (--argc <= 0) {
ALICE_error(10); /* msg 10: transaction number or "all" required */
}
ALICE_down_case(*argv++, string);
ALICE_down_case(*argv++, string, sizeof(string));
if (!(tdgbl->ALICE_data.ua_transaction = atoi(string))) {
if (strcmp(string, "all")) {
ALICE_error(10); /* msg 10: transaction number or "all" required */
@ -430,7 +429,7 @@ int common_main(int argc,
if (--argc <= 0) {
ALICE_error(11); /* msg 11: "sync" or "async" required */
}
ALICE_down_case(*argv++, string);
ALICE_down_case(*argv++, string, sizeof(string));
if (!strcmp(string, ALICE_SW_SYNC)) {
tdgbl->ALICE_data.ua_force = true;
} else if (!strcmp(string, ALICE_SW_ASYNC)) {
@ -444,7 +443,7 @@ int common_main(int argc,
if (--argc <= 0) {
ALICE_error(12); /* msg 12: "full" or "reserve" required */
}
ALICE_down_case(*argv++, string);
ALICE_down_case(*argv++, string, sizeof(string));
if (!strcmp(string, "full")) {
tdgbl->ALICE_data.ua_use = true;
} else if (!strcmp(string, "reserve")) {
@ -456,7 +455,7 @@ int common_main(int argc,
if (table->in_sw_value & sw_user) {
if (--argc <= 0) {
ALICE_error(13); /* msg 13: user name required */
ALICE_error(13); // msg 13: user name required
}
tdgbl->ALICE_data.ua_user =
const_cast<UCHAR* volatile>(reinterpret_cast<UCHAR*>(*argv++));
@ -464,7 +463,7 @@ int common_main(int argc,
if (table->in_sw_value & sw_password) {
if (--argc <= 0) {
ALICE_error(14); /* msg 14: password required */
ALICE_error(14); // msg 14: password required
}
tdgbl->ALICE_data.ua_password =
const_cast<UCHAR* volatile>(reinterpret_cast<UCHAR*>(*argv++));
@ -472,9 +471,9 @@ int common_main(int argc,
if (table->in_sw_value & sw_disable) {
if (--argc <= 0) {
ALICE_error(15); /* msg 15: subsystem name */
ALICE_error(15); // msg 15: subsystem name
}
ALICE_down_case(*argv++, string);
ALICE_down_case(*argv++, string, sizeof(string));
if (strcmp(string, "wal")) {
ALICE_error(16); /* msg 16: "wal" required */
}
@ -482,18 +481,18 @@ int common_main(int argc,
if (table->in_sw_value & (sw_attach | sw_force | sw_tran | sw_cache)) {
if (--argc <= 0) {
ALICE_error(17); /* msg 17: number of seconds required */
ALICE_error(17); // msg 17: number of seconds required
}
ALICE_down_case(*argv++, string);
ALICE_down_case(*argv++, string, sizeof(string));
if ((!(tdgbl->ALICE_data.ua_shutdown_delay = atoi(string)))
&& (strcmp(string, "0")))
{
ALICE_error(7); /* msg 7: numeric value required */
ALICE_error(7); // msg 7: numeric value required
}
if (tdgbl->ALICE_data.ua_shutdown_delay < 0
|| tdgbl->ALICE_data.ua_shutdown_delay > 32767)
{
ALICE_error(18); /* msg 18: numeric value between 0 and 32767 inclusive required */
ALICE_error(18); // msg 18: numeric value between 0 and 32767 inclusive required
}
}
@ -501,7 +500,7 @@ int common_main(int argc,
if (--argc <= 0) {
ALICE_error(110); /* msg 110: "read_only" or "read_write" required */
}
ALICE_down_case(*argv++, string);
ALICE_down_case(*argv++, string, sizeof(string));
if (!strcmp(string, ALICE_SW_MODE_RO)) {
tdgbl->ALICE_data.ua_read_only = true;
} else if (!strcmp(string, ALICE_SW_MODE_RW)) {
@ -518,7 +517,7 @@ int common_main(int argc,
if ((switches & sw_shut)
&& !(switches & ((sw_attach | sw_force | sw_tran | sw_cache))))
{
ALICE_error(19); /* msg 19: must specify type of shutdown */
ALICE_error(19); // msg 19: must specify type of shutdown
}
// catch the case where -z is only command line option
@ -529,7 +528,7 @@ int common_main(int argc,
if (!switches || !(switches & ~(sw_user | sw_password))) {
#ifndef SUPERSERVER
ALICE_print(20, 0, 0, 0, 0, 0); /* msg 20: please retry, specifying an option */
ALICE_print(20, 0, 0, 0, 0, 0); // msg 20: please retry, specifying an option
#endif
error = true;
}
@ -550,7 +549,7 @@ int common_main(int argc,
}
if (!database) {
ALICE_error(23); /* msg 23: please retry, giving a database name */
ALICE_error(23); // msg 23: please retry, giving a database name
}
// generate the database parameter block for the attach,
@ -609,13 +608,13 @@ int common_main(int argc,
int exit_code = tdgbl->exit_code;
/* Close the status output file */
// Close the status output file
if (tdgbl->sw_redirect == REDIRECT && tdgbl->output_file != NULL) {
ib_fclose(tdgbl->output_file);
tdgbl->output_file = NULL;
}
/* Free all unfreed memory used by Gfix itself */
// Free all unfreed memory used by Gfix itself
ALLA_fini();
RESTORE_THREAD_DATA;
@ -627,7 +626,7 @@ int common_main(int argc,
gds_alloc_report(0, __FILE__, __LINE__);
#endif
/* All returns occur from this point - even normal returns */
// All returns occur from this point - even normal returns
return exit_code;
} // catch
@ -640,11 +639,10 @@ int common_main(int argc,
// Copy a string, down casing as we go.
//
void ALICE_down_case(TEXT * in, TEXT * out)
void ALICE_down_case(const TEXT* in, TEXT* out, const size_t buf_size)
{
TEXT c;
while (c = *in++) {
const TEXT* const end = out + buf_size - 1;
for (TEXT c = *in++; c && out < end; c = *in++) {
*out++ = (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c;
}
*out = 0;
@ -657,11 +655,11 @@ void ALICE_down_case(TEXT * in, TEXT * out)
//
void ALICE_print(USHORT number,
TEXT* arg1,
TEXT* arg2,
TEXT* arg3,
TEXT* arg4,
TEXT* arg5)
const TEXT* arg1,
const TEXT* arg2,
const TEXT* arg3,
const TEXT* arg4,
const TEXT* arg5)
{
TEXT buffer[256];
@ -678,14 +676,11 @@ void ALICE_print(USHORT number,
// to allow redirecting output.
//
void ALICE_print_status(ISC_STATUS* status_vector)
void ALICE_print_status(const ISC_STATUS* status_vector)
{
ISC_STATUS* vector;
SCHAR s[1024];
if (status_vector)
{
vector = status_vector;
const ISC_STATUS* vector = status_vector;
#ifdef SUPERSERVER
int i = 0, j;
TGBL tdgbl = GET_THREAD_DATA;
@ -699,11 +694,13 @@ void ALICE_print_status(ISC_STATUS* status_vector)
}
}
#endif
SCHAR s[1024];
isc_interprete(s, &vector);
translate_cp(s);
alice_output("%s\n", s);
/* Continuation of error */
// Continuation of error
s[0] = '-';
while (isc_interprete(s + 1, &vector)) {
translate_cp(s);
@ -719,11 +716,11 @@ void ALICE_print_status(ISC_STATUS* status_vector)
//
void ALICE_error(USHORT number,
TEXT* arg1,
TEXT* arg2,
TEXT* arg3,
TEXT* arg4,
TEXT* arg5)
const TEXT* arg1,
const TEXT* arg2,
const TEXT* arg3,
const TEXT* arg4,
const TEXT* arg5)
{
TGBL tdgbl = GET_THREAD_DATA;
TEXT buffer[256];
@ -813,9 +810,9 @@ static inline void translate_cp(TEXT* sz)
//
// Fully expand a file name. If the file doesn't exist, do something
// intelligent.
//
// CVC: The above comment is either a joke or a copy/paste.
static void expand_filename(TEXT * filename, TEXT * expanded_name)
static void expand_filename(const TEXT* filename, TEXT* expanded_name)
{
strcpy(expanded_name, filename);
}

View File

@ -4,7 +4,7 @@
*____________________________________________________________
*
* PROGRAM: Alice (All Else) Utility
* MODULE: met.e
* MODULE: alice_meta.epp
* DESCRIPTION: Metadata lookup routines
*
* The contents of this file are subject to the Interbase Public
@ -27,7 +27,7 @@
*
*____________________________________________________________
*
* $Id: alice_meta.epp,v 1.20 2003-09-23 19:47:22 brodsom Exp $
* $Id: alice_meta.epp,v 1.21 2003-09-25 11:48:57 robocop Exp $
*/
#include "firebird.h"
@ -69,18 +69,18 @@ static USHORT snarf_blob(SLONG[2], USHORT, TEXT *);
fields in system relations
*/
typedef struct rfr_tab_t {
struct rfr_tab_t {
TEXT *relation;
TEXT *field;
int bit_mask;
} *RFR_TAB;
};
static rfr_tab_t rfr_table[] = {
static const rfr_tab_t rfr_table[] = {
{ "RDB$TRANSACTIONS", "RDB$TRANSACTION_DESCRIPTION", CAP_transactions },
{ 0, 0, 0 }
};
static inline void return_error(ISC_STATUS *user_status)
static inline void return_error(ISC_STATUS* user_status)
{
ALICE_print_status(gds_status);
Firebird::status_exception::raise(0);
@ -92,12 +92,10 @@ static inline void return_error(ISC_STATUS *user_status)
* Drop all the entries from RDB$LOG_FILES
*/
void MET_disable_wal(ISC_STATUS * user_status, isc_db_handle handle)
void MET_disable_wal(ISC_STATUS* user_status, isc_db_handle handle)
{
FRBRD *request = NULL;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
TGBL tdgbl = GET_THREAD_DATA;
if (!(DB = handle))
return;
@ -107,7 +105,8 @@ void MET_disable_wal(ISC_STATUS * user_status, isc_db_handle handle)
return_error(user_status);
END_ERROR;
FOR(REQUEST_HANDLE request)
X IN RDB$LOG_FILES ERASE X;
X IN RDB$LOG_FILES
ERASE X;
END_FOR
COMMIT
ON_ERROR
@ -123,15 +122,14 @@ void MET_disable_wal(ISC_STATUS * user_status, isc_db_handle handle)
* already been attached.
*/
void MET_get_state(ISC_STATUS * user_status, TDR trans)
void MET_get_state(ISC_STATUS* user_status, TDR trans)
{
FRBRD *request = NULL;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
FRBRD* request = NULL;
TGBL tdgbl = GET_THREAD_DATA;
if (!(DB = trans->tdr_db_handle) ||
!(trans->tdr_db_caps & CAP_transactions)) {
!(trans->tdr_db_caps & CAP_transactions))
{
trans->tdr_state = TRA_unknown;
return;
}
@ -169,14 +167,11 @@ void MET_get_state(ISC_STATUS * user_status, TDR trans)
* in other databases.
*/
TDR MET_get_transaction(ISC_STATUS * user_status, isc_db_handle handle, SLONG id)
TDR MET_get_transaction(ISC_STATUS* user_status, isc_db_handle handle, SLONG id)
{
FRBRD *request = NULL;
FRBRD* request = NULL;
TDR trans = NULL;
USHORT capabilities;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
TGBL tdgbl = GET_THREAD_DATA;
if (!(DB = handle))
return 0;
@ -186,7 +181,7 @@ TDR MET_get_transaction(ISC_STATUS * user_status, isc_db_handle handle, SLONG id
return_error(user_status);
END_ERROR;
capabilities = get_capabilities(user_status);
const USHORT capabilities = get_capabilities(user_status);
if (capabilities & CAP_transactions) {
FOR(REQUEST_HANDLE request)
@ -223,11 +218,9 @@ TDR MET_get_transaction(ISC_STATUS * user_status, isc_db_handle handle, SLONG id
* the database for a particular transaction.
*/
void MET_set_capabilities(ISC_STATUS * user_status, TDR trans)
void MET_set_capabilities(ISC_STATUS* user_status, TDR trans)
{
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
TGBL tdgbl = GET_THREAD_DATA;
if (!(DB = trans->tdr_db_handle))
return;
@ -251,21 +244,16 @@ void MET_set_capabilities(ISC_STATUS * user_status, TDR trans)
* Eat a string with a byte-encoded length.
*/
static STR alloc_string(TEXT ** ptr)
static STR alloc_string(TEXT** ptr)
{
TEXT *p, *q;
USHORT length;
STR string;
TGBL tdgbl;
TGBL tdgbl = GET_THREAD_DATA;
tdgbl = GET_THREAD_DATA;
TEXT* p = *ptr;
p = *ptr;
USHORT length = (USHORT) *p++;
STR string = FB_NEW_RPT(*tdgbl->ALICE_default_pool, length + 1) str;
length = (USHORT) * p++;
string = FB_NEW_RPT(*tdgbl->ALICE_default_pool, length + 1) str;
q = (TEXT *) string->str_data;
TEXT* q = (TEXT *) string->str_data;
while (length--)
*q++ = *p++;
*q = 0;
@ -283,25 +271,21 @@ static STR alloc_string(TEXT ** ptr)
* the database for a particular transaction.
*/
static USHORT get_capabilities(ISC_STATUS * user_status)
static USHORT get_capabilities(ISC_STATUS* user_status)
{
FRBRD *req;
RFR_TAB rel_field_table;
USHORT capabilities = CAP_none;
TGBL tdgbl;
TGBL tdgbl = GET_THREAD_DATA;
tdgbl = GET_THREAD_DATA;
// Look for desired fields in system relations
FRBRD* req = NULL;
req = NULL;
/* Look for desired fields in system relations */
for (rel_field_table = rfr_table; rel_field_table->relation;
rel_field_table++) {
FOR(REQUEST_HANDLE req) x IN DB.
RDB$RELATION_FIELDS WITH x.RDB$RELATION_NAME =
rel_field_table->relation AND x.RDB$FIELD_NAME =
rel_field_table->field capabilities |= rel_field_table->bit_mask;
for (const rfr_tab_t* rel_field_table = rfr_table; rel_field_table->relation;
rel_field_table++)
{
FOR(REQUEST_HANDLE req) x IN DB.RDB$RELATION_FIELDS
WITH x.RDB$RELATION_NAME = rel_field_table->relation
AND x.RDB$FIELD_NAME = rel_field_table->field
capabilities |= rel_field_table->bit_mask;
END_FOR
ON_ERROR
return_error(user_status);
@ -328,25 +312,22 @@ static TDR get_description(SLONG blob_id[2])
{
SLONG id_length, id;
USHORT length;
TEXT buffer[1024], *bigger_buffer, *p;
TDR trans, ptr;
STR host_site, database_path;
TGBL tdgbl;
TEXT buffer[1024], *bigger_buffer;
TGBL tdgbl = GET_THREAD_DATA;
tdgbl = GET_THREAD_DATA;
p = buffer;
TEXT* p = buffer;
if (length = snarf_blob(blob_id, (USHORT) sizeof(buffer), buffer)) {
p = bigger_buffer = (TEXT *) gds__alloc((SLONG) length);
snarf_blob(blob_id, length, bigger_buffer);
}
trans = NULL;
host_site = database_path = NULL;
/* skip version number */
TDR trans = NULL;
STR host_site = NULL, database_path = NULL;
// skip version number
p++;
TDR ptr;
while (*p)
switch (*p++) {
@ -401,11 +382,9 @@ static void parse_fullpath(TDR trans)
{
TEXT *start, *p, *q, *end;
USHORT length;
TGBL tdgbl;
TGBL tdgbl = GET_THREAD_DATA;
tdgbl = GET_THREAD_DATA;
/* start at the end of the full pathname */
// start at the end of the full pathname
start = p = (TEXT*) trans->tdr_fullpath->str_data;
while (*p)
@ -447,7 +426,7 @@ static void parse_fullpath(TDR trans)
p -= 2;
trans->tdr_filename = p + 1;
/* now find the last remote node in the chain */
// now find the last remote node in the chain
while (p > start && (*p == ':' || *p == '^' || *p == '@'))
p--;
@ -478,28 +457,24 @@ static USHORT snarf_blob(SLONG blob_id[2],
USHORT buffer_length, TEXT * buffer)
{
USHORT returned_length;
TEXT *ptr, *end;
ISC_STATUS status;
FRBRD *blob;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
TGBL tdgbl = GET_THREAD_DATA;
if (buffer_length)
buffer[0] = 0;
if (buffer_length > 1)
buffer[1] = 0;
blob = NULL;
FRBRD* blob = NULL;
if (gds__open_blob(gds_status, &DB, &gds_trans, &blob, (GDS_QUAD*) blob_id)) {
ALICE_print_status(gds_status);
return 0;
}
/* get the blob into the buffer, if it fits */
// get the blob into the buffer, if it fits
ptr = buffer;
end = buffer + buffer_length;
TEXT* ptr = buffer;
TEXT* const end = buffer + buffer_length;
for (;;) {
if (ptr >= end)
break;
@ -512,7 +487,7 @@ static USHORT snarf_blob(SLONG blob_id[2],
ptr += returned_length;
}
/* snarf failed, get length of blob for retry */
// snarf failed, get length of blob for retry
if (!buffer_length)
for (;;) {
@ -531,3 +506,4 @@ static USHORT snarf_blob(SLONG blob_id[2],
return buffer_length;
}

View File

@ -2,7 +2,7 @@
/*
* PROGRAM: Alice (All Else) Utility
* MODULE: alice_proto.h
* DESCRIPTION: Prototype header file for alice.c
* DESCRIPTION: Prototype header file for alice.cpp
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
@ -29,9 +29,12 @@
int ALICE_main(SVC service);
#endif
void ALICE_down_case(TEXT*, TEXT*);
void ALICE_print(USHORT, TEXT*, TEXT*, TEXT*, TEXT*, TEXT*);
void ALICE_error(USHORT, TEXT*, TEXT*, TEXT*, TEXT*, TEXT*);
void ALICE_print_status(ISC_STATUS*);
void ALICE_down_case(const TEXT*, TEXT*, const size_t);
void ALICE_print(USHORT, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, const TEXT*);
void ALICE_error(USHORT, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, const TEXT*);
void ALICE_print_status(const ISC_STATUS*);
#endif // ALICE_ALICE_PROTO_H

View File

@ -24,7 +24,7 @@
//
//____________________________________________________________
//
// $Id: all.cpp,v 1.12 2003-09-15 16:25:49 brodsom Exp $
// $Id: all.cpp,v 1.13 2003-09-25 11:48:57 robocop Exp $
//
#include "../alice/all.h"
@ -50,7 +50,7 @@ void ALLA_fini(void)
{
TGBL tdgbl = GET_THREAD_DATA;
for(tgbl::pool_vec_t::iterator curr = tdgbl->pools.begin();
for (tgbl::pool_vec_t::iterator curr = tdgbl->pools.begin();
curr != tdgbl->pools.end(); ++curr)
{
AliceMemoryPool::deletePool(*curr);
@ -70,9 +70,7 @@ void ALLA_fini(void)
void ALLA_init(void)
{
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
TGBL tdgbl = GET_THREAD_DATA;
#ifdef NOT_USED_OR_REPLACED
tdgbl->ALICE_default_pool = tdgbl->ALICE_permanent_pool =
AliceMemoryPool::create_new_pool();
@ -97,13 +95,10 @@ void AliceMemoryPool::ALLA_push(class blk *object, class lls** stack)
* Push an object on an LLS stack.
*
**************************************/
class lls* node;
AliceMemoryPool* pool;
TGBL tdgbl = GET_THREAD_DATA;
pool = tdgbl->ALICE_default_pool;
AliceMemoryPool* pool = tdgbl->ALICE_default_pool;
node = pool->lls_cache.newBlock();
class lls* node = pool->lls_cache.newBlock();
node->lls_object = object;
node->lls_next = *stack;
*stack = node;
@ -123,15 +118,11 @@ BLK AliceMemoryPool::ALLA_pop(LLS *stack)
* further use.
*
**************************************/
LLS node;
AliceMemoryPool* pool;
BLK object;
node = *stack;
LLS node = *stack;
*stack = node->lls_next;
object = node->lls_object;
BLK object = node->lls_object;
pool = (AliceMemoryPool*)MemoryPool::blk_pool(node);
AliceMemoryPool* pool = (AliceMemoryPool*)MemoryPool::blk_pool(node);
pool->lls_cache.returnBlock(node);
return object;
@ -157,7 +148,7 @@ AliceMemoryPool* AliceMemoryPool::create_new_pool(MemoryPool* parent)
AliceMemoryPool* pool = new(0, parent) AliceMemoryPool(parent);
tgbl::pool_vec_t::iterator curr;
for(curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
for (curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
{
if (!*curr)
{
@ -167,7 +158,7 @@ AliceMemoryPool* AliceMemoryPool::create_new_pool(MemoryPool* parent)
}
tdgbl->pools.resize(tdgbl->pools.size() + 10);
for(curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
for (curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
{
if (!*curr)
{
@ -186,7 +177,7 @@ void AliceMemoryPool::deletePool(AliceMemoryPool* pool) {
TGBL tdgbl = GET_THREAD_DATA;
tgbl::pool_vec_t::iterator curr;
for(curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
for (curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
{
if (*curr == pool)
{
@ -197,3 +188,4 @@ void AliceMemoryPool::deletePool(AliceMemoryPool* pool) {
pool->lls_cache.~BlockCache<lls>();
MemoryPool::deletePool(pool);
}

View File

@ -24,7 +24,7 @@
//
//____________________________________________________________
//
// $Id: exe.cpp,v 1.18 2003-09-22 08:49:45 brodsom Exp $
// $Id: exe.cpp,v 1.19 2003-09-25 11:48:57 robocop Exp $
//
// 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
// conditionals, as the engine now fully supports
@ -85,29 +85,22 @@ static inline void stuff_dpb_long(UCHAR **d, int blr)
int EXE_action(TEXT * database, ULONG switches)
{
UCHAR dpb[128];
USHORT dpb_length;
bool error;
FRBRD *handle;
UCHAR error_string[128];
USHORT i;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
TGBL tdgbl = GET_THREAD_DATA;
ALLA_init();
for (i = 0; i < MAX_VAL_ERRORS; i++)
for (USHORT i = 0; i < MAX_VAL_ERRORS; i++)
tdgbl->ALICE_data.ua_val_errors[i] = 0;
// generate the database parameter block for the attach,
// based on the various switches
dpb_length = build_dpb(dpb, switches);
const USHORT dpb_length = build_dpb(dpb, switches);
error = false;
handle = NULL;
bool error = false;
FRBRD* handle = NULL;
gds__attach_database(tdgbl->status, 0, database, &handle, dpb_length,
reinterpret_cast <SCHAR *>(dpb));
reinterpret_cast<SCHAR*>(dpb));
SVC_STARTED(tdgbl->service_blk);
@ -118,10 +111,11 @@ int EXE_action(TEXT * database, ULONG switches)
ALICE_print_status(tdgbl->status);
if (handle != NULL) {
UCHAR error_string[128];
if ((switches & sw_validate) && (tdgbl->status[1] != isc_bug_check)) {
gds__database_info(tdgbl->status, &handle, sizeof(val_errors),
val_errors, sizeof(error_string),
reinterpret_cast < char *>(error_string));
reinterpret_cast<char*>(error_string));
extract_db_info(error_string);
}
@ -145,28 +139,22 @@ int EXE_action(TEXT * database, ULONG switches)
int EXE_two_phase(TEXT * database, ULONG switches)
{
UCHAR dpb[128];
USHORT dpb_length;
bool error;
FRBRD *handle;
USHORT i;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
TGBL tdgbl = GET_THREAD_DATA;
ALLA_init();
for (i = 0; i < MAX_VAL_ERRORS; i++)
for (USHORT i = 0; i < MAX_VAL_ERRORS; i++)
tdgbl->ALICE_data.ua_val_errors[i] = 0;
// generate the database parameter block for the attach,
// based on the various switches
dpb_length = build_dpb(dpb, switches);
const USHORT dpb_length = build_dpb(dpb, switches);
error = false;
handle = NULL;
bool error = false;
FRBRD* handle = NULL;
gds__attach_database(tdgbl->status, 0, database, &handle,
dpb_length, reinterpret_cast < char *>(dpb));
dpb_length, reinterpret_cast<char*>(dpb));
SVC_STARTED(tdgbl->service_blk);
@ -196,15 +184,10 @@ int EXE_two_phase(TEXT * database, ULONG switches)
static USHORT build_dpb(UCHAR * dpb, ULONG switches)
{
UCHAR *dpb2;
USHORT dpb_length;
SSHORT i;
TEXT *q;
TGBL tdgbl;
TGBL tdgbl = GET_THREAD_DATA;
tdgbl = GET_THREAD_DATA;
dpb2 = dpb;
UCHAR* dpb2 = dpb;
*dpb2++ = gds_dpb_version1;
*dpb2++ = isc_dpb_gfix_attach;
*dpb2++ = 0;
@ -235,12 +218,10 @@ static USHORT build_dpb(UCHAR * dpb, ULONG switches)
else if (switches & sw_housekeeping) {
*dpb2++ = gds_dpb_sweep_interval;
*dpb2++ = 4;
for (i = 0; i < 4;
i++, tdgbl->ALICE_data.ua_sweep_interval =
tdgbl->ALICE_data.ua_sweep_interval >> 8)
for (int i = 0; i < 4; i++, (tdgbl->ALICE_data.ua_sweep_interval >>= 8))
{
/* TMN: Here we should really have the following assert */
/* assert(tdgbl->ALICE_data.ua_sweep_interval <= MAX_UCHAR); */
// TMN: Here we should really have the following assert
// assert(tdgbl->ALICE_data.ua_sweep_interval <= MAX_UCHAR);
*dpb2++ = (UCHAR) tdgbl->ALICE_data.ua_sweep_interval;
}
}
@ -253,12 +234,10 @@ static USHORT build_dpb(UCHAR * dpb, ULONG switches)
else if (switches & sw_buffers) {
*dpb2++ = isc_dpb_set_page_buffers;
*dpb2++ = 4;
for (i = 0; i < 4;
i++, tdgbl->ALICE_data.ua_page_buffers =
tdgbl->ALICE_data.ua_page_buffers >> 8)
for (int i = 0; i < 4; i++, (tdgbl->ALICE_data.ua_page_buffers >>= 8))
{
/* TMN: Here we should really have the following assert */
/* assert(tdgbl->ALICE_data.ua_page_buffers <= MAX_UCHAR); */
// TMN: Here we should really have the following assert
// assert(tdgbl->ALICE_data.ua_page_buffers <= MAX_UCHAR);
*dpb2++ = (UCHAR) tdgbl->ALICE_data.ua_page_buffers;
}
}
@ -300,10 +279,10 @@ static USHORT build_dpb(UCHAR * dpb, ULONG switches)
*dpb2 |= gds_dpb_shut_transaction;
dpb2++;
*dpb2++ = gds_dpb_shutdown_delay;
*dpb2++ = 2; /* Build room for shutdown delay */
/* TMN: Here we should really have the following assert */
/* assert(tdgbl->ALICE_data.ua_page_buffers <= MAX_USHORT); */
/* or maybe even compare with MAX_SSHORT */
*dpb2++ = 2; // Build room for shutdown delay
// TMN: Here we should really have the following assert
// assert(tdgbl->ALICE_data.ua_page_buffers <= MAX_USHORT);
// or maybe even compare with MAX_SSHORT
*dpb2++ = (UCHAR) tdgbl->ALICE_data.ua_shutdown_delay;
*dpb2++ = (UCHAR) (tdgbl->ALICE_data.ua_shutdown_delay >> 8);
}
@ -327,8 +306,8 @@ static USHORT build_dpb(UCHAR * dpb, ULONG switches)
if (tdgbl->ALICE_data.ua_user) {
*dpb2++ = gds_dpb_user_name;
*dpb2++ = strlen(reinterpret_cast <const char *>(tdgbl->ALICE_data.ua_user));
for (q = reinterpret_cast <TEXT *>(tdgbl->ALICE_data.ua_user); *q;)
*dpb2++ = strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_user));
for (q = reinterpret_cast<TEXT*>(tdgbl->ALICE_data.ua_user); *q;)
*dpb2++ = *q++;
}
@ -337,12 +316,12 @@ static USHORT build_dpb(UCHAR * dpb, ULONG switches)
*dpb2++ = gds_dpb_password;
else
*dpb2++ = gds_dpb_password_enc;
*dpb2++ = strlen(reinterpret_cast <const char *>(tdgbl->ALICE_data.ua_password));
for (q = reinterpret_cast < TEXT * >(tdgbl->ALICE_data.ua_password); *q;)
*dpb2++ = strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_password));
for (q = reinterpret_cast<TEXT*>(tdgbl->ALICE_data.ua_password); *q;)
*dpb2++ = *q++;
}
dpb_length = dpb2 - dpb;
USHORT dpb_length = dpb2 - dpb;
if (dpb_length == 1)
dpb_length = 0;
@ -355,24 +334,20 @@ static USHORT build_dpb(UCHAR * dpb, ULONG switches)
// Extract database info from string
//
static void extract_db_info(UCHAR * db_info_buffer)
static void extract_db_info(UCHAR* db_info_buffer)
{
UCHAR item;
UCHAR *p;
SLONG length;
TGBL tdgbl;
TGBL tdgbl = GET_THREAD_DATA;
tdgbl = GET_THREAD_DATA;
p = db_info_buffer;
UCHAR* p = db_info_buffer;
while ((item = *p++) != gds_info_end) {
length = gds__vax_integer(p, 2);
const SLONG length = gds__vax_integer(p, 2);
p += 2;
/* TMN: Here we should really have the following assert */
/* assert(length <= MAX_SSHORT); */
/* for all cases that use 'length' as input to 'gds__vax_integer' */
// TMN: Here we should really have the following assert
// assert(length <= MAX_SSHORT);
// for all cases that use 'length' as input to 'gds__vax_integer'
switch (item) {
case isc_info_page_errors:
tdgbl->ALICE_data.ua_val_errors[VAL_PAGE_ERRORS] =

View File

@ -24,7 +24,7 @@
//
//____________________________________________________________
//
// $Id: tdr.cpp,v 1.23 2003-09-22 08:49:45 brodsom Exp $
// $Id: tdr.cpp,v 1.24 2003-09-25 11:48:57 robocop Exp $
//
// 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete "Apollo" port
//
@ -80,7 +80,7 @@ static UCHAR limbo_info[] = { gds_info_limbo, gds_info_end };
USHORT TDR_analyze(TDR trans)
{
USHORT state, advice = TRA_none;
USHORT advice = TRA_none;
if (trans == NULL)
return TRA_none;
@ -88,7 +88,7 @@ USHORT TDR_analyze(TDR trans)
// if the tdr for the first transaction is missing,
// we can assume it was committed
state = trans->tdr_state;
USHORT state = trans->tdr_state;
if (state == TRA_none)
state = TRA_commit;
else if (state == TRA_unknown)
@ -96,14 +96,16 @@ USHORT TDR_analyze(TDR trans)
for (trans = trans->tdr_next; trans; trans = trans->tdr_next) {
switch (trans->tdr_state) {
/* an explicitly committed transaction necessitates a check for the
perverse case of a rollback, otherwise a commit if at all possible */
// an explicitly committed transaction necessitates a check for the
// perverse case of a rollback, otherwise a commit if at all possible
case TRA_commit:
if (state == TRA_rollback) {
ALICE_print(105, 0, 0, 0, 0, 0); /* msg 105: Warning: Multidatabase transaction is in inconsistent state for recovery. */
ALICE_print(106, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 106: Transaction %ld was committed, but prior ones were rolled back. */
ALICE_print(105, 0, 0, 0, 0, 0);
// msg 105: Warning: Multidatabase transaction is in inconsistent state for recovery.
ALICE_print(106, reinterpret_cast<char*>(trans->tdr_id), 0,
0, 0, 0);
// msg 106: Transaction %ld was committed, but prior ones were rolled back.
return 0;
}
else
@ -128,9 +130,11 @@ USHORT TDR_analyze(TDR trans)
case TRA_rollback:
if ((state == TRA_commit) || (state == TRA_none)) {
ALICE_print(105, 0, 0, 0, 0, 0); /* msg 105: Warning: Multidatabase transaction is in inconsistent state for recovery. */
ALICE_print(107, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 107: Transaction %ld was rolled back, but prior ones were committed. */
ALICE_print(105, 0, 0, 0, 0, 0);
// msg 105: Warning: Multidatabase transaction is in inconsistent state for recovery.
ALICE_print(107, reinterpret_cast<char*>(trans->tdr_id), 0,
0, 0, 0);
// msg 107: Transaction %ld was rolled back, but prior ones were committed.
return 0;
}
@ -158,8 +162,8 @@ USHORT TDR_analyze(TDR trans)
break;
default:
ALICE_print(67, reinterpret_cast < char *>(trans->tdr_state), 0,
0, 0, 0); /* msg 67: Transaction state %d not in valid range. */
ALICE_print(67, reinterpret_cast<char*>(trans->tdr_state), 0,
0, 0, 0); // msg 67: Transaction state %d not in valid range.
return 0;
}
}
@ -178,16 +182,14 @@ bool TDR_attach_database(ISC_STATUS * status_vector,
TDR trans,
TEXT * pathname)
{
UCHAR dpb[128], *d, *q;
USHORT dpb_length;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
UCHAR dpb[128];
TGBL tdgbl = GET_THREAD_DATA;
if (tdgbl->ALICE_data.ua_debug)
ALICE_print(68, pathname, 0, 0, 0, 0); /* msg 68: ATTACH_DATABASE: attempted attach of %s */
ALICE_print(68, pathname, 0, 0, 0, 0);
// msg 68: ATTACH_DATABASE: attempted attach of %s
d = dpb;
UCHAR* d = dpb;
*d++ = gds_dpb_version1;
*d++ = gds_dpb_no_garbage_collect;
@ -197,8 +199,8 @@ bool TDR_attach_database(ISC_STATUS * status_vector,
if (tdgbl->ALICE_data.ua_user) {
*d++ = gds_dpb_user_name;
*d++ = strlen(reinterpret_cast <const char *>(tdgbl->ALICE_data.ua_user));
for (q = tdgbl->ALICE_data.ua_user; *q;)
*d++ = strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_user));
for (const UCHAR* q = tdgbl->ALICE_data.ua_user; *q;)
*d++ = *q++;
}
@ -208,13 +210,12 @@ bool TDR_attach_database(ISC_STATUS * status_vector,
else
*d++ = gds_dpb_password_enc;
*d++ =
strlen(reinterpret_cast <
const char *>(tdgbl->ALICE_data.ua_password));
for (q = tdgbl->ALICE_data.ua_password; *q;)
strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_password));
for (const UCHAR* q = tdgbl->ALICE_data.ua_password; *q;)
*d++ = *q++;
}
dpb_length = d - dpb;
USHORT dpb_length = d - dpb;
if (dpb_length == 1)
dpb_length = 0;
@ -222,11 +223,11 @@ bool TDR_attach_database(ISC_STATUS * status_vector,
gds__attach_database(status_vector, 0, pathname,
&trans->tdr_db_handle, dpb_length,
reinterpret_cast < char *>(dpb));
reinterpret_cast<char*>(dpb));
if (status_vector[1]) {
if (tdgbl->ALICE_data.ua_debug) {
ALICE_print(69, 0, 0, 0, 0, 0); /* msg 69: failed */
ALICE_print(69, 0, 0, 0, 0, 0); // msg 69: failed
ALICE_print_status(status_vector);
}
return false;
@ -235,7 +236,7 @@ bool TDR_attach_database(ISC_STATUS * status_vector,
MET_set_capabilities(status_vector, trans);
if (tdgbl->ALICE_data.ua_debug)
ALICE_print(70, 0, 0, 0, 0, 0); /* msg 70: succeeded */
ALICE_print(70, 0, 0, 0, 0, 0); // msg 70: succeeded
return true;
}
@ -251,9 +252,8 @@ bool TDR_attach_database(ISC_STATUS * status_vector,
void TDR_get_states(TDR trans)
{
ISC_STATUS_ARRAY status_vector;
TDR ptr;
for (ptr = trans; ptr; ptr = ptr->tdr_next)
for (TDR ptr = trans; ptr; ptr = ptr->tdr_next)
MET_get_state(status_vector, ptr);
}
@ -267,10 +267,9 @@ void TDR_get_states(TDR trans)
void TDR_shutdown_databases(TDR trans)
{
TDR ptr;
ISC_STATUS_ARRAY status_vector;
for (ptr = trans; ptr; ptr = ptr->tdr_next)
for (TDR ptr = trans; ptr; ptr = ptr->tdr_next)
gds__detach_database(status_vector, &ptr->tdr_db_handle);
}
@ -290,31 +289,26 @@ void TDR_shutdown_databases(TDR trans)
void TDR_list_limbo(FRBRD *handle, TEXT * name, ULONG switches)
{
UCHAR buffer[1024], *ptr;
UCHAR buffer[1024];
ISC_STATUS_ARRAY status_vector;
SLONG id;
USHORT item;
bool flag;
USHORT length;
TDR trans;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
TGBL tdgbl = GET_THREAD_DATA;
if (gds__database_info(status_vector, &handle, sizeof(limbo_info),
reinterpret_cast < char *>(limbo_info),
reinterpret_cast<char*>(limbo_info),
sizeof(buffer),
reinterpret_cast < char *>(buffer))) {
reinterpret_cast<char*>(buffer))) {
ALICE_print_status(status_vector);
return;
}
ptr = buffer;
flag = true;
UCHAR* ptr = buffer;
bool flag = true;
while (flag) {
item = *ptr++;
length = (USHORT) gds__vax_integer(ptr, 2);
const USHORT item = *ptr++;
const USHORT length = (USHORT) gds__vax_integer(ptr, 2);
ptr += 2;
switch (item) {
case gds_info_limbo:
@ -327,7 +321,8 @@ void TDR_list_limbo(FRBRD *handle, TEXT * name, ULONG switches)
break;
}
if (!tdgbl->sw_service_thd)
ALICE_print(71, reinterpret_cast < char *>(id), 0, 0, 0, 0); /* msg 71: Transaction %d is in limbo. */
ALICE_print(71, reinterpret_cast<char*>(id), 0, 0, 0, 0);
// msg 71: Transaction %d is in limbo.
if (trans = MET_get_transaction(status_vector, handle, id)) {
#ifdef SUPERSERVER
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_multi_tra_id);
@ -355,7 +350,8 @@ void TDR_list_limbo(FRBRD *handle, TEXT * name, ULONG switches)
case gds_info_truncated:
if (!tdgbl->sw_service_thd)
ALICE_print(72, 0, 0, 0, 0, 0); /* msg 72: More limbo transactions than fit. Try again */
ALICE_print(72, 0, 0, 0, 0, 0);
// msg 72: More limbo transactions than fit. Try again
case gds_info_end:
flag = false;
@ -363,7 +359,8 @@ void TDR_list_limbo(FRBRD *handle, TEXT * name, ULONG switches)
default:
if (!tdgbl->sw_service_thd)
ALICE_print(73, reinterpret_cast < char *>(item), 0, 0, 0, 0); /* msg 73: Unrecognized info item %d */
ALICE_print(73, reinterpret_cast<char*>(item), 0, 0, 0, 0);
// msg 73: Unrecognized info item %d
}
}
}
@ -387,14 +384,13 @@ bool TDR_reconnect_multiple(FRBRD *handle,
TEXT * name,
ULONG switches)
{
TDR trans, ptr;
ISC_STATUS_ARRAY status_vector;
USHORT advice;
bool error = false;
// get the state of all the associated transactions
if (!(trans = MET_get_transaction(status_vector, handle, id)))
TDR trans = MET_get_transaction(status_vector, handle, id);
if (!trans)
return reconnect(handle, id, name, switches);
reattach_databases(trans);
@ -403,7 +399,7 @@ bool TDR_reconnect_multiple(FRBRD *handle,
// analyze what to do with them; if the advice contradicts the user's
// desire, make them confirm it; otherwise go with the flow.
advice = TDR_analyze(trans);
USHORT advice = TDR_analyze(trans);
if (!advice) {
print_description(trans);
@ -413,8 +409,9 @@ bool TDR_reconnect_multiple(FRBRD *handle,
switch (advice) {
case TRA_rollback:
if (switches & sw_commit) {
ALICE_print(74, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 74: "A commit of transaction %ld will violate two-phase commit. */
ALICE_print(74, reinterpret_cast<char*>(trans->tdr_id), 0,
0, 0, 0);
// msg 74: A commit of transaction %ld will violate two-phase commit.
print_description(trans);
switches = ask();
}
@ -423,8 +420,9 @@ bool TDR_reconnect_multiple(FRBRD *handle,
else if (switches & sw_two_phase)
switches |= sw_rollback;
else if (switches & sw_prompt) {
ALICE_print(75, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 75: A rollback of transaction %ld is needed to preserve two-phase commit. */
ALICE_print(75, reinterpret_cast<char*>(trans->tdr_id), 0,
0, 0, 0);
// msg 75: A rollback of transaction %ld is needed to preserve two-phase commit.
print_description(trans);
switches = ask();
}
@ -432,9 +430,11 @@ bool TDR_reconnect_multiple(FRBRD *handle,
case TRA_commit:
if (switches & sw_rollback) {
ALICE_print(76, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 76: Transaction %ld has already been partially committed. */
ALICE_print(77, 0, 0, 0, 0, 0); /* msg 77: A rollback of this transaction will violate two-phase commit. */
ALICE_print(76, reinterpret_cast<char*>(trans->tdr_id), 0,
0, 0, 0);
// msg 76: Transaction %ld has already been partially committed.
ALICE_print(77, 0, 0, 0, 0, 0);
// msg 77: A rollback of this transaction will violate two-phase commit.
print_description(trans);
switches = ask();
}
@ -444,18 +444,22 @@ bool TDR_reconnect_multiple(FRBRD *handle,
switches |= sw_commit;
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. */
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.
print_description(trans);
switches = ask();
}
break;
case TRA_unknown:
ALICE_print(80, 0, 0, 0, 0, 0); /* msg 80: Insufficient information is available to determine */
ALICE_print(81, reinterpret_cast < char *>(trans->tdr_id), 0, 0,
0, 0); /* msg 81: a proper action for transaction %ld. */
ALICE_print(80, 0, 0, 0, 0, 0);
// msg 80: Insufficient information is available to determine
ALICE_print(81, reinterpret_cast<char*>(trans->tdr_id), 0, 0,
0, 0);
// msg 81: a proper action for transaction %ld.
print_description(trans);
switches = ask();
break;
@ -463,9 +467,11 @@ bool TDR_reconnect_multiple(FRBRD *handle,
default:
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. */
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.
print_description(trans);
switches = ask();
}
@ -474,11 +480,11 @@ bool TDR_reconnect_multiple(FRBRD *handle,
if (switches != (ULONG) - 1)
{
/* now do the required operation with all the subtransactions */
// now do the required operation with all the subtransactions
if (switches & (sw_commit | sw_rollback))
{
for (ptr = trans; ptr; ptr = ptr->tdr_next)
for (TDR ptr = trans; ptr; ptr = ptr->tdr_next)
{
if (ptr->tdr_state == TRA_limbo)
{
@ -490,7 +496,7 @@ bool TDR_reconnect_multiple(FRBRD *handle,
}
else
{
ALICE_print(84, 0, 0, 0, 0, 0); /* msg 84: unexpected end of input */
ALICE_print(84, 0, 0, 0, 0, 0); // msg 84: unexpected end of input
error = true;
}
@ -512,13 +518,6 @@ bool TDR_reconnect_multiple(FRBRD *handle,
static void print_description(TDR trans)
{
TDR ptr;
bool prepared_seen;
#ifdef SUPERSERVER
int i;
#endif
TGBL tdgbl = GET_THREAD_DATA;
if (!trans)
@ -528,11 +527,11 @@ static void print_description(TDR trans)
if (!tdgbl->sw_service_thd)
{
ALICE_print(92, 0, 0, 0, 0, 0); /* msg 92: Multidatabase transaction: */
ALICE_print(92, 0, 0, 0, 0, 0); // msg 92: Multidatabase transaction:
}
prepared_seen = false;
for (ptr = trans; ptr; ptr = ptr->tdr_next)
bool prepared_seen = false;
for (TDR ptr = trans; ptr; ptr = ptr->tdr_next)
{
if (ptr->tdr_host_site)
{
@ -540,7 +539,7 @@ static void print_description(TDR trans)
reinterpret_cast<char*>(ptr->tdr_host_site->str_data);
#ifndef SUPERSERVER
/* 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);
@ -548,7 +547,7 @@ static void print_description(TDR trans)
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_host_site);
SVC_putc(tdgbl->service_blk, (UCHAR) nHostSiteLen);
SVC_putc(tdgbl->service_blk, (UCHAR) (nHostSiteLen >> 8 ));
for (i = 0; i < (int) nHostSiteLen; i++)
for (int i = 0; i < (int) nHostSiteLen; i++)
{
SVC_putc(tdgbl->service_blk, (UCHAR) pszHostSize[i]);
}
@ -558,7 +557,7 @@ static void print_description(TDR trans)
if (ptr->tdr_id)
{
#ifndef SUPERSERVER
/* msg 94: Transaction %ld */
// 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);
@ -573,7 +572,7 @@ static void print_description(TDR trans)
{
case TRA_limbo:
#ifndef SUPERSERVER
ALICE_print(95, 0, 0, 0, 0, 0); /* msg 95: has been prepared. */
ALICE_print(95, 0, 0, 0, 0, 0); // msg 95: has been prepared.
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state_limbo);
@ -583,7 +582,7 @@ static void print_description(TDR trans)
case TRA_commit:
#ifndef SUPERSERVER
ALICE_print(96, 0, 0, 0, 0, 0); /* msg 96: has been committed. */
ALICE_print(96, 0, 0, 0, 0, 0); // msg 96: has been committed.
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state_commit);
@ -592,7 +591,7 @@ static void print_description(TDR trans)
case TRA_rollback:
#ifndef SUPERSERVER
ALICE_print(97, 0, 0, 0, 0, 0); /* msg 97: has been rolled back. */
ALICE_print(97, 0, 0, 0, 0, 0); // msg 97: has been rolled back.
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state_rollback);
@ -601,7 +600,7 @@ static void print_description(TDR trans)
case TRA_unknown:
#ifndef SUPERSERVER
ALICE_print(98, 0, 0, 0, 0, 0); /* msg 98: is not available. */
ALICE_print(98, 0, 0, 0, 0, 0); // msg 98: is not available.
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state_unknown);
@ -612,12 +611,12 @@ static void print_description(TDR trans)
#ifndef SUPERSERVER
if (prepared_seen)
{
/* 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
{
/* 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
@ -630,7 +629,7 @@ static void print_description(TDR trans)
reinterpret_cast<char*>(ptr->tdr_remote_site->str_data);
#ifndef SUPERSERVER
/*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);
@ -638,7 +637,7 @@ static void print_description(TDR trans)
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_remote_site);
SVC_putc(tdgbl->service_blk, (UCHAR) nRemoteSiteLen);
SVC_putc(tdgbl->service_blk, (UCHAR) (nRemoteSiteLen >> 8));
for (i = 0; i < (int) nRemoteSiteLen; i++)
for (int i = 0; i < (int) nRemoteSiteLen; i++)
{
SVC_putc(tdgbl->service_blk, (UCHAR) pszRemoteSite[i]);
}
@ -651,7 +650,7 @@ static void print_description(TDR trans)
reinterpret_cast<char*>(ptr->tdr_fullpath->str_data);
#ifndef SUPERSERVER
/* 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);
@ -659,7 +658,7 @@ static void print_description(TDR trans)
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_db_path);
SVC_putc(tdgbl->service_blk, (UCHAR) nFullpathLen);
SVC_putc(tdgbl->service_blk, (UCHAR) (nFullpathLen >> 8));
for (i = 0; i < (int) nFullpathLen; i++)
for (int i = 0; i < (int) nFullpathLen; i++)
{
SVC_putc(tdgbl->service_blk, (UCHAR) pszFullpath[i]);
}
@ -674,7 +673,7 @@ static void print_description(TDR trans)
{
case TRA_commit:
#ifndef SUPERSERVER
/* 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);
@ -684,7 +683,7 @@ static void print_description(TDR trans)
case TRA_rollback:
#ifndef SUPERSERVER
/* 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);
@ -711,31 +710,31 @@ static void print_description(TDR trans)
static ULONG ask(void)
{
UCHAR response[32], *p;
int c;
ULONG switches;
TGBL tdgbl;
UCHAR response[32];
char* const resp_ptr = reinterpret_cast<char*>(response);
TGBL tdgbl = GET_THREAD_DATA;
tdgbl = GET_THREAD_DATA;
switches = 0;
ULONG switches = 0;
while (true) {
ALICE_print(85, 0, 0, 0, 0, 0); /* msg 85: Commit, rollback, or neither (c, r, or n)? */
ALICE_print(85, 0, 0, 0, 0, 0);
// msg 85: Commit, rollback, or neither (c, r, or n)?
if (tdgbl->sw_service)
ib_putc('\001', ib_stdout);
ib_fflush(ib_stdout);
int c;
UCHAR* p;
for (p = response; (c = ib_getchar()) != '\n' && c != EOF;)
*p++ = c;
if (c == EOF && p == response)
return (ULONG) - 1;
*p = 0;
ALICE_down_case(reinterpret_cast < char *>(response),
reinterpret_cast < char *>(response));
if (!strcmp(reinterpret_cast < const char *>(response), "n")
|| !strcmp(reinterpret_cast < const char *>(response), "c")
|| !strcmp(reinterpret_cast < const char *>(response), "r"))
ALICE_down_case(resp_ptr, resp_ptr, sizeof(response));
if (!strcmp(resp_ptr, "n") || !strcmp(resp_ptr, "c")
|| !strcmp(resp_ptr, "r"))
{
break;
}
}
if (response[0] == 'c')
@ -756,19 +755,16 @@ static ULONG ask(void)
static void reattach_database(TDR trans)
{
ISC_STATUS_ARRAY status_vector;
UCHAR buffer[1024], *p, *q, *start;
STR string;
TGBL tdgbl;
UCHAR buffer[1024], *p, *q;
TGBL tdgbl = GET_THREAD_DATA;
tdgbl = GET_THREAD_DATA;
ISC_get_host(reinterpret_cast < char *>(buffer), sizeof(buffer));
ISC_get_host(reinterpret_cast<char*>(buffer), sizeof(buffer));
// if this is being run from the same host,
// try to reconnect using the same pathname
if (!strcmp(reinterpret_cast < const char *>(buffer),
reinterpret_cast < const char *>(trans->tdr_host_site->str_data)))
if (!strcmp(reinterpret_cast<const char*>(buffer),
reinterpret_cast<const char*>(trans->tdr_host_site->str_data)))
{
if (TDR_attach_database(status_vector, trans,
reinterpret_cast<char*>
@ -777,8 +773,6 @@ static void reattach_database(TDR trans)
return;
}
}
// try going through the previous host with all available
// protocols, using chaining to try the same method of
// attachment originally used from that host
@ -786,15 +780,12 @@ static void reattach_database(TDR trans)
else if (trans->tdr_host_site) {
for (p = buffer, q = trans->tdr_host_site->str_data; *q;)
*p++ = *q++;
start = p;
p = start;
*p++ = ':';
for (q = trans->tdr_fullpath->str_data; *q;)
*p++ = *q++;
*q = 0;
if (TDR_attach_database(status_vector, trans,
reinterpret_cast < char *>(buffer)))
reinterpret_cast<char*>(buffer)))
{
return;
}
@ -806,15 +797,12 @@ static void reattach_database(TDR trans)
if (trans->tdr_remote_site) {
for (p = buffer, q = trans->tdr_remote_site->str_data; *q;)
*p++ = *q++;
start = p;
p = start;
*p++ = ':';
for (q = (UCHAR *) trans->tdr_filename; *q;)
*p++ = *q++;
*q = 0;
if (TDR_attach_database (status_vector, trans,
reinterpret_cast < char *>(buffer)))
reinterpret_cast<char*>(buffer)))
{
return;
}
@ -823,12 +811,13 @@ static void reattach_database(TDR trans)
// we have failed to reattach; notify the user
// and let them try to succeed where we have failed
ALICE_print(86, reinterpret_cast < char *>(trans->tdr_id), 0, 0, 0, 0); /* msg 86: Could not reattach to database for transaction %ld. */
ALICE_print(87, reinterpret_cast < char *>(trans->tdr_fullpath->str_data),
0, 0, 0, 0); /* msg 87: Original path: %s */
ALICE_print(86, reinterpret_cast<char*>(trans->tdr_id), 0, 0, 0, 0);
// msg 86: Could not reattach to database for transaction %ld.
ALICE_print(87, reinterpret_cast<char*>(trans->tdr_fullpath->str_data),
0, 0, 0, 0); // msg 87: Original path: %s
for (;;) {
ALICE_print(88, 0, 0, 0, 0, 0); /* msg 88: Enter a valid path: */
ALICE_print(88, 0, 0, 0, 0, 0); // msg 88: Enter a valid path:
for (p = buffer; (*p = ib_getchar()) != '\n'; p++);
*p = 0;
if (!buffer[0])
@ -839,7 +828,7 @@ static void reattach_database(TDR trans)
if (TDR_attach_database(status_vector, trans,
reinterpret_cast<char*>(p)))
{
string = FB_NEW_RPT(*tdgbl->ALICE_default_pool,
STR string = FB_NEW_RPT(*tdgbl->ALICE_default_pool,
strlen(reinterpret_cast<const char*>(p)) + 1) str;
strcpy(reinterpret_cast<char*>(string->str_data),
reinterpret_cast<const char*>(p));
@ -848,7 +837,7 @@ static void reattach_database(TDR trans)
trans->tdr_filename = (TEXT *) string->str_data;
return;
}
ALICE_print(89, 0, 0, 0, 0, 0); /* msg 89: Attach unsuccessful. */
ALICE_print(89, 0, 0, 0, 0, 0); // msg 89: Attach unsuccessful.
}
}
@ -862,9 +851,7 @@ static void reattach_database(TDR trans)
static void reattach_databases(TDR trans)
{
TDR ptr;
for (ptr = trans; ptr; ptr = ptr->tdr_next)
for (TDR ptr = trans; ptr; ptr = ptr->tdr_next)
reattach_database(ptr);
}
@ -880,14 +867,12 @@ static bool reconnect(FRBRD *handle,
TEXT * name,
ULONG switches)
{
FRBRD *transaction;
SLONG id;
ISC_STATUS_ARRAY status_vector;
id = gds__vax_integer((UCHAR *) & number, 4);
transaction = NULL;
SLONG id = gds__vax_integer((UCHAR *) & number, 4);
FRBRD* transaction = NULL;
if (gds__reconnect_transaction(status_vector, &handle, &transaction,
sizeof(id), reinterpret_cast <char *>(&id))) {
sizeof(id), reinterpret_cast<char*>(&id))) {
ALICE_print(90, name, 0, 0, 0, 0);
// msg 90: failed to reconnect to a transaction in database %s
ALICE_print_status(status_vector);
@ -895,7 +880,7 @@ static bool reconnect(FRBRD *handle,
}
if (!(switches & (sw_commit | sw_rollback))) {
ALICE_print(91, reinterpret_cast < char *>(number), 0, 0, 0, 0);
ALICE_print(91, reinterpret_cast<char*>(number), 0, 0, 0, 0);
// msg 91: Transaction %ld:
switches = ask();
if (switches == (ULONG) - 1) {
@ -920,3 +905,4 @@ static bool reconnect(FRBRD *handle,
return false;
}

View File

@ -37,7 +37,7 @@
*/
/*
$Id: backup.epp,v 1.40 2003-09-23 19:47:50 brodsom Exp $
$Id: backup.epp,v 1.41 2003-09-25 11:48:59 robocop Exp $
*/
#include "firebird.h"
@ -158,7 +158,7 @@ enum backup_capabilities
};
#ifdef DEBUG
UCHAR debug_on = 0; /* able to turn this on in debug mode */
UCHAR debug_on = 0; // able to turn this on in debug mode
#endif
@ -268,7 +268,7 @@ int BACKUP_backup(TEXT* dbb_file, const TEXT* file_name)
gds_trans = NULL;
BURP_verbose(130, NULL, NULL, NULL, NULL, NULL);
/* msg 130 starting transaction */
// msg 130 starting transaction
if (tdgbl->gbl_sw_ignore_limbo)
{
@ -296,12 +296,12 @@ int BACKUP_backup(TEXT* dbb_file, const TEXT* file_name)
/* decide what type of database we've got */
// decide what type of database we've got
set_capabilities();
/* Write burp record first with other valuable information */
/* In case of split operation, write a 'split' header first to all the files */
// Write burp record first with other valuable information
// In case of split operation, write a 'split' header first to all the files
if (tdgbl->action->act_action == ACT_backup_split)
{
@ -312,7 +312,7 @@ int BACKUP_backup(TEXT* dbb_file, const TEXT* file_name)
{
BURP_error(269, tdgbl->action->act_file->fil_name, 0, 0, 0,
0);
/* msg 269 can't write a header record to file %s */
// msg 269 can't write a header record to file %s
}
}
tdgbl->action->act_file = tdgbl->gbl_sw_files;
@ -322,14 +322,14 @@ int BACKUP_backup(TEXT* dbb_file, const TEXT* file_name)
reinterpret_cast<const UCHAR*>(file_name),
&tdgbl->io_cnt, &tdgbl->io_ptr);
/* Write database record */
// Write database record
write_database(dbb_file);
/* Write global fields */
// Write global fields
BURP_verbose(150, NULL, NULL, NULL, NULL, NULL);
/* msg 150 writing global fields */
// msg 150 writing global fields
write_global_fields();
if (tdgbl->BCK_capabilities & BCK_ods6)
@ -337,65 +337,65 @@ int BACKUP_backup(TEXT* dbb_file, const TEXT* file_name)
write_field_dimensions();
BURP_verbose(162, NULL, NULL, NULL, NULL, NULL);
/* msg 162 writing shadow files */
// msg 162 writing shadow files
write_shadow_files();
}
/* Write relations */
// Write relations
BURP_verbose(154, NULL, NULL, NULL, NULL, NULL);
/* msg 154 writing relations */
// msg 154 writing relations
write_relations();
if (tdgbl->BCK_capabilities & BCK_ffmptt)
{
/* Write functions */
// Write functions
BURP_verbose(148, NULL, NULL, NULL, NULL, NULL);
/* msg 148 writing functions */
// msg 148 writing functions
write_functions();
/* Write types */
// Write types
BURP_verbose(161, NULL, NULL, NULL, NULL, NULL);
/* msg 161 writing types */
// msg 161 writing types
write_types();
/* Write filters */
// Write filters
BURP_verbose(146, NULL, NULL, NULL, NULL, NULL);
/* msg 146 writing filters */
// msg 146 writing filters
write_filters();
/* Write generators */
// Write generators
BURP_verbose(164, NULL, NULL, NULL, NULL, NULL);
/* msg 164 writing id generators */
// msg 164 writing id generators
write_generators();
}
if (tdgbl->BCK_capabilities & BCK_ods8)
{
/* Write procedures */
// Write procedures
BURP_verbose(192, NULL, NULL, NULL, NULL, NULL);
/* msg 192 writing stored procedures */
// msg 192 writing stored procedures
write_procedures();
/* Write exceptions */
// Write exceptions
BURP_verbose(197, NULL, NULL, NULL, NULL, NULL);
/* msg 197 writing exceptions */
// msg 197 writing exceptions
write_exceptions();
/* Write Character Sets */
// Write Character Sets
BURP_verbose(msgVerbose_write_charsets, NULL, NULL, NULL, NULL, NULL);
write_character_sets();
/* Write Collations */
// Write Collations
BURP_verbose(msgVerbose_write_collations, NULL, NULL, NULL, NULL,
NULL);
write_collations();
}
/* Now go back and write all data */
// Now go back and write all data
for (BURP_REL relation = tdgbl->relations; relation; relation = relation->rel_next) {
put(tdgbl, (UCHAR) (rec_relation_data));
@ -417,15 +417,15 @@ int BACKUP_backup(TEXT* dbb_file, const TEXT* file_name)
/* now for the new triggers in rdb$triggers */
if (tdgbl->BCK_capabilities & BCK_ffmptt) {
BURP_verbose(159, NULL, NULL, NULL, NULL, NULL);
/* msg 159 writing triggers */
// msg 159 writing triggers
write_triggers();
BURP_verbose(158, NULL, NULL, NULL, NULL, NULL);
/* msg 158 writing trigger messages */
// msg 158 writing trigger messages
write_trigger_messages();
write_user_privileges();
}
/* Last, but not least, go back and add any access control lists */
// Last, but not least, go back and add any access control lists
if (tdgbl->BCK_capabilities & BCK_security)
{
@ -436,7 +436,7 @@ int BACKUP_backup(TEXT* dbb_file, const TEXT* file_name)
l = PUT_TEXT (att_class_security_class, X.RDB$SECURITY_CLASS);
MISC_terminate (X.RDB$SECURITY_CLASS, temp, l, sizeof(temp));
BURP_verbose (155, temp, NULL, NULL, NULL, NULL);
/* msg 155 writing security class %s */
// msg 155 writing security class %s
put_blr_blob (att_class_acl, (ISC_QUAD *)&X.RDB$ACL);
put_source_blob (att_class_description2, att_class_description,
(ISC_QUAD *)&X.RDB$DESCRIPTION);
@ -451,32 +451,32 @@ int BACKUP_backup(TEXT* dbb_file, const TEXT* file_name)
if (tdgbl->BCK_capabilities & BCK_ods8)
{
/* Write relation constraints */
// Write relation constraints
BURP_verbose(206, NULL, NULL, NULL, NULL, NULL);
/* msg 206 writing relation constraints */
// msg 206 writing relation constraints
write_rel_constraints();
/* Write referential constraints */
// Write referential constraints
BURP_verbose(209, NULL, NULL, NULL, NULL, NULL);
/* msg 209 writing referential constraints */
// msg 209 writing referential constraints
write_ref_constraints();
/* Write check constraints */
// Write check constraints
BURP_verbose(210, NULL, NULL, NULL, NULL, NULL);
/* msg 210 writing check constraints */
// msg 210 writing check constraints
write_check_constraints();
}
if (tdgbl->BCK_capabilities & BCK_ods9)
{
/* Write SQL roles */
// Write SQL roles
BURP_verbose(248, NULL, NULL, NULL, NULL, NULL);
/* msg 248 writing SQL roles */
// msg 248 writing SQL roles
write_sql_roles();
}
/* Finish up */
// Finish up
put(tdgbl, (UCHAR) (rec_end));
@ -484,12 +484,12 @@ int BACKUP_backup(TEXT* dbb_file, const TEXT* file_name)
if (cumul_count <= MAX_SLONG) {
SLONG tempcount = cumul_count;
BURP_verbose(176, (void*) tempcount, NULL, NULL, NULL, NULL);
/* msg 176 closing file, committing, and finishing. %ld bytes written */
// msg 176 closing file, committing, and finishing. %ld bytes written
} else {
char psz[64];
ib_sprintf(psz, "%" QUADFORMAT "d", cumul_count);
BURP_verbose(283, psz, NULL, NULL, NULL, NULL);
/* msg 283 closing file, committing, and finishing. %s bytes written */
// msg 283 closing file, committing, and finishing. %s bytes written
}
COMMIT;
ON_ERROR
@ -799,7 +799,7 @@ BURP_FLD get_fields( BURP_REL relation)
}
blob_id = &Y.RDB$COMPUTED_BLR;
if (blob_id->gds_quad_low || blob_id->gds_quad_high)
field->fld_flags |= FLD_computed;
field->fld_flags |= FLD_computed;
if (tdgbl->BCK_capabilities & BCK_rfr_sys_flag)
{
FOR (REQUEST_HANDLE tdgbl->handles_get_fields_req_handle3)
@ -911,7 +911,7 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
* Read id for a generator;
*
**************************************/
UCHAR blr_buffer[100]; /* enough to fit blr */
UCHAR blr_buffer[100]; // enough to fit blr
SLONG read_msg0;
SINT64 read_msg1;
ISC_STATUS_ARRAY status_vector;
@ -927,7 +927,7 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
*/
if (tdgbl->BCK_capabilities & BCK_ods10)
{
/* build the blr with the right relation name and 64-bit results. */
// build the blr with the right relation name and 64-bit results.
stuff(&blr, blr_version5);
stuff(&blr, blr_begin);
stuff(&blr, blr_message);
@ -958,7 +958,7 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
}
else
{
/* build the blr with the right relation name and 32-bit results */
// build the blr with the right relation name and 32-bit results
stuff(&blr, blr_version4);
stuff(&blr, blr_begin);
stuff(&blr, blr_message);
@ -998,16 +998,16 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
if (isc_compile_request(status_vector, &DB, &gen_id_reqh,
blr_length, (char*) blr_buffer))
{
/* if there's no gen_id, never mind ... */
// if there's no gen_id, never mind ...
return 0;
}
if (isc_start_request(status_vector, &gen_id_reqh,
&gds_trans, /* use the same one generated by gpre */
&gds_trans, // use the same one generated by gpre
0))
{
BURP_error_redirect(status_vector, 25, NULL, NULL);
/* msg 25 Failed in put_blr_gen_id */
// msg 25 Failed in put_blr_gen_id
}
if (tdgbl->BCK_capabilities & BCK_ods10)
@ -1016,7 +1016,7 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
&read_msg1, 0))
{
BURP_error_redirect(status_vector, 25, NULL, NULL);
/* msg 25 Failed in put_blr_gen_id */
// msg 25 Failed in put_blr_gen_id
}
}
else
@ -1025,7 +1025,7 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
&read_msg0, 0))
{
BURP_error_redirect(status_vector, 25, NULL, NULL);
/* msg 25 Failed in put_blr_gen_id */
// msg 25 Failed in put_blr_gen_id
}
read_msg1 = (SINT64) read_msg0;
}
@ -1063,7 +1063,7 @@ void get_ranges( BURP_FLD field)
if (count != X.RDB$DIMENSION)
BURP_error_redirect (NULL, 52, field->fld_name, NULL);
/* msg 52 array dimension for field %s is invalid */
// msg 52 array dimension for field %s is invalid
*rp++ = X.RDB$LOWER_BOUND;
*rp++ = X.RDB$UPPER_BOUND;
count++;
@ -1075,7 +1075,7 @@ void get_ranges( BURP_FLD field)
if (count != field->fld_dimensions)
BURP_error_redirect(NULL, 52, field->fld_name, NULL);
/* msg 52 array dimension for field %s is invalid */
// msg 52 array dimension for field %s is invalid
}
@ -1092,12 +1092,12 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
*
**************************************/
ISC_STATUS_ARRAY status_vector;
SLONG *returned_range, range_buffer[16]; /* enough for 16 dimensions */
UCHAR blr_buffer[200]; /* enough for a sdl with 16 dimensions */
SLONG *returned_range, range_buffer[16]; // enough for 16 dimensions
UCHAR blr_buffer[200]; // enough for a sdl with 16 dimensions
TGBL tdgbl = GET_THREAD_DATA;
/* If the array is null, don't store it. It will be restored as null. */
// If the array is null, don't store it. It will be restored as null.
if (!blob_id->gds_quad_low && !blob_id->gds_quad_high)
return;
@ -1112,7 +1112,7 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
if (tdgbl->gbl_sw_transportable)
xdr_buffer.lstr_length = field_length + 3;
/* build the sdl */
// build the sdl
stuff(&blr, isc_sdl_version1);
@ -1185,7 +1185,7 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
}
UCHAR *slice = BURP_alloc(slice_length);
/* allocate space for the XDR representation */
// allocate space for the XDR representation
if (tdgbl->gbl_sw_transportable)
{
@ -1201,7 +1201,7 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
slice_length, slice, (SLONG*) &return_length))
{
BURP_print(81, field->fld_name, NULL, NULL, NULL, NULL);
/* msg 81 error accessing blob field %s -- continuing */
// msg 81 error accessing blob field %s -- continuing
BURP_print_status(status_vector);
#ifdef DEBUG
PRETTY_print_sdl(blr_buffer, NULL, NULL, 0);
@ -1329,19 +1329,19 @@ void put_blob( BURP_FLD field, ISC_QUAD * blob_id, ULONG count)
TGBL tdgbl = GET_THREAD_DATA;
/* If the blob is null, don't store it. It will be restored as null. */
// If the blob is null, don't store it. It will be restored as null.
if (!blob_id->gds_quad_high && !blob_id->gds_quad_low)
return;
/* Open the blob and get it's vital statistics */
// Open the blob and get it's vital statistics
FRBRD *blob = NULL;
if (isc_open_blob(status_vector, &DB, &gds_trans, &blob, blob_id))
{
BURP_print(81, field->fld_name, NULL, NULL, NULL, NULL);
/* msg 81 error accessing blob field %s -- continuing */
// msg 81 error accessing blob field %s -- continuing
BURP_print_status(status_vector);
return;
}
@ -1351,7 +1351,7 @@ void put_blob( BURP_FLD field, ISC_QUAD * blob_id, ULONG count)
(char*) blob_info))
{
BURP_error_redirect(status_vector, 20, NULL, NULL);
/* msg 20 isc_blob_info failed */
// msg 20 isc_blob_info failed
}
put(tdgbl, (UCHAR) (rec_blob));
@ -1386,11 +1386,11 @@ void put_blob( BURP_FLD field, ISC_QUAD * blob_id, ULONG count)
default:
BURP_error_redirect(NULL, 21, (void*) (ULONG) item, NULL);
/* msg 21 don't understand blob info item %ld */
// msg 21 don't understand blob info item %ld
}
}
/* Allocate a buffer large enough for the largest segment and start grinding. */
// Allocate a buffer large enough for the largest segment and start grinding.
UCHAR* buffer;
if (!max_segment || max_segment <= sizeof(static_buffer))
@ -1408,7 +1408,7 @@ void put_blob( BURP_FLD field, ISC_QUAD * blob_id, ULONG count)
{
BURP_error_redirect(status_vector, 22, NULL, NULL);
}
/* msg 22 gds__get_segment failed */
// msg 22 gds__get_segment failed
put(tdgbl, (UCHAR) (segment_length));
put(tdgbl, (UCHAR) (segment_length >> 8));
@ -1421,7 +1421,7 @@ void put_blob( BURP_FLD field, ISC_QUAD * blob_id, ULONG count)
if (isc_close_blob(status_vector, &blob))
BURP_error_redirect(status_vector, 23, NULL, NULL);
/* msg 23 isc_close_blob failed */
// msg 23 isc_close_blob failed
if (buffer != static_buffer)
BURP_free(buffer);
@ -1446,19 +1446,19 @@ bool put_blr_blob( SCHAR attribute, ISC_QUAD * blob_id)
TGBL tdgbl = GET_THREAD_DATA;
/* If the blob is null, don't store it. It will be restored as null. */
// If the blob is null, don't store it. It will be restored as null.
if (!blob_id->gds_quad_high && !blob_id->gds_quad_low)
return false;
/* Open the blob and get it's vital statistics */
// Open the blob and get it's vital statistics
FRBRD *blob = NULL;
if (isc_open_blob(status_vector, &DB, &gds_trans, &blob, blob_id))
{
BURP_error_redirect(status_vector, 24, NULL, NULL);
/* msg 24 isc_open_blob failed */
// msg 24 isc_open_blob failed
}
if (isc_blob_info(status_vector, &blob, sizeof(blr_items),
@ -1466,7 +1466,7 @@ bool put_blr_blob( SCHAR attribute, ISC_QUAD * blob_id)
(char*) blob_info))
{
BURP_error_redirect(status_vector, 20, NULL, NULL);
/* msg 20 isc_blob_info failed */
// msg 20 isc_blob_info failed
}
ULONG length = 0;
@ -1492,7 +1492,7 @@ bool put_blr_blob( SCHAR attribute, ISC_QUAD * blob_id)
default:
BURP_print(79, (void *) (ULONG) item, NULL, NULL, NULL, NULL);
/* msg 79 don't understand blob info item %ld */
// msg 79 don't understand blob info item %ld
return false;
}
}
@ -1501,18 +1501,18 @@ bool put_blr_blob( SCHAR attribute, ISC_QUAD * blob_id)
{
if (isc_close_blob(status_vector, &blob))
BURP_error_redirect(status_vector, 23, NULL, NULL);
/* msg 23 isc_close_blob failed */
// msg 23 isc_close_blob failed
return false;
}
/* Rdb sometimes gets the length messed up */
// Rdb sometimes gets the length messed up
if (length < max_segment)
length = max_segment;
put_numeric(attribute, (int) length);
/* Allocate a buffer large enough for the largest segment and start grinding. */
// Allocate a buffer large enough for the largest segment and start grinding.
UCHAR* buffer;
if (!max_segment || max_segment <= sizeof(static_buffer))
@ -1534,7 +1534,7 @@ bool put_blr_blob( SCHAR attribute, ISC_QUAD * blob_id)
{
BURP_error_redirect(status_vector, 23, NULL, NULL);
}
/* msg 23 isc_close_blob failed */
// msg 23 isc_close_blob failed
if (buffer != static_buffer)
BURP_free(buffer);
@ -1672,7 +1672,7 @@ void put_data(BURP_REL relation)
default:
BURP_error_redirect(NULL, 26, (void *) (SLONG) field->fld_type, NULL);
/* msg 26 datatype %ld not understood */
// msg 26 datatype %ld not understood
break;
}
if (alignment)
@ -1682,7 +1682,7 @@ void put_data(BURP_REL relation)
offset += length;
}
/* Next, build fields for null flags */
// Next, build fields for null flags
for (field = relation->rel_fields; field; field = field->fld_next)
{
@ -1695,24 +1695,24 @@ void put_data(BURP_REL relation)
offset += sizeof(SSHORT);
}
/* Finally, make up an EOF field */
// Finally, make up an EOF field
stuff(&blr, blr_short); /* eof field */
stuff(&blr, 0); /* scale for eof field */
stuff(&blr, blr_short); // eof field
stuff(&blr, 0); // scale for eof field
SSHORT eof_parameter = count++;
RCRD_OFFSET record_length = offset;
RCRD_OFFSET eof_offset = FB_ALIGN(offset, sizeof(SSHORT));
// To be used later for the buffer size to receive data
const FLD_LENGTH length = (USHORT) (eof_offset + sizeof(SSHORT));
/* Build FOR loop, body, and eof handler */
// Build FOR loop, body, and eof handler
stuff(&blr, blr_for);
stuff(&blr, blr_rse);
stuff(&blr, 1); /* count of relations */
stuff(&blr, 1); // count of relations
stuff(&blr, blr_rid);
stuff_word(&blr, relation->rel_id);
stuff(&blr, 0); /* context variable */
stuff(&blr, 0); // context variable
stuff(&blr, blr_end);
stuff(&blr, blr_send);
@ -1763,7 +1763,7 @@ void put_data(BURP_REL relation)
#endif
/* Compile request */
// Compile request
FRBRD *request = NULL;
SSHORT blr_length = blr - blr_buffer;
@ -1771,14 +1771,14 @@ void put_data(BURP_REL relation)
blr_length, (SCHAR*) blr_buffer))
{
BURP_error_redirect(status_vector, 27, NULL, NULL);
/* msg 27 isc_compile_request failed */
// msg 27 isc_compile_request failed
isc_print_blr((char*) blr_buffer, (isc_callback)NULL, NULL, 0);
}
BURP_free(blr_buffer);
BURP_verbose(142, relation->rel_name, NULL, NULL, NULL, NULL);
/* msg 142 writing data for relation %s */
// msg 142 writing data for relation %s
if (isc_start_request(status_vector, &request, &gds_trans, 0))
{
@ -1809,12 +1809,12 @@ void put_data(BURP_REL relation)
if (isc_receive(status_vector, &request, 0, length, buffer, 0))
{
BURP_error_redirect(status_vector, 29, NULL, NULL);
/* msg 29 isc_receive failed */
// msg 29 isc_receive failed
}
if (!*eof)
break;
records++;
/* Verbose records */
// Verbose records
if ((records % BACKUP_VERBOSE_INTERVAL) == 0)
BURP_verbose(108, (void *) (SLONG) records, NULL, NULL, NULL, NULL);
@ -1835,7 +1835,7 @@ void put_data(BURP_REL relation)
else if (record_length)
put_block(tdgbl, p, record_length);
/* Look for any blobs to write */
// Look for any blobs to write
for (field = relation->rel_fields; field; field = field->fld_next)
{
@ -1849,8 +1849,8 @@ void put_data(BURP_REL relation)
}
}
/* Look for any array to write */
/* we got back the blob_id for the array from isc_receive in the second param. */
// Look for any array to write
// we got back the blob_id for the array from isc_receive in the second param.
for (field = relation->rel_fields; field; field = field->fld_next)
{
if (field->fld_flags & FLD_array)
@ -1867,11 +1867,11 @@ void put_data(BURP_REL relation)
BURP_free(xdr_buffer.lstr_address);
BURP_verbose(108, (void *) (SLONG) records, NULL, NULL, NULL, NULL);
/* msg 108 %ld records written */
// msg 108 %ld records written
if (isc_release_request(status_vector, &request))
BURP_error_redirect(status_vector, 30, NULL, NULL);
/* msg 30 isc_release_request failed */
// msg 30 isc_release_request failed
}
@ -1934,7 +1934,7 @@ void put_index( BURP_REL relation)
l = PUT_TEXT (att_index_name, X.RDB$INDEX_NAME);
MISC_terminate (X.RDB$INDEX_NAME, temp, l, sizeof(temp));
BURP_verbose (151, temp, NULL, NULL, NULL, NULL);
/* msg 151 writing index %s */
// msg 151 writing index %s
put_numeric (att_segment_count, X.RDB$SEGMENT_COUNT);
put_numeric (att_index_inactive, X.RDB$INDEX_INACTIVE);
put_numeric (att_index_unique_flag, X.RDB$UNIQUE_FLAG);
@ -1963,7 +1963,7 @@ void put_index( BURP_REL relation)
(ISC_QUAD *)&X.RDB$EXPRESSION_BLR);
if (!X.RDB$FOREIGN_KEY.NULL)
PUT_TEXT (att_index_foreign_key, X.RDB$FOREIGN_KEY);
put(tdgbl, att_end);
put(tdgbl, att_end);
END_FOR;
ON_ERROR
@ -2011,7 +2011,7 @@ void put_index( BURP_REL relation)
l = PUT_TEXT (att_index_name, X.RDB$INDEX_NAME);
MISC_terminate (X.RDB$INDEX_NAME, temp, l, sizeof(temp));
BURP_verbose (151, temp, NULL, NULL, NULL, NULL);
/* msg 151 writing index %s */
// msg 151 writing index %s
put_numeric (att_segment_count, X.RDB$SEGMENT_COUNT);
if (tdgbl->BCK_capabilities & BCK_idx_inactive)
FOR (REQUEST_HANDLE tdgbl->handles_put_index_req_handle4)
@ -2237,7 +2237,7 @@ void put_relation( BURP_REL relation)
relation->rel_fields = field;
}
/* Now write the fields in what will become physical backup order */
// Now write the fields in what will become physical backup order
for (field = relation->rel_fields; field; field = field->fld_next)
{
@ -2245,7 +2245,7 @@ void put_relation( BURP_REL relation)
l = PUT_TEXT(att_field_name, field->fld_name);
MISC_terminate(field->fld_name, temp, l, sizeof(temp));
BURP_verbose(144, temp, NULL, NULL, NULL, NULL);
/* msg 144 writing field %s */
// msg 144 writing field %s
PUT_TEXT(att_field_source, field->fld_source);
if (field->fld_query_name[0])
PUT_TEXT(att_field_query_name, field->fld_query_name);
@ -2370,7 +2370,7 @@ bool put_source_blob(SCHAR attribute,
if (isc_open_blob(status_vector, &DB, &gds_trans, &blob, blob_id))
{
BURP_error_redirect(status_vector, 24, NULL, NULL);
/* msg 24 isc_open_blob failed */
// msg 24 isc_open_blob failed
}
if (isc_blob_info(status_vector, &blob, sizeof(source_items),
@ -2378,7 +2378,7 @@ bool put_source_blob(SCHAR attribute,
(SCHAR*) blob_info))
{
BURP_error_redirect(status_vector, 20, NULL, NULL);
/* msg 20 isc_blob_info failed */
// msg 20 isc_blob_info failed
}
SLONG length = 0;
@ -2408,7 +2408,7 @@ bool put_source_blob(SCHAR attribute,
default:
BURP_print(79, (void *) (ULONG) item, NULL, NULL, NULL, NULL);
/* msg 79 don't understand blob info item %ld */
// msg 79 don't understand blob info item %ld
return false;
}
}
@ -2418,19 +2418,19 @@ bool put_source_blob(SCHAR attribute,
if (isc_close_blob(status_vector, &blob))
{
BURP_error_redirect(status_vector, 23, NULL, NULL);
/* msg 23 isc_close_blob failed */
// msg 23 isc_close_blob failed
}
return false;
}
/* Rdb sometimes gets the length messed up */
// Rdb sometimes gets the length messed up
if (length < max_segment)
length = max_segment;
put_numeric(attribute, length + num_seg);
/* Allocate a buffer large enough for the largest segment and start grinding. */
// Allocate a buffer large enough for the largest segment and start grinding.
UCHAR* buffer;
if (!max_segment || max_segment <= sizeof(static_buffer))
@ -2451,7 +2451,7 @@ bool put_source_blob(SCHAR attribute,
if (isc_close_blob(status_vector, &blob))
BURP_error_redirect(status_vector, 23, NULL, NULL);
/* msg 23 isc_close_blob failed */
// msg 23 isc_close_blob failed
if (buffer != static_buffer)
BURP_free(buffer);
@ -2742,7 +2742,7 @@ void write_database( const TEXT * dbb_file)
(SCHAR *) db_info_items, sizeof(buffer), buffer))
{
BURP_error_redirect(status_vector, 31, NULL, NULL);
/* msg 31 isc_database_info failed */
// msg 31 isc_database_info failed
}
USHORT page_size = 0, forced_writes, no_reserve,
@ -2783,8 +2783,8 @@ void write_database( const TEXT * dbb_file)
put_numeric(att_page_buffers, page_buffers);
break;
case isc_info_error: /* old server does not understand new isc_info */
break; /* parametere and returns isc_info_error. skip it */
case isc_info_error: // old server does not understand new isc_info
break; // parametere and returns isc_info_error. skip it
case isc_info_db_sql_dialect:
SQL_dialect = (USHORT) isc_vax_integer(d, length);
@ -2798,7 +2798,7 @@ void write_database( const TEXT * dbb_file)
default:
BURP_error_redirect(status_vector, 31, NULL, NULL);
/* msg 31 isc_database_info failed */
// msg 31 isc_database_info failed
break;
}
}
@ -2806,7 +2806,7 @@ void write_database( const TEXT * dbb_file)
put_asciz(att_file_name, dbb_file);
BURP_verbose(77, dbb_file, (void *) (ULONG) page_size, NULL, NULL, NULL);
/* msg 77 database %s has a page size of %ld bytes. */
// msg 77 database %s has a page size of %ld bytes.
put(tdgbl, (UCHAR) (att_end));
@ -3067,7 +3067,7 @@ void write_function_args( GDS_NAME funcptr)
SSHORT l = PUT_TEXT (att_functionarg_name, X.RDB$FUNCTION_NAME);
MISC_terminate (X.RDB$FUNCTION_NAME, temp, l, sizeof(temp));
BURP_verbose (141, temp, NULL, NULL, NULL, NULL);
/* msg 141 writing argument for function %s */
// msg 141 writing argument for function %s
put_numeric (att_functionarg_position, X.RDB$ARGUMENT_POSITION);
put_numeric (att_functionarg_mechanism, X.RDB$MECHANISM);
put_numeric (att_functionarg_field_type, X.RDB$FIELD_TYPE);
@ -3082,7 +3082,7 @@ void write_function_args( GDS_NAME funcptr)
put(tdgbl, att_end);
END_FOR;
ON_ERROR
general_on_error();
general_on_error();
END_ERROR;
}
else
@ -3095,7 +3095,7 @@ void write_function_args( GDS_NAME funcptr)
SSHORT l = PUT_TEXT (att_functionarg_name, X.RDB$FUNCTION_NAME);
MISC_terminate (X.RDB$FUNCTION_NAME, temp, l, sizeof(temp));
BURP_verbose (141, temp, NULL, NULL, NULL, NULL);
/* msg 141 writing argument for function %s */
// msg 141 writing argument for function %s
put_numeric (att_functionarg_position, X.RDB$ARGUMENT_POSITION);
put_numeric (att_functionarg_mechanism, X.RDB$MECHANISM);
put_numeric (att_functionarg_field_type, X.RDB$FIELD_TYPE);
@ -3113,12 +3113,12 @@ void write_function_args( GDS_NAME funcptr)
if (!(X2.RDB$CHARACTER_SET_ID.NULL))
put_numeric (att_functionarg_character_set, X2.RDB$CHARACTER_SET_ID);
/* Note that BCK_ods10 canNOT be set if we're in this
``else'' branch. Hence there is no need to test that
"else" branch. Hence there is no need to test that
bit and store the RDB$FIELD_PRECISION. */
END_FOR;
ON_ERROR
general_on_error();
general_on_error();
END_ERROR;
}
put(tdgbl, att_end);
@ -3259,7 +3259,7 @@ void write_global_fields(void)
END_FOR;
ON_ERROR
general_on_error();
general_on_error();
END_ERROR;
}
else
@ -3327,7 +3327,7 @@ void write_global_fields(void)
if (!(F.RDB$CHARACTER_SET_ID.NULL))
put_numeric (att_field_character_set, F.RDB$CHARACTER_SET_ID);
if (!(F.RDB$COLLATION_ID.NULL))
put_numeric (att_field_collation_id, F.RDB$COLLATION_ID);
put_numeric (att_field_collation_id, F.RDB$COLLATION_ID);
if (tdgbl->BCK_capabilities & BCK_ods10)
{
@ -3429,7 +3429,7 @@ void write_procedure_prms( GDS_NAME procptr)
SSHORT l = PUT_TEXT (att_procedureprm_name, X.RDB$PARAMETER_NAME);
MISC_terminate (X.RDB$PARAMETER_NAME, temp, l, sizeof(temp));
BURP_verbose (194, temp, NULL, NULL, NULL, NULL);
/* msg 194 writing parameter %s for stored procedure */
// msg 194 writing parameter %s for stored procedure
put_numeric (att_procedureprm_number, X.RDB$PARAMETER_NUMBER);
put_numeric (att_procedureprm_type, X.RDB$PARAMETER_type);
PUT_TEXT (att_procedureprm_field_source, X.RDB$FIELD_SOURCE);
@ -3500,7 +3500,7 @@ void write_rel_constraints(void)
SSHORT l = PUT_TEXT (att_rel_constraint_name, X.RDB$CONSTRAINT_NAME);
MISC_terminate (X.RDB$CONSTRAINT_NAME, temp, l, sizeof(temp));
BURP_verbose (207, temp, NULL, NULL, NULL, NULL);
/* msg 207 writing constraint %s */
// msg 207 writing constraint %s
PUT_MESSAGE (att_rel_constraint_type, X.RDB$CONSTRAINT_TYPE);
PUT_TEXT (att_rel_constraint_rel_name, X.RDB$RELATION_NAME);
PUT_TEXT (att_rel_constraint_defer, X.RDB$DEFERRABLE);
@ -3591,7 +3591,7 @@ void write_relations(void)
put_relation (relation);
END_FOR;
ON_ERROR
general_on_error();
general_on_error();
END_ERROR;
}
else
@ -3623,7 +3623,7 @@ void write_relations(void)
put_numeric (att_relation_flags, R.RDB$FLAGS);
END_FOR;
ON_ERROR
general_on_error();
general_on_error();
END_ERROR;
}
if (tdgbl->BCK_capabilities & BCK_security)
@ -3746,7 +3746,7 @@ void write_sql_roles(void)
put(tdgbl, att_end);
MISC_terminate (X.RDB$ROLE_NAME, temp, l, sizeof(temp));
BURP_verbose (249, temp, NULL, NULL, NULL, NULL);
/* msg 249 writing SQL role: %s */
// msg 249 writing SQL role: %s
END_FOR;
ON_ERROR
@ -3790,7 +3790,7 @@ void write_triggers(void)
SSHORT l = PUT_TEXT (att_trig_name, X.RDB$TRIGGER_NAME);
MISC_terminate (X.RDB$TRIGGER_NAME, temp, l, sizeof(temp));
BURP_verbose (156, temp, NULL, NULL, NULL, NULL);
/* msg 156 writing trigger %s */
// msg 156 writing trigger %s
PUT_TEXT (att_trig_relation_name, X.RDB$RELATION_NAME);
put_numeric (att_trig_sequence, X.RDB$TRIGGER_SEQUENCE);
@ -3808,7 +3808,7 @@ void write_triggers(void)
END_FOR;
ON_ERROR
general_on_error();
general_on_error();
END_ERROR;
}
else
@ -3822,7 +3822,7 @@ void write_triggers(void)
SSHORT l = PUT_TEXT (att_trig_name, X.RDB$TRIGGER_NAME);
MISC_terminate (X.RDB$TRIGGER_NAME, temp, l, sizeof(temp));
BURP_verbose (156, temp, NULL, NULL, NULL, NULL);
/* msg 156 writing trigger %s */
// msg 156 writing trigger %s
PUT_TEXT (att_trig_relation_name, X.RDB$RELATION_NAME);
put_numeric (att_trig_sequence, X.RDB$TRIGGER_SEQUENCE);
@ -3844,7 +3844,7 @@ void write_triggers(void)
END_FOR;
ON_ERROR
general_on_error();
general_on_error();
END_ERROR;
}
@ -3924,11 +3924,11 @@ void write_types(void)
PUT_TEXT (att_type_name, X.RDB$TYPE_NAME);
PUT_TEXT (att_type_field_name, X.RDB$FIELD_NAME);
BURP_verbose (160, X.RDB$TYPE_NAME, X.RDB$FIELD_NAME, NULL, NULL, NULL);
/* msg 160 writing type %s for field %s */
// msg 160 writing type %s for field %s
put_numeric (att_type_type, X.RDB$TYPE);
put_source_blob (att_type_description2, att_type_description, (ISC_QUAD *)&X.RDB$DESCRIPTION);
if (X.RDB$SYSTEM_FLAG)
put_numeric (att_type_system_flag, X.RDB$SYSTEM_FLAG);
put_numeric (att_type_system_flag, X.RDB$SYSTEM_FLAG);
put(tdgbl, att_end);
END_FOR;
ON_ERROR

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Backup and Restore Program
* MODULE: burp.c
* MODULE: burp.cpp
* DESCRIPTION: Command line interpreter for backup/restore
*
* The contents of this file are subject to the Interbase Public
@ -106,20 +106,20 @@
tgbl *gdgbl;
#endif
const char* FOPEN_WRITE_TYPE = "w";
const char* FOPEN_READ_TYPE = "r";
const char* fopen_write_type = "w";
const char* fopen_read_type = "r";
const int OPEN_MASK = 0666;
const int open_mask = 0666;
#ifdef VMS
const char* SWITCH_CHAR = "/";
const char* switch_char = "/";
#else
const char* SWITCH_CHAR = "-";
const char* switch_char = "-";
#endif
const char* output_suppress = "SUPPRESS";
const int BURP_MSG_FAC = 12;
const char* const output_suppress = "SUPPRESS";
const int burp_msg_fac = 12;
enum gbak_action
{
@ -152,12 +152,14 @@ const ULONG GBYTE = MBYTE * KBYTE;
#if defined (WIN95)
static bool fAnsiCP = false;
static inline void translate_cp(SCHAR *a){
static inline void translate_cp(SCHAR* a)
{
if (!fAnsiCP)
AnsiToOem(a, a);
}
#else
static inline void translate_cp(SCHAR *a){
static inline void translate_cp(SCHAR* a)
{
}
#endif
@ -221,7 +223,7 @@ void BURP_svc_error(USHORT errcode,
ISC_STATUS *status = tdgbl->service_blk->svc_status;
CMD_UTIL_put_svc_status(status, BURP_MSG_FAC, errcode,
CMD_UTIL_put_svc_status(status, burp_msg_fac, errcode,
arg1_t, arg1, arg2_t, arg2, arg3_t, arg3,
arg4_t, arg4, arg5_t, arg5);
@ -274,10 +276,10 @@ int CLIB_ROUTINE main(int argc, char* argv[])
if (!string[1])
string = "-*NONE*";
const in_sw_tab_t* in_sw_tab = burp_in_sw_table;
const TEXT *q;
const TEXT* q;
for (; q = in_sw_tab->in_sw_name; in_sw_tab++)
{
TEXT c;
TEXT c;
for (const TEXT *p = string + 1; c = *p++;)
if (UPPER(c) != *q++)
break;
@ -580,7 +582,7 @@ int common_main(int argc,
for (in_sw_tab = burp_in_sw_table; in_sw_tab->in_sw;
in_sw_tab++)
if (in_sw_tab->in_sw_msg) {
BURP_msg_put(in_sw_tab->in_sw_msg, (void*)SWITCH_CHAR, 0, 0,
BURP_msg_put(in_sw_tab->in_sw_msg, (void*)switch_char, 0, 0,
0, 0);
}
@ -685,7 +687,7 @@ int common_main(int argc,
const TEXT *p = redirect;
TEXT c;
const TEXT *q = output_suppress;
const TEXT* q = output_suppress;
tdgbl->sw_redirect = NOOUTPUT;
while (c = *p++) {
if (UPPER(c) != *q++) {
@ -696,7 +698,7 @@ int common_main(int argc,
if (tdgbl->sw_redirect == REDIRECT) { // not NOREDIRECT, and not NOOUTPUT
// Make sure the status file doesn't already exist
IB_FILE* tmp_outfile = ib_fopen(redirect, FOPEN_READ_TYPE);
IB_FILE* tmp_outfile = ib_fopen(redirect, fopen_read_type);
if (tmp_outfile) {
BURP_print(66, redirect, 0, 0, 0, 0);
// msg 66 can't open status and error output file %s
@ -705,7 +707,7 @@ int common_main(int argc,
}
if (!
(tdgbl->output_file =
ib_fopen(redirect, FOPEN_WRITE_TYPE))) {
ib_fopen(redirect, fopen_write_type))) {
BURP_print(66, redirect, 0, 0, 0, 0);
// msg 66 can't open status and error output file %s
exit_local(FINI_ERROR, const_cast<tgbl*>(tdgbl));
@ -1029,7 +1031,7 @@ int common_main(int argc,
if (isc_detach_database(const_cast<ISC_STATUS*>(tdgbl->status_vector),
const_cast<isc_db_handle*>(&tdgbl->db_handle)))
{
BURP_print_status(const_cast<ISC_STATUS*>(tdgbl->status_vector));
BURP_print_status(const_cast<const ISC_STATUS*>(tdgbl->status_vector));
}
}
@ -1108,7 +1110,7 @@ void BURP_error(USHORT errcode,
TGBL tdgbl = GET_THREAD_DATA;
ISC_STATUS *status = tdgbl->service_blk->svc_status;
CMD_UTIL_put_svc_status(status, BURP_MSG_FAC, errcode,
CMD_UTIL_put_svc_status(status, burp_msg_fac, errcode,
isc_arg_string, arg1,
isc_arg_string, arg2,
isc_arg_string, arg3,
@ -1123,7 +1125,7 @@ void BURP_error(USHORT errcode,
}
void BURP_error_redirect( ISC_STATUS* status_vector,
void BURP_error_redirect(const ISC_STATUS* status_vector,
USHORT errcode,
const void* arg1,
const void* arg2)
@ -1164,7 +1166,7 @@ void BURP_msg_partial( USHORT number,
**************************************/
TEXT buffer[256];
gds__msg_format(NULL, BURP_MSG_FAC, number, sizeof(buffer), buffer,
gds__msg_format(NULL, burp_msg_fac, number, sizeof(buffer), buffer,
static_cast<const char*>(arg1),
static_cast<const char*>(arg2),
static_cast<const char*>(arg3),
@ -1193,7 +1195,7 @@ void BURP_msg_put( USHORT number,
**************************************/
TEXT buffer[256];
gds__msg_format(NULL, BURP_MSG_FAC, number, sizeof(buffer), buffer,
gds__msg_format(NULL, burp_msg_fac, number, sizeof(buffer), buffer,
static_cast<const char*>(arg1),
static_cast<const char*>(arg2),
static_cast<const char*>(arg3),
@ -1225,7 +1227,7 @@ void BURP_msg_get( USHORT number,
TEXT buffer[128];
gds__msg_format(NULL,
BURP_MSG_FAC,
burp_msg_fac,
number,
sizeof(buffer),
buffer,
@ -1282,7 +1284,7 @@ void BURP_print(USHORT number,
}
void BURP_print_status( ISC_STATUS * status_vector)
void BURP_print_status(const ISC_STATUS* status_vector)
{
/**************************************
*
@ -1296,7 +1298,7 @@ void BURP_print_status( ISC_STATUS * status_vector)
*
**************************************/
if (status_vector) {
ISC_STATUS *vector = status_vector;
const ISC_STATUS *vector = status_vector;
#ifdef SUPERSERVER
TGBL tdgbl = GET_THREAD_DATA;
ISC_STATUS *status = tdgbl->service_blk->svc_status;
@ -1324,7 +1326,7 @@ void BURP_print_status( ISC_STATUS * status_vector)
}
void BURP_print_warning( ISC_STATUS * status_vector)
void BURP_print_warning(const ISC_STATUS* status_vector)
{
/**************************************
*
@ -1342,7 +1344,7 @@ void BURP_print_warning( ISC_STATUS * status_vector)
assert(status_vector[0] == gds_arg_gds);
assert(status_vector[1] == 0);
// print the warning message
ISC_STATUS* vector = &status_vector[2];
const ISC_STATUS* vector = &status_vector[2];
SCHAR s[1024];
if (isc_interprete(s, &vector)) {
translate_cp(s);
@ -1585,7 +1587,7 @@ static gbak_action open_files(const TEXT * file1,
if ((fil->fil_fd = MVOL_open(fil->fil_name, MODE_WRITE,
CREATE_ALWAYS)) == INVALID_HANDLE_VALUE)
#else
if ((fil->fil_fd = open(fil->fil_name, MODE_WRITE, OPEN_MASK)) == -1)
if ((fil->fil_fd = open(fil->fil_name, MODE_WRITE, open_mask)) == -1)
#endif // WIN_NT
{

View File

@ -45,15 +45,19 @@
#include <fcntl.h>
#endif
static inline UCHAR* BURP_alloc(ULONG size){
static inline UCHAR* BURP_alloc(ULONG size)
{
return MISC_alloc_burp(size);
}
static inline UCHAR* BURP_alloc_zero(ULONG size){
static inline UCHAR* BURP_alloc_zero(ULONG size)
{
return MISC_alloc_burp(size);
}
static inline void BURP_free(void *block){
static inline void BURP_free(void* block)
{
MISC_free_burp(block);
}
@ -625,6 +629,8 @@ enum gfld_flags_vals {
GFLD_validation_source2 = 4
};
// CVC: Could use MAXPATHLEN, but what about restoring in a different system?
// I need to review if we tolerate different lengths for different OS's here.
const int MAX_FILE_NAME_LENGTH = 256;
/* Note that this typedef is also defined in JRD.H and REMOTE.H */
@ -896,6 +902,8 @@ const int GBAK_IO_BUFFER_SIZE = (16 * (BUFSIZ));
#else
const int GBAK_IO_BUFFER_SIZE = (16 * (1024));
#endif
#else
const int GBAK_IO_BUFFER_SIZE = (16 * (IO_BUFFER_SIZE));
#endif
/* Burp will always write a backup in multiples of the following number
@ -919,14 +927,12 @@ inline static ULONG BURP_UP_TO_BLOCK(ULONG size)
#ifdef WIN_NT
static const int MODE_READ = GENERIC_READ;
static const int MODE_WRITE = GENERIC_WRITE;
#else
# ifdef VMS
#elif defined(VMS)
static const int MODE_READ = O_RDONLY;
static const int MODE_WRITE = O_WRONLY | O_CREAT | O_TRUNC;
# else
#else
static const int MODE_READ = O_RDONLY;
static const int MODE_WRITE = O_WRONLY | O_CREAT;
# endif
#endif

View File

@ -32,8 +32,8 @@ extern void BURP_abort(void);
extern void BURP_svc_error(USHORT, USHORT, const void *, USHORT, const void *,
USHORT, const void *, USHORT, const void *, USHORT, const void *);
extern void BURP_error(USHORT, const void*, const void*, const void*, const void*, const void*);
extern void BURP_print_status(ISC_STATUS *);
extern void BURP_error_redirect(ISC_STATUS *, USHORT, const void*, const void*);
extern void BURP_print_status(const ISC_STATUS*);
extern void BURP_error_redirect(const ISC_STATUS*, USHORT, const void*, const void*);
extern void BURP_msg_partial(USHORT, const void*, const void*, const void*,
const void*, const void*);
extern void BURP_msg_put(USHORT, const void*, const void*, const void*,
@ -42,7 +42,7 @@ extern void BURP_msg_get(USHORT, TEXT*, const void*, const void*, const void*,
const void*, const void*);
extern void BURP_output_version(const TEXT *, TEXT *);
extern void BURP_print(USHORT, const void*, const void*, const void*, const void*, const void*);
extern void BURP_print_warning(ISC_STATUS*);
extern void BURP_print_warning(const ISC_STATUS*);
extern void BURP_verbose(USHORT, const void*, const void*, const void*, const void*, const void*);
#endif /* BURP_BURP_PROTO_H */

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Backup and Restore Program
* MODULE: canonical.c
* MODULE: canonical.cpp
* DESCRIPTION:
*
* The contents of this file are subject to the Interbase Public
@ -28,7 +28,7 @@
*
*/
/*
$Id: canonical.cpp,v 1.27 2003-09-22 14:13:53 brodsom Exp $
$Id: canonical.cpp,v 1.28 2003-09-25 11:48:59 robocop Exp $
*/
#include "firebird.h"
@ -209,7 +209,7 @@ ULONG CAN_encode_decode(BURP_REL relation,
}
}
/* Next, get null flags */
// Next, get null flags
for (field = relation->rel_fields; field; field = field->fld_next)
{
@ -674,7 +674,7 @@ static bool_t xdr_slice(XDR* xdrs,
if (!xdr_long(xdrs, reinterpret_cast<long*>(&slice->lstr_length)))
return FALSE;
/* Handle operation specific stuff, particularly memory allocation/deallocation */
// Handle operation specific stuff, particularly memory allocation/deallocation
switch (xdrs->x_op)
{
@ -712,7 +712,7 @@ static bool_t xdr_slice(XDR* xdrs,
return FALSE;
}
/* Get descriptor of array element */
// Get descriptor of array element
if (SDL_info(status_vector, sdl, &info, 0))
return FALSE;

View File

@ -52,7 +52,7 @@ UCHAR *MISC_alloc_burp(ULONG size)
TGBL tdgbl = GET_THREAD_DATA;
/* Add some header space to store a list of blocks allocated for this gbak */
// Add some header space to store a list of blocks allocated for this gbak
size += ROUNDUP(sizeof(UCHAR *), ALIGNMENT);
UCHAR* block = (UCHAR*)gds__alloc(size);
@ -60,7 +60,7 @@ UCHAR *MISC_alloc_burp(ULONG 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 */
BURP_error(238, NULL, NULL, NULL, NULL, NULL); // msg 238: System memory exhaused
return NULL;
}
@ -92,26 +92,26 @@ void MISC_free_burp( void *free)
TGBL tdgbl = GET_THREAD_DATA;
if (free != NULL) {
/* Point at the head of the allocated block */
// Point at the head of the allocated block
UCHAR **block =
(UCHAR **) ((UCHAR *) free - ROUNDUP(sizeof(UCHAR *), ALIGNMENT));
/* Scan for this block in the list of blocks */
// Scan for this block in the list of blocks
for (UCHAR **ptr = &tdgbl->head_of_mem_list; *ptr; ptr = (UCHAR **) *ptr)
{
if (*ptr == (UCHAR *) block) {
/* Found it - remove it from the list */
// Found it - remove it from the list
*ptr = *block;
/* and free it */
// and free it
gds__free((SLONG *) block);
return;
}
}
/* We should always find the block in the list */
BURP_error(238, NULL, NULL, NULL, NULL, NULL); /* msg 238: System memory exhausted */
/* (too lazy to add a better message) */
// We should always find the block in the list
BURP_error(238, NULL, NULL, NULL, NULL, NULL); // msg 238: System memory exhausted
// (too lazy to add a better message)
}
}
@ -147,9 +147,9 @@ void MISC_terminate(const TEXT* from, TEXT* to, ULONG length, ULONG max_length)
if (length) {
length = MIN(length, max_length - 1);
do
do {
*to++ = *from++;
while (--length);
} while (--length);
*to++ = '\0';
}
else {

View File

@ -67,7 +67,7 @@
#include <unistd.h>
#endif
const int OPEN_MASK = 0666;
const int open_mask = 0666;
#ifdef VMS
const char* TERM_INPUT = "sys$input";
@ -84,11 +84,13 @@ const char* TERM_OUTPUT = "/dev/tty";
const int MAX_HEADER_SIZE = 512;
static inline int get(TGBL tdgbl){
static inline int get(TGBL tdgbl)
{
return (--(tdgbl->mvol_io_cnt) >= 0 ? *(tdgbl->mvol_io_ptr)++ : 255);
}
static inline void put(TGBL tdgbl, ULONG c){
static inline void put(TGBL tdgbl, ULONG c)
{
--(tdgbl->mvol_io_cnt);
*(tdgbl->mvol_io_ptr)++ = (UCHAR) (c);
}
@ -187,9 +189,6 @@ void MVOL_init_read(const UCHAR* database_name, // unused?
int* cnt,
UCHAR** ptr)
{
ULONG temp_buffer_size;
UCHAR *new_buffer;
TGBL tdgbl = GET_THREAD_DATA;
tdgbl->mvol_volume_count = 1;
@ -205,8 +204,8 @@ void MVOL_init_read(const UCHAR* database_name, // unused?
tdgbl->mvol_old_file[0] = 0;
}
tdgbl->mvol_actual_buffer_size = temp_buffer_size =
tdgbl->mvol_io_buffer_size;
ULONG temp_buffer_size = tdgbl->mvol_io_buffer_size;
tdgbl->mvol_actual_buffer_size = temp_buffer_size;
tdgbl->mvol_io_buffer = BURP_alloc(temp_buffer_size);
tdgbl->gbl_backup_start_time[0] = 0;
@ -214,7 +213,7 @@ void MVOL_init_read(const UCHAR* database_name, // unused?
if (temp_buffer_size > tdgbl->mvol_actual_buffer_size)
{
new_buffer = BURP_alloc(temp_buffer_size);
UCHAR* new_buffer = BURP_alloc(temp_buffer_size);
memcpy(new_buffer, tdgbl->mvol_io_buffer, tdgbl->mvol_io_buffer_size);
BURP_free(tdgbl->mvol_io_buffer);
tdgbl->mvol_io_ptr =
@ -811,13 +810,11 @@ static SLONG get_numeric(void)
//
static int get_text(UCHAR* text, SSHORT length)
{
unsigned int l, l2;
TGBL tdgbl = GET_THREAD_DATA;
l = get(tdgbl);
ULONG l = get(tdgbl);
length -= l;
l2 = l;
const ULONG l2 = l;
if (length < 0)
{
@ -844,10 +841,6 @@ static int get_text(UCHAR* text, SSHORT length)
//
static DESC next_volume( DESC handle, int mode, bool full_buffer)
{
SCHAR new_file[MAX_FILE_NAME_LENGTH];
ULONG temp_buffer_size;
USHORT format;
TGBL tdgbl = GET_THREAD_DATA;
/* We must close the old handle before the user inserts
@ -885,6 +878,7 @@ static DESC next_volume( DESC handle, int mode, bool full_buffer)
// Loop until we have opened a file successfully
SCHAR new_file[MAX_FILE_NAME_LENGTH];
DESC new_desc = INVALID_HANDLE_VALUE;
for (;;)
{
@ -903,7 +897,7 @@ static DESC next_volume( DESC handle, int mode, bool full_buffer)
new_desc = MVOL_open(new_file, mode, OPEN_ALWAYS);
if (new_desc == INVALID_HANDLE_VALUE)
#else
new_desc = open(new_file, mode, OPEN_MASK);
new_desc = open(new_file, mode, open_mask);
if (new_desc < 0)
#endif // WIN_NT
{
@ -917,7 +911,7 @@ static DESC next_volume( DESC handle, int mode, bool full_buffer)
#ifdef WIN_NT
if (mode == MODE_WRITE)
#else
if ( (mode = mode & O_WRONLY) || (mode = mode & O_RDWR))
if ((O_WRONLY == (mode & O_WRONLY)) || (O_RDWR == (mode & O_RDWR)))
#endif // WIN_NT
{
if (!write_header(new_desc, 0L, full_buffer))
@ -938,6 +932,8 @@ static DESC next_volume( DESC handle, int mode, bool full_buffer)
{
// File is open for read only. Read the header.
ULONG temp_buffer_size;
USHORT format;
if (!read_header(new_desc, &temp_buffer_size, &format, false))
{
BURP_print(224, new_file, 0, 0, 0, 0);
@ -1060,7 +1056,7 @@ static void prompt_for_name(SCHAR* name, int length)
//
// Write an attribute starting with a null terminated string.
//
static void put_asciz( SCHAR attribute, const TEXT * string)
static void put_asciz( SCHAR attribute, const TEXT* string)
{
TGBL tdgbl = GET_THREAD_DATA;
@ -1069,13 +1065,13 @@ static void put_asciz( SCHAR attribute, const TEXT * string)
{
l++;
}
fb_assert(l <= MAX_UCHAR);
put(tdgbl, attribute);
put(tdgbl, l);
if (l)
{
do
{
do {
put(tdgbl, *string++);
} while (--l);
}
@ -1092,7 +1088,7 @@ static void put_numeric( SCHAR attribute, int value)
TGBL tdgbl = GET_THREAD_DATA;
ULONG vax_value = gds__vax_integer((UCHAR *) & value, sizeof(value));
UCHAR *p = (UCHAR *) & vax_value;
UCHAR* p = (UCHAR *) &vax_value;
put(tdgbl, attribute);
put(tdgbl, sizeof(value));
@ -1112,7 +1108,6 @@ static bool read_header(DESC handle,
USHORT* format,
bool init_flag)
{
int attribute, temp;
SSHORT l;
ULONG temp_buffer_size;
TEXT buffer[256], *p, msg[128];
@ -1132,10 +1127,13 @@ static bool read_header(DESC handle,
#endif
tdgbl->mvol_io_ptr = tdgbl->mvol_io_buffer;
if ((attribute = (att_type) get(tdgbl)) != rec_burp)
BURP_error_redirect(0, 45, NULL, NULL); // msg 45 expected backup description record
int attribute = get(tdgbl);
if (attribute != rec_burp)
BURP_error_redirect(0, 45, NULL, NULL);
// msg 45 expected backup description record
while ((attribute = (att_type) get(tdgbl)) != att_end)
int temp;
for (attribute = get(tdgbl); attribute != att_end; attribute = get(tdgbl))
{
switch (attribute)
{
@ -1158,9 +1156,9 @@ static bool read_header(DESC handle,
else
p = buffer;
if (l)
do
do {
*p++ = get(tdgbl);
while (--l);
} while (--l);
*p = 0;
if (!init_flag && strcmp(buffer, tdgbl->gbl_backup_start_time))
{

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/*************************************************************************
**
** PROGRAM: JRD file split utility program
** MODULE: spit.c
** MODULE: spit.cpp
** DESCRIPTION: Command line interpreter for backup file split/join
** utility program
**
@ -60,11 +60,11 @@
#include <io.h>
#endif
static const int MODE_READ = O_RDONLY;
static const int MODE_WRITE = O_WRONLY | O_CREAT;
static const int MASK = 0666;
static const int mode_read = O_RDONLY;
static const int mode_write = O_WRONLY | O_CREAT;
static const int mask = 0666;
/* Definitions for GSPLIT */
// Definitions for GSPLIT
enum gsplit_option
{
IN_SW_SPIT_0 = 0, // the unknowable switch
@ -214,7 +214,7 @@ int main( int argc, char *argv[])
switch (sw_replace) {
case (IN_SW_SPIT_SP):
if (!file_nm_sw) { /* process file name */
if (!file_nm_sw) { // process file name
file_size = 0;
file_num = file_num + 1;
@ -298,8 +298,8 @@ int main( int argc, char *argv[])
} /* and of switch (sw_replace) */
argv++;
} /* processing function specific command line options */
} /* while (argv < end) */
} // processing function specific command line options
} // while (argv < end)
if (!file_list && sw_replace != IN_SW_SPIT_0) {
ib_fprintf(ib_stderr,
@ -399,11 +399,11 @@ static int get_function_option(const SCHAR* prog_name,
ret_cd = print_clo(prog_name);
return FB_FAILURE;
}
else /* compatible option */
else // compatible option
break;
}
} /* end of if (!c) */
} /* end of for loop */
} // end of if (!c)
} // end of for loop
if (!in_sw_tab->in_sw) {
ib_fprintf(ib_stderr, "%s: invalid option '%s'\n", prog_name, string);
@ -495,7 +495,7 @@ static int get_file_size(const SCHAR* prog_name, const SCHAR* string, double* fi
*file_size = *file_size * size_indicator;
}
else { /* invalid size indicator */
else { // invalid size indicator
ib_fprintf(ib_stderr,
"%s: invalid size indicator '%s'\n", prog_name,
@ -505,7 +505,7 @@ static int get_file_size(const SCHAR* prog_name, const SCHAR* string, double* fi
}
}
}
if (*file_size < MIN_FILE_SIZE) { /* handling user specifies file size 0 */
if (*file_size < MIN_FILE_SIZE) { // handling user specifies file size 0
ib_fprintf(ib_stderr,
"%s: invalid option '%s', minimum file size is 1 megabyte\n",
prog_name, string);
@ -650,7 +650,7 @@ static int gen_multy_bakup_files(b_fil* file_list,
file_size = fl_ptr->b_fil_size - header_rec_len;
file_name = fl_ptr->b_fil_name;
output_fl_desc = open(file_name, MODE_WRITE, MASK);
output_fl_desc = open(file_name, mode_write, mask);
if (output_fl_desc == -1) {
free(io_buffer);
ib_fprintf(ib_stderr, "can not open back up file %s\n",
@ -721,7 +721,7 @@ static int gen_multy_bakup_files(b_fil* file_list,
file_name = fl_ptr->b_fil_name;
output_fl_desc =
open(file_name, MODE_WRITE, MASK);
open(file_name, mode_write, mask);
if (output_fl_desc == -1) {
free(io_buffer);
ib_fprintf(ib_stderr,
@ -753,7 +753,7 @@ static int gen_multy_bakup_files(b_fil* file_list,
return FB_FAILURE;
}
}
else { /* got a lot of backup files */
else { // got a lot of backup files
ret_cd = flush_io_buff(remaining_io,
remaining_io_len,
@ -840,21 +840,21 @@ static int read_and_write(FILE_DESC input_file_desc,
read_cnt = read(input_file_desc, *io_buffer, io_size);
switch (read_cnt) {
case (0): /* no more data to be read */
case (0): // no more data to be read
close(output_fl_desc);
*end_of_input = true;
*byte_read = *byte_read + read_cnt;
return FB_SUCCESS;
break;
case (-1): /* read failed */
case (-1): // read failed
close(output_fl_desc);
ib_fprintf(ib_stderr,
"fail to read input from ib_stdin, errno = %d\n", errno);
return FB_FAILURE;
break;
default: /* read ok */
default: // read ok
*byte_read = *byte_read + read_cnt;
break;
}
@ -862,15 +862,15 @@ static int read_and_write(FILE_DESC input_file_desc,
SLONG write_cnt = write(output_fl_desc, *io_buffer, read_cnt);
switch (write_cnt) {
case (-1): /* write failed */
case (-1): // write failed
close(output_fl_desc);
return FB_FAILURE;
break;
default:
if (write_cnt == read_cnt) /* write ok */
if (write_cnt == read_cnt) // write ok
return FB_SUCCESS;
else { /* write less data then it reads in */
else { // write less data then it reads in
close(output_fl_desc);
*byte_write = write_cnt;
@ -906,35 +906,35 @@ static int final_read_and_write(FILE_DESC input_file_desc,
SLONG read_cnt = read(input_file_desc, *io_buffer, io_size);
switch (read_cnt) {
case (0): /* no more data to be read */
case (0): // no more data to be read
close(output_fl_desc);
*end_of_input = true;
return FB_SUCCESS;
break;
case (-1): /* read failed */
case (-1): // read failed
close(output_fl_desc);
ib_fprintf(ib_stderr,
"problem when reading input file, errno = %d\n", errno);
return FB_FAILURE;
break;
default: /* read ok */
default: // read ok
break;
}
SLONG write_cnt = write(output_fl_desc, *io_buffer, read_cnt);
switch (write_cnt) {
case (-1): /* write failed */
case (-1): // write failed
close(output_fl_desc);
return FB_FAILURE;
break;
default:
if (write_cnt == read_cnt) /* write ok */
if (write_cnt == read_cnt) // write ok
return FB_SUCCESS;
else { /* write less data then it reads in */
else { // write less data then it reads in
ib_fprintf(ib_stderr,
"There is no enough space to write to back up file %s\n",
@ -995,7 +995,7 @@ static int join_multy_bakup_files( b_fil* file_list)
return FB_FAILURE;
}
} /* end of for loop */
} // end of for loop
free(io_buffer);
return FB_SUCCESS;
@ -1025,7 +1025,7 @@ static int read_and_write_for_join(FILE_DESC output_fl_desc,
TEXT num_arr[5], total_arr[5];
header_rec hdr_rec;
FILE_DESC input_fl_desc = open(file_name, MODE_READ);
FILE_DESC input_fl_desc = open(file_name, mode_read);
if (input_fl_desc == -1) {
ib_fprintf(ib_stderr, "can not open input file %s\n", file_name);
@ -1087,24 +1087,24 @@ static int read_and_write_for_join(FILE_DESC output_fl_desc,
while (true) {
switch (read_cnt) {
case (0): /* no more data to be read */
case (0): // no more data to be read
close(input_fl_desc);
return FB_SUCCESS;
break;
case (-1): /* read failed */
case (-1): // read failed
close(input_fl_desc);
return FB_FAILURE;
break;
default: /* this is the last read */
default: // this is the last read
break;
}
SLONG write_cnt = write(output_fl_desc, *io_buffer, read_cnt);
switch (write_cnt) {
case (-1): /* write failed */
case (-1): // write failed
close(input_fl_desc);
return FB_FAILURE;
break;
@ -1241,7 +1241,7 @@ static int write_header(b_fil* fl_ptr,
SLONG write_cnt = write(output_fl_desc, header_str, header_rec_len);
switch (write_cnt)
{
case (-1): /* write failed */
case (-1): // write failed
close(output_fl_desc);
return FB_FAILURE;
break;
@ -1301,16 +1301,16 @@ static int flush_io_buff(UCHAR* remaining_io,
}
switch (write_cnt) {
case (-1): /* write failed */
case (-1): // write failed
close(output_fl_desc);
*flush_done = false;
return FB_FAILURE;
break;
default:
if (write_cnt == remaining_io_len) /* write ok */
if (write_cnt == remaining_io_len) // write ok
*flush_done = true;
else { /* could not write out all remaining data */
else { // could not write out all remaining data
close(output_fl_desc);
*flush_done = false;
@ -1342,15 +1342,15 @@ static int final_flush_io_buff(UCHAR * remaining_io,
SLONG write_cnt = write(output_fl_desc, remaining_io, remaining_io_len);
switch (write_cnt)
{
case (-1): /* write failed */
case (-1): // write failed
close(output_fl_desc);
return FB_FAILURE;
break;
default:
if (write_cnt == remaining_io_len) /* write ok */
if (write_cnt == remaining_io_len) // write ok
return FB_SUCCESS;
else { /* could not write out all remaining data */
else { // could not write out all remaining data
close(output_fl_desc);
return FB_FAILURE;

View File

@ -42,9 +42,10 @@ public:
static void ALLD_push(class blk*, class dsql_lls**);
private:
BlockCache<class dsql_lls> lls_cache; /* Was plb_lls */
BlockCache<class dsql_lls> lls_cache; // Was plb_lls
};
extern DsqlMemoryPool *DSQL_permanent_pool;
#endif // DSQL_ALL_H

View File

@ -21,10 +21,11 @@
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_ALLD_PROTO_H_
#define _DSQL_ALLD_PROTO_H_
#ifndef DSQL_ALLD_PROTO_H
#define DSQL_ALLD_PROTO_H
void ALLD_init(); /* initialize pool system */
void ALLD_fini(); /* get rid of everything */
void ALLD_init(); // initialize pool system
void ALLD_fini(); // get rid of everything
#endif /* DSQL_ALLD_PROTO_H */
#endif /* _DSQL_ALLD_PROTO_H_ */

View File

@ -29,8 +29,8 @@
*
*/
#ifndef _DSQL_DSQL_H_
#define _DSQL_DSQL_H_
#ifndef DSQL_DSQL_H
#define DSQL_DSQL_H
#include "../jrd/common.h"
#include "../dsql/all.h"
@ -662,4 +662,5 @@ extern unsigned DSQL_debug;
(*request->req_blr++ = (UCHAR)(byte)) : GEN_expand_buffer (request, (UCHAR)(byte))
#endif // _DSQL_DSQL_H_
#endif // DSQL_DSQL_H

View File

@ -37,13 +37,17 @@
#include "ib_udf.h"
#ifndef SOLARIS
int MATHERR(struct exception *e)
#ifdef WIN_NT
#define exception_type _exception
#else
#define exception_type exception
#endif
int MATHERR(struct exception_type *e)
{
return 1;
}
#endif
#undef exception_type
#endif /* SOLARIS */
double EXPORT IB_UDF_abs( double *a)
{

View File

@ -24,7 +24,7 @@
//
//____________________________________________________________
//
// $Id: ada.cpp,v 1.25 2003-09-16 14:01:56 brodsom Exp $
// $Id: ada.cpp,v 1.26 2003-09-25 11:49:02 robocop Exp $
//
#include "firebird.h"
@ -144,25 +144,25 @@ static int first_flag;
#define FLOAT_DCL "interbase.isc_float"
#define DOUBLE_DCL "interbase.isc_double"
static inline void endif(int column)
static inline void endif(const int column)
{
printa(column, "end if;");
}
static inline void begin(int column)
static inline void begin(const int column)
{
printa(column, "begin");
}
static inline void endp(int column)
static inline void endp(const int column)
{
printa(column, "end");
}
static inline void set_sqlcode(ACT action, int column)
static inline void set_sqlcode(ACT action, const int column)
{
if (action->act_flags & ACT_sql)
printa (column, "SQLCODE := interbase.sqlcode (isc_status);");
printa(column, "SQLCODE := interbase.sqlcode(isc_status);");
}
//____________________________________________________________

View File

@ -27,7 +27,7 @@
//
//____________________________________________________________
//
// $Id: c_cxx.cpp,v 1.29 2003-09-16 14:01:56 brodsom Exp $
// $Id: c_cxx.cpp,v 1.30 2003-09-25 11:49:02 robocop Exp $
//
#include "firebird.h"
@ -160,20 +160,20 @@ static TEXT *status_name;
#define DCL_QUAD "ISC_QUAD"
#endif
static inline void begin(int column)
static inline void begin(const int column)
{
printa(column, "{");
}
static inline void endp(int column)
static inline void endp(const int column)
{
printa(column, "}");
}
static inline void set_sqlcode(ACT action, int column)
static inline void set_sqlcode(ACT action, const int column)
{
if (action->act_flags & ACT_sql)
printa (column, "SQLCODE = isc_sqlcode (%s);", status_name);
printa(column, "SQLCODE = isc_sqlcode(%s);", status_name);
}
//____________________________________________________________

View File

@ -25,7 +25,7 @@
//
//____________________________________________________________
//
// $Id: cme.cpp,v 1.10 2003-09-12 16:35:40 brodsom Exp $
// $Id: cme.cpp,v 1.11 2003-09-25 11:49:02 robocop Exp $
//
#include "firebird.h"
@ -134,7 +134,7 @@ const op_table operators[] =
};
static inline void assign_dtype(gpre_fld *f, gpre_fld *field)
static inline void assign_dtype(gpre_fld* f, const gpre_fld* field)
{
f->fld_dtype = field->fld_dtype;
f->fld_length = field->fld_length;
@ -147,10 +147,10 @@ static inline void assign_dtype(gpre_fld *f, gpre_fld *field)
}
/* One of d1,d2 is time, the other is date */
static inline bool is_date_and_time(USHORT d1, USHORT d2)
static inline bool is_date_and_time(const USHORT d1, const USHORT d2)
{
return ((((d1)==dtype_sql_time)&&((d2)==dtype_sql_date)) ||
(((d2)==dtype_sql_time)&&((d1)==dtype_sql_date)));
return (d1 == dtype_sql_time && d2 == dtype_sql_date) ||
(d2 == dtype_sql_time && d1 == dtype_sql_date);
}
//____________________________________________________________

View File

@ -24,7 +24,7 @@
//
//____________________________________________________________
//
// $Id: ftn.cpp,v 1.26 2003-09-13 12:23:31 brodsom Exp $
// $Id: ftn.cpp,v 1.27 2003-09-25 11:49:02 robocop Exp $
//
// 2002.10.28 Sean Leyne - Completed removal of obsolete "DGUX" port
// 2002.10.28 Sean Leyne - Completed removal of obsolete "SGI" port
@ -919,14 +919,14 @@ static void gen_based( ACT action)
// print the first variable, then precede the rest with commas
bool first_flag_l = true;
bool first = true;
while (based_on->bas_variables) {
variable = (TEXT *) POP(&based_on->bas_variables);
if (!first_flag_l)
if (!first)
ib_fprintf(out_file, ",\n%s", CONTINUE);
ib_fprintf(out_file, "%s", variable);
first_flag_l = false;
first = false;
if (field->fld_array_info && !(based_on->bas_flags & BAS_segment)) {
/* Print out the dimension part of the declaration */
ib_fprintf(out_file, "(");

View File

@ -25,7 +25,7 @@
//
//____________________________________________________________
//
// $Id: int.cpp,v 1.15 2003-09-16 14:01:55 brodsom Exp $
// $Id: int.cpp,v 1.16 2003-09-25 11:49:02 robocop Exp $
//
#include "firebird.h"
@ -38,7 +38,7 @@
#include "../gpre/lang_proto.h"
#include "../jrd/gds_proto.h"
static void align(int);
static void align(const int);
static void asgn_from(REF, int);
#ifdef NOT_USED_OR_REPLACED
static void asgn_to(REF);
@ -60,12 +60,12 @@ static void gen_routine(ACT, int);
static void gen_s_end(ACT, int);
static void gen_s_fetch(ACT, int);
static void gen_s_start(ACT, int);
static void gen_send(GPRE_REQ, POR, int, bool);
static void gen_start(GPRE_REQ, POR, int, bool);
static void gen_send(GPRE_REQ, const por*, int, bool);
static void gen_start(GPRE_REQ, const por*, int, bool);
static void gen_type(ACT, int);
static void gen_variable(ACT, int);
static void make_port(POR, int);
static void printa(int, TEXT *, ...) ATTRIBUTE_FORMAT(2,3);
static void printa(const int, const TEXT*, ...) ATTRIBUTE_FORMAT(2,3);
static int first_flag = 0;
@ -75,12 +75,12 @@ static int first_flag = 0;
#define JRD_VTOF "jrd_vtof"
#define VTO_CALL "%s ((const char*)%s, (char*)%s, %d);"
static inline void begin(int column)
static inline void begin(const int column)
{
printa(column, "{");
}
static inline void endp(int column)
static inline void endp(const int column)
{
printa(column, "}");
}
@ -167,7 +167,7 @@ void INT_action( ACT action, int column)
// Align output to a specific column for output.
//
static void align( int column)
static void align(const int column)
{
int i;
@ -261,10 +261,9 @@ static void asgn_to( REF reference)
static void gen_at_end( ACT action, int column)
{
GPRE_REQ request;
TEXT s[20];
request = action->act_request;
GPRE_REQ request = action->act_request;
printa(column, "if (!%s) ", gen_name(s, request->req_eof));
}
@ -290,12 +289,9 @@ static int gen_blr( int *user_arg, int offset, TEXT * string)
static void gen_compile( GPRE_REQ request, int column)
{
DBB db;
SYM symbol;
column += INDENT;
db = request->req_database;
symbol = db->dbb_name;
DBB db = request->req_database;
SYM symbol = db->dbb_name;
ib_fprintf(out_file, "if (!%s)", request->req_handle);
align(column);
ib_fprintf(out_file,
@ -311,13 +307,11 @@ static void gen_compile( GPRE_REQ request, int column)
static void gen_database( ACT action, int column)
{
GPRE_REQ request;
if (first_flag++ != 0)
return;
align(0);
for (request = requests; request; request = request->req_next)
for (GPRE_REQ request = requests; request; request = request->req_next)
gen_request(request);
}
@ -329,20 +323,17 @@ static void gen_database( ACT action, int column)
static void gen_emodify( ACT action, int column)
{
UPD modify;
REF reference;
GPRE_FLD field;
TEXT s1[20], s2[20];
modify = (UPD) action->act_object;
UPD modify = (UPD) action->act_object;
for (reference = modify->upd_port->por_references; reference;
for (REF reference = modify->upd_port->por_references; reference;
reference = reference->ref_next)
{
REF source = reference->ref_source;
if (!source)
continue;
field = reference->ref_field;
GPRE_FLD field = reference->ref_field;
align(column);
if (field->fld_dtype == dtype_text)
@ -370,9 +361,7 @@ static void gen_emodify( ACT action, int column)
static void gen_estore( ACT action, int column, bool special)
{
GPRE_REQ request;
request = action->act_request;
GPRE_REQ request = action->act_request;
align(column);
gen_compile(request, column);
gen_start(request, request->req_primary, column, special);
@ -386,9 +375,7 @@ static void gen_estore( ACT action, int column, bool special)
static void gen_endfor( ACT action, int column)
{
GPRE_REQ request;
request = action->act_request;
GPRE_REQ request = action->act_request;
column += INDENT;
if (request->req_sync)
@ -405,9 +392,7 @@ static void gen_endfor( ACT action, int column)
static void gen_erase( ACT action, int column)
{
UPD erase;
erase = (UPD) action->act_object;
UPD erase = (UPD) action->act_object;
gen_send(erase->upd_request, erase->upd_port, column, false);
}
@ -419,13 +404,12 @@ static void gen_erase( ACT action, int column)
static void gen_for( ACT action, int column)
{
GPRE_REQ request;
TEXT s[20];
gen_s_start(action, column);
align(column);
request = action->act_request;
GPRE_REQ request = action->act_request;
ib_fprintf(out_file, "while (1)");
column += INDENT;
begin(column);
@ -459,17 +443,15 @@ static TEXT* gen_name(TEXT* string, const REF reference)
static void gen_raw( GPRE_REQ request)
{
UCHAR *blr, c;
TEXT buffer[80], *p;
int blr_length;
TEXT buffer[80];
blr = request->req_blr;
blr_length = request->req_length;
p = buffer;
UCHAR* blr = request->req_blr;
int blr_length = request->req_length;
TEXT* p = buffer;
align(0);
while (--blr_length) {
c = *blr++;
const UCHAR c = *blr++;
if ((c >= 'A' && c <= 'Z') || c == '$' || c == '_')
sprintf(p, "'%c',", c);
else
@ -536,13 +518,12 @@ static void gen_request( GPRE_REQ request)
static void gen_routine( ACT action, int column)
{
GPRE_REQ request;
POR port;
for (request = (GPRE_REQ) action->act_object; request;
request = request->req_routine) for (port = request->req_ports; port;
port = port->por_next)
for (GPRE_REQ request = (GPRE_REQ) action->act_object; request;
request = request->req_routine)
{
for (POR port = request->req_ports; port; port = port->por_next)
make_port(port, column + INDENT);
}
}
@ -553,9 +534,7 @@ static void gen_routine( ACT action, int column)
static void gen_s_end( ACT action, int column)
{
GPRE_REQ request;
request = action->act_request;
GPRE_REQ request = action->act_request;
printa(column, "EXE_unwind (tdbb, %s);", request->req_handle);
}
@ -567,9 +546,7 @@ static void gen_s_end( ACT action, int column)
static void gen_s_fetch( ACT action, int column)
{
GPRE_REQ request;
request = action->act_request;
GPRE_REQ request = action->act_request;
if (request->req_sync)
gen_send(request, request->req_sync, column, false);
@ -585,13 +562,11 @@ static void gen_s_fetch( ACT action, int column)
static void gen_s_start( ACT action, int column)
{
GPRE_REQ request;
POR port;
request = action->act_request;
GPRE_REQ request = action->act_request;
gen_compile(request, column);
if (port = request->req_vport)
const por* port = request->req_vport;
if (port)
asgn_from(port->por_references, column);
gen_start(request, port, column, false);
@ -603,7 +578,7 @@ static void gen_s_start( ACT action, int column)
// Generate a send or receive call for a port.
//
static void gen_send( GPRE_REQ request, POR port, int column, bool special)
static void gen_send( GPRE_REQ request, const por* port, int column, bool special)
{
if (special) {
@ -625,7 +600,7 @@ static void gen_send( GPRE_REQ request, POR port, int column, bool special)
// Generate a START.
//
static void gen_start( GPRE_REQ request, POR port, int column, bool special)
static void gen_start( GPRE_REQ request, const por* port, int column, bool special)
{
align(column);
@ -644,7 +619,6 @@ static void gen_start( GPRE_REQ request, POR port, int column, bool special)
static void gen_type( ACT action, int column)
{
printa(column, "%ld", (SLONG) action->act_object);
}
@ -671,19 +645,17 @@ static void gen_variable( ACT action, int column)
static void make_port( POR port, int column)
{
GPRE_FLD field;
REF reference;
SYM symbol;
TEXT *name, s[50];
TEXT s[50];
printa(column, "struct {");
for (reference = port->por_references; reference;
reference = reference->ref_next) {
for (REF reference = port->por_references; reference;
reference = reference->ref_next)
{
align(column + INDENT);
field = reference->ref_field;
symbol = field->fld_symbol;
name = symbol->sym_string;
GPRE_FLD field = reference->ref_field;
SYM symbol = field->fld_symbol;
TEXT* name = symbol->sym_string;
switch (field->fld_dtype) {
case dtype_short:
ib_fprintf(out_file, " SSHORT jrd_%d;\t/* %s */",
@ -756,7 +728,7 @@ static void make_port( POR port, int column)
// Print a fixed string at a particular column.
//
static void printa( int column, TEXT * string, ...)
static void printa(const int column, const TEXT* string, ...)
{
va_list ptr;
@ -764,3 +736,4 @@ static void printa( int column, TEXT * string, ...)
align(column);
ib_vfprintf(out_file, string, ptr);
}

View File

@ -25,7 +25,7 @@
//
//____________________________________________________________
//
// $Id: int_cxx.cpp,v 1.14 2003-09-16 14:01:55 brodsom Exp $
// $Id: int_cxx.cpp,v 1.15 2003-09-25 11:49:02 robocop Exp $
//
#include "firebird.h"
@ -38,7 +38,7 @@
#include "../gpre/lang_proto.h"
#include "../jrd/gds_proto.h"
static void align(int);
static void align(const int);
static void asgn_from(REF, int);
#ifdef NOT_USED_OR_REPLACED
static void asgn_to(REF);
@ -60,12 +60,12 @@ static void gen_routine(ACT, int);
static void gen_s_end(ACT, int);
static void gen_s_fetch(ACT, int);
static void gen_s_start(ACT, int);
static void gen_send(GPRE_REQ, POR, int, bool);
static void gen_start(GPRE_REQ, POR, int, bool);
static void gen_send(GPRE_REQ, const por*, int, bool);
static void gen_start(GPRE_REQ, const por*, int, bool);
static void gen_type(ACT, int);
static void gen_variable(ACT, int);
static void make_port(POR, int);
static void printa(int, TEXT *, ...);
static void printa(const int, const TEXT*, ...);
static int first_flag = 0;
@ -75,12 +75,12 @@ static int first_flag = 0;
#define JRD_VTOF "jrd_vtof"
#define VTO_CALL "%s ((const char*)%s, (char*)%s, %d);"
static inline void begin(int column)
static inline void begin(const int column)
{
printa(column, "{");
}
static inline void endp(int column)
static inline void endp(const int column)
{
printa(column, "}");
}
@ -167,7 +167,7 @@ void INT_CXX_action( ACT action, int column)
// Align output to a specific column for output.
//
static void align( int column)
static void align(const int column)
{
int i;
@ -234,12 +234,10 @@ static void asgn_from( REF reference, int column)
#ifdef NOT_USED_OR_REPLACED
static void asgn_to( REF reference)
{
GPRE_FLD field;
REF source;
TEXT s[20];
source = reference->ref_friend;
field = source->ref_field;
REF source = reference->ref_friend;
GPRE_FLD field = source->ref_field;
gen_name(s, source);
#pragma FB_COMPILER_MESSAGE("BUG: Checking for zero pointer - then using it!")
@ -266,10 +264,9 @@ static void asgn_to( REF reference)
static void gen_at_end( ACT action, int column)
{
GPRE_REQ request;
TEXT s[20];
request = action->act_request;
GPRE_REQ request = action->act_request;
printa(column, "if (!%s) ", gen_name(s, request->req_eof));
}
@ -376,9 +373,7 @@ static void gen_emodify( ACT action, int column)
static void gen_estore( ACT action, int column, bool special)
{
GPRE_REQ request;
request = action->act_request;
GPRE_REQ request = action->act_request;
align(column);
gen_compile(request, column);
gen_start(request, request->req_primary, column, special);
@ -392,9 +387,7 @@ static void gen_estore( ACT action, int column, bool special)
static void gen_endfor( ACT action, int column)
{
GPRE_REQ request;
request = action->act_request;
GPRE_REQ request = action->act_request;
column += INDENT;
if (request->req_sync)
@ -411,9 +404,7 @@ static void gen_endfor( ACT action, int column)
static void gen_erase( ACT action, int column)
{
UPD erase;
erase = (UPD) action->act_object;
UPD erase = (UPD) action->act_object;
gen_send(erase->upd_request, erase->upd_port, column, false);
}
@ -425,13 +416,12 @@ static void gen_erase( ACT action, int column)
static void gen_for( ACT action, int column)
{
GPRE_REQ request;
TEXT s[20];
gen_s_start(action, column);
align(column);
request = action->act_request;
GPRE_REQ request = action->act_request;
ib_fprintf(out_file, "while (1)");
column += INDENT;
begin(column);
@ -465,17 +455,15 @@ static char* gen_name(char* string, const REF reference)
static void gen_raw( GPRE_REQ request)
{
UCHAR *blr, c;
TEXT buffer[80], *p;
int blr_length;
TEXT buffer[80];
blr = request->req_blr;
blr_length = request->req_length;
p = buffer;
const UCHAR* blr = request->req_blr;
int blr_length = request->req_length;
TEXT* p = buffer;
align(0);
while (--blr_length) {
c = *blr++;
const UCHAR c = *blr++;
if ((c >= 'A' && c <= 'Z') || c == '$' || c == '_')
sprintf(p, "'%c',", c);
else
@ -542,13 +530,12 @@ static void gen_request( GPRE_REQ request)
static void gen_routine( ACT action, int column)
{
GPRE_REQ request;
POR port;
for (request = (GPRE_REQ) action->act_object; request;
for (GPRE_REQ request = (GPRE_REQ) action->act_object; request;
request = request->req_routine)
for (port = request->req_ports; port; port = port->por_next)
{
for (POR port = request->req_ports; port; port = port->por_next)
make_port(port, column + INDENT);
}
}
@ -559,9 +546,7 @@ static void gen_routine( ACT action, int column)
static void gen_s_end( ACT action, int column)
{
GPRE_REQ request;
request = action->act_request;
GPRE_REQ request = action->act_request;
printa(column, "EXE_unwind (tdbb, %s);", request->req_handle);
}
@ -573,9 +558,7 @@ static void gen_s_end( ACT action, int column)
static void gen_s_fetch( ACT action, int column)
{
GPRE_REQ request;
request = action->act_request;
GPRE_REQ request = action->act_request;
if (request->req_sync)
gen_send(request, request->req_sync, column, false);
@ -591,13 +574,11 @@ static void gen_s_fetch( ACT action, int column)
static void gen_s_start( ACT action, int column)
{
GPRE_REQ request;
POR port;
request = action->act_request;
GPRE_REQ request = action->act_request;
gen_compile(request, column);
if (port = request->req_vport)
const por* port = request->req_vport;
if (port)
asgn_from(port->por_references, column);
gen_start(request, port, column, false);
@ -609,7 +590,7 @@ static void gen_s_start( ACT action, int column)
// Generate a send or receive call for a port.
//
static void gen_send( GPRE_REQ request, POR port, int column, bool special)
static void gen_send( GPRE_REQ request, const por* port, int column, bool special)
{
if (special) {
align(column);
@ -630,7 +611,7 @@ static void gen_send( GPRE_REQ request, POR port, int column, bool special)
// Generate a START.
//
static void gen_start( GPRE_REQ request, POR port, int column, bool special)
static void gen_start( GPRE_REQ request, const por* port, int column, bool special)
{
align(column);
@ -676,19 +657,17 @@ static void gen_variable( ACT action, int column)
static void make_port( POR port, int column)
{
GPRE_FLD field;
REF reference;
SYM symbol;
TEXT *name, s[50];
TEXT s[50];
printa(column, "struct {");
for (reference = port->por_references; reference;
reference = reference->ref_next) {
for (REF reference = port->por_references; reference;
reference = reference->ref_next)
{
align(column + INDENT);
field = reference->ref_field;
symbol = field->fld_symbol;
name = symbol->sym_string;
GPRE_FLD field = reference->ref_field;
SYM symbol = field->fld_symbol;
TEXT* name = symbol->sym_string;
switch (field->fld_dtype) {
case dtype_short:
ib_fprintf(out_file, " SSHORT jrd_%d;\t/* %s */",
@ -761,7 +740,7 @@ static void make_port( POR port, int column)
// Print a fixed string at a particular column.
//
static void printa( int column, TEXT * string, ...)
static void printa(const int column, const TEXT* string, ...)
{
va_list ptr;
@ -769,3 +748,4 @@ static void printa( int column, TEXT * string, ...)
align(column);
ib_vfprintf(out_file, string, ptr);
}

View File

@ -24,7 +24,7 @@
//
//____________________________________________________________
//
// $Id: pas.cpp,v 1.21 2003-09-16 14:01:55 brodsom Exp $
// $Id: pas.cpp,v 1.22 2003-09-25 11:49:02 robocop Exp $
//
#include "firebird.h"
@ -49,7 +49,7 @@
// why I rather than trying to use it currently remove it from compilation.
static void align(int);
static void align(const int);
static void asgn_from(ACT, REF, int);
static void asgn_sqlda_from(REF, int, TEXT *, int);
static void asgn_to(ACT, REF, int);
@ -159,25 +159,25 @@ static int first_flag;
#define GDS_EVENT_COUNTS "GDS__EVENT_COUNTS"
#define GDS_EVENT_WAIT "GDS__EVENT_WAIT"
static inline void begin(int column)
static inline void begin(const int column)
{
printa(column, "begin");
}
static inline void endp(int column)
static inline void endp(const int column)
{
printa(column, "end");
}
static inline void ends(int column)
static inline void ends(const int column)
{
printa(column, "end;");
}
static inline void set_sqlcode(ACT action, int column)
static inline void set_sqlcode(ACT action, const int column)
{
if (action->act_flags & ACT_sql)
printa (column, "SQLCODE := gds__sqlcode (gds__status);");
printa(column, "SQLCODE := gds__sqlcode (gds__status);");
}
//____________________________________________________________
@ -522,7 +522,7 @@ void PAS_action( ACT action, int column)
// Align output to a specific column for output.
//
static void align( int column)
static void align(const int column)
{
int i;
@ -1303,7 +1303,7 @@ static void gen_database( ACT action, int column)
for (reference = port->por_references; reference;
reference = reference->ref_next)
{
if (reference-> ref_flags & REF_fetch_array) {
if (reference->ref_flags & REF_fetch_array) {
make_array_declaration(reference);
array_flag = true;
}
@ -2659,7 +2659,7 @@ static void gen_request( GPRE_REQ request, int column)
sw_volatile = FB_DP_VOLATILE;
printa(column, " ");
if (!(request-> req_flags & (REQ_exp_hand | REQ_sql_blob_open |
if (!(request->req_flags & (REQ_exp_hand | REQ_sql_blob_open |
REQ_sql_blob_create)) && request->req_type != REQ_slice
&& request->req_type != REQ_procedure)
{
@ -3760,3 +3760,4 @@ static void t_start_auto( ACT action, GPRE_REQ request, TEXT * vector, int colum
set_sqlcode(action, column);
ends(column);
}

View File

@ -25,7 +25,7 @@
//
//____________________________________________________________
//
// $Id: sql.cpp,v 1.24 2003-09-13 12:23:31 brodsom Exp $
// $Id: sql.cpp,v 1.25 2003-09-25 11:49:02 robocop Exp $
//
#include "firebird.h"
@ -149,10 +149,10 @@ static SWE whenever[SWE_max], whenever_list;
static inline bool end_of_command(void)
{
return (((sw_language != lang_cobol) &&
return ((sw_language != lang_cobol) &&
((int) token.tok_keyword == (int) KW_SEMI_COLON)) ||
((sw_language == lang_cobol) &&
((int) token.tok_keyword == (int) KW_END_EXEC)));
((int) token.tok_keyword == (int) KW_END_EXEC));
}
@ -6291,7 +6291,7 @@ void SQL_resolve_identifier( TEXT * err_mesg, TEXT * str)
static void dialect1_bad_type(USHORT field_dtype)
{
char buffer[200];
char *s = NULL;
const char *s = NULL;
switch (field_dtype) {
case dtype_sql_date:

View File

@ -3256,7 +3256,7 @@ static void send_no_wait( ICC icc)
}
static void send_response( ICC icc, ISC_STATUS * status_vector)
static void send_response( ICC icc, ISC_STATUS* status_vector)
{
/**************************************
*
@ -3271,7 +3271,6 @@ static void send_response( ICC icc, ISC_STATUS * status_vector)
ISC_STATUS *comm_status;
USHORT i, length;
ULONG to_copy, size_left;
TEXT *p, buffer[1024];
TEXT *acursor, *scursor, *abase;
ips_comm_area *comm;
TEXT *comm_ptr;
@ -3297,9 +3296,11 @@ static void send_response( ICC icc, ISC_STATUS * status_vector)
{
/* transfer the status vector, putting strings in the comm area's
data area */
TEXT buffer[1024];
while (*status_vector)
{
const TEXT* p;
switch (*status_vector)
{
case isc_arg_interpreted:

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: Interactive SQL utility
* MODULE: isql.e
* MODULE: isql.epp
* DESCRIPTION: Main line routine
*
* The contents of this file are subject to the Interbase Public
@ -785,7 +785,7 @@ void ISQL_copy_SQL_id(TEXT * in_str,
}
void ISQL_errmsg(ISC_STATUS * status)
void ISQL_errmsg(const ISC_STATUS* status)
{
/**************************************
*
@ -798,14 +798,13 @@ void ISQL_errmsg(ISC_STATUS * status)
* Simulate isc_print_status exactly, to control ib_stderr
**************************************/
TEXT errbuf[MSG_LENGTH];
ISC_STATUS *vec;
#if defined (WIN95)
#define TRANSLATE_CP if (!fAnsiCP) AnsiToOem(errbuf, errbuf)
#else
#define TRANSLATE_CP
#endif
vec = status;
const ISC_STATUS* vec = status;
if (Quiet)
Exit_value = FINI_ERROR;
else {
@ -814,7 +813,10 @@ void ISQL_errmsg(ISC_STATUS * status)
&& vec[2] != gds_arg_warning) || (vec[0] == gds_arg_gds
&& vec[1] == 0
&& vec[2] == gds_arg_warning
&& !Warnings)) return;
&& !Warnings))
{
return;
}
gds__msg_format(NULL, ISQL_MSG_FAC, 0, sizeof(errbuf), errbuf,
(TEXT *) isc_sqlcode(status), NULL, NULL, NULL, NULL);
TRANSLATE_CP;
@ -833,7 +835,7 @@ void ISQL_errmsg(ISC_STATUS * status)
}
void ISQL_warning(ISC_STATUS * status)
void ISQL_warning(ISC_STATUS* status)
{
/**************************************
*
@ -845,8 +847,6 @@ void ISQL_warning(ISC_STATUS * status)
* Report warning
* Simulate isc_print_status exactly, to control ib_stderr
**************************************/
ISC_STATUS *vec;
TEXT buf[MSG_LENGTH];
#if defined (WIN95)
#define TRANSLATE_CP if (!fAnsiCP) AnsiToOem(buf, buf)
#else
@ -854,13 +854,17 @@ void ISQL_warning(ISC_STATUS * status)
#endif
vec = status;
const ISC_STATUS* vec = status;
fb_assert(vec[1] == 0); /* shouldn't be any errors */
if (!Quiet) {
if (vec[0] != gds_arg_gds ||
vec[2] != gds_arg_warning ||
(vec[2] == gds_arg_warning && !Warnings)) return;
(vec[2] == gds_arg_warning && !Warnings))
{
return;
}
TEXT buf[MSG_LENGTH];
isc_interprete(buf, &vec);
TRANSLATE_CP;
STDERROUT(buf, 1);

View File

@ -36,8 +36,8 @@ extern int ISQL_create_database(TEXT *,
SCHAR *, IB_FILE *, IB_FILE *, IB_FILE *);
extern bool ISQL_dbcheck(void);
extern void ISQL_disconnect_database(bool);
extern void ISQL_errmsg(ISC_STATUS *);
extern void ISQL_warning(ISC_STATUS *);
extern void ISQL_errmsg(const ISC_STATUS*);
extern void ISQL_warning(ISC_STATUS*);
extern void ISQL_exit_db(void);
extern int ISQL_extract(TEXT *, int, IB_FILE *, IB_FILE *, IB_FILE *);
extern int ISQL_frontend_command(TEXT *, IB_FILE *, IB_FILE *, IB_FILE *);
@ -65,3 +65,4 @@ extern void ISQL_truncate_term(TEXT *, USHORT);
extern void ISQL_win_err(SCHAR *);
#endif /* ISQL_ISQL_PROTO_H */

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: alt.c
* MODULE: alt.cpp
* DESCRIPTION: Alternative entrypoints
*
* The contents of this file are subject to the Interbase Public
@ -665,12 +665,12 @@ void API_ROUTINE isc_qtoq(GDS_QUAD * quad1, GDS_QUAD * quad2)
gds__qtoq(quad1, quad2);
}
SLONG API_ROUTINE isc_sqlcode(ISC_STATUS * status_vector)
SLONG API_ROUTINE isc_sqlcode(const ISC_STATUS* status_vector)
{
return gds__sqlcode(status_vector);
}
void API_ROUTINE isc_sqlcode_s(ISC_STATUS * status_vector, ULONG * sqlcode)
void API_ROUTINE isc_sqlcode_s(const ISC_STATUS* status_vector, ULONG * sqlcode)
{
*sqlcode = gds__sqlcode(status_vector);
return;
@ -712,7 +712,7 @@ ISC_STATUS API_ROUTINE isc_wait_for_event(ISC_STATUS * status_vector,
}
#endif
ISC_STATUS API_ROUTINE isc_interprete(SCHAR * buffer, ISC_STATUS ** status_vector_p)
ISC_STATUS API_ROUTINE isc_interprete(SCHAR* buffer, const ISC_STATUS** status_vector_p)
{
return gds__interprete(buffer, status_vector_p);
}

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: gds.c
* MODULE: gds.cpp
* DESCRIPTION: User callable routines
*
* The contents of this file are subject to the Interbase Public
@ -782,7 +782,7 @@ void API_ROUTINE gds_alloc_report(ULONG flags, char* filename, int lineno)
}
#endif // DEBUG_GDS_ALLOC
SLONG API_ROUTINE gds__interprete(char *s, ISC_STATUS ** vector)
SLONG API_ROUTINE gds__interprete(char* s, const ISC_STATUS** vector)
{
/**************************************
*
@ -796,13 +796,6 @@ SLONG API_ROUTINE gds__interprete(char *s, ISC_STATUS ** vector)
* message is null (end of messages) or invalid, return 0;
*
**************************************/
TEXT *p, *q, *temp;
SSHORT l, temp_len;
TEXT **arg, *args[10];
ISC_STATUS code, *v;
UCHAR x;
ISC_STATUS decoded;
#ifdef VMS
ISC_STATUS status;
TEXT flags[4];
@ -812,8 +805,8 @@ SLONG API_ROUTINE gds__interprete(char *s, ISC_STATUS ** vector)
if (!**vector)
return 0;
temp = NULL;
const ISC_STATUS* v;
ISC_STATUS code;
/* handle a case: "no errors, some warning(s)" */
if ((*vector)[1] == 0 && (*vector)[2] == isc_arg_warning) {
v = *vector + 4;
@ -824,16 +817,23 @@ SLONG API_ROUTINE gds__interprete(char *s, ISC_STATUS ** vector)
code = (*vector)[1];
}
arg = args;
TEXT* args[10];
TEXT** arg = args;
/* Parse and collect any arguments that may be present */
TEXT* p;
const TEXT* q;
const SSHORT temp_len = (SSHORT) BUFFER_SMALL;
TEXT* temp = NULL;
SSHORT l;
for (;;) {
x = (UCHAR) * v++;
const UCHAR x = (UCHAR) *v++;
switch (x) {
case gds_arg_string:
case gds_arg_number:
*arg++ = (TEXT *) * v++;
*arg++ = (TEXT*) *v++;
continue;
case gds_arg_cstring:
@ -842,21 +842,20 @@ SLONG API_ROUTINE gds__interprete(char *s, ISC_STATUS ** vector)
Give up if we can't get one. */
p = temp = (TEXT*) gds__alloc((SLONG) BUFFER_SMALL);
temp_len = (SSHORT) BUFFER_SMALL;
/* FREE: at procedure exit */
if (!temp) /* NOMEM: */
return 0;
}
l = (SSHORT) * v++;
q = (TEXT *) * v++;
l = (SSHORT) *v++;
q = (const TEXT*) *v++;
*arg++ = p;
/* ensure that we do not overflow the buffer allocated */
l = (temp_len < l) ? temp_len : l;
if (l)
do
do {
*p++ = *q++;
while (--l);
} while (--l);
*p++ = 0;
continue;
@ -874,10 +873,11 @@ SLONG API_ROUTINE gds__interprete(char *s, ISC_STATUS ** vector)
case gds_arg_gds:
{
USHORT fac = 0, class_ = 0;
decoded = gds__decode(code, &fac, &class_);
const ISC_STATUS decoded = gds__decode(code, &fac, &class_);
if (gds__msg_format(0, fac, (USHORT) decoded,
128, s, args[0], args[1], args[2], args[3],
args[4]) < 0) {
args[4]) < 0)
{
if ((decoded < FB_NELEM(messages) - 1) && (decoded >= 0))
sprintf(s, messages[decoded], args[0], args[1], args[2],
args[3], args[4]);
@ -889,14 +889,14 @@ SLONG API_ROUTINE gds__interprete(char *s, ISC_STATUS ** vector)
case gds_arg_interpreted:
p = s;
q = (TEXT *) (*vector)[1];
q = (const TEXT*) (*vector)[1];
while ((*p++ = *q++) /*!= NULL*/);
break;
case gds_arg_unix:
/* The strerror() function returns the appropriate description
string, or an unknown error message if the error code is unknown. */
p = (TEXT*)strerror(code);
p = (TEXT*) strerror(code);
break;
case gds_arg_dos:
@ -949,18 +949,18 @@ SLONG API_ROUTINE gds__interprete(char *s, ISC_STATUS ** vector)
gds__free((SLONG *) temp);
*vector = v;
p = s;
while (*p)
p++;
const TEXT* end = s;
while (*end)
end++;
return p - s;
return end - s;
}
void API_ROUTINE gds__interprete_a(
SCHAR * s,
SSHORT * length,
ISC_STATUS * vector, SSHORT * offset)
const ISC_STATUS* vector, SSHORT * offset)
{
/**************************************
*
@ -976,9 +976,7 @@ void API_ROUTINE gds__interprete_a(
* the concept of indexing into the vector.
*
**************************************/
ISC_STATUS *v;
v = vector + *offset;
const ISC_STATUS *v = vector + *offset;
*length = (SSHORT) gds__interprete(s, &v);
*offset = v - vector;
}
@ -1155,7 +1153,7 @@ void API_ROUTINE gds__log(const TEXT * text, ...)
}
void API_ROUTINE gds__log_status(TEXT * database, ISC_STATUS * status_vector)
void API_ROUTINE gds__log_status(TEXT * database, const ISC_STATUS* status_vector)
{
/**************************************
*
@ -1853,7 +1851,7 @@ void API_ROUTINE gds__prefix_msg(TEXT * string, const TEXT * root)
#endif
ISC_STATUS API_ROUTINE gds__print_status(ISC_STATUS * vec)
ISC_STATUS API_ROUTINE gds__print_status(const ISC_STATUS* vec)
{
/**************************************
*
@ -1865,18 +1863,15 @@ ISC_STATUS API_ROUTINE gds__print_status(ISC_STATUS * vec)
* Interprete a status vector.
*
**************************************/
ISC_STATUS *vector;
TEXT *s;
if (!vec || (!vec[1] && vec[2] == gds_arg_end))
return FB_SUCCESS;
s = (TEXT *) gds__alloc((SLONG) BUFFER_LARGE);
TEXT* s = (TEXT *) gds__alloc((SLONG) BUFFER_LARGE);
/* FREE: at procedure return */
if (!s) /* NOMEM: */
return vec[1];
vector = vec;
const ISC_STATUS* vector = vec;
if (!gds__interprete(s, &vector)) {
gds__free((SLONG *) s);
@ -2180,7 +2175,7 @@ void API_ROUTINE gds__register_cleanup(FPTR_VOID_PTR routine, void *arg)
}
SLONG API_ROUTINE gds__sqlcode(ISC_STATUS * status_vector)
SLONG API_ROUTINE gds__sqlcode(const ISC_STATUS* status_vector)
{
/**************************************
*
@ -2199,18 +2194,13 @@ SLONG API_ROUTINE gds__sqlcode(ISC_STATUS * status_vector)
* first code for which there is a non-generic SQLCODE, return it.
*
**************************************/
USHORT code;
SLONG sqlcode;
ISC_STATUS *s;
USHORT have_sqlcode;
if (!status_vector) {
DEV_REPORT("gds__sqlcode: NULL status vector");
return GENERIC_SQLCODE;
}
have_sqlcode = FALSE;
sqlcode = GENERIC_SQLCODE; /* error of last resort */
bool have_sqlcode = false;
SLONG sqlcode = GENERIC_SQLCODE; /* error of last resort */
/* SQL code -999 (GENERIC_SQLCODE) is generic, meaning "no other sql code
* known". Now scan the status vector, seeing if there is ANY sqlcode
@ -2219,7 +2209,7 @@ SLONG API_ROUTINE gds__sqlcode(ISC_STATUS * status_vector)
* sqlerr reported.
*/
s = status_vector;
const ISC_STATUS* s = status_vector;
while (*s != gds_arg_end)
{
if (*s == gds_arg_gds)
@ -2235,13 +2225,13 @@ SLONG API_ROUTINE gds__sqlcode(ISC_STATUS * status_vector)
sql_codes */
USHORT fac = 0, class_ = 0;
code = (USHORT) gds__decode(status_vector[1], &fac, &class_);
USHORT code = (USHORT) gds__decode(status_vector[1], &fac, &class_);
if ((code < FB_NELEM(gds__sql_code)) &&
(gds__sql_code[code] != GENERIC_SQLCODE))
{
sqlcode = gds__sql_code[code];
have_sqlcode = TRUE;
have_sqlcode = true;
}
}
s++;
@ -2256,7 +2246,7 @@ SLONG API_ROUTINE gds__sqlcode(ISC_STATUS * status_vector)
}
void API_ROUTINE gds__sqlcode_s(ISC_STATUS * status_vector, ULONG * sqlcode)
void API_ROUTINE gds__sqlcode_s(const ISC_STATUS* status_vector, ULONG* sqlcode)
{
/**************************************
*
@ -2268,7 +2258,7 @@ void API_ROUTINE gds__sqlcode_s(ISC_STATUS * status_vector, ULONG * sqlcode)
* Translate GDS error code to SQL error code. This is a little
* imprecise (to say the least) because we don't know the proper
* SQL codes. One must do what what can; stiff upper lip, and all
* that. THIS IS THE COBOL VERSION. (Some cobols son't have
* that. THIS IS THE COBOL VERSION. (Some cobols don't have
* return values for calls...
*
**************************************/

View File

@ -79,11 +79,11 @@ 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*, ISC_STATUS**);
void API_ROUTINE gds__interprete_a(SCHAR*, SSHORT*, ISC_STATUS*, SSHORT*);
SLONG API_ROUTINE gds__interprete(char*, const ISC_STATUS**);
void API_ROUTINE gds__interprete_a(SCHAR*, SSHORT*, const ISC_STATUS*, SSHORT*);
void API_ROUTINE gds__log(const TEXT*, ...);
void API_ROUTINE gds__trace(const TEXT*);
void API_ROUTINE gds__log_status(TEXT*, ISC_STATUS*);
void API_ROUTINE gds__log_status(TEXT*, const ISC_STATUS*);
int API_ROUTINE gds__msg_close(void*);
SSHORT API_ROUTINE gds__msg_format(void* handle,
USHORT facility,
@ -105,7 +105,7 @@ void API_ROUTINE gds__prefix_lock(TEXT*, const TEXT*);
void API_ROUTINE gds__prefix_msg(TEXT*, const TEXT*);
SLONG API_ROUTINE gds__get_prefix(SSHORT, TEXT*);
ISC_STATUS API_ROUTINE gds__print_status(ISC_STATUS*);
ISC_STATUS API_ROUTINE gds__print_status(const ISC_STATUS*);
USHORT API_ROUTINE gds__parse_bpb(USHORT, UCHAR*, USHORT*, USHORT*);
USHORT API_ROUTINE gds__parse_bpb2(USHORT, UCHAR*, SSHORT*, SSHORT*,
USHORT*, USHORT*);
@ -115,8 +115,8 @@ 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(ISC_STATUS*);
void API_ROUTINE gds__sqlcode_s(ISC_STATUS*, ULONG*);
SLONG API_ROUTINE gds__sqlcode(const ISC_STATUS*);
void API_ROUTINE gds__sqlcode_s(const ISC_STATUS*, ULONG*);
void API_ROUTINE gds__temp_dir(TEXT*);
void* API_ROUTINE gds__temp_file(BOOLEAN, TEXT*, TEXT*, TEXT* = NULL, BOOLEAN = FALSE);
void API_ROUTINE gds__unregister_cleanup(FPTR_VOID_PTR, void*);

View File

@ -263,9 +263,9 @@ int GDS_EXPORT gds__disable_subsystem(char *);
int GDS_EXPORT gds__enable_subsystem(char *);
ISC_STATUS GDS_EXPORT gds__print_status(ISC_STATUS *);
ISC_STATUS GDS_EXPORT gds__print_status(const ISC_STATUS*);
ISC_STATUS GDS_EXPORT gds__sqlcode(ISC_STATUS *);
ISC_STATUS GDS_EXPORT gds__sqlcode(const ISC_STATUS*);
ISC_STATUS GDS_EXPORT gds__ddl(ISC_STATUS *,
FRBRD **,

View File

@ -33,7 +33,7 @@
*
*/
/*
$Id: ibase.h,v 1.45 2003-09-21 13:33:45 skidder Exp $
$Id: ibase.h,v 1.46 2003-09-25 11:49:06 robocop Exp $
*/
#ifndef JRD_IBASE_H
@ -636,8 +636,8 @@ ISC_STATUS ISC_EXPORT isc_get_slice(ISC_STATUS *,
void *,
ISC_LONG *);
ISC_STATUS ISC_EXPORT isc_interprete(char *,
ISC_STATUS * *);
ISC_STATUS ISC_EXPORT isc_interprete(char*,
const ISC_STATUS**);
ISC_STATUS ISC_EXPORT isc_open_blob(ISC_STATUS *,
isc_db_handle *,
@ -702,7 +702,7 @@ ISC_STATUS ISC_EXPORT_VARARG isc_start_transaction(ISC_STATUS *,
isc_tr_handle *,
short, ...);
ISC_LONG ISC_EXPORT isc_sqlcode(ISC_STATUS *);
ISC_LONG ISC_EXPORT isc_sqlcode(const ISC_STATUS*);
void ISC_EXPORT isc_sql_interprete(short,
char *,

View File

@ -24,8 +24,8 @@
* in the texttype struct so we remain compatible with any IB WRT intl module.
*/
#ifndef _JRD_INTLOBJ_H_
#define _JRD_INTLOBJ_H_
#ifndef JRD_INTLOBJ_H
#define JRD_INTLOBJ_H
#ifdef __cplusplus
extern "C" {
@ -69,7 +69,7 @@ typedef struct intl_blk {
USHORT blk_length;
} intl_blk;
typedef unsigned short(*pfn_INTL_init)(struct texttype *,short,short);
typedef unsigned short(*pfn_INTL_init)(struct texttype*, short, short);
typedef struct texttype {
struct intl_blk texttype_blk;
@ -184,4 +184,5 @@ typedef struct charset
} /* extern "C" */
#endif
#endif /* _JRD_INTLOBJ_H_ */
#endif /* JRD_INTLOBJ_H */

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: isc.c
* MODULE: isc.cpp
* DESCRIPTION: General purpose but non-user routines.
*
* The contents of this file are subject to the Interbase Public
@ -36,7 +36,7 @@
*
*/
/*
$Id: isc.cpp,v 1.38 2003-09-22 17:52:27 brodsom Exp $
$Id: isc.cpp,v 1.39 2003-09-25 11:49:06 robocop Exp $
*/
#ifdef DARWIN
#define _STLP_CCTYPE
@ -229,9 +229,7 @@ int DLL_EXPORT ISC_check_process_existence(SLONG pid,
#ifdef VMS
#define CHECK_EXIST
ULONG item;
item = JPI$_PID;
ULONG item = JPI$_PID;
return (lib$getjpi(&item, &pid, NULL, NULL, NULL, NULL) == SS$_NONEXPR) ?
FALSE : TRUE;
#endif
@ -270,9 +268,7 @@ int ISC_expand_logical_once(
* Expand a logical name. If it doesn't exist, return 0.
*
**************************************/
int attr;
USHORT l;
TEXT *p;
ITM items[2];
struct dsc$descriptor_s desc1, desc2;
@ -290,7 +286,7 @@ int ISC_expand_logical_once(
items[1].itm_length = 0;
items[1].itm_code = 0;
attr = LNM$M_CASE_BLIND;
int attr = LNM$M_CASE_BLIND;
if (!(sys$trnlnm(&attr, &desc2, &desc1, NULL, items) & 1)) {
while (file_length--)
@ -346,12 +342,10 @@ TEXT *INTERNAL_API_ROUTINE ISC_get_host(TEXT * string, USHORT length)
* Get host name.
*
**************************************/
TEXT *p;
if (!ISC_expand_logical_once("SYS$NODE", sizeof("SYS$NODE") - 1, string))
strcpy(string, "local");
else {
p = string;
TEXT* p = string;
if (*p == '_')
++p;
@ -494,11 +488,13 @@ int INTERNAL_API_ROUTINE ISC_get_user(TEXT* name,
#ifdef VMS
int INTERNAL_API_ROUTINE ISC_get_user(
TEXT * name,
int *id,
int *group,
TEXT * project,
TEXT * organization, int *node, TEXT * user_string)
TEXT* name,
int* id,
int* group,
TEXT* project,
TEXT* organization,
int* node,
TEXT* user_string)
{
/**************************************
*
@ -510,10 +506,9 @@ TEXT * organization, int *node, TEXT * user_string)
* Find out who the user is.
*
**************************************/
SLONG status, privileges[2];
SLONG privileges[2];
USHORT uic[2], len0, len1, len2;
TEXT *p, *q, *end, user_name[256];
ITM items[4];
if (user_string && *user_string) {
for (p = user_name, q = user_string; (*p = *q++) && *p != '.'; p++);
@ -537,6 +532,7 @@ TEXT * organization, int *node, TEXT * user_string)
}
}
else {
ITM items[4];
items[0].itm_code = JPI$_UIC;
items[0].itm_length = sizeof(uic);
items[0].itm_buffer = uic;
@ -555,7 +551,7 @@ TEXT * organization, int *node, TEXT * user_string)
items[3].itm_code = 0;
items[3].itm_length = 0;
status = sys$getjpiw(NULL, NULL, NULL, items, NULL, NULL, NULL);
SLONG status = sys$getjpiw(NULL, NULL, NULL, items, NULL, NULL, NULL);
if (!(status & 1)) {
len1 = 0;
@ -694,7 +690,7 @@ static BOOLEAN check_user_privilege(void)
TOKEN_GROUPS* ptg = NULL;
DWORD token_len = 0;
while (TRUE)
while (true)
{
/* Then we must query the size of the group information associated with
the token. This is guarenteed to fail the first time through
@ -955,14 +951,10 @@ void ISC_wake(SLONG process_id)
* remote (but on the same CPU).
*
**************************************/
int status;
POKE poke;
TEXT string[32];
struct dsc$descriptor_s desc;
/* Try to do a simple wake. If this succeeds, we're done. */
status = sys$wake(&process_id, 0);
int status = sys$wake(&process_id, 0);
#ifdef __ALPHA
THREAD_wakeup();
#endif
@ -974,6 +966,7 @@ void ISC_wake(SLONG process_id)
/* Find a free poke block to use */
POKE poke;
for (poke = pokes; poke; poke = poke->poke_next)
if (!poke->poke_use_count)
break;
@ -991,6 +984,8 @@ void ISC_wake(SLONG process_id)
++poke->poke_use_count;
TEXT string[32];
struct dsc$descriptor_s desc;
sprintf(string, WAKE_LOCK, process_id);
ISC_make_desc(string, &desc, 0);
@ -1022,9 +1017,7 @@ void ISC_wake_init(void)
* Set up to be awakened by another process thru a blocking AST.
*
**************************************/
int status;
TEXT string[32];
FPTR_INT master;
struct dsc$descriptor_s desc;
/* If we already have lock, we're done */
@ -1035,7 +1028,7 @@ void ISC_wake_init(void)
sprintf(string, WAKE_LOCK, getpid());
ISC_make_desc(string, &desc, 0);
status = sys$enqw(0, /* event flag */
int status = sys$enqw(0, /* event flag */
LCK$K_PWMODE, /* lock mode */
&wake_lock, /* Lock status block */
LCK$M_SYSTEM, /* flags */
@ -1063,11 +1056,10 @@ static void blocking_ast(void)
* Somebody else is trying to post a lock.
*
**************************************/
int status;
/* Initially down grade the lock to let the other guy complete */
status = sys$enqw(0, /* event flag */
int status = sys$enqw(0, /* event flag */
LCK$K_NLMODE, /* lock mode */
&wake_lock, /* Lock status block */
LCK$M_CONVERT, /* flags */
@ -1114,11 +1106,8 @@ static void poke_ast(POKE poke)
* and deque the lock.
*
**************************************/
int status;
LKSB *lksb;
lksb = &poke->poke_lksb;
status = sys$deq(lksb->lksb_lock_id, 0, 0, 0);
LKSB* lksb = &poke->poke_lksb;
int status = sys$deq(lksb->lksb_lock_id, 0, 0, 0);
--poke->poke_use_count;
}
#endif
@ -1170,9 +1159,7 @@ SLONG ISC_get_user_group_id(TEXT * user_group_name)
**************************************/
struct group *user_group;
SLONG n;
n = 0;
SLONG n = 0;
if ( (user_group = getgrnam(user_group_name)) )
@ -1199,9 +1186,7 @@ SLONG ISC_get_user_group_id(TEXT * user_group_name)
*
**************************************/
SLONG n;
n = 0;
SLONG n = 0;
return (n);
}
#endif /* end of ifdef UNIX */
@ -1214,6 +1199,7 @@ BOOLEAN ISC_is_WinNT()
{
OSVERSIONINFO OsVersionInfo;
// thread safe??? :-)
if (!os_type)
{
os_type = 1; /* Default to NT */
@ -1271,3 +1257,4 @@ LPSECURITY_ATTRIBUTES ISC_get_security_desc()
}
#endif

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: isc_file.c
* MODULE: isc_file.cpp
* DESCRIPTION: General purpose but non-user routines.
*
* The contents of this file are subject to the Interbase Public
@ -1770,3 +1770,4 @@ bool ISC_verify_database_access(TEXT *name) {
#endif
return true;
}

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: isc_sync.c
* MODULE: isc_sync.cpp
* DESCRIPTION: General purpose but non-user routines.
*
* The contents of this file are subject to the Interbase Public

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: jrd.c
* MODULE: jrd.cpp
* DESCRIPTION: User visible entrypoints
*
* The contents of this file are subject to the Interbase Public
@ -6645,3 +6645,4 @@ static bool verify_database_name(TEXT *name, ISC_STATUS *status)
}
} // extern "C"

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: jrn.c
* MODULE: jrn.cpp
* DESCRIPTION: Journalling interface for database system.
*
* The contents of this file are subject to the Interbase Public

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: met.e
* MODULE: met.epp
* DESCRIPTION: Meta data handler
*
* The contents of this file are subject to the Interbase Public
@ -37,7 +37,7 @@
*
*/
/*
$Id: met.epp,v 1.69 2003-09-22 17:52:27 brodsom Exp $
$Id: met.epp,v 1.70 2003-09-25 11:49:06 robocop Exp $
*/
// This MUST be at the top of the file
#ifdef DARWIN

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: perf.c
* MODULE: perf.cpp
* DESCRIPTION: Performance monitoring routines
*
* The contents of this file are subject to the Interbase Public

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: scl.e
* MODULE: scl.epp
* DESCRIPTION: Security class handler
*
* The contents of this file are subject to the Interbase Public
@ -135,9 +135,6 @@ void SCL_check_access(SCL s_class,
* object in question.
*
**************************************/
const P_NAMES* names;
SCL att_class;
TDBB tdbb = GET_THREAD_DATA;
if (s_class && (s_class->scl_flags & SCL_corrupt))
@ -150,8 +147,8 @@ void SCL_check_access(SCL s_class,
ATT attachment = tdbb->tdbb_attachment;
if ((att_class = attachment->att_security_class) &&
!(att_class->scl_flags & mask))
SCL att_class = attachment->att_security_class;
if (att_class && !(att_class->scl_flags & mask))
{
type = "DATABASE";
name = "";
@ -179,6 +176,7 @@ void SCL_check_access(SCL s_class,
return;
}
const P_NAMES* names;
for (names = p_names; names->p_names_priv; names++)
{
if (names->p_names_priv & mask)
@ -214,7 +212,6 @@ void SCL_check_index(TDBB tdbb, TEXT* index_name, UCHAR index_id, USHORT mask)
* becomes relation_name since index ids are relative to tables.
*
*******************************************************/
volatile BLK request;
SCL s_class, default_s_class;
TEXT reln_name[32], aux_idx_name[32];
TEXT *idx_name_ptr = index_name, *relation_name_ptr = index_name;
@ -231,7 +228,7 @@ void SCL_check_index(TDBB tdbb, TEXT* index_name, UCHAR index_id, USHORT mask)
reln_name[0] = aux_idx_name[0] = 0;
request = NULL;
volatile BLK request = NULL;
// No need to cache this request handle, it's only used when
// new constraints are created
@ -335,9 +332,7 @@ void SCL_check_procedure(DSC* dsc_name, USHORT mask)
* scanned. This is used exclusively for meta-data operations.
*
**************************************/
BLK request;
SCL s_class;
TEXT *p, *q, *endp, *endq, name[32];
TEXT name[32];
TDBB tdbb = GET_THREAD_DATA;
@ -345,18 +340,22 @@ void SCL_check_procedure(DSC* dsc_name, USHORT mask)
assert(dsc_name->dsc_dtype == dtype_text);
for (p = name, endp = name + sizeof(name) - 1,
q = (TEXT*)dsc_name->dsc_address, endq = q + dsc_name->dsc_length;
q < endq && p < endp && *q;)
{ // scope only block
TEXT* p = name;
const TEXT* const endp = name + sizeof(name) - 1;
const TEXT* q = (TEXT*) dsc_name->dsc_address;
const TEXT* const endq = q + dsc_name->dsc_length;
while (q < endq && p < endp && *q)
*p++ = *q++;
*p = 0;
} // end scope block
MET_exact_name(name);
DBB dbb = tdbb->tdbb_database;
s_class = NULL;
SCL s_class = NULL;
request = (BLK) CMP_find_request(tdbb, irq_p_security, IRQ_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, irq_p_security, IRQ_REQUESTS);
FOR(REQUEST_HANDLE request) JRD_PRC IN RDB$PROCEDURES WITH
JRD_PRC.RDB$PROCEDURE_NAME EQ name
@ -389,9 +388,7 @@ void SCL_check_relation(DSC* dsc_name, USHORT mask)
* scanned. This is used exclusively for meta-data operations.
*
**************************************/
BLK request;
SCL s_class;
TEXT *p, *q, *endp, *endq, name[32];
TEXT name[32];
TDBB tdbb = GET_THREAD_DATA;
@ -399,18 +396,22 @@ void SCL_check_relation(DSC* dsc_name, USHORT mask)
assert(dsc_name->dsc_dtype == dtype_text);
for (p = name, endp = name + sizeof(name) - 1,
q = (TEXT*)dsc_name->dsc_address, endq = q + dsc_name->dsc_length;
q < endq && p < endp && *q;)
{ // scope only block
TEXT* p = name;
const TEXT* const endp = name + sizeof(name) - 1;
const TEXT* q = (TEXT*) dsc_name->dsc_address;
const TEXT* const endq = q + dsc_name->dsc_length;
while (q < endq && p < endp && *q)
*p++ = *q++;
*p = 0;
} // end scope block
MET_exact_name(name);
DBB dbb = tdbb->tdbb_database;
s_class = NULL;
SCL s_class = NULL;
request = (BLK) CMP_find_request(tdbb, irq_v_security, IRQ_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, irq_v_security, IRQ_REQUESTS);
FOR(REQUEST_HANDLE request) REL IN RDB$RELATIONS WITH
REL.RDB$RELATION_NAME EQ name
@ -443,9 +444,6 @@ SCL SCL_get_class(/* INOUT */ TEXT* string)
* class block.
*
**************************************/
SCL s_class;
ATT attachment;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
@ -459,10 +457,11 @@ SCL SCL_get_class(/* INOUT */ TEXT* string)
if (!string[0])
return NULL;
attachment = tdbb->tdbb_attachment;
ATT attachment = tdbb->tdbb_attachment;
// Look for the class already known
SCL s_class;
for (s_class = attachment->att_security_classes;
s_class;
s_class = s_class->scl_next)
@ -507,18 +506,14 @@ int SCL_get_mask(const TEXT* relation_name, const TEXT* field_name)
*
**************************************/
JRD_REL relation;
JRD_FLD field;
SSHORT id;
USHORT access;
SCL s_class;
TDBB tdbb = GET_THREAD_DATA;
ATT attachment = tdbb->tdbb_attachment;
// Start with database security class
access =
(s_class = attachment->att_security_class) ? s_class->scl_flags : -1;
SCL s_class = attachment->att_security_class;
USHORT access = (s_class) ? s_class->scl_flags : -1;
// If there's a relation, track it down
@ -530,6 +525,9 @@ int SCL_get_mask(const TEXT* relation_name, const TEXT* field_name)
{
access &= s_class->scl_flags;
}
JRD_FLD field;
SSHORT id;
if (field_name &&
(id = MET_lookup_field(tdbb, relation, field_name, 0)) >= 0 &&
(field = MET_get_field(relation, id)) &&
@ -570,32 +568,27 @@ void SCL_init(bool create,
* in, encrypting if necessary.
*
**************************************/
DBB dbb;
BLK handle, handle1;
volatile BLK request;
USR user;
TEXT name[129], project[33], organization[33], *p;
USHORT length;
int id, group, wheel, node_id;
TEXT role_name[33], login_name[129], *q;
USHORT major_version, minor_original;
bool preODS9;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
major_version = (SSHORT) dbb->dbb_ods_version;
minor_original = (SSHORT) dbb->dbb_minor_original;
DBB dbb = tdbb->tdbb_database;
USHORT major_version = dbb->dbb_ods_version;
USHORT minor_original = dbb->dbb_minor_original;
*project = *organization = *name = *role_name = *login_name = '\0';
node_id = 0;
id = group = -1; // CVC: This var contained trash
int node_id = 0;
int id = -1, group = -1; // CVC: This var contained trash
#ifdef NO_SECURITY
wheel = 1;
bool wheel = true;
#else
bool wheel = false;
if (!user_name) {
wheel = ISC_get_user(name,
wheel = (bool) ISC_get_user(name,
&id,
&group,
project,
@ -603,10 +596,6 @@ void SCL_init(bool create,
&node_id,
sys_user_name);
}
else
{
wheel = 0;
}
if (user_name || (id == -1))
{
@ -626,7 +615,7 @@ void SCL_init(bool create,
if (!strcmp(name, SYSDBA_USER_NAME))
{
wheel = 1;
wheel = true;
}
}
#endif // NO_SECURITY
@ -738,9 +727,10 @@ void SCL_init(bool create,
strcpy(role_name, "NONE");
}
length = strlen(name) + strlen(role_name) + strlen(project) +
USHORT length = strlen(name) + strlen(role_name) + strlen(project) +
strlen(organization) + 4; /* for the terminating nulls */
tdbb->tdbb_attachment->att_user = user = FB_NEW_RPT(*dbb->dbb_permanent, length) usr();
usr* user = FB_NEW_RPT(*dbb->dbb_permanent, length) usr();
tdbb->tdbb_attachment->att_user = user;
p = user->usr_data;
user->usr_user_name = save_string(name, &p);
user->usr_project_name = save_string(project, &p);
@ -752,7 +742,7 @@ void SCL_init(bool create,
if (wheel)
user->usr_flags |= USR_locksmith;
handle = handle1 = NULL;
BLK handle = NULL, handle1 = NULL;
if (!create) {
FOR(REQUEST_HANDLE handle) X IN RDB$DATABASE
@ -1034,11 +1024,10 @@ static bool check_string(const TEXT* acl, const TEXT* string)
*
* Functional description
* Check a string against and acl string. If they don't match,
* return TRUE.
* return true.
*
**************************************/
USHORT l;
TEXT c1, c2;
// Add these asserts to catch calls to this function with NULL,
// the caller to this function must check to ensure that the arguments are not
@ -1052,8 +1041,8 @@ static bool check_string(const TEXT* acl, const TEXT* string)
if ( (l = *acl++) )
{
do {
c1 = *acl++;
c2 = *string++;
TEXT c1 = *acl++;
TEXT c2 = *string++;
if (UPPER7(c1) != UPPER7(c2))
return true;
} while (--l);
@ -1088,10 +1077,7 @@ static SLONG compute_access(TDBB tdbb,
* access permissions. Return a flag word of recognized privileges.
*
**************************************/
BLK request;
BLB blob;
TEXT *acl;
TEXT *buffer;
BLB blob = NULL;
volatile STR str_buffer = NULL;
SLONG length = BLOB_BUFFER_SIZE, *length_ptr = &length;
@ -1106,9 +1092,9 @@ static SLONG compute_access(TDBB tdbb,
str_buffer = FB_NEW_RPT(*dbb->dbb_permanent, BLOB_BUFFER_SIZE) str();
str_buffer->str_length = BLOB_BUFFER_SIZE - 1;
buffer = (TEXT*) str_buffer->str_data;
TEXT* buffer = (TEXT*) str_buffer->str_data;
request = (BLK) CMP_find_request(tdbb, irq_l_security, IRQ_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, irq_l_security, IRQ_REQUESTS);
FOR(REQUEST_HANDLE request) X IN RDB$SECURITY_CLASSES
WITH X.RDB$SECURITY_CLASS EQ s_class->scl_name
@ -1118,8 +1104,8 @@ static SLONG compute_access(TDBB tdbb,
privileges |= SCL_exists;
blob = BLB_open(tdbb, dbb->dbb_sys_trans, (BID) & X.RDB$ACL);
acl = buffer;
while (TRUE)
TEXT* acl = buffer;
while (true)
{
acl += BLB_get_segment(tdbb, blob, (UCHAR*)acl,
(USHORT) (length -
@ -1141,6 +1127,7 @@ static SLONG compute_access(TDBB tdbb,
}
}
BLB_close(tdbb, blob);
blob = NULL;
if (acl != buffer)
{
// TMN: The cast is really a const_cast to
@ -1163,6 +1150,7 @@ static SLONG compute_access(TDBB tdbb,
}
catch (const std::exception&) {
delete str_buffer;
// CVC: we may need to call BLB_close here
Firebird::status_exception::raise(tdbb->tdbb_status_vector[1]);
}
@ -1183,12 +1171,11 @@ static TEXT *save_string(TEXT* string, TEXT** ptr)
* pointer.
*
**************************************/
TEXT *p, *start;
if (!*string)
return NULL;
start = p = *ptr;
TEXT* p = *ptr;
TEXT* const start = p;
while ( (*p++ = *string++) )
;
@ -1443,3 +1430,4 @@ static SLONG walk_acl(TDBB tdbb,
return privilege;
}

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _JRD_SCL_PROTO_H_
#define _JRD_SCL_PROTO_H_
#ifndef JRD_SCL_PROTO_H
#define JRD_SCL_PROTO_H
#ifdef __cplusplus
extern "C" {
@ -44,4 +44,5 @@ void SCL_check_index(TDBB, TEXT*, UCHAR, USHORT);
} /* extern "C" */
#endif
#endif /* _JRD_SCL_PROTO_H_ */
#endif /* JRD_SCL_PROTO_H */

View File

@ -152,16 +152,16 @@ static inline void is_service_running(SVC service)
if (!(service->svc_flags & SVC_forked)) {
THREAD_ENTER;
ERR_post (isc_svcnoexe, isc_arg_string,
service->svc_service->serv_name, 0);
service->svc_service->serv_name, 0);
}
}
static inline void need_admin_privs(ISC_STATUS **status, char* message)
static inline void need_admin_privs(ISC_STATUS** status, const char* message)
{
ISC_STATUS *stat = *status;
ISC_STATUS* stat = *status;
*stat++ = isc_insufficient_svc_privileges;
*stat++ = isc_arg_string;
*stat++ = (ISC_STATUS) ERR_string(message,strlen(message));
*stat++ = (ISC_STATUS) ERR_string(message, strlen(message));
*stat++ = isc_arg_end;
*status = stat;
}

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: utl.c
* MODULE: utl.cpp
* DESCRIPTION: User callable routines
*
* The contents of this file are subject to the Interbase Public

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: all.c
* MODULE: all.cpp
* DESCRIPTION: Internal block allocator
*
* The contents of this file are subject to the Interbase Public
@ -21,7 +21,7 @@
* Contributor(s): ______________________________________.
*/
/*
$Id: all.cpp,v 1.20 2003-09-19 10:26:46 aafemt Exp $
$Id: all.cpp,v 1.21 2003-09-25 11:49:07 robocop Exp $
*/
/***************************************************
@ -68,7 +68,7 @@ static struct {
static void extend_pool(PLB, USHORT);
static VEC pools;
static VEC global_pools;
#define MIN_ALLOCATION 1024
@ -86,18 +86,15 @@ BLK ALLQ_alloc( PLB pool, UCHAR type, int count)
* This is the primary block allocation routine.
*
**************************************/
FRB block;
FRB free, *best, *ptr;
USHORT l;
USHORT size;
SLONG best_tail, tail;
if (type <= (SCHAR) type_MIN || type >= (SCHAR) type_MAX)
BUGCHECK(1); // Msg1 bad block type
BUGCHECK(1); // Msg1 bad block type
// Compute block length
// Compute block length
size = block_sizes[type].typ_root_length;
USHORT size = block_sizes[type].typ_root_length;
if (tail = block_sizes[type].typ_tail_length)
size += count * tail;
@ -109,7 +106,7 @@ BLK ALLQ_alloc( PLB pool, UCHAR type, int count)
#endif
if (size <= 4 || size > 65535)
BUGCHECK(2); // Msg2 bad block size
BUGCHECK(2); // Msg2 bad block size
/* Find best fit. Best fit is defined to be the free block of SHORTest
tail. If there isn't a fit, extend the pool and try, try again. */
@ -118,11 +115,11 @@ BLK ALLQ_alloc( PLB pool, UCHAR type, int count)
best = NULL;
best_tail = 32767;
for (ptr = &pool->plb_free; (free = *ptr); ptr = &free->frb_next)
if (free->frb_next
&& (SCHAR *) free >=
(SCHAR *) free->frb_next) BUGCHECK(434); // memory pool free list is incorrect
if (free->frb_next && (SCHAR *) free >= (SCHAR *) free->frb_next)
BUGCHECK(434); // memory pool free list is incorrect
else if ((tail = free->frb_header.blk_length - size) >= 0
&& tail < best_tail) {
&& tail < best_tail)
{
best = ptr;
best_tail = tail;
if (tail == 0)
@ -138,8 +135,9 @@ BLK ALLQ_alloc( PLB pool, UCHAR type, int count)
the entire free block as our block (a little extra won't hurt). */
free = *best;
FRB block;
if (best_tail > sizeof(frb)) {
l = free->frb_header.blk_length - size;
USHORT l = free->frb_header.blk_length - size;
block = (FRB) ((SCHAR *) free + l);
free->frb_header.blk_length -= size;
}
@ -172,15 +170,12 @@ BLK ALLQ_extend(BLK * pointer, int size)
* Extend a repeating block, copying the constant part.
*
**************************************/
BLK block, new_blk;
int length;
block = *pointer;
new_blk = (BLK) ALLQ_alloc((PLB) pools->vec_object[block->blk_pool_id],
BLK block = *pointer;
BLK new_blk = (BLK) ALLQ_alloc((PLB) global_pools->vec_object[block->blk_pool_id],
block->blk_type, size);
length = MIN(block->blk_length, new_blk->blk_length) - sizeof(blk);
MOVQ_fast((SCHAR *) block + sizeof(blk),
(SCHAR *) new_blk + sizeof(blk), length);
const int length = MIN(block->blk_length, new_blk->blk_length) - sizeof(blk);
MOVQ_fast((SCHAR*) block + sizeof(blk),
(SCHAR*) new_blk + sizeof(blk), length);
ALLQ_release((FRB) block);
if (new_blk->blk_type == (SCHAR) type_vec)
@ -206,16 +201,20 @@ void ALLQ_fini(void)
* Get rid of everything.
*
**************************************/
PLB pool, *vector, *until;
HNK hunks, hunk;
for (vector = (PLB *) pools->vec_object + pools->vec_count,
until = (PLB *) pools->vec_object; --vector >= until;)
if (pool = *vector)
PLB* vector = (PLB*) global_pools->vec_object + global_pools->vec_count;
PLB* until = (PLB*) global_pools->vec_object;
while (--vector >= until)
{
PLB pool = *vector;
if (pool)
{
HNK hunks, hunk;
for (hunks = pool->plb_hunks; hunk = hunks;) {
hunks = hunk->hnk_next;
ALLQ_free(hunk->hnk_address);
}
}
}
}
@ -249,16 +248,16 @@ void ALLQ_init(void)
*
**************************************/
ISC_STATUS_ARRAY temp_vector;
PLB pool;
pools = (VEC) temp_vector;
pools->vec_count = 1;
pools->vec_object[0] = NULL;
global_pools = (VEC) temp_vector;
global_pools->vec_count = 1;
global_pools->vec_object[0] = NULL;
QLI_default_pool = QLI_permanent_pool = pool = ALLQ_pool();
pools = (VEC) ALLQ_alloc(pool, type_vec, 10);
pools->vec_count = 10;
pools->vec_object[0] = (BLK) pool;
PLB pool = ALLQ_pool();
QLI_default_pool = QLI_permanent_pool = pool;
global_pools = (VEC) ALLQ_alloc(pool, type_vec, 10);
global_pools->vec_count = 10;
global_pools->vec_object[0] = (BLK) pool;
}
@ -274,16 +273,16 @@ SCHAR *ALLQ_malloc(SLONG size)
* Get memory from system.
*
**************************************/
SCHAR *memory;
SCHAR *memory = (SCHAR*) gds__alloc(size);
if (memory = (SCHAR *) gds__alloc(size)) {
if (memory) {
#ifdef DEBUG_GDS_ALLOC
gds_alloc_flag_unfreed((void *) memory); /* Don't care about QLI leaks */
gds_alloc_flag_unfreed((void *) memory); // Don't care about QLI leaks
#endif
return memory;
}
IBERROR(5); /* Msg5 "memory gonzo" */
IBERROR(5); // Msg5 "memory gonzo"
return 0;
}
@ -302,31 +301,30 @@ PLB ALLQ_pool(void)
* In SHORT, by mirrors.
*
**************************************/
plb temp_pool;
PLB pool;
int pool_id;
// Start by assigning a pool id
// Start by assigning a pool id
for (pool_id = 0; pool_id < pools->vec_count; pool_id++)
if (!(pools->vec_object[pool_id]))
for (pool_id = 0; pool_id < global_pools->vec_count; pool_id++)
if (!(global_pools->vec_object[pool_id]))
break;
if (pool_id >= pools->vec_count)
ALLQ_extend((BLK*) &pools, pool_id + 10);
if (pool_id >= global_pools->vec_count)
ALLQ_extend((BLK*) &global_pools, pool_id + 10);
pools->vec_object[pool_id] = (BLK) & temp_pool;
plb temp_pool;
global_pools->vec_object[pool_id] = (BLK) &temp_pool;
temp_pool.plb_free = NULL;
temp_pool.plb_hunks = NULL;
temp_pool.plb_pool_id = pool_id;
if (pool_id == 0)
QLI_permanent_pool = &temp_pool;
pool = (PLB) ALLQ_alloc(&temp_pool, type_plb, 0);
PLB pool = (PLB) ALLQ_alloc(&temp_pool, type_plb, 0);
pool->plb_pool_id = pool_id;
pool->plb_free = temp_pool.plb_free;
pool->plb_hunks = temp_pool.plb_hunks;
pools->vec_object[pool_id] = (BLK) pool;
global_pools->vec_object[pool_id] = (BLK) pool;
if (pool_id == 0)
QLI_permanent_pool = pool;
@ -347,12 +345,10 @@ void ALLQ_push( BLK object, LLS * stack)
* Push an object on an LLS stack.
*
**************************************/
LLS node;
PLB pool;
PLB pool = QLI_default_pool;
pool = QLI_default_pool;
if (node = pool->plb_lls)
LLS node = pool->plb_lls;
if (node)
pool->plb_lls = node->lls_next;
else
node = (LLS) ALLQ_alloc(pool, type_lls, 0);
@ -376,11 +372,8 @@ BLK ALLQ_pop(LLS * stack)
* further use.
*
**************************************/
LLS node;
PLB pool;
node = *stack;
pool = (PLB) pools->vec_object[node->lls_header.blk_pool_id];
LLS node = *stack;
PLB pool = (PLB) global_pools->vec_object[node->lls_header.blk_pool_id];
*stack = node->lls_next;
node->lls_next = pool->plb_lls;
pool->plb_lls = node;
@ -404,18 +397,21 @@ void ALLQ_release( FRB block)
* of addresses).
*
**************************************/
FRB prior, free;
FRB *ptr;
PLB pool;
int pool_id;
block->frb_header.blk_type = (SCHAR) type_frb;
pool_id = block->frb_header.blk_pool_id;
int pool_id = block->frb_header.blk_pool_id;
if (pool_id >= pools->vec_count ||
!(pool = (PLB) pools->vec_object[pool_id])) BUGCHECK(4); // Msg4 bad pool id
if (pool_id >= global_pools->vec_count ||
!(pool = (PLB) global_pools->vec_object[pool_id]))
{
BUGCHECK(4);
// Msg4 bad pool id
}
prior = NULL;
FRB prior = NULL;
FRB free;
FRB* ptr;
for (ptr = &pool->plb_free; free = *ptr;
prior = free, ptr = &free->frb_next)
{
@ -424,14 +420,14 @@ void ALLQ_release( FRB block)
}
if ((SCHAR *) block == (SCHAR *) free)
BUGCHECK(435); // block released twice
BUGCHECK(435); // block released twice
// Merge block into list first, then try to combine blocks
// Merge block into list first, then try to combine blocks
block->frb_next = free;
*ptr = block;
// Try to merge the free block with the next one down.
// Try to merge the free block with the next one down.
if (free) {
if ((SCHAR *) block + block->frb_header.blk_length ==
@ -441,10 +437,10 @@ void ALLQ_release( FRB block)
}
else if ((SCHAR *) block + block->frb_header.blk_length >
(SCHAR *) free)
BUGCHECK(436); // released block overlaps following free block
BUGCHECK(436); // released block overlaps following free block
}
// Try and merge the block with the prior free block
// Try and merge the block with the prior free block
if (prior) {
if ((SCHAR *) prior + prior->frb_header.blk_length ==
@ -454,7 +450,7 @@ void ALLQ_release( FRB block)
}
else if ((SCHAR *) prior + prior->frb_header.blk_length >
(SCHAR *) block)
BUGCHECK(437); // released block overlaps prior free block
BUGCHECK(437); // released block overlaps prior free block
}
}
@ -474,7 +470,7 @@ void ALLQ_rlpool( PLB pool)
**************************************/
HNK hunk, hunks;
pools->vec_object[pool->plb_pool_id] = NULL;
global_pools->vec_object[pool->plb_pool_id] = NULL;
for (hunks = pool->plb_hunks; hunk = hunks;) {
hunks = hunk->hnk_next;
@ -496,24 +492,23 @@ static void extend_pool( PLB pool, USHORT count)
* of given size.
*
**************************************/
HNK hunk;
BLK block;
SLONG size;
size = (count + sizeof(hnk) + MIN_ALLOCATION - 1) & ~(MIN_ALLOCATION - 1);
SLONG size =
(count + sizeof(hnk) + MIN_ALLOCATION - 1) & ~(MIN_ALLOCATION - 1);
if ((USHORT) size < count)
IBERROR(481); // msg 481 unsuccessful attempt to extend pool beyond 64KB
IBERROR(481); // msg 481 unsuccessful attempt to extend pool beyond 64KB
block = (BLK) ALLQ_malloc(size);
BLK block = (BLK) ALLQ_malloc(size);
block->blk_length = size;
block->blk_type = (SCHAR) type_frb;
block->blk_pool_id = pool->plb_pool_id;
ALLQ_release((FRB) block);
hunk = (HNK) ALLQ_alloc(pool, type_hnk, 0);
HNK hunk = (HNK) ALLQ_alloc(pool, type_hnk, 0);
hunk->hnk_address = (SCHAR *) block;
hunk->hnk_length = size;
hunk->hnk_next = pool->plb_hunks;
pool->plb_hunks = hunk;
}

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_ALL_PROTO_H_
#define _QLI_ALL_PROTO_H_
#ifndef QLI_ALL_PROTO_H
#define QLI_ALL_PROTO_H
extern blk* ALLQ_alloc(plb*, UCHAR, int);
extern blk* ALLQ_extend(blk**, int);
@ -36,4 +36,5 @@ extern blk* ALLQ_pop(lls**);
extern void ALLQ_release(frb*);
extern void ALLQ_rlpool(plb*);
#endif /* _QLI_ALL_PROTO_H_ */
#endif /* QLI_ALL_PROTO_H */

View File

@ -47,7 +47,7 @@ BLKDEF (type_brk, brk, 0)
BLKDEF (type_rpt, rpt, 0)
BLKDEF (type_pic, pics, 0)
BLKDEF (type_prt, prt, 0)
BLKDEF (type_map, map, 0)
BLKDEF (type_map, qli_map, 0)
BLKDEF (type_qpr, qpr, 0)
BLKDEF (type_qfn, qfn, 0)
BLKDEF (type_qfl, qfl, 0)

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_COMMA_PROTO_H_
#define _QLI_COMMA_PROTO_H_
#ifndef QLI_COMMA_PROTO_H
#define QLI_COMMA_PROTO_H
extern int CMD_check_ready(void);
extern void CMD_copy_procedure(syn*);
@ -36,4 +36,4 @@ extern void CMD_set(syn*);
extern void CMD_shell(syn*);
extern void CMD_transaction(syn*);
#endif /* _QLI_COMMA_PROTO_H_ */
#endif /* QLI_COMMA_PROTO_H */

View File

@ -60,7 +60,7 @@ int CMD_check_ready(void)
**************************************
*
* Functional description
* Make sure at least one database is ready. If not, give a
* Make sure at least one database is ready. If not, give a
* message.
*
**************************************/
@ -68,7 +68,7 @@ int CMD_check_ready(void)
if (QLI_databases)
return FALSE;
ERRQ_msg_put(95, NULL, NULL, NULL, NULL, NULL); // Msg95 No databases are currently ready
ERRQ_msg_put(95, NULL, NULL, NULL, NULL, NULL); // Msg95 No databases are currently ready
return TRUE;
}
@ -83,7 +83,7 @@ void CMD_copy_procedure( SYN node)
**************************************
*
* Functional description
* Copy one procedure to another, possibly
* Copy one procedure to another, possibly
* across databases
*
**************************************/
@ -140,7 +140,7 @@ void CMD_delete_proc( SYN node)
if (PRO_delete_procedure(proc->qpr_database, proc->qpr_name->nam_string))
return;
ERRQ_msg_put(88, proc->qpr_name->nam_string, /* Msg88 Procedure %s not found in database %s */
ERRQ_msg_put(88, proc->qpr_name->nam_string, // Msg88 Procedure %s not found in database %s
proc->qpr_database->dbb_symbol->sym_string, NULL, NULL,
NULL);
}
@ -194,7 +194,7 @@ void CMD_extract( SYN node)
database = QLI_databases;
name = proc->qpr_name;
if (!(blob = PRO_fetch_procedure(database, name->nam_string))) {
ERRQ_msg_put(89, /* Msg89 Procedure %s not found in database %s */
ERRQ_msg_put(89, // Msg89 Procedure %s not found in database %s
name->nam_string,
database->dbb_symbol->sym_string, NULL, NULL,
NULL);
@ -264,14 +264,14 @@ void CMD_rename_proc( SYN node)
database = QLI_databases;
if (new_proc->qpr_database && (new_proc->qpr_database != database))
IBERROR(84); // Msg84 Procedures can not be renamed across databases. Try COPY
IBERROR(84); // Msg84 Procedures can not be renamed across databases. Try COPY
NAM old_name = old_proc->qpr_name;
NAM new_name = new_proc->qpr_name;
if (PRO_rename_procedure
(database, old_name->nam_string, new_name->nam_string)) return;
ERRQ_error(85, /* Msg85 Procedure %s not found in database %s */
ERRQ_error(85, // Msg85 Procedure %s not found in database %s
old_name->nam_string, database->dbb_symbol->sym_string, NULL,
NULL, NULL);
}
@ -325,7 +325,7 @@ void CMD_set( SYN node)
break;
case set_form:
IBERROR(484); // FORMs not supported
IBERROR(484); // FORMs not supported
break;
case set_password:
@ -340,7 +340,7 @@ void CMD_set( SYN node)
case set_prompt:
string = (CON) value;
if (string->con_desc.dsc_length > sizeof(QLI_prompt_string))
ERRQ_error(86, NULL, NULL, NULL, NULL, NULL); // Msg86 substitute prompt string too long
ERRQ_error(86, NULL, NULL, NULL, NULL, NULL); // Msg86 substitute prompt string too long
strncpy(QLI_prompt_string, (char*) string->con_data,
string->con_desc.dsc_length);
QLI_prompt_string[string->con_desc.dsc_length] = 0;
@ -349,7 +349,7 @@ void CMD_set( SYN node)
case set_continuation:
string = (CON) value;
if (string->con_desc.dsc_length > sizeof(QLI_cont_string))
ERRQ_error(87, NULL, NULL, NULL, NULL, NULL); // Msg87 substitute prompt string too long
ERRQ_error(87, NULL, NULL, NULL, NULL, NULL); // Msg87 substitute prompt string too long
strncpy(QLI_cont_string, (char*) string->con_data,
string->con_desc.dsc_length);
QLI_cont_string[string->con_desc.dsc_length] = 0;
@ -409,7 +409,7 @@ void CMD_set( SYN node)
#endif
default:
BUGCHECK(6); // Msg6 set option not implemented
BUGCHECK(6); // Msg6 set option not implemented
}
}
}
@ -431,16 +431,16 @@ void CMD_shell( SYN node)
USHORT l;
CON constant;
// Copy command, inserting extra blank at end.
// Copy command, inserting extra blank at end.
TEXT* p = buffer;
if (constant = (CON) node->syn_arg[0]) {
const TEXT* q = (TEXT*) constant->con_data;
if (l = constant->con_desc.dsc_length)
do
do {
*p++ = *q++;
while (--l);
} while (--l);
*p++ = ' ';
*p = 0;
}
@ -465,13 +465,13 @@ void CMD_shell( SYN node)
int return_status = 0;
int mask = 1;
int status = lib$spawn(ptr, // Command to be executed
NULL, // Command file
NULL, // Output file
NULL, // Command file
NULL, // Output file
&mask, // sub-process characteristics mask
NULL, // sub-process name
NULL, // returned process id
&return_status, // completion status
&15); // event flag for completion
NULL, // returned process id
&return_status, // completion status
&15); // event flag for completion
if (status & 1)
while (!return_status)
sys$waitfr(15);
@ -602,3 +602,4 @@ static void extract_procedure(
dump_procedure(database, file, name, length, blob);
}

View File

@ -132,7 +132,7 @@ int CMP_node_match( QLI_NOD node1, QLI_NOD node2)
*
**************************************/
QLI_NOD *ptr1, *ptr2, *end;
MAP map1, map2;
QLI_MAP map1, map2;
USHORT l;
UCHAR *p1, *p2;
@ -158,17 +158,17 @@ int CMP_node_match( QLI_NOD node1, QLI_NOD node2)
p1 = node1->nod_desc.dsc_address;
p2 = node2->nod_desc.dsc_address;
if (l = node1->nod_desc.dsc_length)
do
do {
if (*p1++ != *p2++)
return FALSE;
while (--l);
} while (--l);
return TRUE;
}
case nod_map:
{
map1 = (MAP) node1->nod_arg[e_map_map];
map2 = (MAP) node2->nod_arg[e_map_map];
map1 = (QLI_MAP) node1->nod_arg[e_map_map];
map2 = (QLI_MAP) node2->nod_arg[e_map_map];
return CMP_node_match(map1->map_node, map2->map_node);
}
@ -238,7 +238,7 @@ static QLI_NOD compile_any( QLI_NOD node, QLI_REQ old_request, int internal_flag
}
if (old_request && request->req_database != old_request->req_database)
IBERROR(357); // Msg357 relations from multiple databases in single rse
IBERROR(357); // Msg357 relations from multiple databases in single rse
if (old_request && (!receive || !receive->msg_parameters)) {
if (receive)
@ -275,7 +275,7 @@ static QLI_NOD compile_assignment( QLI_NOD node, QLI_REQ request, int statement_
* the logic of such things, the 'internal' flags
* mean external to qli, but internal to jrd.
* As is well known, the seat of the soul is the
* dbms).
* dbms).
*
**************************************/
QLI_NOD target, initial;
@ -310,7 +310,7 @@ static QLI_NOD compile_assignment( QLI_NOD node, QLI_REQ request, int statement_
compile_expression(initial, request, FALSE);
if (statement_internal) {
node->nod_arg[e_asn_valid] = NULL; // Memory reclaimed in the main loop
node->nod_arg[e_asn_valid] = NULL; // Memory reclaimed in the main loop
node->nod_flags |= NOD_remote;
node = NULL;
}
@ -412,14 +412,14 @@ static QLI_NOD compile_edit( QLI_NOD node, QLI_REQ request)
can't find the target database. */
if (!request)
BUGCHECK(358); /* Msg358 can't find database for blob edit */
BUGCHECK(358); // Msg358 can't find database for blob edit
// If there is an input blob, get it now.
// If there is an input blob, get it now.
if (value = node->nod_arg[e_edt_input]) {
QLI_FLD field = (QLI_FLD) value->nod_arg[e_fld_field];
if (value->nod_type != nod_field || field->fld_dtype != dtype_blob)
IBERROR(356); // Msg356 EDIT argument must be a blob field
IBERROR(356); // Msg356 EDIT argument must be a blob field
node->nod_arg[e_edt_input] =
compile_expression(value, request, FALSE);
}
@ -475,11 +475,11 @@ static QLI_NOD compile_expression( QLI_NOD node, QLI_REQ request, int internal_f
* Functional description
* Compile a value. The value may be used internally as part of
* another expression (internal_flag == TRUE) or may be referenced
* in the QLI context (internal_flag == FALSE).
* in the QLI context (internal_flag == FALSE).
*
**************************************/
QLI_NOD *ptr, *end, value;
MAP map;
QLI_MAP map;
PAR parm;
QLI_FLD field;
@ -544,7 +544,7 @@ static QLI_NOD compile_expression( QLI_NOD node, QLI_REQ request, int internal_f
return node;
case nod_map:
map = (MAP) node->nod_arg[e_map_map];
map = (QLI_MAP) node->nod_arg[e_map_map];
map->map_node = value =
compile_expression(map->map_node, request, TRUE);
make_descriptor(value, &node->nod_desc);
@ -664,7 +664,7 @@ static QLI_NOD compile_expression( QLI_NOD node, QLI_REQ request, int internal_f
return node;
default:
BUGCHECK(359); // Msg359 compile_expression: not yet implemented
BUGCHECK(359); // Msg359 compile_expression: not yet implemented
return NULL;
}
}
@ -832,7 +832,7 @@ static QLI_NOD compile_function( QLI_NOD node, QLI_REQ old_request, int internal
else
request = old_request;
// If there is a value, compile it here
// If there is a value, compile it here
if (!internal_flag) {
node->nod_import = parameter =
@ -1058,7 +1058,7 @@ static QLI_NOD compile_prompt( QLI_NOD node)
QLI_FLD field;
USHORT prompt_length;
// Make up a plausible prompt length
// Make up a plausible prompt length
if (!(field = (QLI_FLD) node->nod_arg[e_prm_field]))
prompt_length = PROMPT_LENGTH;
@ -1086,7 +1086,7 @@ static QLI_NOD compile_prompt( QLI_NOD node)
break;
}
/* Allocate string buffer to hold data, a two byte count,
/* Allocate string buffer to hold data, a two byte count,
a possible carriage return, and a null */
prompt_length += 2 + sizeof(SSHORT);
@ -1202,7 +1202,7 @@ static QLI_REQ compile_rse(
database = &local_dbb;
}
// Loop thru relations to make sure only a single database is presented
// Loop thru relations to make sure only a single database is presented
QLI_CTX* ctx_ptr = (QLI_CTX*) node->nod_arg + e_rse_count;
QLI_CTX* ctx_end = ctx_ptr + node->nod_count;
@ -1220,7 +1220,7 @@ static QLI_REQ compile_rse(
if (!*database)
*database = relation->rel_database;
else if (*database != relation->rel_database)
IBERROR(357); // Msg357 relations from multiple databases in single rse
IBERROR(357); // Msg357 relations from multiple databases in single rse
}
}
@ -1240,7 +1240,7 @@ static QLI_REQ compile_rse(
compile_context(node, request, internal_flag);
// Process various clauses
// Process various clauses
if (node->nod_arg[e_rse_first])
compile_expression(node->nod_arg[e_rse_first], request, TRUE);
@ -1266,7 +1266,7 @@ static QLI_REQ compile_rse(
if (node->nod_arg[e_rse_having])
compile_expression(node->nod_arg[e_rse_having], request, TRUE);
/* If we didn't allocate a new request block, say so by returning NULL */
// If we didn't allocate a new request block, say so by returning NULL
if (request == original_request)
return NULL;
@ -1393,7 +1393,7 @@ static QLI_NOD compile_statistical( QLI_NOD node, QLI_REQ old_request, int inter
else
request = old_request;
// If there is a value, compile it here
// If there is a value, compile it here
if (!internal_flag) {
node->nod_import = parameter =
@ -1440,7 +1440,7 @@ static QLI_NOD compile_store( QLI_NOD node, QLI_REQ request, int internal_flag)
**************************************/
QLI_MSG send;
// Find or make up request for statement
// Find or make up request for statement
QLI_CTX context = (QLI_CTX) node->nod_arg[e_sto_context];
QLI_REL relation = context->ctx_relation;
@ -1491,7 +1491,7 @@ static int computable( QLI_NOD node, QLI_REQ request)
**************************************/
QLI_NOD *ptr, *end, sub;
QLI_CTX context;
MAP map;
QLI_MAP map;
switch (node->nod_type) {
case nod_max:
@ -1538,7 +1538,7 @@ static int computable( QLI_NOD node, QLI_REQ request)
return (request == context->ctx_request);
case nod_map:
map = (MAP) node->nod_arg[e_map_map];
map = (QLI_MAP) node->nod_arg[e_map_map];
return computable(map->map_node, request);
case nod_print:
@ -1608,7 +1608,7 @@ static int computable( QLI_NOD node, QLI_REQ request)
if (node->nod_arg[e_asn_valid]) {
sub = node->nod_arg[e_asn_from];
if (sub->nod_type == nod_prompt)
/* Try to do validation in QLI as soon as
/* Try to do validation in QLI as soon as
the user responds to the prompt */
return FALSE;
}
@ -1646,7 +1646,7 @@ static int computable( QLI_NOD node, QLI_REQ request)
return TRUE;
default:
BUGCHECK(361); // Msg361 computable: not yet implemented
BUGCHECK(361); // Msg361 computable: not yet implemented
return FALSE;
}
}
@ -1667,7 +1667,7 @@ static void make_descriptor( QLI_NOD node, DSC * desc)
DSC desc1, desc2;
QLI_FLD field;
PAR parameter;
MAP map;
QLI_MAP map;
FUN function;
USHORT dtype;
@ -1695,7 +1695,7 @@ static void make_descriptor( QLI_NOD node, DSC * desc)
return;
case nod_map:
map = (MAP) node->nod_arg[e_map_map];
map = (QLI_MAP) node->nod_arg[e_map_map];
make_descriptor(map->map_node, desc);
return;
@ -1846,7 +1846,7 @@ static void make_descriptor( QLI_NOD node, DSC * desc)
case nod_substr:
default:
BUGCHECK(362); // Msg362 make_descriptor: not yet implemented
BUGCHECK(362); // Msg362 make_descriptor: not yet implemented
}
}
@ -1933,11 +1933,11 @@ static QLI_NOD make_reference( QLI_NOD node, QLI_MSG message)
**************************************
*
* Functional description
* Make a reference to a value to be computed in the
* Make a reference to a value to be computed in the
* database context. Since a field can be referenced
* several times, construct reference blocks linking
* the single field to the single parameter. (I think.)
* In any event, if a parameter for a field exists,
* In any event, if a parameter for a field exists,
* use it rather than generating an new one. Make it
* parameter2 style if necessary.
*
@ -1945,15 +1945,15 @@ static QLI_NOD make_reference( QLI_NOD node, QLI_MSG message)
PAR parm;
if (!message)
BUGCHECK(363); // Msg363 missing message
BUGCHECK(363); // Msg363 missing message
// Look for an existing field reference
// Look for an existing field reference
for (parm = message->msg_parameters; parm; parm = parm->par_next)
if (CMP_node_match(parm->par_value, node))
break;
/* Parameter doesn't exits -- make a new one. */
// Parameter doesn't exits -- make a new one.
if (!parm) {
parm = make_parameter(message, node);
@ -2019,7 +2019,7 @@ static void release_message( QLI_MSG message)
break;
if (!*ptr)
BUGCHECK(364); // Msg 364 lost message
BUGCHECK(364); // Msg 364 lost message
*ptr = message->msg_next;
ALL_release((FRB) message);
@ -2042,3 +2042,4 @@ static int string_length(const dsc* desc)
return DSC_string_length(desc);
}

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_COMPILE_H_
#define _QLI_COMPILE_H_
#ifndef QLI_COMPILE_H
#define QLI_COMPILE_H
/* Name nodes -- used to hold names between parse and compilation */
@ -252,4 +252,4 @@ enum set_t {
#define s_dfi_flag_order 32
#define s_dfi_flag_statistics 64
#endif /* _QLI_COMPILE_H_ */
#endif /* QLI_COMPILE_H */

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: dtr.c
* MODULE: dtr.cpp
* DESCRIPTION: Top level driving module
*
* The contents of this file are subject to the Interbase Public
@ -77,7 +77,7 @@ bool sw_trace;
USHORT sw_buffers;
USHORT QLI_lines = 60, QLI_prompt_count, QLI_reprompt, QLI_name_columns = 0;
/* Let's define the default number of columns on a machine by machine basis */
// Let's define the default number of columns on a machine by machine basis
#ifdef VMS
USHORT QLI_columns = 80;
@ -252,7 +252,7 @@ int CLIB_ROUTINE main( int argc, char **argv)
break;
default:
ERRQ_msg_put(469, (TEXT *) c, NULL, NULL, NULL, NULL); /* Msg469 qli: ignoring unknown switch %c */
ERRQ_msg_put(469, (TEXT *) c, NULL, NULL, NULL, NULL); // Msg469 qli: ignoring unknown switch %c
break;
}
}
@ -263,7 +263,7 @@ int CLIB_ROUTINE main( int argc, char **argv)
ERRQ_msg_put(24, NULL, NULL, NULL, NULL, NULL); // Msg24 Welcome to QLI Query Language Interpreter
if (version_flag)
ERRQ_msg_put(25, GDS_VERSION, NULL, NULL, NULL, NULL); /* Msg25 qli version %s */
ERRQ_msg_put(25, GDS_VERSION, NULL, NULL, NULL, NULL); // Msg25 qli version %s
if (application_file)
LEX_push_file(application_file, true);
@ -476,8 +476,8 @@ static bool process_statement(bool flush_flag)
dbb->dbb_statistics =
(int *) gds__alloc((SLONG) sizeof(PERF));
#ifdef DEBUG_GDS_ALLOC
/* We don't care about QLI specific memory leaks for V4.0 */
gds_alloc_flag_unfreed((void *) dbb->dbb_statistics); /* QLI: don't care */
// We don't care about QLI specific memory leaks for V4.0
gds_alloc_flag_unfreed((void *) dbb->dbb_statistics); // QLI: don't care
#endif
}
perf_get_info(&dbb->dbb_handle, (perf *)dbb->dbb_statistics);
@ -500,7 +500,7 @@ static bool process_statement(bool flush_flag)
perf_get_info(&dbb->dbb_handle, &statistics);
perf_format((perf*) dbb->dbb_statistics, &statistics,
report, buffer, 0);
ERRQ_msg_put(26, dbb->dbb_filename, buffer, NULL, NULL, NULL); /* Msg26 Statistics for database %s %s */
ERRQ_msg_put(26, dbb->dbb_filename, buffer, NULL, NULL, NULL); // Msg26 Statistics for database %s %s
QLI_skip_line = TRUE;
}
}
@ -534,6 +534,11 @@ static void CLIB_ROUTINE signal_arith_excp(USHORT sig, USHORT code, USHORT scp)
**************************************/
USHORT msg_number;
#if defined(FPE_INOVF_TRAP) || defined(FPE_INTDIV_TRAP)
|| defined(FPE_FLTOVF_TRAP) || defined(FPE_FLTDIV_TRAP)
|| defined(FPE_FLTUND_TRAP) || defined(FPE_FLTOVF_FAULT)
|| defined(FPE_FLTUND_FAULT)
switch (code) {
#ifdef FPE_INOVF_TRAP
case FPE_INTOVF_TRAP:
@ -580,6 +585,9 @@ static void CLIB_ROUTINE signal_arith_excp(USHORT sig, USHORT code, USHORT scp)
default:
msg_number = 21; // Msg21 arithmetic exception
}
#else
msg_number = 21;
#endif
signal(SIGFPE, (void(*)(int)) signal_arith_excp);

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_DTR_H_
#define _QLI_DTR_H_
#ifndef QLI_DTR_H
#define QLI_DTR_H
#include "../jrd/common.h"
#include "../jrd/dsc.h"
@ -501,4 +501,4 @@ EXTERN USHORT QLI_interp;
#include "../qli/all_proto.h"
#endif /* _QLI_DTR_H_ */
#endif /* QLI_DTR_H */

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: err.c
* MODULE: err.cpp
* DESCRIPTION: Error handlers
*
* The contents of this file are subject to the Interbase Public
@ -58,11 +58,11 @@ void ERRQ_bugcheck( USHORT number)
TEXT s[256];
ERRQ_msg_format(number, sizeof(s), s, NULL, NULL, NULL, NULL, NULL);
ERRQ_error(9, s, NULL, NULL, NULL, NULL); /* Msg9 INTERNAL: %s */
ERRQ_error(9, s, NULL, NULL, NULL, NULL); // Msg9 INTERNAL: %s
}
void ERRQ_database_error( DBB dbb, ISC_STATUS * status_vector)
void ERRQ_database_error( DBB dbb, ISC_STATUS* status_vector)
{
/**************************************
*
@ -101,8 +101,11 @@ void ERRQ_database_error( DBB dbb, ISC_STATUS * status_vector)
void ERRQ_error(
USHORT number,
TEXT * arg1,
TEXT * arg2, TEXT * arg3, TEXT * arg4, TEXT * arg5)
const TEXT* arg1,
const TEXT* arg2,
const TEXT* arg3,
const TEXT* arg4,
const TEXT* arg5)
{
/**************************************
*
@ -131,8 +134,11 @@ void ERRQ_error(
void ERRQ_error_format(
USHORT number,
TEXT * arg1,
TEXT * arg2, TEXT * arg3, TEXT * arg4, TEXT * arg5)
const TEXT* arg1,
const TEXT* arg2,
const TEXT* arg3,
const TEXT* arg4,
const TEXT* arg5)
{
/**************************************
*
@ -150,7 +156,8 @@ void ERRQ_error_format(
gds__msg_format(0, QLI_MSG_FAC, number, sizeof(s), s,
arg1, arg2, arg3, arg4, arg5);
gds__msg_format(0, QLI_MSG_FAC, 12, sizeof(ERRQ_message),
ERRQ_message, s, NULL, NULL, NULL, NULL); /* Msg12 ** QLI error: %s ** */
ERRQ_message, s, NULL, NULL, NULL, NULL);
/* Msg12 ** QLI error: %s ** */
QLI_error = (TEXT*) ERRQ_message;
QLI_skip_line = TRUE;
}
@ -178,9 +185,12 @@ void ERRQ_exit( int status)
void ERRQ_msg_format(
USHORT number,
USHORT length,
TEXT * string,
TEXT * arg1,
TEXT * arg2, TEXT * arg3, TEXT * arg4, TEXT * arg5)
TEXT* output_string,
const TEXT* arg1,
const TEXT* arg2,
const TEXT* arg3,
const TEXT* arg4,
const TEXT* arg5)
{
/**************************************
*
@ -193,18 +203,18 @@ void ERRQ_msg_format(
*
**************************************/
gds__msg_format(0, QLI_MSG_FAC, number, length, string, arg1, arg2, arg3,
arg4, arg5);
gds__msg_format(0, QLI_MSG_FAC, number, length, output_string,
arg1, arg2, arg3, arg4, arg5);
}
void ERRQ_msg_partial(
USHORT number,
const TEXT * arg1,
const TEXT * arg2,
const TEXT * arg3,
const TEXT * arg4,
const TEXT * arg5)
const TEXT* arg1,
const TEXT* arg2,
const TEXT* arg3,
const TEXT* arg4,
const TEXT* arg5)
{
/**************************************
*
@ -225,11 +235,11 @@ void ERRQ_msg_partial(
void ERRQ_msg_put(
USHORT number,
const TEXT * arg1,
const TEXT * arg2,
const TEXT * arg3,
const TEXT * arg4,
const TEXT * arg5)
const TEXT* arg1,
const TEXT* arg2,
const TEXT* arg3,
const TEXT* arg4,
const TEXT* arg5)
{
/**************************************
*
@ -249,7 +259,7 @@ void ERRQ_msg_put(
}
int ERRQ_msg_get( USHORT number, TEXT * msg)
int ERRQ_msg_get( USHORT number, TEXT* output_msg)
{
/**************************************
*
@ -261,12 +271,12 @@ int ERRQ_msg_get( USHORT number, TEXT * msg)
* Retrieve a message from the error file
*
**************************************/
SSHORT l;
TEXT buffer[128];
l = gds__msg_format(0, QLI_MSG_FAC, number, sizeof(buffer), buffer,
const SSHORT l = gds__msg_format(0, QLI_MSG_FAC, number,
sizeof(buffer), buffer,
NULL, NULL, NULL, NULL, NULL);
strcpy(msg, buffer);
strcpy(output_msg, buffer);
return (l >= 0);
}
@ -294,8 +304,11 @@ void ERRQ_pending(void)
void ERRQ_print_error(
USHORT number,
TEXT * arg1,
TEXT * arg2, TEXT * arg3, TEXT * arg4, TEXT * arg5)
const TEXT* arg1,
const TEXT* arg2,
const TEXT* arg3,
const TEXT* arg4,
const TEXT* arg5)
{
/**************************************
*
@ -329,5 +342,8 @@ void ERRQ_syntax( USHORT number)
TEXT s[256];
ERRQ_msg_format(number, sizeof(s), s, NULL, NULL, NULL, NULL, NULL);
ERRQ_error(13, s, QLI_token->tok_string, NULL, NULL, NULL); /* Msg13 expected %s, encountered %s */
ERRQ_error(13, s, QLI_token->tok_string, NULL, NULL, NULL);
// Msg13 expected %s, encountered %s
}

View File

@ -1,7 +1,7 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: err_proto.h
* DESCRIPTION: Prototype header file for err.c
* DESCRIPTION: Prototype header file for err.cpp
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
@ -26,17 +26,21 @@
extern void ERRQ_bugcheck (USHORT);
extern void ERRQ_database_error(dbb*, ISC_STATUS*);
extern void ERRQ_error (USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);
extern void ERRQ_error_format (USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);
extern void ERRQ_error (USHORT, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, const TEXT*);
extern void ERRQ_error_format (USHORT, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, const TEXT*);
extern void ERRQ_exit (int);
extern void ERRQ_msg_format (USHORT, USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);
extern int ERRQ_msg_get (USHORT, TEXT *);
extern void ERRQ_msg_partial (USHORT, const TEXT *, const TEXT *, const TEXT *,
const TEXT *, const TEXT *);
extern void ERRQ_msg_put (USHORT, const TEXT *, const TEXT *, const TEXT *,
const TEXT *, const TEXT *);
extern void ERRQ_msg_format (USHORT, USHORT, TEXT*, const TEXT*, const TEXT*,
const TEXT*, const TEXT*, const TEXT*);
extern int ERRQ_msg_get (USHORT, TEXT*);
extern void ERRQ_msg_partial (USHORT, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, const TEXT*);
extern void ERRQ_msg_put (USHORT, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, const TEXT*);
extern void ERRQ_pending (void);
extern void ERRQ_print_error (USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);
extern void ERRQ_print_error (USHORT, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, const TEXT*);
extern void ERRQ_syntax (USHORT);
#endif /* QLI_ERR_PROTO_H */

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: eval.c
* MODULE: eval.cpp
* DESCRIPTION: Value and boolean expression evaluator
*
* The contents of this file are subject to the Interbase Public
@ -177,7 +177,7 @@ int EVAL_boolean( QLI_NOD node)
return result;
default:
BUGCHECK(28); // Msg28 EVAL_boolean: not finished
BUGCHECK(28); // Msg28 EVAL_boolean: not finished
return FALSE;
}
}
@ -223,7 +223,7 @@ void EVAL_break_increment( QLI_NOD node)
DSC* desc1 = &node->nod_desc;
// Knock off count as trivial
// Knock off count as trivial
if (node->nod_type == nod_rpt_count) {
*(SLONG *) node->nod_desc.dsc_address += 1;
@ -236,7 +236,7 @@ void EVAL_break_increment( QLI_NOD node)
if (!(desc2 = EVAL_value(node->nod_arg[e_stt_value])))
return;
// If this is the first value, just move it in.
// If this is the first value, just move it in.
SLONG count = (SLONG) node->nod_arg[e_stt_default] + 1;
if (count == 1) {
@ -255,10 +255,10 @@ void EVAL_break_increment( QLI_NOD node)
node->nod_arg[e_stt_default] = (QLI_NOD) (SLONG) count;
desc1->dsc_missing = FALSE;
// Finish off as per operator
// Finish off as per operator
SSHORT comparison;
switch (node->nod_type) {
case nod_rpt_min:
case nod_rpt_max:
@ -485,14 +485,14 @@ DSC *EVAL_value(QLI_NOD node)
break;
default:
IBERROR(30); // Msg30 data type not supported for arithmetic
IBERROR(30); // Msg30 data type not supported for arithmetic
}
return desc;
case nod_prompt:
if (!prompt[0][0]) {
ERRQ_msg_get(499, prompt[0]); // Msg499 Re-enter
ERRQ_msg_get(500, prompt[1]); // Msg500 Enter
ERRQ_msg_get(499, prompt[0]); // Msg499 Re-enter
ERRQ_msg_get(500, prompt[1]); // Msg500 Enter
}
return execute_prompt(node);
@ -533,7 +533,7 @@ DSC *EVAL_value(QLI_NOD node)
desc->dsc_length = p - desc->dsc_address;
return desc;
case nod_user_name:
IBERROR(31); // Msg31 user name is supported only in RSEs temporarily
IBERROR(31); // Msg31 user name is supported only in RSEs temporarily
case nod_parameter:
case nod_position:
@ -543,7 +543,7 @@ DSC *EVAL_value(QLI_NOD node)
case nod_via:
default:
BUGCHECK(29); // Msg29 EVAL_value: not finished
BUGCHECK(29); // Msg29 EVAL_value: not finished
return NULL;
}
}
@ -605,14 +605,14 @@ static DSC *execute_concatenate( QLI_NOD node, DSC * value1, DSC * value2)
length2 = MAX(MIN(length2, desc->dsc_length - 2 - length1), 0);
if (length1)
do
do {
*p++ = *address1++;
while (--length1);
} while (--length1);
if (length2)
do
do {
*p++ = *address2++;
while (--length2);
} while (--length2);
vary->vary_length = p - vary->vary_string;
@ -725,9 +725,9 @@ static DSC *execute_prompt( QLI_NOD node)
}
else {
if (reprompt)
sprintf(string, "\07%s: ", prompt[0]); // Msg497 Re-enter
sprintf(string, "\07%s: ", prompt[0]); // Msg497 Re-enter
else
sprintf(string, "%s: ", prompt[1]); // Msg498 Enter
sprintf(string, "%s: ", prompt[1]); // Msg498 Enter
}
if (!LEX_get_line(string, value, length)) {
@ -742,7 +742,7 @@ static DSC *execute_prompt( QLI_NOD node)
if (p > value && p[-1] == '\n')
*--p = 0;
// Get rid of trailing blanks on non-text data types
// Get rid of trailing blanks on non-text data types
if (desc->dsc_dtype > dtype_varying) {
while (p > value && p[-1] == ' ')
@ -759,7 +759,7 @@ static DSC *execute_prompt( QLI_NOD node)
return desc;
}
ERRQ_msg_put(32, NULL, NULL, NULL, NULL, NULL); // Msg32 Input value is too long
ERRQ_msg_put(32, NULL, NULL, NULL, NULL, NULL); // Msg32 Input value is too long
reprompt = TRUE;
}
}
@ -861,8 +861,8 @@ static TEXT *make_blob_buffer( FRBRD * blob, USHORT * length)
*length = max_segment;
buffer = (TEXT *) gds__alloc((SLONG) * length);
#ifdef DEBUG_GDS_ALLOC
/* We don't care about QLI specific memory leaks for V4.0 */
gds_alloc_flag_unfreed((void *) buffer); /* QLI: don't care */
// We don't care about QLI specific memory leaks for V4.0
gds_alloc_flag_unfreed((void *) buffer); // QLI: don't care
#endif
return buffer;
}
@ -934,22 +934,22 @@ static int sleuth( QLI_NOD node, DSC * desc1, DSC * desc2, DSC * desc3)
l1 = MOVQ_get_string(desc3, &p1, (VARY*) temp1, TEMP_LENGTH);
// Get address and length of search string
// Get address and length of search string
l2 = MOVQ_get_string(desc2, &p2, (VARY*) temp2, TEMP_LENGTH);
// Merge search and control strings
// Merge search and control strings
l2 = sleuth_merge((UCHAR*) p2, (UCHAR*) (p2 + l2), (UCHAR*) p1, (UCHAR*) (p1 + l1), (UCHAR*) control);
// If source is not a blob, do a simple search
// If source is not a blob, do a simple search
if (desc1->dsc_dtype != dtype_blob) {
l1 = MOVQ_get_string(desc1, &p1, (VARY*) temp1, TEMP_LENGTH);
return sleuth_check(0, (UCHAR*) p1, (UCHAR*) (p1 + l1), (UCHAR*) control, (UCHAR*) (control + l2));
}
// Source string is a blob, things get interesting
// Source string is a blob, things get interesting
result = FALSE;
@ -1142,9 +1142,9 @@ static int sleuth_merge(
*
* Functional description
* Merge the matching pattern and control strings to give a cannonical
* matching pattern. Return the length of the combined string.
* matching pattern. Return the length of the combined string.
*
* What this routine does is to take the language template, strip off
* What this routine does is to take the language template, strip off
* the prefix and put it in the output string, then parse the definitions
* into an array of character pointers. The index array is the defined
* character. The routine then takes the actual match pattern and uses
@ -1163,7 +1163,7 @@ static int sleuth_merge(
v = vector;
t = temp;
// Parse control string into substitution strings and initializing string
// Parse control string into substitution strings and initializing string
while (control < end_control) {
c = *control++;
@ -1192,19 +1192,19 @@ static int sleuth_merge(
max_op = v - vector;
// Interpret matching string, substituting where appropriate
// Interpret matching string, substituting where appropriate
while (c = *match++) {
/* if we've got a defined character, slurp the definition */
// if we've got a defined character, slurp the definition
if (c <= max_op && (p = vector[c])) {
while (*p)
*comb++ = *p++;
/* if we've got the definition of a quote character, slurp the next character too */
// if we've got the definition of a quote character, slurp the next character too
if (comb[-1] == '@' && *match)
*comb++ = *match++;
}
/* at this point we've got a non-match, but as it might be one of ours, quote it. */
// at this point we've got a non-match, but as it might be one of ours, quote it.
else {
if (special[c] && comb[-1] != '@')
*comb++ = '@';
@ -1212,7 +1212,7 @@ static int sleuth_merge(
}
}
// Put in trailing stuff
// Put in trailing stuff
while (control < end_control)
*comb++ = *control++;
@ -1258,18 +1258,18 @@ static int string_boolean( QLI_NOD node)
if (node->nod_type == nod_sleuth)
return sleuth(node, desc1, desc2, desc3);
// Get address and length of strings
// Get address and length of strings
l2 = MOVQ_get_string(desc2, &p2, (VARY*) temp2, TEMP_LENGTH);
// If source is not a blob, do a simple search
// If source is not a blob, do a simple search
if (desc1->dsc_dtype != dtype_blob) {
l1 = MOVQ_get_string(desc1, &p1, (VARY*) temp1, TEMP_LENGTH);
return string_function(node, l1, p1, l2, p2) ? TRUE : FALSE;
}
// Source string is a blob, things get interesting
// Source string is a blob, things get interesting
result = FALSE;
blob = EXEC_open_blob(node->nod_arg[0]);
@ -1279,7 +1279,7 @@ static int string_boolean( QLI_NOD node)
if (!(buffer = make_blob_buffer( blob, &buffer_length)))
buffer = fixed_buffer;
while (!gds__get_segment(status_vector, &blob, (USHORT*) &l1,
while (!gds__get_segment(status_vector, &blob, (USHORT*) &l1,
buffer_length, buffer))
{
if (string_function(node, l1, buffer, l2, p2)) {
@ -1320,7 +1320,7 @@ static bool string_function(
TEXT *q1, *q2, c1, c2, temp[16];
SSHORT l;
/* Handle "STARTS WITH" */
// Handle "STARTS WITH"
if (node->nod_type == nod_starts) {
if (l1 < l2)
@ -1331,7 +1331,7 @@ static bool string_function(
return true;
}
// Handle CONTAINS
// Handle CONTAINS
if (node->nod_type == nod_containing) {
while (l1 >= l2) {
@ -1349,7 +1349,7 @@ static bool string_function(
return false;
}
// Handle LIKE
// Handle LIKE
if (node->nod_type == nod_like) {
c1 = 0;
@ -1364,7 +1364,7 @@ static bool string_function(
return false;
}
// Handle MATCHES
// Handle MATCHES
if (node->nod_type == nod_matches)
if (matches(p1, l1, p2, l2))
@ -1373,3 +1373,4 @@ static bool string_function(
return false;
}

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_EVAL_PROTO_H_
#define _QLI_EVAL_PROTO_H_
#ifndef QLI_EVAL_PROTO_H
#define QLI_EVAL_PROTO_H
extern int EVAL_boolean (struct qli_nod *);
extern void EVAL_break_compute (struct qli_nod *);
@ -31,4 +31,4 @@ extern void EVAL_break_init (struct qli_nod *);
extern struct dsc *EVAL_parameter (struct par *);
extern struct dsc *EVAL_value (struct qli_nod *);
#endif /* _QLI_EVAL_PROTO_H_ */
#endif /* QLI_EVAL_PROTO_H */

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: exe.c
* MODULE: exe.cpp
* DESCRIPTION: Execution phase
*
* The contents of this file are subject to the Interbase Public
@ -64,7 +64,7 @@ extern USHORT QLI_prompt_count, QLI_reprompt;
static DSC *assignment(QLI_NOD, DSC *, QLI_NOD, QLI_NOD, PAR);
static void commit_retaining(QLI_NOD);
static int copy_blob(QLI_NOD, PAR);
static bool copy_blob(QLI_NOD, PAR);
static void db_error(QLI_REQ, ISC_STATUS *);
static void execute_abort(QLI_NOD);
static void execute_assignment(QLI_NOD);
@ -79,7 +79,7 @@ static void print_counts(QLI_REQ);
static void set_null(QLI_MSG);
static void transaction_state(QLI_NOD, DBB);
// definitions for SET COUNT
// definitions for SET COUNT
#define COUNT_ITEMS 4
@ -105,9 +105,8 @@ void EXEC_abort(void)
*
**************************************/
ISC_STATUS_ARRAY status_vector;
QLI_REQ request;
for (request = QLI_requests; request; request = request->req_next)
for (QLI_REQ request = QLI_requests; request; request = request->req_next)
if (request->req_handle)
gds__unwind_request(status_vector, &request->req_handle, 0);
@ -197,7 +196,7 @@ void EXEC_execute( QLI_NOD node)
return;
default:
BUGCHECK(33); // Msg33 EXEC_execute: not implemented
BUGCHECK(33); // Msg33 EXEC_execute: not implemented
}
}
@ -214,35 +213,26 @@ FRBRD *EXEC_open_blob( QLI_NOD node)
* Given a blob field node, open and return the blob.
*
**************************************/
QLI_CTX context;
QLI_REQ request;
DBB dbb;
DSC *desc;
UCHAR bpb[20], *p;
USHORT bpb_length;
FRBRD *blob;
ISC_STATUS_ARRAY status_vector;
desc = EVAL_value(node);
dsc* desc = EVAL_value(node);
if (!desc)
return FALSE;
// Starting from the print item, work our way back to the database block
// Starting from the print item, work our way back to the database block
if (node->nod_type == nod_reference)
node = node->nod_arg[0];
if (node->nod_type != nod_field)
BUGCHECK(34); // Msg34 print_blob: expected field node
BUGCHECK(34); // Msg34 print_blob: expected field node
context = (QLI_CTX) node->nod_arg[e_fld_context];
request = context->ctx_request;
dbb = request->req_database;
blob = NULL;
QLI_CTX context = (QLI_CTX) node->nod_arg[e_fld_context];
QLI_REQ request = context->ctx_request;
DBB dbb = request->req_database;
FRBRD* blob = NULL;
// Format blob parameter block
p = bpb;
// Format blob parameter block
UCHAR bpb[20];
UCHAR* p = bpb;
*p++ = gds_bpb_version1;
*p++ = gds_bpb_source_type;
*p++ = 2;
@ -252,11 +242,12 @@ FRBRD *EXEC_open_blob( QLI_NOD node)
*p++ = 1;
*p++ = 1;
bpb_length = p - bpb;
const USHORT bpb_length = p - bpb;
ISC_STATUS_ARRAY status_vector;
if (gds__open_blob2(status_vector, &dbb->dbb_handle, &dbb->dbb_transaction,
&blob, (GDS_QUAD*) desc->dsc_address, bpb_length,
(char*) bpb))
(char*) bpb))
ERRQ_database_error(dbb, status_vector);
return blob;
@ -275,47 +266,45 @@ file* EXEC_open_output(QLI_NOD node)
* Open output stream to re-direct output.
*
**************************************/
IB_FILE *out_file;
DSC *desc;
TEXT filename[256], temp[64], *p, *q;
#ifndef WIN_NT
TEXT *argv[20], **arg;
int pair[2];
#endif
SSHORT l;
// Evaluate filename and copy to a null terminated string
// Evaluate filename and copy to a null terminated string
dsc* desc = EVAL_value(node->nod_arg[e_out_file]);
TEXT* p = NULL;
TEXT temp[64];
SSHORT l = MOVQ_get_string(desc, &p, (VARY*) temp, sizeof(temp));
desc = EVAL_value(node->nod_arg[e_out_file]);
l = MOVQ_get_string(desc, &p, (VARY*) temp, sizeof(temp));
q = filename;
TEXT filename[256];
TEXT* q = filename;
if (l)
do
do {
*q++ = *p++;
while (--l);
} while (--l);
*q = 0;
// If output is to a file, just do it
// If output is to a file, just do it
if (!node->nod_arg[e_out_pipe]) {
if (out_file = ib_fopen(filename, FOPEN_WRITE_TYPE))
return (file*)out_file;
IB_FILE* out_file = ib_fopen(filename, FOPEN_WRITE_TYPE);
if (out_file)
return (file*) out_file;
ERRQ_print_error(42, filename, NULL, NULL, NULL, NULL);
/* Msg42 Can't open output file %s */
// Msg42 Can't open output file %s
}
// Output is to a file. Setup file and fork process
// Output is to a file. Setup file and fork process
#ifdef VMS
IBERROR(35); // Msg35 output pipe is not supported on VMS
IBERROR(35); // Msg35 output pipe is not supported on VMS
#else
#ifdef WIN_NT
if (out_file = _popen(filename, "w"))
return (file*)out_file;
IB_FILE* out_file = _popen(filename, "w");
if (out_file)
return (file*) out_file;
#else
arg = argv;
TEXT* argv[20];
TEXT** arg = argv;
p = filename;
while (*p) {
*arg++ = p;
@ -329,8 +318,9 @@ file* EXEC_open_output(QLI_NOD node)
}
*arg = NULL;
int pair[2];
if (pipe(pair) < 0)
IBERROR(36); /* Msg36 couldn't create pipe */
IBERROR(36); // Msg36 couldn't create pipe
if (!vfork()) {
close(pair[1]);
@ -338,17 +328,17 @@ file* EXEC_open_output(QLI_NOD node)
dup(pair[0]);
close(pair[0]);
execvp(argv[0], argv);
ERRQ_msg_put(43, filename, NULL, NULL, NULL, NULL); /* Msg43 Couldn't run %s */
ERRQ_msg_put(43, filename, NULL, NULL, NULL, NULL); // Msg43 Couldn't run %s
_exit(-1);
}
close(pair[0]);
if (out_file = ib_fdopen(pair[1], "w"))
return (file*)out_file;
return (file*) out_file;
#endif
IBERROR(37); // Msg37 ib_fdopen failed
IBERROR(37); // Msg37 ib_fdopen failed
#endif
return NULL;
}
@ -371,7 +361,7 @@ void EXEC_poll_abort(void)
if (!QLI_abort)
return;
IBERROR(38); // Msg38 execution terminated by signal
IBERROR(38); // Msg38 execution terminated by signal
}
@ -387,13 +377,12 @@ DSC *EXEC_receive(QLI_MSG message, PAR parameter)
* Receive a message from a running request.
*
**************************************/
QLI_REQ request;
ISC_STATUS_ARRAY status_vector;
request = message->msg_request;
QLI_REQ request = message->msg_request;
if (gds__receive(status_vector, &request->req_handle, message->msg_number,
message->msg_length, message->msg_buffer, 0))
message->msg_length, message->msg_buffer, 0))
db_error(request, status_vector);
if (!parameter)
@ -416,10 +405,9 @@ void EXEC_send( QLI_MSG message)
* any data to the message.
*
**************************************/
QLI_REQ request;
ISC_STATUS_ARRAY status_vector;
request = message->msg_request;
QLI_REQ request = message->msg_request;
map_data(message);
if (gds__send(status_vector, &request->req_handle, message->msg_number,
@ -448,12 +436,12 @@ void EXEC_start_request( QLI_REQ request, QLI_MSG message)
if (!gds__start_and_send(status_vector, &request->req_handle,
&request->req_database-> dbb_transaction,
message->msg_number, message->msg_length,
message->msg_buffer, 0))
message->msg_buffer, 0))
return;
}
else
if (!gds__start_request(status_vector, &request->req_handle,
&request->req_database-> dbb_transaction, 0))
&request->req_database-> dbb_transaction, 0))
return;
db_error(request, status_vector);
@ -494,17 +482,15 @@ static DSC *assignment( QLI_NOD from_node,
* goes wrong and there was a prompt, try again.
*
**************************************/
DSC *from_desc;
UCHAR *p;
QLI_MSG message;
USHORT l, *missing_flag, trash;
jmp_buf old_env;
memcpy(old_env, QLI_env, sizeof(QLI_env));
QLI_reprompt = FALSE;
QLI_prompt_count = 0;
missing_flag = &trash;
USHORT trash;
USHORT* missing_flag = &trash;
QLI_MSG message = NULL;
if (parameter) {
message = parameter->par_message;
missing_flag =
@ -514,7 +500,7 @@ static DSC *assignment( QLI_NOD from_node,
try {
memcpy(QLI_env, old_env, sizeof(QLI_env));
from_desc = EVAL_value(from_node);
dsc* from_desc = EVAL_value(from_node);
if (from_desc->dsc_missing & DSC_initial) {
from_desc = EVAL_value(initial);
@ -523,8 +509,9 @@ static DSC *assignment( QLI_NOD from_node,
/* If there is a value present, do any assignment; otherwise null fill */
if (*missing_flag = to_desc->dsc_missing = from_desc->dsc_missing) {
p = from_desc->dsc_address;
if (l = from_desc->dsc_length) {
UCHAR* p = from_desc->dsc_address;
USHORT l = from_desc->dsc_length;
if (l) {
do {
*p++ = 0;
} while (--l);
@ -535,7 +522,7 @@ static DSC *assignment( QLI_NOD from_node,
}
if (validation && EVAL_boolean(validation) <= 0) {
IBERROR(39); // Msg39 field validation error
IBERROR(39); // Msg39 field validation error
}
QLI_reprompt = FALSE;
@ -567,12 +554,11 @@ static void commit_retaining( QLI_NOD node)
*
* Functional description
* Execute commit retaining statement for
* one or more named databases or all databases.
* one or more named databases or all databases.
* If there's more than one, prepare it.
*
**************************************/
DBB database;
QLI_NOD *ptr, *end;
/* If there aren't any open databases then obviously
there isn't anything to commit. */
@ -582,7 +568,8 @@ static void commit_retaining( QLI_NOD node)
if (node->nod_type == nod_commit_retaining &&
((node->nod_count > 1) ||
(node->nod_count == 0 && QLI_databases->dbb_next))) {
(node->nod_count == 0 && QLI_databases->dbb_next)))
{
node->nod_type = nod_prepare;
commit_retaining(node);
node->nod_type = nod_commit_retaining;
@ -600,8 +587,10 @@ static void commit_retaining( QLI_NOD node)
database = database->dbb_next) {
if ((node->nod_type == nod_commit_retaining)
&& !(database->dbb_flags & DBB_prepared))
{
ERRQ_msg_put(465, database->dbb_symbol->sym_string, NULL,
NULL, NULL, NULL);
}
else if (node->nod_type == nod_prepare)
database->dbb_flags |= DBB_prepared;
if (database->dbb_transaction)
@ -610,12 +599,15 @@ static void commit_retaining( QLI_NOD node)
return;
}
for (ptr = node->nod_arg, end = ptr + node->nod_count; ptr < end; ptr++) {
database = (DBB) * ptr;
QLI_NOD* ptr = node->nod_arg;
for (QLI_NOD* const end = ptr + node->nod_count; ptr < end; ptr++) {
database = (DBB) *ptr;
if ((node->nod_type == nod_commit_retaining) &&
!(database->dbb_flags & DBB_prepared))
{
ERRQ_msg_put(465, database->dbb_symbol->sym_string, NULL, NULL,
NULL, NULL);
}
else if (node->nod_type == nod_prepare)
database->dbb_flags |= DBB_prepared;
if (database->dbb_transaction)
@ -625,7 +617,7 @@ static void commit_retaining( QLI_NOD node)
static int copy_blob( QLI_NOD value, PAR parameter)
static bool copy_blob( QLI_NOD value, PAR parameter)
{
/**************************************
*
@ -639,52 +631,47 @@ static int copy_blob( QLI_NOD value, PAR parameter)
* copy the blob ids.
*
**************************************/
QLI_CTX context;
QLI_MSG message;
QLI_REQ from_request, to_request;
DBB to_dbb, from_dbb;
DSC *from_desc, *to_desc;
FRBRD *from_blob, *to_blob;
SLONG size, segment_count, max_segment;
ISC_STATUS_ARRAY status_vector;
USHORT bpb_length, length, buffer_length;
UCHAR bpb[20], *p, fixed_buffer[4096], *buffer;
/* If assignment isn't from a field, there isn't a blob copy, so
do a dumb assignment. */
if (value->nod_type != nod_field)
return FALSE;
return false;
/* Find the sending and receiving requests. If they are the same
and no filtering is necessary, a simple assignment will suffice. */
context = (QLI_CTX) value->nod_arg[e_fld_context];
from_request = context->ctx_request;
from_dbb = from_request->req_database;
message = parameter->par_message;
to_request = message->msg_request;
to_dbb = to_request->req_database;
QLI_CTX context = (QLI_CTX) value->nod_arg[e_fld_context];
QLI_REQ from_request = context->ctx_request;
DBB from_dbb = from_request->req_database;
QLI_MSG message = parameter->par_message;
QLI_REQ to_request = message->msg_request;
DBB to_dbb = to_request->req_database;
from_desc = EVAL_value(value);
to_desc = EVAL_parameter(parameter);
dsc* from_desc = EVAL_value(value);
dsc* to_desc = EVAL_parameter(parameter);
if (to_dbb == from_dbb &&
(!to_desc->dsc_sub_type ||
from_desc->dsc_sub_type == to_desc->dsc_sub_type)) return FALSE;
from_desc->dsc_sub_type == to_desc->dsc_sub_type))
{
return false;
}
/* We've got a blob copy on our hands. */
// We've got a blob copy on our hands.
if (!from_desc) {
*to_desc->dsc_address = 0;
return TRUE;
return true;
}
to_blob = from_blob = NULL;
FRBRD* to_blob = NULL;
FRBRD* from_blob = NULL;
// Format blob parameter block for the existing blob
// Format blob parameter block for the existing blob
p = bpb;
UCHAR bpb[20];
UCHAR* p = bpb;
*p++ = gds_bpb_version1;
*p++ = gds_bpb_source_type;
*p++ = 2;
@ -694,40 +681,51 @@ static int copy_blob( QLI_NOD value, PAR parameter)
*p++ = 2;
*p++ = to_desc->dsc_sub_type;
*p++ = to_desc->dsc_sub_type >> 8;
bpb_length = p - bpb;
const USHORT bpb_length = p - bpb;
ISC_STATUS_ARRAY status_vector;
if (gds__create_blob(status_vector, &to_dbb->dbb_handle,
&to_dbb->dbb_transaction, &to_blob,
(GDS__QUAD*) to_desc->dsc_address))
{
ERRQ_database_error(to_dbb, status_vector);
}
if (gds__open_blob2(status_vector, &from_dbb->dbb_handle,
&from_dbb->dbb_transaction, &from_blob,
(GDS__QUAD*) from_desc->dsc_address, bpb_length,
(char*) bpb))
(char*) bpb))
{
ERRQ_database_error(from_dbb, status_vector);
}
SLONG size, segment_count, max_segment;
gds__blob_size(&from_blob, &size, &segment_count, &max_segment);
UCHAR fixed_buffer[4096];
UCHAR* buffer;
USHORT buffer_length;
if (max_segment < (SLONG) sizeof(fixed_buffer)) {
buffer_length = sizeof(fixed_buffer);
buffer = fixed_buffer;
}
else {
else
{
buffer_length = max_segment;
buffer = (UCHAR*) gds__alloc(buffer_length);
#ifdef DEBUG_GDS_ALLOC
/* We don't care about QLI specific memory leaks for V4.0 */
gds_alloc_flag_unfreed((void *) buffer); /* QLI: don't care */
// We don't care about QLI specific memory leaks for V4.0
gds_alloc_flag_unfreed((void *) buffer); // QLI: don't care
#endif
}
USHORT length;
while (!gds__get_segment(status_vector, &from_blob, &length, buffer_length,
(char*) buffer))
if (gds__put_segment(status_vector, &to_blob, length,
(char*) buffer))
ERRQ_database_error(to_dbb, status_vector);
{
if (gds__put_segment(status_vector, &to_blob, length, (char*) buffer))
ERRQ_database_error(to_dbb, status_vector);
}
if (buffer != fixed_buffer)
gds__free(buffer);
@ -738,7 +736,7 @@ static int copy_blob( QLI_NOD value, PAR parameter)
if (gds__close_blob(status_vector, &to_blob))
ERRQ_database_error(to_dbb, status_vector);
return TRUE;
return true;
}
@ -773,19 +771,20 @@ static void execute_abort( QLI_NOD node)
* Abort a statement.
*
**************************************/
USHORT l;
UCHAR *ptr, temp[80], msg[128];
if (node->nod_count) {
l =
MOVQ_get_string(EVAL_value(node->nod_arg[0]), (TEXT**) &ptr, (VARY*) temp,
sizeof(temp));
UCHAR* ptr = NULL;
UCHAR temp[80];
USHORT l =
MOVQ_get_string(EVAL_value(node->nod_arg[0]), (TEXT**) &ptr,
(VARY*) temp, sizeof(temp));
UCHAR msg[128];
MOVQ_terminate((SCHAR*) ptr, (SCHAR*) msg, l, sizeof(msg));
ERRQ_error(40, (TEXT*) msg, NULL, NULL, NULL, NULL);
/* Msg40 Request terminated by statement: %s */
// Msg40 Request terminated by statement: %s
}
IBERROR(41); // Msg41 Request terminated by statement
IBERROR(41); // Msg41 Request terminated by statement
}
@ -800,23 +799,23 @@ static void execute_assignment( QLI_NOD node)
* Functional description
*
**************************************/
QLI_NOD to, from, reference, initial;
QLI_FLD field;
PAR parameter;
if (node->nod_flags & NOD_remote)
return;
to = node->nod_arg[e_asn_to];
from = node->nod_arg[e_asn_from];
initial = node->nod_arg[e_asn_initial];
QLI_NOD to = node->nod_arg[e_asn_to];
QLI_NOD from = node->nod_arg[e_asn_from];
QLI_NOD initial = node->nod_arg[e_asn_initial];
PAR parameter;
if (to->nod_type == nod_field) {
reference = to->nod_arg[e_fld_reference];
QLI_NOD reference = to->nod_arg[e_fld_reference];
parameter = reference->nod_import;
if (to->nod_desc.dsc_dtype == dtype_blob &&
from->nod_desc.dsc_dtype == dtype_blob &&
copy_blob(from, parameter)) return;
copy_blob(from, parameter))
{
return;
}
}
else
parameter = node->nod_import;
@ -827,10 +826,10 @@ static void execute_assignment( QLI_NOD node)
assignment(from, EVAL_value(to),
node->nod_arg[e_asn_valid], initial, parameter);
// propagate the missing flag in variable assignments
// propagate the missing flag in variable assignments
if (to->nod_type == nod_variable) {
field = (QLI_FLD) to->nod_arg[e_fld_field];
QLI_FLD field = (QLI_FLD) to->nod_arg[e_fld_field];
if (to->nod_desc.dsc_missing & DSC_missing)
field->fld_flags |= FLD_missing;
else
@ -854,29 +853,31 @@ static void execute_for( QLI_NOD node)
* absolutely nothing to do.
*
**************************************/
QLI_REQ request;
QLI_MSG message;
DSC *desc;
/* If there is a request associated with the node, start it and possibly
send a message along with it. */
if (request = (QLI_REQ) node->nod_arg[e_for_request])
QLI_REQ request = (QLI_REQ) node->nod_arg[e_for_request];
if (request)
EXEC_start_request(request, (QLI_MSG) node->nod_arg[e_for_send]);
else if (message = (QLI_MSG) node->nod_arg[e_for_send])
EXEC_send(message);
else {
QLI_MSG amessage = (QLI_MSG) node->nod_arg[e_for_send];
if (amessage)
EXEC_send(amessage);
}
/* If there isn't a receive message, the body of the loop has been
optimized out of existance. So skip it. */
if (!(message = (QLI_MSG) node->nod_arg[e_for_receive]))
QLI_MSG message = (QLI_MSG) node->nod_arg[e_for_receive];
if (!message)
goto count;
/* Receive messages in a loop until the end of file field comes up
true. */
while (true) {
desc = EXEC_receive(message, (PAR) node->nod_arg[e_for_eof]);
dsc* desc = EXEC_receive(message, (PAR) node->nod_arg[e_for_eof]);
if (*(USHORT *) desc->dsc_address)
break;
EXEC_execute(node->nod_arg[e_for_statement]);
@ -903,13 +904,11 @@ static void execute_modify( QLI_NOD node)
* message to the running request and executing a sub-statement.
*
**************************************/
QLI_MSG message;
if (node->nod_flags & NOD_remote)
return;
if (message = (QLI_MSG) node->nod_arg[e_mod_send])
QLI_MSG message = (QLI_MSG) node->nod_arg[e_mod_send];
if (message)
set_null(message);
EXEC_execute(node->nod_arg[e_mod_statement]);
@ -931,21 +930,20 @@ static void execute_output( QLI_NOD node)
* Open output stream to re-direct output.
*
**************************************/
PRT print;
jmp_buf old_env;
jmp_buf env;
print = (PRT) node->nod_arg[e_out_print];
PRT print = (PRT) node->nod_arg[e_out_print];
print->prt_file = EXEC_open_output(node);
// Set up error handling
// Set up error handling
memcpy(old_env, QLI_env, sizeof(QLI_env));
memcpy(QLI_env, env, sizeof(QLI_env));
try {
// Finally, execute the query
// Finally, execute the query
EXEC_execute(node->nod_arg[e_out_statement]);
memcpy(QLI_env, old_env, sizeof(QLI_env));
@ -989,7 +987,7 @@ static void execute_repeat( QLI_NOD node)
{
/**************************************
*
* e x e c u t e _ r e p e a t
* e x e c u t e _ r e p e a t
*
**************************************
*
@ -997,9 +995,7 @@ static void execute_repeat( QLI_NOD node)
* Execute a REPEAT statement. In short, loop.
*
**************************************/
SLONG count;
count = MOVQ_get_long(EVAL_value(node->nod_arg[e_rpt_value]), 0);
SLONG count = MOVQ_get_long(EVAL_value(node->nod_arg[e_rpt_value]), 0);
while (--count >= 0)
EXEC_execute(node->nod_arg[e_rpt_statement]);
@ -1022,10 +1018,8 @@ static void execute_store( QLI_NOD node)
* here.
*
**************************************/
QLI_REQ request;
QLI_MSG message;
if (message = (QLI_MSG) node->nod_arg[e_sto_send])
QLI_MSG message = (QLI_MSG) node->nod_arg[e_sto_send];
if (message)
set_null(message);
if (!(node->nod_flags & NOD_remote))
@ -1034,7 +1028,8 @@ static void execute_store( QLI_NOD node)
/* If there is a request associated with the node, start it and possibly
send a message along with it. */
if (request = (QLI_REQ) node->nod_arg[e_sto_request])
QLI_REQ request = (QLI_REQ) node->nod_arg[e_sto_request];
if (request)
EXEC_start_request(request, (QLI_MSG) node->nod_arg[e_sto_send]);
else if (message)
EXEC_send(message);
@ -1056,22 +1051,19 @@ static void map_data( QLI_MSG message)
* Map data to a message in preparation for sending.
*
**************************************/
PAR parameter, missing_parameter;
QLI_NOD from;
DSC *desc;
USHORT *missing_flag;
for (parameter = message->msg_parameters; parameter;
parameter = parameter->par_next) {
desc = &parameter->par_desc;
for (PAR parameter = message->msg_parameters; parameter;
parameter = parameter->par_next)
{
dsc* desc = &parameter->par_desc;
desc->dsc_address = message->msg_buffer + parameter->par_offset;
if (missing_parameter = parameter->par_missing) {
missing_flag = (USHORT *) (message->msg_buffer +
PAR missing_parameter = parameter->par_missing;
if (missing_parameter) {
USHORT* missing_flag = (USHORT*) (message->msg_buffer +
missing_parameter->par_offset);
*missing_flag = (desc->dsc_missing & DSC_missing) ? DSC_missing : 0;
}
from = parameter->par_value;
QLI_NOD from = parameter->par_value;
if (desc->dsc_dtype == dtype_blob && copy_blob(from, parameter))
continue;
assignment(from, desc, 0, 0, parameter->par_missing);
@ -1088,28 +1080,28 @@ static void print_counts( QLI_REQ request)
**************************************
*
* Functional description
* Print out the count of records affected
* Print out the count of records affected
* by the last statement.
*
**************************************/
UCHAR item;
int length;
ULONG number;
ISC_STATUS_ARRAY status_vector;
SCHAR count_buffer[COUNT_ITEMS * 7 + 1], *c;
SCHAR count_buffer[COUNT_ITEMS * 7 + 1];
if (gds__request_info(status_vector, &request->req_handle, 0,
sizeof(count_info), count_info,
sizeof(count_buffer), count_buffer))
sizeof(count_buffer), count_buffer))
{
return;
}
// print out the counts of any records affected
// print out the counts of any records affected
for (c = count_buffer; *c != gds_info_end; c += length) {
item = *c++;
int length = 0;
for (SCHAR* c = count_buffer; *c != gds_info_end; c += length) {
UCHAR item = *c++;
length = gds__vax_integer((UCHAR*) c, 2);
c += 2;
number = gds__vax_integer((UCHAR*) c, length);
const ULONG number = gds__vax_integer((UCHAR*) c, length);
if (number)
switch (item) {
@ -1151,15 +1143,12 @@ static void set_null( QLI_MSG message)
* statements.
*
**************************************/
PAR parameter;
QLI_NOD from;
DSC *desc;
for (parameter = message->msg_parameters; parameter;
parameter = parameter->par_next) {
from = parameter->par_value;
for (PAR parameter = message->msg_parameters; parameter;
parameter = parameter->par_next)
{
QLI_NOD from = parameter->par_value;
if (from->nod_type == nod_field) {
desc = EVAL_value(from);
dsc* desc = EVAL_value(from);
desc->dsc_missing |= DSC_missing;
}
else
@ -1178,7 +1167,7 @@ static void transaction_state( QLI_NOD node, DBB database)
**************************************
*
* Functional description
*
*
* set the state of the working transaction
* in a particular database to prepared or
* committed.
@ -1197,3 +1186,5 @@ static void transaction_state( QLI_NOD node, DBB database)
}
}
}

View File

@ -90,18 +90,18 @@ typedef struct qli_ctx {
struct qli_nod* ctx_rse; /* RSE node for root context */
struct qli_nod* ctx_sub_rse; /* RSE node aggregate */
qli_ctx* ctx_parent; /* Parent context for map */
struct map *ctx_map; /* Map items, if any */
struct qli_map *ctx_map; /* Map items, if any */
USHORT ctx_context; /* Context in request */
} *QLI_CTX;
/* Aggregate/union map block */
typedef struct map {
typedef struct qli_map {
blk map_header;
map* map_next; /* Next map in item */
qli_map* map_next; /* Next map in item */
struct qli_nod* map_node; /* Value for map item */
USHORT map_position; /* Position in map */
} *MAP;
} *QLI_MAP;
/* Message block */

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_EXE_PROTO_H_
#define _QLI_EXE_PROTO_H_
#ifndef QLI_EXE_PROTO_H
#define QLI_EXE_PROTO_H
extern void EXEC_abort (void);
extern void EXEC_execute(qli_nod*);
@ -34,4 +34,4 @@ extern void EXEC_send(qli_msg*);
extern void EXEC_start_request(qli_req*, qli_msg*);
extern void EXEC_top(qli_nod*);
#endif /* _QLI_EXE_PROTO_H_ */
#endif /* QLI_EXE_PROTO_H */

View File

@ -21,9 +21,9 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_EXPAN_PROTO_H_
#define _QLI_EXPAN_PROTO_H_
#ifndef QLI_EXPAN_PROTO_H
#define QLI_EXPAN_PROTO_H
extern qli_nod* EXP_expand(syn*);
#endif /* _QLI_EXPAN_PROTO_H_ */
#endif /* QLI_EXPAN_PROTO_H */

File diff suppressed because it is too large Load Diff

View File

@ -127,7 +127,7 @@ TEXT *FMT_format(LLS stack)
USHORT j, l, n, lengths[10], *ptr;
TEXT *p, *q, *segments[10];
// Start by inverting the item stack into an item que
// Start by inverting the item stack into an item que
LLS temp = stack;
stack = NULL;
@ -191,7 +191,7 @@ TEXT *FMT_format(LLS stack)
format_value(item, 0);
// If the item would overflow the line, reset to beginning of line
// If the item would overflow the line, reset to beginning of line
if (offset + MAX(item->itm_print_length, item->itm_header_length) >
QLI_columns) offset = 0;
@ -220,9 +220,9 @@ TEXT *FMT_format(LLS stack)
}
if (flag && (l = n)) {
BOTTOM_CHECK(bottom, bottom - BOTTOM_LINE + n);
do
do {
*bottom++ = '=';
while (--l);
} while (--l);
}
else {
item->itm_query_header = NULL;
@ -240,7 +240,7 @@ TEXT *FMT_format(LLS stack)
max_offset = MAX(max_offset, offset);
}
// Make another pass checking for overlapping fields
// Make another pass checking for overlapping fields
for (temp = stack; temp; temp = temp->lls_next) {
item = (ITM) temp->lls_object;
@ -261,7 +261,7 @@ TEXT *FMT_format(LLS stack)
if (number_segments == 0)
return NULL;
// Allocate a string block big enough to hold all lines of the print header
// Allocate a string block big enough to hold all lines of the print header
const ULONG size = (max_offset + 1) * (number_segments + 1) + 2;
@ -272,7 +272,7 @@ TEXT *FMT_format(LLS stack)
STR header = (STR) ALLOCDV(type_str, size);
p = header->str_data;
// Generate the various lines of the header line at a time.
// Generate the various lines of the header line at a time.
for (j = 0; j < number_segments; j++) {
*p++ = '\n';
@ -292,20 +292,20 @@ TEXT *FMT_format(LLS stack)
*p++ = ' ';
q = segments[segment];
if (l)
do
do {
*p++ = *q++;
while (--l);
} while (--l);
}
}
// Make one last pass to put in underlining of headers
// Make one last pass to put in underlining of headers
if (l = bottom - BOTTOM_LINE) {
*p++ = '\n';
bottom = BOTTOM_LINE;
do
do {
*p++ = *bottom++;
while (--l);
} while (--l);
}
*p++ = '\n';
@ -444,11 +444,11 @@ void FMT_print( QLI_NOD list, PRT print)
RPT report;
ISC_STATUS_ARRAY status_vector;
// Now go thru and make up the first line
// Now go thru and make up the first line
if (!list)
return;
TEXT* buffer = NULL;
TEXT* p = BUFFER_INIT;
qli_nod** const end = list->nod_arg + list->nod_count;
@ -514,7 +514,7 @@ void FMT_print( QLI_NOD list, PRT print)
while (p < q)
*p++ = ' ';
// Next, handle simple formated values
// Next, handle simple formated values
if (item->itm_dtype != dtype_blob) {
desc = EVAL_value(item->itm_value);
@ -526,7 +526,7 @@ void FMT_print( QLI_NOD list, PRT print)
continue;
}
// Finally, handle blobs
// Finally, handle blobs
if (!(item->itm_stream = EXEC_open_blob(item->itm_value)))
continue;
@ -544,11 +544,11 @@ void FMT_print( QLI_NOD list, PRT print)
put_line(print, &p, buffer, '\n');
// Now go back until all blobs have been fetched
// Now go back until all blobs have been fetched
print_blobs(print, (ITM*) list->nod_arg, (ITM*) end);
// Finish by closing all blobs
// Finish by closing all blobs
for (ptr = list->nod_arg; ptr < end; ptr++) {
ITM item = (ITM) *ptr;
@ -581,7 +581,7 @@ void FMT_put(const TEXT* line, PRT print)
TEXT* const end = buffer + sizeof(buffer) - 1;
const TEXT* q = line;
TEXT* p;
if (print && print->prt_file)
while (*q) {
for (p = buffer; p < end && *q;)
@ -596,7 +596,7 @@ void FMT_put(const TEXT* line, PRT print)
*p = 0;
#ifdef DEV_BUILD
if (QLI_hex_output) {
// Hex mode output to assist debugging of multicharset work
// Hex mode output to assist debugging of multicharset work
for (p = buffer; p < end && *p; p++)
if (is_printable(*p))
@ -652,7 +652,7 @@ void FMT_report( RPT report)
report->rpt_column_header = format_report(columns_vec, width, &width);
// Handle report name, if any
// Handle report name, if any
if (report->rpt_name) {
const USHORT n =
@ -660,16 +660,16 @@ void FMT_report( RPT report)
USHORT i;
for (i = 0; i < n; i++)
width = MAX(width, lengths[i] + 15);
STR string = (STR) ALLOCDV(type_str, width * n);
TEXT* p = string->str_data;
report->rpt_header = p;
for (i = 0; i < n; i++) {
USHORT column = (width - lengths[i]) / 2;
if (column > 0)
do
do {
*p++ = ' ';
while (--column);
} while (--column);
const TEXT* q = segments[i];
const TEXT* const end = q + lengths[i];
while (q < end)
@ -703,7 +703,7 @@ static int decompose_header(SCHAR* string,
SSHORT n = 0;
// Handle simple name first
// Handle simple name first
if (*string != '"' && *string != '\'')
while (*string) {
@ -752,7 +752,7 @@ static void format_index( ITM item, QLI_NOD field, const bool print_flag)
return;
}
// Start the label with the current query header, if any
// Start the label with the current query header, if any
USHORT l;
const TEXT* q;
@ -771,7 +771,7 @@ static void format_index( ITM item, QLI_NOD field, const bool print_flag)
while (l--)
*p++ = *q++;
// Loop through the subscripts, adding to the label
// Loop through the subscripts, adding to the label
const TEXT* r;
if (print_flag) {
@ -780,7 +780,7 @@ static void format_index( ITM item, QLI_NOD field, const bool print_flag)
}
else
r = "[";
TEXT s[32];
QLI_NOD *ptr, *end;
for (ptr = args->nod_arg, end = ptr + args->nod_count; ptr < end; ptr++) {
@ -799,7 +799,7 @@ static void format_index( ITM item, QLI_NOD field, const bool print_flag)
break;
default:
// Punt on anything but constants, fields, and variables
// Punt on anything but constants, fields, and variables
ALL_release((FRB) str);
return;
@ -956,14 +956,14 @@ static TEXT *format_report( VEC columns_vec, USHORT width, USHORT * max_width)
if (number_segments == 0)
return NULL;
// Allocate a string block big enough to hold all lines of the print header
// Allocate a string block big enough to hold all lines of the print header
l = bottom - BOTTOM_LINE;
STR header = (STR) ALLOCDV(type_str,
(max_offset + 1) * (number_segments + 1) + 2 + l);
p = header->str_data;
// Generate the various lines of the header line at a time.
// Generate the various lines of the header line at a time.
for (j = 0; j < number_segments; j++) {
*p++ = '\n';
@ -988,21 +988,21 @@ static TEXT *format_report( VEC columns_vec, USHORT width, USHORT * max_width)
*p++ = ' ';
q = segments[segment];
if (l)
do
do {
*p++ = *q++;
while (--l);
} while (--l);
}
}
}
// Make one last pass to put in underlining of headers
// Make one last pass to put in underlining of headers
if (l = bottom - BOTTOM_LINE) {
*p++ = '\n';
bottom = BOTTOM_LINE;
do
do {
*p++ = *bottom++;
while (--l);
} while (--l);
}
*p++ = '\n';
@ -1055,7 +1055,7 @@ static void format_value( ITM item, int flags)
field = (QLI_FLD) node->nod_arg[e_fld_field];
if ((field->fld_flags & FLD_array) && !node->nod_arg[e_fld_subs])
ERRQ_print_error(480, field->fld_name->sym_string, NULL, NULL,
NULL, NULL); /* msg 480 can not format unsubscripted array %s */
NULL, NULL); // msg 480 can not format unsubscripted array %s
}
if (!(item->itm_picture->pic_missing) &&
@ -1099,9 +1099,9 @@ static TEXT* get_buffer(STR* str, TEXT* ptr, USHORT length)
const TEXT* q = (*str)->str_data;
if (ptr && (l = ptr - q))
do
do {
*p++ = *q++;
while (--l);
} while (--l);
ALL_release((FRB) *str);
*str = temp_str;
@ -1124,7 +1124,7 @@ static int match_expr( QLI_NOD node1, QLI_NOD node2)
**************************************/
QLI_NOD *ptr1, *ptr2, *end;
/* If either is missing, they can't match. */
// If either is missing, they can't match.
if (!node1 || !node2)
return FALSE;
@ -1135,12 +1135,12 @@ static int match_expr( QLI_NOD node1, QLI_NOD node2)
if (node2->nod_type == nod_reference)
node2 = node2->nod_arg[0];
// A constant more or less matches anything
// A constant more or less matches anything
if (node1->nod_type == nod_constant)
return TRUE;
/* Hasn't matched yet. Check for statistical expression */
// Hasn't matched yet. Check for statistical expression
switch (node1->nod_type) {
case nod_average:
@ -1273,7 +1273,7 @@ static int print_line( ITM item, TEXT ** ptr)
EXEC_poll_abort();
/* If we're already at end of stream, there's nothing to do */
// If we're already at end of stream, there's nothing to do
if (!item->itm_stream)
return EOF;
@ -1383,7 +1383,7 @@ static void report_item( ITM item, VEC * columns_vec, USHORT * col_ndx)
if (item->itm_query_header && *item->itm_query_header == '-')
item->itm_query_header = NULL;
/* If it's a constant, dump it in the next logical column */
// If it's a constant, dump it in the next logical column
columns = *columns_vec;
if (columns->vec_object[*col_ndx] &&
@ -1408,7 +1408,7 @@ static void report_item( ITM item, VEC * columns_vec, USHORT * col_ndx)
}
}
/* Didn't fit -- make a new logical column */
// Didn't fit -- make a new logical column
*col_ndx = new_index = col - (LLS *) columns->vec_object;
if (new_index >= columns->vec_count) {
@ -1449,3 +1449,4 @@ static void report_line( QLI_NOD list, VEC * columns_vec)
}
}

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_FORMAT_H_
#define _QLI_FORMAT_H_
#ifndef QLI_FORMAT_H
#define QLI_FORMAT_H
/* Logical column block */
@ -116,4 +116,4 @@ typedef struct pics {
#define PIC_literal 2 /* We're in a quoted string */
#define PIC_signed 4 /* This numeric edit string has a sign indicator */
#endif /* _QLI_FORMAT_H_ */
#endif /* QLI_FORMAT_H */

View File

@ -21,7 +21,7 @@
* Contributor(s): ______________________________________.
*/
/*
$Id: gener.cpp,v 1.22 2003-09-15 12:30:28 robocop Exp $
$Id: gener.cpp,v 1.23 2003-09-25 11:49:07 robocop Exp $
*/
#include "firebird.h"
@ -56,7 +56,7 @@ static void gen_for(QLI_NOD, QLI_REQ);
static void gen_function(QLI_NOD, QLI_REQ);
static void gen_if(QLI_NOD, QLI_REQ);
static void gen_literal(const dsc*, QLI_REQ);
static void gen_map(MAP, QLI_REQ);
static void gen_map(QLI_MAP, QLI_REQ);
static void gen_modify(QLI_NOD, QLI_REQ);
static void gen_parameter(PAR, QLI_REQ);
static void gen_print_list(QLI_NOD, QLI_REQ);
@ -128,7 +128,7 @@ RLB GEN_rlb_extend(RLB rlb)
**************************************
*
* Functional description
*
*
* Allocate a new larger request language buffer
* and copy generated request language into it
*
@ -161,7 +161,7 @@ void GEN_rlb_release( RLB rlb)
**************************************
*
* Functional description
*
*
* Release the request language buffer
* contents. The buffer itself will go away
* with the default pool.
@ -191,7 +191,7 @@ static void explain(const UCHAR* explain_buffer)
**************************************
*
* Functional description
* Print out the access path for a blr
* Print out the access path for a blr
* request in pretty-printed form.
*
**************************************/
@ -243,7 +243,7 @@ static void explain(const UCHAR* explain_buffer)
case gds_info_rsb_indexed:
ib_printf("gds_info_rsb_indexed,\n");
level++;
explain_index_tree(level, relation_name,
explain_index_tree(level, relation_name,
reinterpret_cast<const SCHAR**>(&explain_buffer),
&buffer_length);
level--;
@ -521,14 +521,14 @@ static void gen_assignment( QLI_NOD node, QLI_REQ request)
**************************************/
qli_nod* from = node->nod_arg[e_asn_from];
// Handle a local expression locally
// Handle a local expression locally
if (node->nod_flags & NOD_local) {
gen_expression(from, 0);
return;
}
// Generate a remote assignment
// Generate a remote assignment
RLB rlb = CHECK_RLB(request->req_blr);
@ -603,7 +603,7 @@ static void gen_compile( QLI_REQ request)
DBB dbb = request->req_database;
if (gds__compile_request(status_vector, &dbb->dbb_handle,
&request->req_handle, length,
&request->req_handle, length,
(char*) rlb->rlb_base)) {
RELEASE_RLB;
ERRQ_database_error(dbb, status_vector);
@ -698,7 +698,7 @@ static void gen_descriptor(const dsc* desc, QLI_REQ request)
break;
default:
BUGCHECK(352); // Msg352 gen_descriptor: dtype not recognized
BUGCHECK(352); // Msg352 gen_descriptor: dtype not recognized
}
}
@ -743,7 +743,7 @@ static void gen_expression( QLI_NOD node, QLI_REQ request)
**************************************/
QLI_NOD *ptr, *end;
QLI_CTX context;
MAP map;
QLI_MAP map;
USHORT operatr;
RLB rlb;
@ -779,7 +779,7 @@ static void gen_expression( QLI_NOD node, QLI_REQ request)
return;
case nod_map:
map = (MAP) node->nod_arg[e_map_map];
map = (QLI_MAP) node->nod_arg[e_map_map];
context = (QLI_CTX) node->nod_arg[e_map_context];
if (context->ctx_request != request &&
map->map_node->nod_type == nod_field) {
@ -944,7 +944,7 @@ static void gen_expression( QLI_NOD node, QLI_REQ request)
gen_parameter(node->nod_export, request);
return;
}
BUGCHECK(353); // Msg353 gen_expression: not understood
BUGCHECK(353); // Msg353 gen_expression: not understood
}
if (request) {
@ -974,7 +974,7 @@ static void gen_field( QLI_NOD node, QLI_REQ request)
* requests or not.
*
**************************************/
/* If there isn't a request specified, this is a reference. */
// If there isn't a request specified, this is a reference.
if (!request)
return;
@ -1042,12 +1042,12 @@ static void gen_for( QLI_NOD node, QLI_REQ request)
if (message = (QLI_MSG) node->nod_arg[e_for_receive])
STUFF(blr_begin);
// If there is a message to be sent, build a receive for it
// If there is a message to be sent, build a receive for it
if (node->nod_arg[e_for_send])
gen_send_receive((QLI_MSG) node->nod_arg[e_for_send], blr_receive);
// Generate the FOR loop proper.
// Generate the FOR loop proper.
STUFF(blr_for);
gen_rse(node->nod_arg[e_for_rse], request);
@ -1062,7 +1062,7 @@ static void gen_for( QLI_NOD node, QLI_REQ request)
gen_send_receive(message, blr_send);
STUFF(blr_begin);
// Build assigments for all values referenced.
// Build assigments for all values referenced.
for (PAR parameter = message->msg_parameters; parameter;
parameter = parameter->par_next)
@ -1074,7 +1074,7 @@ static void gen_for( QLI_NOD node, QLI_REQ request)
}
}
// Next, make a FALSE for the end of file parameter
// Next, make a FALSE for the end of file parameter
eof = (PAR) node->nod_arg[e_for_eof];
desc.dsc_dtype = dtype_short;
@ -1091,7 +1091,7 @@ static void gen_for( QLI_NOD node, QLI_REQ request)
STUFF(blr_end);
}
// Build the body of the loop.
// Build the body of the loop.
QLI_MSG continuation = request->req_continue;
if (continuation) {
@ -1113,7 +1113,7 @@ static void gen_for( QLI_NOD node, QLI_REQ request)
if (continuation)
STUFF(blr_end);
// Finish off by building a SEND to indicate end of file
// Finish off by building a SEND to indicate end of file
if (message) {
gen_send_receive(message, blr_send);
@ -1124,7 +1124,7 @@ static void gen_for( QLI_NOD node, QLI_REQ request)
STUFF(blr_end);
}
// If this is our request, compile it.
// If this is our request, compile it.
if (node->nod_arg[e_for_request])
gen_compile(request);
@ -1167,7 +1167,7 @@ static void gen_function( QLI_NOD node, QLI_REQ request)
else
rlb = CHECK_RLB(request->req_blr);
// Generate function body
// Generate function body
STUFF(blr_function);
FUN function = (FUN) node->nod_arg[e_fun_function];
@ -1176,7 +1176,7 @@ static void gen_function( QLI_NOD node, QLI_REQ request)
for (const UCHAR* p = (UCHAR *) symbol->sym_string; *p;)
STUFF(*p++);
// Generate function arguments
// Generate function arguments
QLI_NOD args = node->nod_arg[e_fun_args];
STUFF(args->nod_count);
@ -1284,14 +1284,14 @@ static void gen_literal(const dsc* desc, QLI_REQ request)
default:
if (l)
do
do {
STUFF(*p++);
while (--l);
} while (--l);
}
}
static void gen_map( MAP map, QLI_REQ request)
static void gen_map(QLI_MAP map, QLI_REQ request)
{
/**************************************
*
@ -1303,7 +1303,7 @@ static void gen_map( MAP map, QLI_REQ request)
* Generate a value map for a record selection expression.
*
**************************************/
MAP temp;
QLI_MAP temp;
RLB rlb = CHECK_RLB(request->req_blr);
@ -1332,7 +1332,7 @@ static void gen_modify( QLI_NOD node, QLI_REQ org_request)
**************************************
*
* Functional description
* Generate a MODIFY statement.
* Generate a MODIFY statement.
*
**************************************/
QLI_NOD *ptr, *end;
@ -1459,7 +1459,7 @@ static void gen_request( QLI_REQ request)
STUFF(blr_version4);
STUFF(blr_begin);
// Build declarations for all messages.
// Build declarations for all messages.
for (QLI_MSG message = request->req_messages; message;
message = message->msg_next)
@ -1523,7 +1523,7 @@ static void gen_rse( QLI_NOD node, QLI_REQ request)
STUFF(blr_rs_stream);
STUFF(node->nod_count);
// Check for aggregate case
// Check for aggregate case
QLI_CTX context = (QLI_CTX) node->nod_arg[e_rse_count];
@ -1553,7 +1553,7 @@ static void gen_rse( QLI_NOD node, QLI_REQ request)
return;
}
// Make relation clauses for all relations
// Make relation clauses for all relations
for (ptr = &node->nod_arg[e_rse_count], end = ptr + node->nod_count;
ptr < end; ptr++)
@ -1569,7 +1569,7 @@ static void gen_rse( QLI_NOD node, QLI_REQ request)
}
}
// Handle various clauses
// Handle various clauses
if (list = node->nod_arg[e_rse_first]) {
STUFF(blr_first);
@ -1726,7 +1726,7 @@ static void gen_statement( QLI_NOD node, QLI_REQ request)
return;
default:
BUGCHECK(354); // Msg354 gen_statement: not yet implemented
BUGCHECK(354); // Msg354 gen_statement: not yet implemented
}
}
@ -1800,7 +1800,7 @@ static void gen_statistical( QLI_NOD node, QLI_REQ request)
break;
default:
BUGCHECK(355); // Msg355 gen_statistical: not understood
BUGCHECK(355); // Msg355 gen_statistical: not understood
}
/* If there is a request associated with the statement, prepare to
@ -1863,12 +1863,12 @@ static void gen_store( QLI_NOD node, QLI_REQ request)
RLB rlb = CHECK_RLB(request->req_blr);
// If there is a message to be sent, build a receive for it
// If there is a message to be sent, build a receive for it
if (node->nod_arg[e_sto_send])
gen_send_receive((QLI_MSG) node->nod_arg[e_sto_send], blr_receive);
// Generate the STORE statement proper.
// Generate the STORE statement proper.
STUFF(blr_store);
QLI_CTX context = (QLI_CTX) node->nod_arg[e_sto_context];
@ -1877,15 +1877,16 @@ static void gen_store( QLI_NOD node, QLI_REQ request)
STUFF_WORD(relation->rel_id);
STUFF(context->ctx_context);
// Build the body of the loop.
// Build the body of the loop.
STUFF(blr_begin);
gen_statement(node->nod_arg[e_sto_statement], request);
STUFF(blr_end);
// If this is our request, compile it.
// If this is our request, compile it.
if (node->nod_arg[e_sto_request])
gen_compile(request);
}

View File

@ -133,7 +133,7 @@ static int additional_topics( TEXT * parent, TEXT * banner, TEXT * string)
**************************************/
TEXT line[256];
/* Print list of know topics. When we find the first,
/* Print list of know topics. When we find the first,
print the banner, if any */
TEXT* ptr = line;
@ -161,9 +161,9 @@ static int additional_topics( TEXT * parent, TEXT * banner, TEXT * string)
while (ptr < p)
*ptr++ = ' ';
p = X.TOPIC;
do
do {
*ptr++ = *p++;
while (--l);
} while (--l);
*ptr++ = ' ';
END_FOR;
@ -199,12 +199,12 @@ static void print_more(
ERRQ_msg_get(502, prompt); /* Msg502 "Subtopic? " */
// Prompt the user for a line
// Prompt the user for a line
if (!LEX_get_line(prompt, buffer, sizeof(buffer)))
return;
// Upcase the response and zap the blanks
// Upcase the response and zap the blanks
topics[1] = p = topic;
@ -213,7 +213,7 @@ static void print_more(
*p++ = UPPER(*q);
*p = 0;
// If we got anything, print the new topic
// If we got anything, print the new topic
if (p != topic)
print_topic(level + 1, depth + 1, topics + 1, max_level, parent,
@ -244,7 +244,7 @@ static void print_topic(
TEXT string[128], banner[128], *next, *p, *q, *path, buffer[128],
prompt[80];
// Copy the parent string inserting a blank at the end
// Copy the parent string inserting a blank at the end
p = string;
@ -272,7 +272,7 @@ static void print_topic(
FOR(LEVEL level) X IN TOPICS WITH X.FACILITY EQ "QLI" AND
(X.TOPIC STARTING WITH * topics AND X.PARENT EQ parent) OR
(X.TOPIC = X.FACILITY AND X.TOPIC = *topics AND X.TOPIC = X.PARENT)
SORTED BY X.TOPIC
SORTED BY X.TOPIC
if (QLI_abort)
return;
@ -303,7 +303,7 @@ static void print_topic(
ib_printf("%s%s", INDENT, B.SEGMENT);
END_FOR;
ERRQ_msg_format(81, sizeof(banner), banner, INDENT, NULL, NULL,
NULL, NULL); /* Msg81 %sSub-topics available: */
NULL, NULL); // Msg81 %sSub-topics available:
if (additional_topics(string, banner, INDENT))
print_more(level, depth, topics, max_level, string,
error_flag);
@ -312,8 +312,8 @@ static void print_topic(
if (!count && error_flag && level > *max_level) {
path = strip(parent);
ERRQ_msg_put(82, path, *topics, NULL, NULL, NULL); /* Msg82 No help is available for %s %s */
ERRQ_msg_format(83, sizeof(banner), banner, path, NULL, NULL, NULL, NULL); /* Msg83 Sub-topics available for %s are: */
ERRQ_msg_put(82, path, *topics, NULL, NULL, NULL); // Msg82 No help is available for %s %s
ERRQ_msg_format(83, sizeof(banner), banner, path, NULL, NULL, NULL, NULL); // Msg83 Sub-topics available for %s are:
additional_topics(parent, banner, path);
}
}
@ -345,3 +345,4 @@ static TEXT *strip( TEXT * string)
return p;
}

View File

@ -21,10 +21,10 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_HELP_PROTO_H_
#define _QLI_HELP_PROTO_H_
#ifndef QLI_HELP_PROTO_H
#define QLI_HELP_PROTO_H
extern void HELP_fini (void);
extern void HELP_help(syn*);
#endif /* _QLI_HELP_PROTO_H_ */
#endif /* QLI_HELP_PROTO_H */

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: hsh.c
* MODULE: hsh.cpp
* DESCRIPTION: Hash table and symbol manager
*
* The contents of this file are subject to the Interbase Public
@ -28,18 +28,20 @@
#include "../qli/err_proto.h"
#include "../qli/hsh_proto.h"
#define HASH_SIZE 224
static int hash(SCHAR *, int);
static bool scompare(SCHAR *, int, SCHAR *, int);
static int hash(const SCHAR*, int);
static bool scompare(const SCHAR*, int, const SCHAR*, int);
const int HASH_SIZE = 224;
static SYM hash_table[HASH_SIZE];
static SYM key_symbols;
struct word_t {
struct qli_kword {
KWWORDS id;
SCHAR *keyword;
} keywords[] = {
};
const qli_kword keywords[] =
{
#include "../qli/words.h"
{KW_continuation, "-\n"}
};
@ -57,10 +59,8 @@ void HSH_fini(void)
* Release space used by keywords.
*
**************************************/
SYM symbol;
while (key_symbols) {
symbol = key_symbols;
SYM symbol = key_symbols;
key_symbols = (SYM) key_symbols->sym_object;
HSH_remove(symbol);
ALL_release((FRB) symbol);
@ -81,18 +81,17 @@ void HSH_init(void)
* inserting all known keywords.
*
**************************************/
SCHAR *string;
SYM symbol;
int i;
word_t* word;
const qli_kword* qword = keywords;
for (i = 0, word = keywords; i < FB_NELEM(keywords); i++, word++) {
for (string = word->keyword; *string; string++);
symbol = (SYM) ALLOCPV(type_sym, 0);
for (int i = 0; i < FB_NELEM(keywords); i++, qword++) {
const SCHAR* string = qword->keyword;
while (*string)
++string;
SYM symbol = (SYM) ALLOCPV(type_sym, 0);
symbol->sym_type = SYM_keyword;
symbol->sym_length = string - word->keyword;
symbol->sym_string = word->keyword;
symbol->sym_keyword = (int) word->id;
symbol->sym_length = string - qword->keyword;
symbol->sym_string = qword->keyword;
symbol->sym_keyword = (int) qword->id;
HSH_insert(symbol);
symbol->sym_object = (BLK) key_symbols;
key_symbols = symbol;
@ -112,14 +111,12 @@ void HSH_insert( SYM symbol)
* Insert a symbol into the hash table.
*
**************************************/
int h;
SYM old;
const int h = hash(symbol->sym_string, symbol->sym_length);
h = hash(symbol->sym_string, symbol->sym_length);
for (old = hash_table[h]; old; old = old->sym_collision)
for (SYM old = hash_table[h]; old; old = old->sym_collision)
if (scompare(symbol->sym_string, symbol->sym_length,
old->sym_string, old->sym_length)) {
old->sym_string, old->sym_length))
{
symbol->sym_homonym = old->sym_homonym;
old->sym_homonym = symbol;
return;
@ -130,7 +127,7 @@ void HSH_insert( SYM symbol)
}
SYM HSH_lookup(SCHAR * string, int length)
SYM HSH_lookup(const SCHAR* string, int length)
{
/**************************************
*
@ -142,13 +139,12 @@ SYM HSH_lookup(SCHAR * string, int length)
* Perform a string lookup against hash table.
*
**************************************/
SYM symbol;
for (symbol = hash_table[hash(string, length)]; symbol;
for (SYM symbol = hash_table[hash(string, length)]; symbol;
symbol = symbol->sym_collision)
if (scompare
(string, length, symbol->sym_string,
symbol->sym_length)) return symbol;
{
if (scompare(string, length, symbol->sym_string, symbol->sym_length))
return symbol;
}
return NULL;
}
@ -158,7 +154,7 @@ void HSH_remove( SYM symbol)
{
/**************************************
*
* H S H _ r e m o v e
* H S H _ r e m o v e
*
**************************************
*
@ -166,12 +162,11 @@ void HSH_remove( SYM symbol)
* Remove a symbol from the hash table.
*
**************************************/
int h;
SYM *next, *ptr, homonym;
SYM *ptr, homonym;
h = hash(symbol->sym_string, symbol->sym_length);
const int h = hash(symbol->sym_string, symbol->sym_length);
for (next = &hash_table[h]; *next; next = &(*next)->sym_collision)
for (SYM* next = &hash_table[h]; *next; next = &(*next)->sym_collision)
if (symbol == *next)
if (homonym = symbol->sym_homonym) {
homonym->sym_collision = symbol->sym_collision;
@ -189,11 +184,11 @@ void HSH_remove( SYM symbol)
return;
}
ERRQ_error(27, NULL, NULL, NULL, NULL, NULL); // Msg 27 HSH_remove failed
ERRQ_error(27, NULL, NULL, NULL, NULL, NULL); // Msg 27 HSH_remove failed
}
static int hash( SCHAR * string, int length)
static int hash(const SCHAR* string, int length)
{
/**************************************
*
@ -205,13 +200,10 @@ static int hash( SCHAR * string, int length)
* Returns the hash function of a string.
*
**************************************/
int value;
SCHAR c;
value = 0;
int value = 0;
while (length--) {
c = *string++;
const SCHAR c = *string++;
value = (value << 1) + UPPER(c);
}
@ -219,9 +211,9 @@ static int hash( SCHAR * string, int length)
}
static bool scompare(SCHAR * string1,
static bool scompare(const SCHAR* string1,
int length1,
SCHAR * string2,
const SCHAR* string2,
int length2)
{
/**************************************
@ -234,14 +226,18 @@ static bool scompare(SCHAR * string1,
* Compare two strings
*
**************************************/
SCHAR c1, c2;
if (length1 != length2)
return false;
while (length1--)
if ((c1 = *string1++) != (c2 = *string2++) && UPPER(c1) != UPPER(c2))
{
const SCHAR c1 = *string1++;
const SCHAR c2 = *string2++;
if (c1 != c2 && UPPER(c1) != UPPER(c2))
return false;
}
return true;
}

View File

@ -1,7 +1,7 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: hsh_proto.h
* DESCRIPTION: Prototype header file for hsh.c
* DESCRIPTION: Prototype header file for hsh.cpp
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
@ -27,7 +27,8 @@
extern void HSH_fini (void);
extern void HSH_init (void);
extern void HSH_insert(sym*);
extern sym* HSH_lookup(SCHAR*, int);
extern sym* HSH_lookup(const SCHAR*, int);
extern void HSH_remove(sym*);
#endif /* QLI_HSH_PROTO_H */

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: lex.c
* MODULE: lex.cpp
* DESCRIPTION: Lexical analyser
*
* The contents of this file are subject to the Interbase Public
@ -39,6 +39,7 @@
#include "../qli/proc_proto.h"
#include "../jrd/gds_proto.h"
#include "../jrd/utl_proto.h"
#include "../jrd/gdsassert.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@ -77,40 +78,39 @@ extern bool sw_verify;
extern bool sw_trace;
static bool get_line(IB_FILE *, TEXT *, USHORT);
static int nextchar(bool);
static void next_line(bool);
static void retchar(SSHORT);
static int nextchar(const bool);
static void next_line(const bool);
static void retchar(const SSHORT);
static bool scan_number(SSHORT, TEXT **);
static int skip_white(void);
static LLS QLI_statements;
static int QLI_position;
static IB_FILE *input_file = NULL, *trace_file = NULL;
static UCHAR trace_file_name[128];
static char trace_file_name[MAXPATHLEN];
static SLONG trans_limit;
#define TRANS_LIMIT 10
#define CHR_ident 1
#define CHR_letter 2
#define CHR_digit 4
#define CHR_quote 8
#define CHR_white 16
#define CHR_eol 32
const char CHR_ident = char(1);
const char CHR_letter = char(2);
const char CHR_digit = char(4);
const char CHR_quote = char(8);
const char CHR_white = char(16);
const char CHR_eol = char(32);
#define CHR_IDENT CHR_ident
#define CHR_LETTER CHR_letter + CHR_ident
#define CHR_DIGIT CHR_digit + CHR_ident
#define CHR_QUOTE CHR_quote
#define CHR_WHITE CHR_white
#define CHR_EOL CHR_eol
const char CHR_IDENT = CHR_ident;
const char CHR_LETTER = CHR_letter + CHR_ident;
const char CHR_DIGIT = CHR_digit + CHR_ident;
const char CHR_QUOTE = CHR_quote;
const char CHR_WHITE = CHR_white;
const char CHR_EOL = CHR_eol;
#ifdef NOT_USED_OR_REPLACED
static SCHAR *eol_string = "*end_of_line*";
#endif
static SCHAR *eof_string = "*end_of_file*";
static const char* const eol_string = "end of line";
static const char* const eof_string = "*end_of_file*";
static SCHAR classes[256] = {
static const char classes[256] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, CHR_WHITE, CHR_EOL, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@ -170,24 +170,22 @@ void LEX_edit( SLONG start, SLONG stop)
* push the scratch file on the input stack.
*
**************************************/
IB_FILE *scratch;
TEXT filename[128];
SSHORT c;
TEXT filename[MAXPATHLEN];
scratch = (IB_FILE *) gds__temp_file(TRUE, SCRATCH, filename);
IB_FILE* scratch = (IB_FILE*) gds__temp_file(TRUE, SCRATCH, filename);
if (scratch == (IB_FILE *) - 1)
IBERROR(61); /* Msg 61 couldn't open scratch file */
IBERROR(61); // Msg 61 couldn't open scratch file
#ifdef WIN_NT
stop--;
#endif
if (ib_fseek(trace_file, start, 0)) {
ib_fseek(trace_file, (SLONG) 0, 2);
IBERROR(59); // Msg 59 ib_fseek failed
IBERROR(59); // Msg 59 ib_fseek failed
}
while (++start <= stop) {
c = ib_getc(trace_file);
const SSHORT c = ib_getc(trace_file);
if (c == EOF)
break;
ib_putc(c, scratch);
@ -216,16 +214,13 @@ TOK LEX_edit_string(void)
* Parse the next token as an edit_string.
*
**************************************/
TOK token;
SSHORT c, d;
TEXT *p;
SSHORT c;
TOK token = QLI_token;
token = QLI_token;
do
do {
c = skip_white();
while (c == '\n');
p = token->tok_string;
} while (c == '\n');
TEXT* p = token->tok_string;
*p = c;
if (!QLI_line) {
@ -238,7 +233,8 @@ TOK LEX_edit_string(void)
*p++ = c;
if (classes[c] & CHR_quote)
for (;;) {
if ((d = nextchar(false)) == '\n') {
const SSHORT d = nextchar(false);
if (d == '\n') {
retchar(d);
break;
}
@ -278,20 +274,17 @@ TOK LEX_filename(void)
* Parse the next token as a filename.
*
**************************************/
TOK token;
SSHORT c, save;
USHORT class_;
TEXT *p;
SSHORT c;
token = QLI_token;
TOK token = QLI_token;
do
do {
c = skip_white();
while (c == '\n');
p = token->tok_string;
} while (c == '\n');
TEXT* p = token->tok_string;
*p++ = c;
/* If there isn't a line, we're all done */
// If there isn't a line, we're all done
if (!QLI_line) {
token->tok_symbol = NULL;
@ -299,49 +292,48 @@ TOK LEX_filename(void)
return NULL;
}
// notice if this looks like a quoted file name
// notice if this looks like a quoted file name
SSHORT save = 0;
if (classes[c] & CHR_quote) {
token->tok_type = tok_quoted;
save = c;
}
else
save = 0;
// Look for white space or end of line, allowing embedded quoted strings.
// Look for white space or end of line, allowing embedded quoted strings.
for (;;) {
c = nextchar(true);
class_ = classes[c];
char char_class = classes[c];
if (c == '"' && c != save) {
*p++ = c;
for (;;) {
c = nextchar(true);
class_ = classes[c];
if ((class_ & CHR_eol) || c == '"')
char_class = classes[c];
if ((char_class & CHR_eol) || c == '"')
break;
*p++ = c;
}
}
if (class_ & (CHR_white | CHR_eol))
if (char_class & (CHR_white | CHR_eol))
break;
*p++ = c;
}
retchar(c);
// Drop trailing semi-colon to avoid confusion
// Drop trailing semi-colon to avoid confusion
if (p[-1] == ';') {
retchar(c);
--p;
}
// complain on unterminated quoted string
// complain on unterminated quoted string
if ((token->tok_type == tok_quoted) && (p[-1] != save))
IBERROR(60); // Msg 60 unterminated quoted string
IBERROR(60); // Msg 60 unterminated quoted string
token->tok_length = p - token->tok_string;
*p = 0;
@ -370,7 +362,7 @@ void LEX_fini(void)
if (trace_file && (trace_file != (IB_FILE *) - 1)) {
ib_fclose(trace_file);
unlink((char*) trace_file_name);
unlink(trace_file_name);
}
}
@ -384,7 +376,7 @@ void LEX_flush(void)
**************************************
*
* Functional description
* Flush the input stream after an error.
* Flush the input stream after an error.
*
**************************************/
@ -393,12 +385,12 @@ void LEX_flush(void)
if (!QLI_line)
return;
/* Pop off line sources until we're down to the last one. */
// Pop off line sources until we're down to the last one.
while (QLI_line->line_next)
LEX_pop_line();
// Look for a semi-colon
// Look for a semi-colon
if (QLI_semi)
while (QLI_line && QLI_token->tok_keyword != KW_SEMI)
@ -427,18 +419,17 @@ bool LEX_get_line(TEXT * prompt,
* return false. Regardless, a null terminated string is returned.
*
**************************************/
TEXT *p;
bool overflow_flag = false;
SSHORT c;
// UNIX flavor
// UNIX flavor
if (prompt)
ib_printf(prompt);
errno = 0;
p = buffer;
TEXT* p = buffer;
bool overflow_flag = false;
while (true) {
c = ib_getc(input_file);
if (c == EOF) {
@ -447,9 +438,9 @@ bool LEX_get_line(TEXT * prompt,
continue;
}
/* The check for this actually being a terminal that is at
end of file is to prevent looping through a redirected
ib_stdin (e.g., a script file). */
// The check for this actually being a terminal that is at
// end of file is to prevent looping through a redirected
// ib_stdin (e.g., a script file).
if (prompt && isatty(ib_fileno(ib_stdin))) {
ib_rewind(ib_stdin);
@ -474,7 +465,7 @@ bool LEX_get_line(TEXT * prompt,
if (overflow_flag) {
buffer[0] = 0;
IBERROR(476); // Msg 476 input line too long
IBERROR(476); // Msg 476 input line too long
}
if (sw_verify)
@ -506,9 +497,8 @@ bool LEX_get_line(TEXT * prompt,
struct dsc$descriptor_s line_desc, prompt_desc;
SLONG status;
SSHORT length;
SCHAR *p;
/* We're going to add a null to the end, so don't read too much */
// We're going to add a null to the end, so don't read too much
--size;
@ -527,13 +517,13 @@ bool LEX_get_line(TEXT * prompt,
else
status = lib$get_input(&line_desc, NULL, &length);
p = buffer + length;
SCHAR* p = buffer + length;
if (!(status & 1)) {
if (status != LIB$_INPSTRTRU)
return false;
buffer[0] = 0;
IBERROR(476); // Msg 476 input line too long
IBERROR(476); // Msg 476 input line too long
}
else if (length < size)
*p++ = '\n';
@ -564,9 +554,9 @@ void LEX_init(void)
*
**************************************/
trace_file = (IB_FILE*) gds__temp_file(TRUE, SCRATCH, (TEXT*) trace_file_name);
trace_file = (IB_FILE*) gds__temp_file(TRUE, SCRATCH, trace_file_name);
if (trace_file == (IB_FILE *) - 1)
IBERROR(61); /* Msg 61 couldn't open scratch file */
IBERROR(61); // Msg 61 couldn't open scratch file
QLI_token = (TOK) ALLOCPV(type_tok, MAXSYMLEN);
@ -595,15 +585,17 @@ void LEX_mark_statement(void)
* the statement stack.
*
**************************************/
LLS statement;
LINE temp;
for (temp = QLI_line;
temp->line_next && QLI_statements;
temp = temp->line_next)
if (temp->line_next->line_position == (SLONG) QLI_statements->lls_object) return;
{
if (temp->line_next->line_position == (SLONG) QLI_statements->lls_object)
return;
}
statement = (LLS) ALLOCP(type_lls);
LLS statement = (LLS) ALLOCP(type_lls);
statement->lls_object = (BLK) temp->line_position;
statement->lls_next = QLI_statements;
QLI_statements = statement;
@ -623,9 +615,7 @@ void LEX_pop_line(void)
* and release the line block.
*
**************************************/
LINE temp;
temp = QLI_line;
LINE temp = QLI_line;
QLI_line = temp->line_next;
if (temp->line_type == line_blob)
@ -650,9 +640,7 @@ void LEX_procedure( DBB database, FRBRD *blob)
* stack;
*
**************************************/
LINE temp;
temp = (LINE) ALLOCPV(type_line, QLI_token->tok_length);
LINE temp = (LINE) ALLOCPV(type_line, QLI_token->tok_length);
temp->line_source = blob;
strncpy(temp->line_source_name, QLI_token->tok_string,
QLI_token->tok_length);
@ -666,12 +654,12 @@ void LEX_procedure( DBB database, FRBRD *blob)
}
bool LEX_push_file(TEXT * filename,
bool error_flag)
bool LEX_push_file(const TEXT* filename,
const bool error_flag)
{
/**************************************
*
* L E X _ p u s h _ f i l e
* L E X _ p u s h _ f i l e
*
**************************************
*
@ -681,20 +669,20 @@ bool LEX_push_file(TEXT * filename,
* if the error flag is set, otherwise return quietly.
*
**************************************/
TEXT buffer[64];
IB_FILE *file;
LINE line;
if (!(file = ib_fopen(filename, FOPEN_INPUT_TYPE))) {
TEXT buffer[64];
sprintf(buffer, "%s.com", filename);
if (!(file = ib_fopen(buffer, FOPEN_INPUT_TYPE))) {
if (error_flag)
ERRQ_msg_put(67, filename, NULL, NULL, NULL, NULL); /* Msg 67 can't open command file \"%s\"\n */
ERRQ_msg_put(67, filename, NULL, NULL, NULL, NULL);
// Msg 67 can't open command file \"%s\"\n
return false;
}
}
line = (LINE) ALLOCPV(type_line, strlen(filename));
LINE line = (LINE) ALLOCPV(type_line, strlen(filename));
line->line_type = line_file;
line->line_source = (FRBRD *) file;
line->line_size = sizeof(line->line_data);
@ -708,7 +696,7 @@ bool LEX_push_file(TEXT * filename,
}
bool LEX_push_string( TEXT * string)
bool LEX_push_string(const TEXT* const string)
{
/**************************************
*
@ -720,9 +708,7 @@ bool LEX_push_string( TEXT * string)
* Push a simple string on as an input source.
*
**************************************/
LINE line;
line = (LINE) ALLOCPV(type_line, 0);
LINE line = (LINE) ALLOCPV(type_line, 0);
line->line_type = line_string;
line->line_size = strlen(string);
line->line_ptr = line->line_data;
@ -748,25 +734,25 @@ void LEX_put_procedure( FRBRD *blob, SLONG start, SLONG stop)
*
**************************************/
ISC_STATUS_ARRAY status_vector;
int length;
SSHORT l, c;
TEXT buffer[1024], *p;
if (ib_fseek(trace_file, start, 0)) {
ib_fseek(trace_file, (SLONG) 0, 2);
IBERROR(62); // Msg 62 ib_fseek failed
IBERROR(62); // Msg 62 ib_fseek failed
}
length = stop - start;
int length = stop - start;
TEXT buffer[1024];
while (length) {
p = buffer;
TEXT* p = buffer;
while (length) {
--length;
*p++ = c = ib_getc(trace_file);
const SSHORT c = ib_getc(trace_file);
*p++ = c;
if (c == '\n') {
#ifdef PC_FILE_SEEK
// account for the extra line-feed on OS/2 and Windows NT
// account for the extra line-feed on OS/2 and Windows NT
if (length)
--length;
@ -774,9 +760,10 @@ void LEX_put_procedure( FRBRD *blob, SLONG start, SLONG stop)
break;
}
}
if (l = p - buffer)
const SSHORT l = p - buffer;
if (l)
if (gds__put_segment(status_vector, &blob, l, buffer))
BUGCHECK(58); // Msg 58 gds__put_segment failed
BUGCHECK(58); // Msg 58 gds__put_segment failed
}
ib_fseek(trace_file, (SLONG) 0, 2);
@ -832,32 +819,27 @@ TOK LEX_token(void)
* Parse and return the next token.
*
**************************************/
TOK token;
SSHORT c, next, peek;
TEXT class_, *p, *q;
SYM symbol;
LINE prior;
SSHORT c;
token = QLI_token;
p = token->tok_string;
TOK token = QLI_token;
TEXT* p = token->tok_string;
/* Get next significant byte. If it's the last EOL of a blob, throw it
away */
// Get next significant byte. If it's the last EOL of a blob, throw it away
for (;;) {
c = skip_white();
if (c != '\n' || QLI_line->line_type != line_blob)
break;
prior = QLI_line;
LINE prior = QLI_line;
next_line(true);
if (prior == QLI_line)
break;
}
// If we hit end of file, make up a phoney token
// If we hit end of file, make up a phoney token
if (!QLI_line) {
q = eof_string;
const TEXT* q = eof_string;
while (*p++ = *q++);
token->tok_type = tok_eof;
token->tok_keyword = KW_none;
@ -868,34 +850,35 @@ TOK LEX_token(void)
QLI_token->tok_position = QLI_line->line_position +
QLI_line->line_ptr - QLI_line->line_data - 1;
// On end of file, generate furious but phone end of line tokens
// On end of file, generate furious but phone end of line tokens
class_ = classes[c];
char char_class = classes[c];
if (class_ & CHR_letter) {
while (classes[c = nextchar(true)] & CHR_ident)
if (char_class & CHR_letter) {
for (c = nextchar(true); classes[c] & CHR_ident; c = nextchar(true))
*p++ = c;
retchar(c);
token->tok_type = tok_ident;
}
else if (((class_ & CHR_digit) || c == '.') && scan_number(c, &p))
else if (((char_class & CHR_digit) || c == '.') && scan_number(c, &p))
token->tok_type = tok_number;
else if (class_ & CHR_quote) {
else if (char_class & CHR_quote) {
token->tok_type = tok_quoted;
SSHORT next;
while (true) {
if (!(next = nextchar(false)) || next == '\n') {
retchar(next);
IBERROR(63); // Msg 63 unterminated quoted string
IBERROR(63); // Msg 63 unterminated quoted string
break;
}
*p++ = next;
if ((p - token->tok_string) >= MAXSYMLEN)
ERRQ_msg_put(470, (TEXT *) MAXSYMLEN, NULL, NULL, NULL, NULL); // Msg 470 literal too long
ERRQ_msg_put(470, (TEXT *) MAXSYMLEN, NULL, NULL, NULL, NULL); // Msg 470 literal too long
// If there are 2 quotes in a row, interpret 2nd as a literal
// If there are 2 quotes in a row, interpret 2nd as a literal
if (next == c) {
peek = nextchar(false);
const SSHORT peek = nextchar(false);
retchar(peek);
if (peek != c)
break;
@ -904,9 +887,10 @@ TOK LEX_token(void)
}
}
else if (c == '\n') {
// end of line, signal it properly with a phoney token.
token->tok_type = tok_eol;
--p;
q = "end of line";
const TEXT* q = eol_string;
while (*q)
*p++ = *q++;
}
@ -921,7 +905,8 @@ TOK LEX_token(void)
*p = '\0';
if (token->tok_string[0] == '$' &&
trans_limit < TRANS_LIMIT && (p = getenv(token->tok_string + 1))) {
trans_limit < TRANS_LIMIT && (p = getenv(token->tok_string + 1)))
{
LEX_push_string(p);
++trans_limit;
token = LEX_token();
@ -929,8 +914,8 @@ TOK LEX_token(void)
return token;
}
token->tok_symbol = symbol =
HSH_lookup(token->tok_string, token->tok_length);
SYM symbol = HSH_lookup(token->tok_string, token->tok_length);
token->tok_symbol = symbol;
if (symbol && symbol->sym_type == SYM_keyword)
token->tok_keyword = (KWWORDS) symbol->sym_keyword;
else
@ -960,14 +945,12 @@ static bool get_line(IB_FILE * file,
* return false. Regardless, a null terminated string is returned.
*
**************************************/
TEXT *p;
SLONG length;
bool overflow_flag = false;
SSHORT c;
errno = 0;
p = buffer;
length = size;
TEXT* p = buffer;
SLONG length = size;
while (true) {
c = ib_getc(file);
@ -994,7 +977,7 @@ static bool get_line(IB_FILE * file,
return false;
if (overflow_flag)
IBERROR(477); // Msg 477 input line too long
IBERROR(477); // Msg 477 input line too long
if (sw_verify)
ib_fputs(buffer, ib_stdout);
@ -1003,7 +986,7 @@ static bool get_line(IB_FILE * file,
}
static int nextchar(bool eof_ok)
static int nextchar(const bool eof_ok)
{
/**************************************
*
@ -1017,10 +1000,10 @@ static int nextchar(bool eof_ok)
**************************************/
SSHORT c;
/* Get the next character in the current line. If we run out,
get the next line. If the line source runs out, pop the
line source. If we run out of line sources, we are distinctly
at end of file. */
// Get the next character in the current line. If we run out,
// get the next line. If the line source runs out, pop the
// line source. If we run out of line sources, we are distinctly
// at end of file.
while (QLI_line) {
if (c = *QLI_line->line_ptr++)
@ -1032,7 +1015,7 @@ static int nextchar(bool eof_ok)
}
static void next_line(bool eof_ok)
static void next_line(const bool eof_ok)
{
/**************************************
*
@ -1044,23 +1027,22 @@ static void next_line(bool eof_ok)
* Get the next line from the input stream.
*
**************************************/
TEXT *p, *q, filename[256];
bool flag;
TEXT *p, *q;
while (QLI_line) {
flag = false;
bool flag = false;
/* Get next line from where ever. If it comes from either the terminal
or command file, check for another command file. */
// Get next line from where ever. If it comes from either the terminal
// or command file, check for another command file.
if (QLI_line->line_type == line_blob) {
// If the current blob segment contains another line, use it
// If the current blob segment contains another line, use it
if ((p = QLI_line->line_ptr) != QLI_line->line_data
&& p[-1] == '\n' && *p)
flag = true;
else {
// Initialize line block for retrieval
// Initialize line block for retrieval
p = QLI_line->line_data;
QLI_line->line_ptr = QLI_line->line_data;
@ -1072,7 +1054,7 @@ static void next_line(bool eof_ok)
}
}
else {
// Initialize line block for retrieval
// Initialize line block for retrieval
QLI_line->line_ptr = QLI_line->line_data;
p = QLI_line->line_data;
@ -1087,45 +1069,46 @@ static void next_line(bool eof_ok)
if (flag) {
for (q = p; classes[*q] & CHR_white; q++);
if (*q == '@') {
TEXT filename[MAXPATHLEN];
for (p = q + 1, q = filename; *p && *p != '\n';)
*q++ = *p++;
*q = 0;
QLI_line->line_ptr = (TEXT *) p;
QLI_line->line_ptr = p;
LEX_push_file(filename, true);
continue;
}
}
}
/* If get got a line, we're almost done */
// If get got a line, we're almost done
if (flag)
break;
/* We hit end of file. Either complain about the circumstances
or just close out the current input source. Don't close the
input source if it's the terminal and we're at a continuation
prompt. */
// We hit end of file. Either complain about the circumstances
// or just close out the current input source. Don't close the
// input source if it's the terminal and we're at a continuation
// prompt.
if (eof_ok && (QLI_line->line_next || QLI_prompt != QLI_cont_string)) {
LEX_pop_line();
return;
}
// this is an unexpected end of file
// this is an unexpected end of file
if (QLI_line->line_type == line_blob)
ERRQ_print_error(64, QLI_line->line_source_name, NULL, NULL, NULL,
NULL);
/* Msg 64 unexpected end of procedure in procedure %s */
// Msg 64 unexpected end of procedure in procedure %s
else if (QLI_line->line_type == line_file)
ERRQ_print_error(65, QLI_line->line_source_name, NULL, NULL, NULL,
NULL);
/* Msg 65 unexpected end of file in file %s */
// Msg 65 unexpected end of file in file %s
else {
if (QLI_line->line_type == line_string)
LEX_pop_line();
IBERROR(66); // Msg 66 unexpected eof
IBERROR(66); // Msg 66 unexpected eof
}
}
@ -1134,7 +1117,7 @@ static void next_line(bool eof_ok)
QLI_line->line_position = QLI_position;
// Dump output to the trace file
// Dump output to the trace file
if (QLI_line->line_type == line_blob)
while (*p)
@ -1144,8 +1127,8 @@ static void next_line(bool eof_ok)
ib_putc(*p++, trace_file);
QLI_position += (TEXT *) p - QLI_line->line_data;
#ifdef PC_FILE_SEEK
/* account for the extra line-feed on OS/2 and Windows NT
to determine file position */
// account for the extra line-feed on OS/2 and Windows NT
// to determine file position
QLI_position++;
#endif
@ -1155,7 +1138,7 @@ static void next_line(bool eof_ok)
}
static void retchar( SSHORT c)
static void retchar(const SSHORT c) // unused, now checked in DEBUG mode.
{
/**************************************
*
@ -1168,6 +1151,9 @@ static void retchar( SSHORT c)
*
**************************************/
// CVC: Too naive implementation: what if the pointer is at the beginning?
// What if the character being returned isn't the character that was gotten?
fb_assert(QLI_line && QLI_line->line_ptr[-1] == c);
--QLI_line->line_ptr;
}
@ -1185,13 +1171,12 @@ static bool scan_number(SSHORT c,
* Pass on a possible numeric literal.
*
**************************************/
TEXT *p;
bool dot = false;
p = *ptr;
TEXT* p = *ptr;
/* If this is a leading decimal point, check that the next
character is really a digit, otherwise backout */
// If this is a leading decimal point, check that the next
// character is really a digit, otherwise backout
if (c == '.') {
retchar(c = nextchar(true));
@ -1200,7 +1185,7 @@ static bool scan_number(SSHORT c,
dot = true;
}
// Gobble up digits up to a single decimal point
// Gobble up digits up to a single decimal point
for (;;) {
c = nextchar(true);
@ -1214,7 +1199,7 @@ static bool scan_number(SSHORT c,
break;
}
// If this is an exponential, eat the exponent sign and digits
// If this is an exponential, eat the exponent sign and digits
if (UPPER(c) == 'E') {
*p++ = c;
@ -1248,14 +1233,15 @@ static int skip_white(void)
* Skip over while space and comments in input stream
*
**************************************/
SSHORT c, next, class_;
SSHORT c;
while (true) {
c = nextchar(true);
class_ = classes[c];
if (class_ & CHR_white)
const char char_class = classes[c];
if (char_class & CHR_white)
continue;
if (c == '/') {
SSHORT next;
if ((next = nextchar(true)) != '*') {
retchar(next);
return c;
@ -1270,3 +1256,5 @@ static int skip_white(void)
return c;
}

View File

@ -1,7 +1,7 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: lex_proto.h
* DESCRIPTION: Prototype header file for lex.c
* DESCRIPTION: Prototype header file for lex.cpp
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_LEX_PROTO_H_
#define _QLI_LEX_PROTO_H_
#ifndef QLI_LEX_PROTO_H
#define QLI_LEX_PROTO_H
extern bool LEX_active_procedure (void);
extern void LEX_edit (SLONG, SLONG);
@ -35,11 +35,12 @@ extern void LEX_init (void);
extern void LEX_mark_statement (void);
extern void LEX_pop_line (void);
extern void LEX_procedure(dbb*, FRBRD*);
extern bool LEX_push_file (TEXT *, bool);
extern bool LEX_push_string (TEXT *);
extern bool LEX_push_file (const TEXT*, const bool);
extern bool LEX_push_string (const TEXT* const);
extern void LEX_put_procedure (FRBRD *, SLONG, SLONG);
extern void LEX_real (void);
extern lls* LEX_statement_list(void);
extern tok* LEX_token(void);
#endif /* _QLI_LEX_PROTO_H_ */
#endif /* QLI_LEX_PROTO_H */

File diff suppressed because it is too large Load Diff

View File

@ -169,44 +169,44 @@ int MOVQ_compare( DSC * arg1, DSC * arg2)
case dtype_text:
if (arg1->dsc_length >= arg2->dsc_length) {
if (length = arg2->dsc_length)
do
do {
if (*p1++ != *p2++)
if (p1[-1] > p2[-1])
return 1;
else
return -1;
while (--length);
} while (--length);
if (length = arg1->dsc_length - arg2->dsc_length)
do
do {
if (*p1++ != ' ')
if (p1[-1] > ' ')
return 1;
else
return -1;
while (--length);
} while (--length);
return 0;
}
if (length = arg1->dsc_length)
do
do {
if (*p1++ != *p2++)
if (p1[-1] > p2[-1])
return 1;
else
return -1;
while (--length);
} while (--length);
length = arg2->dsc_length - arg1->dsc_length;
do
do {
if (*p2++ != ' ')
if (' ' > p2[-1])
return 1;
else
return -1;
while (--length);
} while (--length);
return 0;
}
}
// Handle mixed string comparisons
// Handle mixed string comparisons
if (arg1->dsc_dtype <= dtype_varying && arg2->dsc_dtype <= dtype_varying) {
length = MOVQ_get_string(arg1, (TEXT**) &p1, 0, 0);
@ -214,42 +214,43 @@ int MOVQ_compare( DSC * arg1, DSC * arg2)
fill = length - length2;
if (length >= length2) {
if (length2)
do
do {
if (*p1++ != *p2++)
if (p1[-1] > p2[-1])
return 1;
else
return -1;
while (--length2);
} while (--length2);
if (fill > 0)
do
do {
if (*p1++ != ' ')
if (p1[-1] > ' ')
return 1;
else
return -1;
while (--fill);
} while (--fill);
return 0;
}
if (length)
do
if (length) {
do {
if (*p1++ != *p2++)
if (p1[-1] > p2[-1])
return 1;
else
return -1;
while (--length);
do
} while (--length);
}
do {
if (*p2++ != ' ')
if (' ' > p2[-1])
return 1;
else
return -1;
while (++fill);
} while (++fill);
return 0;
}
// Handle hetergeneous compares
// Handle hetergeneous compares
if (arg1->dsc_dtype < arg2->dsc_dtype)
return (-MOVQ_compare(arg2, arg1));
@ -326,7 +327,7 @@ int MOVQ_compare( DSC * arg1, DSC * arg2)
}
case dtype_blob:
IBERROR(48); // Msg 48 Blob conversion is not supported
IBERROR(48); // Msg 48 Blob conversion is not supported
default:
mover_error(410, arg1->dsc_dtype, arg2->dsc_dtype);
@ -349,14 +350,14 @@ double MOVQ_date_to_double(const dsc* desc)
* date arithmetic routines.
*
**************************************/
DSC temp_desc;
SLONG temp[2], *date;
// If the input descriptor is not in date form, convert it.
// If the input descriptor is not in date form, convert it.
if (desc->dsc_dtype == dtype_timestamp)
date = (SLONG *) desc->dsc_address;
else {
dsc temp_desc;
temp_desc.dsc_dtype = dtype_timestamp;
temp_desc.dsc_length = sizeof(temp);
temp_desc.dsc_scale = 0;
@ -382,11 +383,10 @@ int MOVQ_decompose(const TEXT* string, USHORT length, SLONG* return_value)
* Decompose a numeric string in mantissa and exponent.
*
**************************************/
SSHORT scale;
SLONG value;
SSHORT scale = 0;
SLONG value = 0;
SCHAR temp[128];
scale = value = 0;
bool sign = false;
bool fraction = false;
@ -473,7 +473,7 @@ void MOVQ_double_to_date( double real, SLONG fixed[2])
void MOVQ_fast(const SCHAR* from,
SCHAR* to,
SCHAR* to,
ULONG length)
{
/**************************************
@ -488,9 +488,9 @@ void MOVQ_fast(const SCHAR* from,
**************************************/
if (length)
do
do {
*to++ = *from++;
while (--length);
} while (--length);
}
@ -504,7 +504,7 @@ double MOVQ_get_double(const dsc* desc)
*
* Functional description
* Convert something arbitrary to a
* double_precision representation.
* double_precision representation.
*
**************************************/
double value;
@ -541,7 +541,7 @@ double MOVQ_get_double(const dsc* desc)
}
else if (*p == '.')
if (fraction)
IBERROR(52); // Msg 52 conversion error
IBERROR(52); // Msg 52 conversion error
else
fraction = 1;
else if (!value && *p == '-')
@ -551,7 +551,7 @@ double MOVQ_get_double(const dsc* desc)
else if (*p == 'e' || *p == 'E')
break;
else if (*p != ' ')
IBERROR(53); // Msg 53 conversion error
IBERROR(53); // Msg 53 conversion error
}
if (sign)
@ -569,7 +569,7 @@ double MOVQ_get_double(const dsc* desc)
sign = TRUE;
else if (*p == '+' && !exp);
else if (*p != ' ')
IBERROR(54); // Msg 54 conversion error
IBERROR(54); // Msg 54 conversion error
}
if (sign)
scale += exp;
@ -578,13 +578,13 @@ double MOVQ_get_double(const dsc* desc)
}
if (scale > 0)
do
do {
value /= 10.;
while (--scale);
} while (--scale);
else if (scale)
do
do {
value *= 10.;
while (++scale);
} while (++scale);
return value;
@ -592,19 +592,19 @@ double MOVQ_get_double(const dsc* desc)
mover_error(410, desc->dsc_dtype, dtype_double);
}
// Last, but not least, adjust for scale
// Last, but not least, adjust for scale
if ((scale = desc->dsc_scale) == 0)
return value;
if (scale > 0)
do
do {
value *= 10.;
while (--scale);
} while (--scale);
else
do
do {
value /= 10.;
while (++scale);
} while (++scale);
return value;
}
@ -625,12 +625,11 @@ SLONG MOVQ_get_long(const dsc* desc, SSHORT scale)
**************************************/
SLONG value;
double d;
SSHORT fraction, length;
TEXT *p;
SSHORT length;
scale -= (SSHORT) desc->dsc_scale;
p = (TEXT *) desc->dsc_address;
TEXT* p = (TEXT *) desc->dsc_address;
switch (desc->dsc_dtype) {
case dtype_short:
value = *((SSHORT *) p);
@ -643,13 +642,13 @@ SLONG MOVQ_get_long(const dsc* desc, SSHORT scale)
case dtype_real:
d = *((float *) p);
if (scale > 0)
do
do {
d /= 10.;
while (--scale);
} while (--scale);
else if (scale < 0)
do
do {
d *= 10.;
while (++scale);
} while (++scale);
if (d > 0)
d += 0.5;
else
@ -659,13 +658,13 @@ SLONG MOVQ_get_long(const dsc* desc, SSHORT scale)
case dtype_double:
d = *((double *) p);
if (scale > 0)
do
do {
d /= 10.;
while (--scale);
} while (--scale);
else if (scale < 0)
do
do {
d *= 10.;
while (++scale);
} while (++scale);
if (d > 0)
d += 0.5;
else
@ -683,7 +682,7 @@ SLONG MOVQ_get_long(const dsc* desc, SSHORT scale)
mover_error(410, desc->dsc_dtype, dtype_long);
}
// Last, but not least, adjust for scale
// Last, but not least, adjust for scale
if (scale == 0)
return value;
@ -691,7 +690,7 @@ SLONG MOVQ_get_long(const dsc* desc, SSHORT scale)
if (scale > 0) {
if ((desc->dsc_dtype == dtype_short)
|| (desc->dsc_dtype == dtype_long)) {
fraction = 0;
SSHORT fraction = 0;
do {
if (scale == 1)
fraction = value % 10;
@ -701,14 +700,14 @@ SLONG MOVQ_get_long(const dsc* desc, SSHORT scale)
value++;
}
else
do
do {
value /= 10;
while (--scale);
} while (--scale);
}
else
do
do {
value *= 10;
while (++scale);
} while (++scale);
return value;
}
@ -732,8 +731,6 @@ int MOVQ_get_string(const dsc* desc, TEXT ** address, VARY * temp, USHORT length
* argument (temp buffer) may be omitted.
*
**************************************/
VARY *varying;
DSC temp_desc;
/* If the value is already a string (fixed or varying), just return
the address and length. */
@ -743,21 +740,22 @@ int MOVQ_get_string(const dsc* desc, TEXT ** address, VARY * temp, USHORT length
return desc->dsc_length;
}
/* Perhaps it a "C" type string? */
// Perhaps it a "C" type string?
if (desc->dsc_dtype == dtype_cstring) {
*address = (TEXT *) desc->dsc_address;
return MIN(strlen((char*)desc->dsc_address), desc->dsc_length - 1);
}
// No luck -- convert value to varying string.
// No luck -- convert value to varying string.
if (desc->dsc_dtype == dtype_varying) {
varying = (VARY *) desc->dsc_address;
VARY* varying = (VARY*) desc->dsc_address;
*address = varying->vary_string;
return varying->vary_length;
}
dsc temp_desc;
temp_desc.dsc_length = length;
temp_desc.dsc_address = (UCHAR *) temp;
temp_desc.dsc_scale = 0;
@ -785,14 +783,14 @@ void MOVQ_move(const dsc* from, dsc* to)
SSHORT fill;
SLONG l;
UCHAR *ptr;
// This is USHORT!!
SSHORT length = from->dsc_length;
UCHAR* p = to->dsc_address;
const UCHAR* q = from->dsc_address;
/* If the datatypes and lengths are identical, just move the
stuff byte by byte. Although this may seem slower than
stuff byte by byte. Although this may seem slower than
optimal, it would cost more to find the fast move than the
fast move would gain. */
@ -802,9 +800,9 @@ if (((ALT_DSC*) from)->dsc_combined_type == ((ALT_DSC*) to)->dsc_combined_type)
*/
{
if (length)
do
do {
*p++ = *q++;
while (--length);
} while (--length);
return;
}
@ -847,7 +845,7 @@ if (((ALT_DSC*) from)->dsc_combined_type == ((ALT_DSC*) to)->dsc_combined_type)
((SLONG *) to->dsc_address)[0] = ((SLONG *) from->dsc_address)[0];
return;
case dtype_sql_time:
// Error situation
// Error situation
break;
}
break;
@ -868,7 +866,7 @@ if (((ALT_DSC*) from)->dsc_combined_type == ((ALT_DSC*) to)->dsc_combined_type)
((SLONG *) to->dsc_address)[0] = ((SLONG *) from->dsc_address)[1];
return;
case dtype_sql_date:
// Error situation
// Error situation
break;
}
break;
@ -887,21 +885,21 @@ if (((ALT_DSC*) from)->dsc_combined_type == ((ALT_DSC*) to)->dsc_combined_type)
length = MIN(length, to->dsc_length);
fill = to->dsc_length - length;
if (length)
do
do {
*p++ = *q++;
while (--length);
} while (--length);
if (fill > 0)
do
do {
*p++ = ' ';
while (--fill);
} while (--fill);
return;
case dtype_cstring:
length = MIN(length, to->dsc_length - 1);
if (length)
do
do {
*p++ = *q++;
while (--length);
} while (--length);
*p = 0;
return;
@ -910,9 +908,9 @@ if (((ALT_DSC*) from)->dsc_combined_type == ((ALT_DSC*) to)->dsc_combined_type)
((VARY *) p)->vary_length = length;
p = (UCHAR *) ((VARY *) p)->vary_string;
if (length)
do
do {
*p++ = *q++;
while (--length);
} while (--length);
return;
}
@ -954,7 +952,7 @@ if (((ALT_DSC*) from)->dsc_combined_type == ((ALT_DSC*) to)->dsc_combined_type)
case dtype_short:
*(SSHORT *) p = l = MOVQ_get_long(from, to->dsc_scale);
if (*(SSHORT *) p != l)
IBERROR(14); // Msg14 integer overflow
IBERROR(14); // Msg14 integer overflow
return;
case dtype_long:
@ -971,7 +969,7 @@ if (((ALT_DSC*) from)->dsc_combined_type == ((ALT_DSC*) to)->dsc_combined_type)
}
if (to->dsc_dtype == dtype_blob || from->dsc_dtype == dtype_blob)
IBERROR(55); // Msg 55 Blob conversion is not supported
IBERROR(55); // Msg 55 Blob conversion is not supported
mover_error(410, from->dsc_dtype, to->dsc_dtype);
}
@ -997,9 +995,9 @@ void MOVQ_terminate(const SCHAR* from,
if (length) {
length = MIN(length, max_length - 1);
do
do {
*to++ = *from++;
while (--length);
} while (--length);
*to++ = '\0';
}
else {
@ -1024,7 +1022,8 @@ static void date_error(const TEXT* string, const USHORT length)
SCHAR temp[128];
MOVQ_terminate(string, temp, length, sizeof(temp));
ERRQ_error(56, temp, NULL, NULL, NULL, NULL); /* Msg 56 Error converting string \"%s\" to date */
ERRQ_error(56, temp, NULL, NULL, NULL, NULL);
// Msg 56 Error converting string \"%s\" to date
}
@ -1040,19 +1039,21 @@ static void sql_date_to_text( SLONG date[1], DSC * to)
* Convert date to text.
*
**************************************/
DSC desc;
TEXT *p, temp[35];
tm times;
SLONG date2[2];
date2[0] = date[0];
date2[1] = 0;
isc_decode_date((GDS_QUAD*) date2, &times);
TEXT temp[35];
sprintf(temp, "%2d-%.3s-%04d", times.tm_mday,
months[times.tm_mon], times.tm_year + 1900);
TEXT* p;
for (p = temp; *p; p++);
dsc desc;
desc.dsc_length = p - temp;
desc.dsc_address = (UCHAR *) temp;
desc.dsc_dtype = dtype_text;
@ -1075,8 +1076,6 @@ static void sql_time_to_text( ULONG date[1], DSC * to)
* Convert sql time to text.
*
**************************************/
DSC desc;
TEXT *p, temp[35];
tm times;
SLONG date2[2];
@ -1085,11 +1084,14 @@ static void sql_time_to_text( ULONG date[1], DSC * to)
isc_decode_date((GDS_QUAD*) date2, &times);
TEXT temp[35];
sprintf(temp, " %2d:%.2d:%.2d.%.4"SLONGFORMAT, times.tm_hour, times.tm_min,
times.tm_sec, date2[1] % PRECISION);
TEXT* p;
for (p = temp; *p; p++);
dsc desc;
desc.dsc_length = p - temp;
desc.dsc_address = (UCHAR *) temp;
desc.dsc_dtype = dtype_text;
@ -1112,23 +1114,24 @@ static void timestamp_to_text( SLONG date[2], DSC * to)
* Convert date to text.
*
**************************************/
DSC desc;
TEXT *p, temp[35], time[15];
tm times;
isc_decode_date((GDS_QUAD*)date, &times);
TEXT temp[35];
sprintf(temp, "%2d-%.3s-%04d", times.tm_mday,
months[times.tm_mon], times.tm_year + 1900);
if (times.tm_hour || times.tm_min || times.tm_sec || date[1]) {
TEXT time[15];
sprintf(time, " %2d:%.2d:%.2d.%.4"SLONGFORMAT, times.tm_hour, times.tm_min,
times.tm_sec, date[1] % PRECISION);
strcat(temp, time);
}
TEXT* p;
for (p = temp; *p; p++);
dsc desc;
desc.dsc_length = p - temp;
desc.dsc_address = (UCHAR *) temp;
desc.dsc_dtype = dtype_text;
@ -1143,7 +1146,7 @@ static void mover_error( int pattern, USHORT in_type, USHORT out_type)
{
/**************************************
*
* m o v e r _ e r r o r
* m o v e r _ e r r o r
*
**************************************
*
@ -1153,16 +1156,18 @@ static void mover_error( int pattern, USHORT in_type, USHORT out_type)
* comparisons.
*
**************************************/
TEXT *in, *out, in_name[25], out_name[25], msg_unknown[40];
TEXT in_name[25], out_name[25], msg_unknown[40];
ERRQ_msg_get(504, msg_unknown); /* Msg504 unknown datatype %d */
ERRQ_msg_get(504, msg_unknown); // Msg504 unknown datatype %d
if (!(in = type_name(in_type))) {
TEXT* in = type_name(in_type);
if (!in) {
in = in_name;
sprintf(in_name, msg_unknown, in_type);
}
if (!(out = type_name(out_type))) {
TEXT* out = type_name(out_type);
if (!out) {
out = out_name;
sprintf(out, msg_unknown, out_type);
}
@ -1204,39 +1209,38 @@ static void numeric_to_text(const dsc* from, dsc* to)
* Convert your basic number to nice, formatted text.
*
**************************************/
DSC intermediate;
SLONG n;
TEXT temp[32], *p, *q;
SSHORT l, scale, neg, pad, decimal, length;
pad = decimal = neg = 0;
/* Save (or compute) scale of source. Then convert source to ordinary
longword. */
scale = from->dsc_scale;
SSHORT scale = from->dsc_scale;
SSHORT pad = 0, decimal = 0;
if (scale > 0)
pad = scale;
else if (scale < 0)
decimal = 1;
SLONG n;
dsc intermediate;
intermediate.dsc_dtype = dtype_long;
intermediate.dsc_length = sizeof(SLONG);
intermediate.dsc_scale = scale;
intermediate.dsc_sub_type = 0;
intermediate.dsc_address = (UCHAR *) & n;
intermediate.dsc_address = (UCHAR *) &n;
MOVQ_move(from, &intermediate);
// Check for negation, then convert the number to a string of digits
// Check for negation, then convert the number to a string of digits
SSHORT neg = 0;
if (n < 0) {
neg = 1;
n = -n;
}
p = temp;
TEXT temp[32];
TEXT* p = temp;
do {
*p++ = n % 10 + '0';
@ -1247,20 +1251,23 @@ static void numeric_to_text(const dsc* from, dsc* to)
fits. Keep in mind that routine handles both string and varying
string fields. */
l = p - temp;
length = l + neg + decimal + pad;
SSHORT l = p - temp;
const SSHORT length = l + neg + decimal + pad;
if ((to->dsc_dtype == dtype_text && length > to->dsc_length) ||
(to->dsc_dtype == dtype_cstring && length >= to->dsc_length) ||
(to->dsc_dtype == dtype_varying
&& length > to->dsc_length - sizeof(SSHORT)))
IBERROR(57); // Msg 57 overflow during conversion
{
IBERROR(57); // Msg 57 overflow during conversion
}
q =
// Hopefully a cstring never reached this point.
TEXT* q =
(TEXT *) ((to->dsc_dtype == dtype_text) ? to->dsc_address : to->
dsc_address + sizeof(SSHORT));
// If negative, put in minus sign
// If negative, put in minus sign
if (neg)
*q++ = '-';
@ -1270,34 +1277,34 @@ static void numeric_to_text(const dsc* from, dsc* to)
if (scale < 0) {
if ((l += scale) > 0)
do
do {
*q++ = *--p;
while (--l);
} while (--l);
*q++ = '.';
do
do {
*q++ = *--p;
while (++scale);
} while (++scale);
}
else
do
do {
*q++ = *--p;
while (--l);
} while (--l);
// If padding is required, do it now.
// If padding is required, do it now.
if (pad)
do
do {
*q++ = '0';
while (--pad);
} while (--pad);
/* Finish up by padding (if fixed) or computing the actual length
(varying string) */
if (to->dsc_dtype == dtype_text) {
if (l = to->dsc_length - length)
do
do {
*q++ = ' ';
while (--l);
} while (--l);
return;
}
@ -1323,11 +1330,6 @@ static void string_to_date(const TEXT* string, USHORT length, SLONG date[2])
* Convert an arbitrary string to a date.
*
**************************************/
TEXT c, temp[15], *t;
USHORT n, month_position, i, components[7], precision, year;
tm times, times2;
tm* today;
if (!length) {
date[0] = date[1] = 0;
return;
@ -1336,15 +1338,21 @@ static void string_to_date(const TEXT* string, USHORT length, SLONG date[2])
const TEXT* p = string;
const TEXT* const end = p + length;
year = month_position = 0;
USHORT month_position = 0;
time_t clock = time(0);
today = localtime(&clock);
tm* today = localtime(&clock);
USHORT i;
USHORT components[7];
for (i = 0; i < 7; i++)
components[i] = 0;
// Parse components
// Parse components
TEXT temp[15];
USHORT n, precision;
bool year = false;
for (i = 0; i < 7; i++) {
@ -1356,9 +1364,9 @@ static void string_to_date(const TEXT* string, USHORT length, SLONG date[2])
if (p == end)
break;
// Handle digit or character strings
// Handle digit or character strings
c = UPPER(*p);
TEXT c = UPPER(*p);
if (DIGIT(c)) {
precision = n = 0;
while (p < end && DIGIT(*p)) {
@ -1366,10 +1374,10 @@ static void string_to_date(const TEXT* string, USHORT length, SLONG date[2])
precision++;
}
if (i == 2)
year = TRUE;
year = true;
}
else if (LETTER(c)) {
t = temp;
TEXT* t = temp;
while (p < end && LETTER(c)) {
c = UPPER(*p);
if (!LETTER(c))
@ -1431,8 +1439,9 @@ static void string_to_date(const TEXT* string, USHORT length, SLONG date[2])
}
}
// Slide things into day, month, year form
// Slide things into day, month, year form
tm times;
if (month_position) {
times.tm_mon = components[1];
times.tm_mday = components[0];
@ -1442,7 +1451,7 @@ static void string_to_date(const TEXT* string, USHORT length, SLONG date[2])
times.tm_mday = components[1];
}
// Handle defaulting of year
// Handle defaulting of year
if (((times.tm_year = components[2]) == 0) && !year)
times.tm_year = today->tm_year + 1900;
@ -1459,9 +1468,10 @@ static void string_to_date(const TEXT* string, USHORT length, SLONG date[2])
times.tm_min = components[4];
times.tm_sec = components[5];
// convert day/month/year to Julian and validate result
// convert day/month/year to Julian and validate result
isc_encode_date(&times, (GDS_QUAD*)date);
tm times2;
isc_decode_date((GDS_QUAD*)date, &times2);
if (times.tm_year != times2.tm_year ||
@ -1488,27 +1498,26 @@ static void string_to_time( TEXT * string, USHORT length, SLONG date[2])
* Convert an arbitrary string to a t i m e.
*
**************************************/
TEXT c, *p, temp[15], *t, *end;
USHORT n, i, components[7], precision;
time_t clock;
tm times;
tm* today;
if (!length) {
date[0] = date[1] = 0;
return;
}
p = string;
const TEXT* p = string;
const TEXT* const end = p + length;
end = p + length;
clock = time(0);
today = localtime(&clock);
time_t clock = time(0);
tm* today = localtime(&clock);
USHORT i;
USHORT components[7];
for (i = 0; i < 7; i++)
components[i] = 0;
// Parse components
// Parse components
TEXT temp[15];
USHORT n, precision;
for (i = 3; i < 7; i++) {
@ -1520,9 +1529,9 @@ static void string_to_time( TEXT * string, USHORT length, SLONG date[2])
if (p == end)
break;
// Handle digit or character strings
// Handle digit or character strings
c = UPPER(*p);
TEXT c = UPPER(*p);
if (DIGIT(c)) {
precision = n = 0;
while (p < end && DIGIT(*p)) {
@ -1531,7 +1540,7 @@ static void string_to_time( TEXT * string, USHORT length, SLONG date[2])
}
}
else if (LETTER(c)) {
t = temp;
TEXT* t = temp;
while (p < end && LETTER(c)) {
c = UPPER(*p);
if (!LETTER(c))
@ -1565,11 +1574,12 @@ static void string_to_time( TEXT * string, USHORT length, SLONG date[2])
}
tm times;
times.tm_hour = components[3];
times.tm_min = components[4];
times.tm_sec = components[5];
// convert day/month/year to Julian and validate result
// convert day/month/year to Julian and validate result
isc_encode_date(&times, (GDS_QUAD*)date);
@ -1599,3 +1609,4 @@ static TEXT *type_name( USHORT dtype)
return NULL;
}

View File

@ -1,7 +1,7 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: mov_proto.h
* DESCRIPTION: Prototype header file for mov.c
* DESCRIPTION: Prototype header file for mov.cpp
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: nounix.c
* MODULE: nounix.cpp
* DESCRIPTION: Dummy routines
*
* The contents of this file are subject to the Interbase Public
@ -32,3 +32,4 @@ int vfork(void)
{
return -1;
}

File diff suppressed because it is too large Load Diff

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_PARSE_H_
#define _QLI_PARSE_H_
#ifndef QLI_PARSE_H
#define QLI_PARSE_H
#define MAXSYMLEN 256
@ -95,4 +95,5 @@ EXTERN TEXT *QLI_prompt;
#undef EXTERN
#endif /* _QLI_PARSE_H_ */
#endif /* QLI_PARSE_H */

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_PARSE_PROTO_H_
#define _QLI_PARSE_PROTO_H_
#ifndef QLI_PARSE_PROTO_H
#define QLI_PARSE_PROTO_H
extern syn* PARQ_parse(void);
extern int PAR_match (KWWORDS);
@ -30,4 +30,4 @@ extern void PAR_real (void);
extern void PAR_real_token (void);
extern void PAR_token (void);
#endif /* _QLI_PARSE_PROTO_H_ */
#endif /* QLI_PARSE_PROTO_H */

View File

@ -85,22 +85,19 @@ PICS PIC_analyze(TEXT* string, const dsc* desc)
* Analyze a picture in preparation for formatting.
*
**************************************/
PICS picture;
TEXT c, d, debit;
if (!string)
if (!desc)
return NULL;
else
string = default_edit_string(desc, NULL);
debit = 0;
picture = (PICS) ALLOCD(type_pic);
PICS picture = (PICS) ALLOCD(type_pic);
picture->pic_string = picture->pic_pointer = string;
// Make a first pass just counting characters
// Make a first pass just counting characters
bool debit = false;
TEXT c, d;
while ((c = generate(picture)) && c != '?') {
c = UPPER(c);
@ -113,8 +110,8 @@ PICS PIC_analyze(TEXT* string, const dsc* desc)
case '9':
case 'Z':
case '*':
/* Count all digits;
count them as fractions only after a decimal pt and
/* Count all digits;
count them as fractions only after a decimal pt and
before an E */
++picture->pic_digits;
if (picture->pic_decimals && !picture->pic_exponents)
@ -146,12 +143,12 @@ PICS PIC_analyze(TEXT* string, const dsc* desc)
break;
case 'D':
// DB is ambiguous, could be Day Blank or DeBit...
// DB is ambiguous, could be Day Blank or DeBit...
d = UPPER(*picture->pic_pointer);
if (d == 'B') {
++picture->pic_pointer;
++picture->pic_literals;
++debit;
debit = true;
}
++picture->pic_days;
break;
@ -237,7 +234,7 @@ PICS PIC_analyze(TEXT* string, const dsc* desc)
if (c == '?')
picture->pic_missing = PIC_analyze(picture->pic_pointer, 0);
// if a DB showed up, and the string is numeric, treat the DB as DeBit
// if a DB showed up, and the string is numeric, treat the DB as DeBit
if (debit && (picture->pic_digits || picture->pic_hex_digits)) {
--picture->pic_days;
@ -323,7 +320,7 @@ void PIC_edit( DSC * desc, PICS picture, TEXT ** output, USHORT max_length)
edit_float(desc, picture, output);
return;
default:
BUGCHECK(68); // Msg 68 PIC_edit: class not yet implemented
BUGCHECK(68); // Msg 68 PIC_edit: class not yet implemented
}
}
@ -339,29 +336,24 @@ void PIC_missing( CON constant, PICS picture)
* Functional description
* Create a literal picture string from
* a descriptor for a missing value so
* we can print the missing value
* we can print the missing value
*
**************************************/
STR scratch;
int l;
TEXT *p;
PICS missing_picture;
DSC *desc;
desc = &constant->con_desc;
dsc* desc = &constant->con_desc;
l = MAX(desc->dsc_length, picture->pic_length);
int l = MAX(desc->dsc_length, picture->pic_length);
scratch = (STR) ALLOCDV(type_str, l + 3);
p = scratch->str_data;
STR scratch = (STR) ALLOCDV(type_str, l + 3);
TEXT* p = scratch->str_data;
*p++ = '\"';
PIC_edit(desc, picture, &p, l);
*p++ = '\"';
*p = 0;
picture->pic_missing = missing_picture =
PIC_analyze(scratch->str_data, desc);
PICS missing_picture = PIC_analyze(scratch->str_data, desc);
picture->pic_missing = missing_picture;
picture->pic_length =
MAX(picture->pic_print_length, missing_picture->pic_print_length);
missing_picture->pic_length = picture->pic_length;
@ -381,10 +373,8 @@ static TEXT *cvt_to_ascii( SLONG number, TEXT * pointer, int length)
* null), updating pointer.
*
**************************************/
TEXT *p;
pointer += length + 1;
p = pointer;
TEXT* p = pointer;
*--p = 0;
while (--length >= 0) {
@ -520,7 +510,7 @@ static void edit_alpha(
if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z'))
*out++ = *p++;
else
IBERROR(69); // Msg 69 conversion error
IBERROR(69); // Msg 69 conversion error
break;
case 'B':
@ -556,7 +546,7 @@ static void edit_date( DSC * desc, PICS picture, TEXT ** output)
* output pointer.
*
**************************************/
SLONG date[2], rel_day;
SLONG date[2];
DSC temp_desc;
TEXT d, temp[256];
@ -604,7 +594,8 @@ static void edit_date( DSC * desc, PICS picture, TEXT ** output)
if (*hours == '0')
*hours = ' ';
if ((rel_day = (date[0] + 3) % 7) < 0)
SLONG rel_day = (date[0] + 3) % 7;
if (rel_day < 0)
rel_day += 7;
const TEXT* weekday = alpha_weekdays[rel_day];
const TEXT* month = alpha_months[times.tm_mon];
@ -612,7 +603,7 @@ static void edit_date( DSC * desc, PICS picture, TEXT ** output)
picture->pic_pointer = picture->pic_string;
picture->pic_count = 0;
TEXT* out = *output;
bool sig_day = false;
bool blank = true;
@ -701,11 +692,10 @@ static void edit_float( DSC * desc, PICS picture, TEXT ** output)
* output pointer.
*
**************************************/
TEXT c, d, e, *p, *out, temp[512];
TEXT c, d, e, *p, temp[512];
bool negative = false;
bool is_signed = false;
USHORT l, width, decimal_digits, w_digits, f_digits;
double number;
#ifdef VMS
bool hack_for_vms_flag = false;
@ -714,7 +704,7 @@ static void edit_float( DSC * desc, PICS picture, TEXT ** output)
bool hack_for_nt_flag = false;
#endif
number = MOVQ_get_double(desc);
double number = MOVQ_get_double(desc);
if (number < 0) {
negative = true;
number = -number;
@ -722,7 +712,7 @@ static void edit_float( DSC * desc, PICS picture, TEXT ** output)
/* If exponents are explicitly requested (E-format edit_string), generate them.
Otherwise, the rules are: if the number in f-format will fit into the allotted
space, print it in f-format; otherwise print it in e-format.
space, print it in f-format; otherwise print it in e-format.
(G-format is untrustworthy.) */
if (picture->pic_exponents) {
@ -747,13 +737,13 @@ static void edit_float( DSC * desc, PICS picture, TEXT ** output)
sprintf(temp, "%.*f", f_digits, number);
w_digits = strlen(temp);
if (f_digits) {
p = temp + w_digits; // find the end
p = temp + w_digits; // find the end
w_digits = w_digits - (f_digits + 1);
while (*--p == '0')
--f_digits;
if (*p != '.')
++p;
*p = 0; // move the end
*p = 0; // move the end
}
if ((w_digits > width)
|| (!f_digits && w_digits == 1 && temp[0] == '0')) {
@ -810,7 +800,7 @@ static void edit_float( DSC * desc, PICS picture, TEXT ** output)
p = temp;
picture->pic_pointer = picture->pic_string;
picture->pic_count = 0;
out = *output;
TEXT* out = *output;
for (l = picture->pic_length - picture->pic_print_length; l > 0; --l)
*out++ = ' ';
@ -913,28 +903,14 @@ static void edit_numeric( DSC * desc, PICS picture, TEXT ** output)
* output pointer.
*
**************************************/
TEXT c;
TEXT d;
TEXT float_char;
TEXT temp[512];
TEXT *p;
TEXT *float_ptr = NULL;
TEXT *out;
TEXT *hex;
TEXT *digits;
bool negative = false;
bool signif = false;
bool hex_overflow = false;
bool overflow = false;
USHORT power, l;
SSHORT scale;
SLONG n;
double check, number;
out = *output;
float_ptr = NULL;
TEXT* out = *output;
TEXT* float_ptr = NULL;
number = MOVQ_get_double(desc);
double number = MOVQ_get_double(desc);
if (number < 0) {
number = -number;
negative = true;
@ -942,18 +918,22 @@ static void edit_numeric( DSC * desc, PICS picture, TEXT ** output)
overflow = true;
}
if (scale = picture->pic_fractions)
SSHORT scale = picture->pic_fractions;
if (scale)
if (scale < 0)
do
do {
number /= 10.;
while (++scale);
} while (++scale);
else if (scale > 0)
do
do {
number *= 10.;
while (--scale);
} while (--scale);
digits = p = temp;
TEXT* p = temp;
TEXT* digits = p;
double check;
USHORT power;
if (picture->pic_digits && !overflow) {
for (check = number, power = picture->pic_digits; power; --power)
check /= 10.;
@ -966,6 +946,8 @@ static void edit_numeric( DSC * desc, PICS picture, TEXT ** output)
}
picture->pic_pointer = picture->pic_string;
bool hex_overflow = false;
TEXT* hex;
if (picture->pic_hex_digits) {
hex = p;
p += picture->pic_hex_digits;
@ -974,18 +956,22 @@ static void edit_numeric( DSC * desc, PICS picture, TEXT ** output)
if (check >= 1)
hex_overflow = true;
else {
n = number;
SLONG nh = number;
while (p-- > hex) {
*p = "0123456789abcdef"[n & 15];
n >>= 4;
*p = "0123456789abcdef"[nh & 15];
nh >>= 4;
}
}
}
for (l = picture->pic_length - picture->pic_print_length; l-- > 0;)
for (USHORT l = picture->pic_length - picture->pic_print_length; l-- > 0;)
*out++ = ' ';
n = (number + 0.5 < 1) ? 0 : 1;
const SLONG n = (number + 0.5 < 1) ? 0 : 1;
TEXT float_char;
TEXT c, d;
bool signif = false;
for (;;) {
c = generate(picture);
@ -1115,18 +1101,18 @@ static int generate( PICS picture)
TEXT c, *p;
for (;;) {
/* If we're in a repeat, pass it back */
// If we're in a repeat, pass it back
if (picture->pic_count > 0) {
--picture->pic_count;
return picture->pic_character;
}
/* Get the next character. If null, we're done */
// Get the next character. If null, we're done
c = *picture->pic_pointer++;
/* If we're in literal mode, just return the character */
// If we're in literal mode, just return the character
if (picture->pic_flags & PIC_literal)
break;
@ -1139,12 +1125,12 @@ static int generate( PICS picture)
return (picture->pic_character = c);
}
/* If the character is null and not a repeat count, we're done */
// If the character is null and not a repeat count, we're done
if (!c || c != '(')
break;
/* We're got a potential repeat count. If real, extract it. */
// We're got a potential repeat count. If real, extract it.
p = picture->pic_pointer;
while (*p >= '0' && *p <= '9')
@ -1184,11 +1170,10 @@ static void literal( PICS picture, TEXT c, TEXT ** ptr)
* Handle a literal string in a picture string.
*
**************************************/
TEXT *p, d;
p = *ptr;
TEXT* p = *ptr;
picture->pic_flags |= PIC_literal;
TEXT d;
if (c == '\\')
*p++ = generate(picture);
else
@ -1199,3 +1184,4 @@ static void literal( PICS picture, TEXT c, TEXT ** ptr)
picture->pic_flags &= ~PIC_literal;
}

View File

@ -155,7 +155,7 @@ void PRO_copy_procedure(
DB1 = new_database->dbb_handle;
// create blob parameter block since procedure is a text blob
// create blob parameter block since procedure is a text blob
UCHAR* p = bpb;
@ -179,7 +179,7 @@ void PRO_copy_procedure(
PRO_close(new_database, new_blob);
END_STORE;
// Release the FOR and STORE requests
// Release the FOR and STORE requests
gds__release_request(gds_status, &store_request);
PRO_commit(new_database);
}
@ -201,7 +201,7 @@ void PRO_create( DBB database, TEXT * name)
ISC_STATUS_ARRAY status_vector;
UCHAR bpb[20];
// See if procedure is already in use
// See if procedure is already in use
probe(database, name);
@ -236,7 +236,7 @@ void PRO_create( DBB database, TEXT * name)
gds__close_blob(status_vector, &blob);
END_STORE;
// Commit the procedure transaction, if there is one
// Commit the procedure transaction, if there is one
PRO_commit(database);
}
@ -260,14 +260,14 @@ int PRO_delete_procedure( DBB database, TEXT * name)
PRO_setup(database);
FOR(REQUEST_HANDLE request) X IN DB.QLI$PROCEDURES WITH
X.QLI$PROCEDURE_NAME EQ name
X.QLI$PROCEDURE_NAME EQ name
ERASE X;
count++;
END_FOR;
gds__release_request(gds_status, &request);
// Commit the procedure transaction, if there is one
// Commit the procedure transaction, if there is one
PRO_commit(database);
@ -310,7 +310,7 @@ void PRO_edit_procedure( DBB database, TEXT * name)
gds__vtof(name, X.QLI$PROCEDURE_NAME, sizeof(X.QLI$PROCEDURE_NAME));
END_STORE
// Commit the procedure transaction, if there is one
// Commit the procedure transaction, if there is one
PRO_commit(database);
}
@ -439,7 +439,7 @@ FRBRD *PRO_open_blob( DBB database, SLONG * blob_id)
if (gds__open_blob2(status_vector, &database->dbb_handle,
&database->dbb_proc_trans, &blob, (GDS__QUAD*) blob_id,
bpb_length, (char*) bpb))
bpb_length, (char*) bpb))
ERRQ_database_error(database, status_vector);
return blob;
@ -479,7 +479,7 @@ int PRO_rename_procedure( DBB database, TEXT * old_name, TEXT * new_name)
gds__release_request(gds_status, &request);
// Commit the procedure transaction, if there is one
// Commit the procedure transaction, if there is one
PRO_commit(database);
@ -556,7 +556,7 @@ void PRO_setup( DBB dbb)
if (!dbb)
IBERROR(77);
// Msg 77 database handle required
// Msg 77 database handle required
/* If we don't have a QLI$PROCEDURES relation, and can't get one, punt */
@ -571,7 +571,7 @@ void PRO_setup( DBB dbb)
return;
}
/* Sigh. Relation doesn't exist. So make it exist. */
// Sigh. Relation doesn't exist. So make it exist.
create_qli_procedures(dbb);
@ -601,7 +601,7 @@ FRBRD *PRO_transaction( DBB database, int update_flag)
FRBRD *transaction;
if (!database)
IBERROR(248); // Msg248 no active database for operation
IBERROR(248); // Msg248 no active database for operation
transaction = (database->dbb_capabilities & DBB_cap_multi_trans) ?
database->dbb_proc_trans : NULL;
@ -620,20 +620,20 @@ FRBRD *PRO_transaction( DBB database, int update_flag)
else
database->dbb_capabilities |= DBB_cap_multi_trans;
/* If we already have a procedure transaction, there's more nothing to do */
// If we already have a procedure transaction, there's more nothing to do
gds_trans = transaction;
// If we only support a single transaction, use the data transaction
// If we only support a single transaction, use the data transaction
if (!gds_trans && (database->dbb_capabilities & DBB_cap_single_trans)) {
if (update_flag)
IBERROR(249); // Msg249 Interactive metadata updates are not available on Rdb
IBERROR(249); // Msg249 Interactive metadata updates are not available on Rdb
if (!(gds_trans = database->dbb_transaction))
gds_trans = MET_transaction(nod_start_trans, database);
}
// otherwise make one more effort to start the transaction
// otherwise make one more effort to start the transaction
else if (!gds_trans) {
START_TRANSACTION
@ -672,7 +672,7 @@ static int clear_out_qli_procedures( DBB dbb)
F IN DB.RDB$FIELDS CROSS RFR IN DB.RDB$RELATION_FIELDS WITH
RFR.RDB$RELATION_NAME = R.RDB$RELATION_NAME AND
RFR.RDB$FIELD_NAME = F.RDB$FIELD_NAME AND
R.RDB$RELATION_NAME = "QLI$PROCEDURES"
R.RDB$RELATION_NAME = "QLI$PROCEDURES"
count++;
END_FOR
ON_ERROR
@ -710,7 +710,7 @@ static int clear_out_qli_procedures( DBB dbb)
FOR(REQUEST_HANDLE req) X IN DB.RDB$RELATION_FIELDS
WITH X.RDB$FIELD_NAME = "QLI$PROCEDURE_NAME" OR
X.RDB$FIELD_NAME = "QLI$PROCEDURE"
X.RDB$FIELD_NAME = "QLI$PROCEDURE"
ERASE X;
count++;
END_FOR
@ -722,7 +722,7 @@ static int clear_out_qli_procedures( DBB dbb)
FOR(REQUEST_HANDLE req) X IN DB.RDB$FIELDS
WITH X.RDB$FIELD_NAME = "QLI$PROCEDURE_NAME" OR
X.RDB$FIELD_NAME = "QLI$PROCEDURE"
X.RDB$FIELD_NAME = "QLI$PROCEDURE"
ERASE X;
count++;
END_FOR
@ -733,7 +733,7 @@ static int clear_out_qli_procedures( DBB dbb)
gds__release_request(gds_status, &req);
FOR(REQUEST_HANDLE req) X IN DB.RDB$RELATIONS
WITH X.RDB$RELATION_NAME = "QLI$PROCEDURES"
WITH X.RDB$RELATION_NAME = "QLI$PROCEDURES"
ERASE X;
count++;
END_FOR
@ -757,7 +757,7 @@ static void create_qli_procedures( DBB dbb)
*
* Functional description
* The procedures relation can't be found. Clean
* out residual trash and (re)create the relation.
* out residual trash and (re)create the relation.
* Before cleaning out the trash, see if somebody
* else has set up for us.
*
@ -787,14 +787,14 @@ static void create_qli_procedures( DBB dbb)
/* Msg 74 Could not create QLI$PROCEDURE field */
}
if (gds__ddl(gds_status, &DB, &gds_trans, sizeof(dyn_gdl3),
if (gds__ddl(gds_status, &DB, &gds_trans, sizeof(dyn_gdl3),
(char*) dyn_gdl3)) {
PRO_rollback(dbb);
IBERROR(75);
/* Msg 75 Could not create QLI$PROCEDURES relation */
}
if (gds__ddl(gds_status, &DB, &gds_trans, sizeof(dyn_gdl4),
if (gds__ddl(gds_status, &DB, &gds_trans, sizeof(dyn_gdl4),
(char*) dyn_gdl4)) {
PRO_rollback(dbb);
IBERROR(409);
@ -823,7 +823,7 @@ static void probe( DBB database, TEXT * name)
FRBRD *blob;
ISC_STATUS_ARRAY status_vector;
// Probe to see if procedure is already in use
// Probe to see if procedure is already in use
if (blob = PRO_fetch_procedure(database, name)) {
gds__close_blob(status_vector, &blob);
@ -855,8 +855,9 @@ static int upcase_name(const TEXT* name, TEXT* buffer)
if (!c)
return l;
if (++l > 31)
IBERROR(79); // Msg 79 procedure name over 31 characters
IBERROR(79); // Msg 79 procedure name over 31 characters
}
}

View File

@ -1,7 +1,7 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: proc_proto.h
* DESCRIPTION: Prototype header file for proc.c
* DESCRIPTION: Prototype header file for proc.cpp
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_PROC_PROTO_H_
#define _QLI_PROC_PROTO_H_
#ifndef QLI_PROC_PROTO_H
#define QLI_PROC_PROTO_H
extern void PRO_close(dbb*, FRBRD*);
extern void PRO_commit(dbb*);
@ -40,4 +40,4 @@ extern void PRO_scan(dbb*, void(*)(), void*);
extern void PRO_setup(dbb*);
extern FRBRD* PRO_transaction(dbb*, int);
#endif /* _QLI_PROC_PROTO_H_ */
#endif /* QLI_PROC_PROTO_H */

View File

@ -1,7 +1,7 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: repor_proto.h
* DESCRIPTION: Prototype header file for report.c
* DESCRIPTION: Prototype header file for report.cpp
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
@ -21,9 +21,9 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_REPOR_PROTO_H_
#define _QLI_REPOR_PROTO_H_
#ifndef QLI_REPOR_PROTO_H
#define QLI_REPOR_PROTO_H
extern void RPT_report(qli_nod*);
#endif /* _QLI_REPOR_PROTO_H_ */
#endif /* QLI_REPOR_PROTO_H */

View File

@ -67,7 +67,7 @@ void RPT_report( QLI_NOD loop)
**************************************/
QLI_REQ request;
// Get to actual report node
// Get to actual report node
QLI_NOD node = loop->nod_arg[e_for_statement];
RPT report = (RPT) node->nod_arg[e_prt_list];
@ -75,7 +75,7 @@ void RPT_report( QLI_NOD loop)
print->prt_new_page = (int(*)()) top_of_page;
print->prt_page_number = 0;
// Get to actual report node
// Get to actual report node
/* If there is a request associated with the loop, start it and possibly
send a message slong with it. */
@ -116,13 +116,13 @@ void RPT_report( QLI_NOD loop)
initialize_break(report->rpt_bottom_page);
initialize_break(report->rpt_bottom_rpt);
// Force TOP breaks for all fields
// Force TOP breaks for all fields
for (control = report->rpt_top_breaks; control;
control = control->brk_next) FMT_print((QLI_NOD) control->brk_line, print);
for (;;) {
// Check for bottom breaks. If we find one, force all lower breaks.
// Check for bottom breaks. If we find one, force all lower breaks.
for (control = report->rpt_bottom_breaks; control;
control = control->brk_next)
@ -139,7 +139,7 @@ void RPT_report( QLI_NOD loop)
if (print->prt_lines_remaining <= 0)
top_of_page(print, false);
// Now check for top breaks.
// Now check for top breaks.
for (control = report->rpt_top_breaks; control;
control = control->brk_next)
@ -150,7 +150,7 @@ void RPT_report( QLI_NOD loop)
}
}
// Increment statisticals and print detail line, if any
// Increment statisticals and print detail line, if any
increment_break(report->rpt_bottom_breaks);
increment_break(report->rpt_bottom_page);
@ -159,7 +159,7 @@ void RPT_report( QLI_NOD loop)
if (node = report->rpt_detail_line)
FMT_print(node, print);
/* Get the next record. If we're at end, we're almost done. */
// Get the next record. If we're at end, we're almost done.
swap_uchar(message->msg_buffer, report->rpt_buffer);
desc = EXEC_receive(message, (PAR) loop->nod_arg[e_for_eof]);
@ -167,7 +167,7 @@ void RPT_report( QLI_NOD loop)
break;
}
// Force BOTTOM breaks for all fields
// Force BOTTOM breaks for all fields
swap_uchar(message->msg_buffer, report->rpt_buffer);
bottom_break(report->rpt_bottom_breaks, print);
@ -262,7 +262,7 @@ static bool test_break(BRK control,
DSC desc1, desc2, *ptr1, *ptr2;
UCHAR *p2;
// Evaluate the two versions of the expression
// Evaluate the two versions of the expression
if (ptr1 = EVAL_value((QLI_NOD) control->brk_field))
desc1 = *ptr1;
@ -275,7 +275,7 @@ static bool test_break(BRK control,
message->msg_buffer = p1;
// Check for consistently missing
// Check for consistently missing
if (!ptr1 || !ptr2)
return (ptr1 != ptr2);
@ -291,10 +291,10 @@ static bool test_break(BRK control,
l = 2 + *(USHORT *) p1;
if (l)
do
do {
if (*p1++ != *p2++)
return true;
while (--l);
} while (--l);
return false;
}
@ -361,3 +361,4 @@ static void top_of_page(PRT print,
initialize_break(report->rpt_bottom_page);
}

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_REPORT_H_
#define _QLI_REPORT_H_
#ifndef QLI_REPORT_H
#define QLI_REPORT_H
/* Control break block */
@ -53,4 +53,4 @@ typedef struct rpt {
USHORT rpt_lines; /* Lines per page */
} *RPT;
#endif /* _QLI_REPORT_H_ */
#endif /* QLI_REPORT_H */

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_REQS_H_
#define _QLI_REQS_H_
#ifndef QLI_REQS_H
#define QLI_REQS_H
#define REQ_relation_def 0
#define REQ_store_relation 1
@ -90,4 +90,4 @@
#define REQ_show_dimensions 64
#define REQ_max 65
#endif /* _QLI_REQS_H_ */
#endif /* QLI_REQS_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: show_proto.h
* DESCRIPTION: Prototype header file for show.c
* DESCRIPTION: Prototype header file for show.cpp
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
@ -21,9 +21,9 @@
* Contributor(s): ______________________________________.
*/
#ifndef _QLI_SHOW_PROTO_H_
#define _QLI_SHOW_PROTO_H_
#ifndef QLI_SHOW_PROTO_H
#define QLI_SHOW_PROTO_H
extern void SHOW_stuff(syn*);
#endif /* _QLI_SHOW_PROTO_H_ */
#endif /* QLI_SHOW_PROTO_H */

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Remote Interface/Server
* MODULE: inet.c
* MODULE: inet.cpp
* DESCRIPTION: TCP/UCP/IP Communications module.
*
* The contents of this file are subject to the Interbase Public
@ -41,7 +41,7 @@
*
*/
/*
$Id: inet.cpp,v 1.77 2003-09-24 14:53:25 dimitr Exp $
$Id: inet.cpp,v 1.78 2003-09-25 11:49:09 robocop Exp $
*/
#include "firebird.h"
#include "../jrd/ib_stdio.h"

View File

@ -80,7 +80,7 @@ static void RefreshIBControls(HWND, BOOL);
static void RefreshOSControls(HWND, BOOL);
#endif
static BOOL ValidateUser(HWND);
static void PrintCfgStatus(ISC_STATUS *, int, HWND);
static void PrintCfgStatus(const ISC_STATUS*, int, HWND);
static void FillSysdbaSPB(char *, char *);
// Define an array of dword pairs,
@ -672,7 +672,7 @@ BOOL CALLBACK PasswordDlgProc(HWND hDlg, UINT unMsg, WPARAM wParam,
return FALSE;
}
void PrintCfgStatus(ISC_STATUS * status_vector, int nErrCode, HWND hDlg)
void PrintCfgStatus(const ISC_STATUS* status_vector, int nErrCode, HWND hDlg)
{
/**************************************
*
@ -685,14 +685,13 @@ void PrintCfgStatus(ISC_STATUS * status_vector, int nErrCode, HWND hDlg)
* to allow redirecting output.
*
**************************************/
ISC_STATUS *vector;
SCHAR szErrStr[ERR_BUFLEN];
SCHAR szHdrStr[HDR_BUFLEN];
szErrStr[0] = '\0';
if (status_vector) {
vector = status_vector;
const ISC_STATUS* vector = status_vector;
if (isc_interprete(szErrStr, &vector)) {
SCHAR *ptr = szErrStr + strlen(szErrStr);;

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Remote Interface/Server
* MODULE: wnet.c
* MODULE: wnet.cpp
* DESCRIPTION: Windows Net Communications module.
*
* The contents of this file are subject to the Interbase Public

View File

@ -465,7 +465,7 @@ typedef struct port
ISC_STATUS receive_msg(P_DATA*, PACKET*);
ISC_STATUS seek_blob(P_SEEK*, PACKET*);
ISC_STATUS send_msg(P_DATA*, PACKET*);
ISC_STATUS send_response(PACKET*, OBJCT, USHORT, ISC_STATUS*);
ISC_STATUS send_response(PACKET*, OBJCT, USHORT, const ISC_STATUS*);
ISC_STATUS service_attach(P_ATCH*, PACKET*);
ISC_STATUS service_end(P_RLSE*, PACKET*);
ISC_STATUS service_start(P_INFO*, PACKET*);

View File

@ -1082,20 +1082,14 @@ ISC_STATUS port::compile(P_CMPL* compile, PACKET* send)
* Compile and request.
*
**************************************/
RDB rdb;
RRQ request;
REM_MSG message, next;
UCHAR *blr;
USHORT max_msg, blr_length;
FRBRD *handle;
ISC_STATUS_ARRAY status_vector;
rrq::rrq_repeat* tail;
OBJCT object;
rdb = this->port_context;
handle = NULL;
blr = compile->p_cmpl_blr.cstr_address;
blr_length = compile->p_cmpl_blr.cstr_length;
RDB rdb = this->port_context;
FRBRD* handle = NULL;
UCHAR* blr = compile->p_cmpl_blr.cstr_address;
USHORT blr_length = compile->p_cmpl_blr.cstr_length;
THREAD_EXIT;
isc_compile_request(status_vector, &rdb->rdb_handle, &handle, blr_length,
@ -1107,15 +1101,16 @@ ISC_STATUS port::compile(P_CMPL* compile, PACKET* send)
/* Parse the request to find the messages */
message = PARSE_messages(blr, blr_length);
max_msg = 0;
REM_MSG message = PARSE_messages(blr, blr_length);
USHORT max_msg = 0;
REM_MSG next;
for (next = message; next; next = next->msg_next)
max_msg = MAX(max_msg, next->msg_number);
/* Allocate block and merge into data structures */
request = (RRQ) ALLOCV(type_rrq, max_msg + 1);
RRQ request = (RRQ) ALLOCV(type_rrq, max_msg + 1);
#ifdef DEBUG_REMOTE_MEMORY
ib_printf("compile(server) allocate request %x\n", request);
#endif
@ -2250,7 +2245,7 @@ static bool get_next_msg_no(RRQ request,
THREAD_EXIT;
isc_request_info(status_vector, &request->rrq_handle, incarnation,
sizeof(request_info), (SCHAR *) request_info, /* const_cast */
sizeof(request_info), (SCHAR *) request_info, // const_cast
sizeof(info_buffer), reinterpret_cast<char*>(info_buffer));
THREAD_ENTER;
@ -4119,7 +4114,7 @@ ISC_STATUS port::send_msg(P_DATA * data, PACKET* send)
ISC_STATUS port::send_response( PACKET* send,
OBJCT object,
USHORT length,
ISC_STATUS* status_vector)
const ISC_STATUS* status_vector)
{
/**************************************
*

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Remote Interface/Server
* MODULE: xnet.c
* MODULE: xnet.cpp
* DESCRIPTION: Interprocess Server Communications module.
*
* The contents of this file are subject to the Interbase Public

View File

@ -1,7 +1,7 @@
/*
*
* PROGRAM: Security data base manager
* MODULE: gsec.c
* MODULE: gsec.cpp
* DESCRIPTION: Main line routine
*
* The contents of this file are subject to the Interbase Public
@ -1134,7 +1134,7 @@ static SSHORT parse_cmd_line( int argc, TEXT ** argv, TSEC tdsec)
return ret;
}
void GSEC_print_status( ISC_STATUS * status_vector)
void GSEC_print_status(const ISC_STATUS* status_vector)
{
/**************************************
*
@ -1147,26 +1147,21 @@ void GSEC_print_status( ISC_STATUS * status_vector)
* to allow redirecting output.
*
**************************************/
#ifdef SUPERSERVER
TSEC tdsec;
ISC_STATUS *status;
int i = 0, j;
#endif
ISC_STATUS *vector;
SCHAR s[1024];
if (status_vector) {
vector = status_vector;
const ISC_STATUS* vector = status_vector;
#ifdef SUPERSERVER
tdsec = GET_THREAD_DATA;
status = tdsec->tsec_service_blk->svc_status;
TSEC tdsec = GET_THREAD_DATA;
ISC_STATUS* status = tdsec->tsec_service_blk->svc_status;
if (status != status_vector) {
int i = 0, j;
while (*status && (++i < ISC_STATUS_LENGTH))
status++;
for (j = 0; status_vector[j] && (i < ISC_STATUS_LENGTH); j++, i++)
*status++ = status_vector[j];
}
#endif
SCHAR s[1024];
if (isc_interprete(s, &vector)) {
TRANSLATE_CP(s);
util_output("%s\n", s);
@ -1213,8 +1208,7 @@ static void util_output( const SCHAR * format, ...)
gsec_exit(exit_code, tdsec);
}
void GSEC_error_redirect(
ISC_STATUS * status_vector,
void GSEC_error_redirect(const ISC_STATUS* status_vector,
USHORT errcode, TEXT * arg1, TEXT * arg2)
{
/**************************************

View File

@ -6,8 +6,8 @@ extern int GSEC_main(SVC service);
#endif
// Output reporting utilities
extern void GSEC_print_status(ISC_STATUS *);
extern void GSEC_error_redirect(ISC_STATUS *, USHORT, TEXT *, TEXT *);
extern void GSEC_print_status(const ISC_STATUS*);
extern void GSEC_error_redirect(const ISC_STATUS*, USHORT, TEXT *, TEXT *);
extern void GSEC_error(USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);
extern void GSEC_print(USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);
extern void GSEC_print_partial(USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: dba.e
* MODULE: dba.epp
* DESCRIPTION: Database analysis tool
*
* The contents of this file are subject to the Interbase Public
@ -308,7 +308,6 @@ int CLIB_ROUTINE main(int argc, char **argv)
JMP_BUF env;
isc_tr_handle transact1;
isc_req_handle request1, request2, request3;
ISC_STATUS *status_vector;
#if defined (WIN95) && !defined (SUPERSERVER)
BOOL fAnsiCP;
#endif
@ -324,6 +323,8 @@ int CLIB_ROUTINE main(int argc, char **argv)
argv = service->svc_argv;
#endif
ISC_STATUS* status_vector = NULL;
try {
#ifdef SUPERSERVER
@ -844,15 +845,11 @@ int CLIB_ROUTINE main(int argc, char **argv)
if (status_vector[1])
{
ISC_STATUS *vector;
SCHAR s[1024];
#ifdef SUPERSERVER
ISC_STATUS *status;
int i = 0, j;
status = tddba->dba_service_blk->svc_status;
ISC_STATUS* status = tddba->dba_service_blk->svc_status;
if (status != status_vector)
{
int i = 0, j;
while (*status && (++i < ISC_STATUS_LENGTH)) {
status++;
}
@ -863,7 +860,8 @@ int CLIB_ROUTINE main(int argc, char **argv)
}
}
#endif
vector = status_vector;
const ISC_STATUS* vector = status_vector;
SCHAR s[1024];
if (isc_interprete(s, &vector))
{
FPRINTF(tddba->sw_outfile, "%s\n", s);