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

Treat string literals and string constants with more respect.

This commit is contained in:
robocop 2004-11-08 05:38:42 +00:00
parent 9f035f1daf
commit 2ec848a3b9
6 changed files with 29 additions and 112 deletions

View File

@ -79,19 +79,11 @@ static DBB setup_update(DBB);
static void sql_grant_revoke(qli_syntax*, USHORT);
static void stuff_priv(qli_rlb*, USHORT, const TEXT*, USHORT, const TEXT*, const TEXT*);
static int truncate_string(TEXT*);
static void wal_info(const UCHAR*, SLONG*, SCHAR*, SLONG*);
static const UCHAR tpb[] = { isc_tpb_version1, isc_tpb_write };
static const UCHAR db_info[] = { isc_info_implementation, isc_info_end };
static UCHAR global_parm_buffer[256];
static const UCHAR db_log_info[] =
{
isc_info_logfile,
isc_info_cur_logfile_name,
isc_info_cur_log_part_offset
};
/*
static const UCHAR dpb_trace [] = { isc_dpb_version1, isc_dpb_trace, 1, 1 };
static const UCHAR dpb_num_buffers [ ] = { isc_dpb_version1, isc_dpb_num_buffers, 1, 1 };
@ -492,7 +484,7 @@ void MET_delete_database( DBB dbb)
/* generate a database parameter block to
include the user/password, if necessary */
TEXT* user;
const TEXT* user;
USHORT user_length;
if (dbb->dbb_user) {
user = (TEXT *) dbb->dbb_user->con_data;
@ -542,7 +534,6 @@ void MET_delete_database( DBB dbb)
&dbb->dbb_handle, dpb_length, (char*) dpb))
ERRQ_database_error(dbb, status_vector);
qli_lls* log_stack = NULL;
qli_lls* stack = NULL;
gds_trans = MET_transaction(nod_start_trans, dbb);
@ -557,21 +548,6 @@ void MET_delete_database( DBB dbb)
ERRQ_database_error(dbb, gds_status);
END_ERROR;
// Get write ahead log information
TEXT db_info_buffer[512];
if (isc_database_info(status_vector, &DB, sizeof(db_log_info),
reinterpret_cast<const char*>(db_log_info),
sizeof(db_info_buffer),
db_info_buffer))
ERRQ_database_error(dbb, status_vector);
// extract info from buffer
TEXT cur_log[512];
SLONG part_offset, log = 0;
wal_info((const UCHAR*) db_info_buffer, &log, cur_log, &part_offset);
MET_transaction(nod_commit, dbb);
if (isc_detach_database(gds_status, &dbb->dbb_handle))
@ -591,11 +567,6 @@ void MET_delete_database( DBB dbb)
// Msg431 Could not drop database file "%s"
}
while (log_stack) {
const qli_str* log_string = (qli_str*) ALLQ_pop(&log_stack);
unlink(log_string->str_data); // do not check for error
}
if (unlink(dbb->dbb_filename))
ERRQ_print_error(431, dbb->dbb_filename, NULL, NULL, NULL, NULL);
// Msg431 Could not drop database file "%s"
@ -3691,55 +3662,3 @@ static void stuff_priv(
STUFF(isc_dyn_end);
}
static void wal_info(
const UCHAR* db_info_buffer,
SLONG* log, SCHAR* cur_log, SLONG* part_offset)
{
/**************************************
*
* w a l _ i n f o
*
**************************************
*
* Functional description
* Extract wal name and log offset
*
**************************************/
*log = 0;
*part_offset = 0;
cur_log[0] = 0;
const UCHAR* p = db_info_buffer;
UCHAR item;
while ((item = *p++) != isc_info_end) {
const SLONG length = gds__vax_integer(p, 2);
p += 2;
switch (item) {
case isc_info_logfile:
*log = gds__vax_integer(p, length);
p += length;
break;
case isc_info_cur_logfile_name:
{
const UCHAR* d = p;
p += length;
const SLONG log_length = *d++;
memcpy(cur_log, d, log_length);
cur_log[log_length] = 0;
break;
}
case isc_info_cur_log_part_offset:
*part_offset = gds__vax_integer(p, length);
p += length;
break;
default:
;
}
}
}

View File

@ -78,7 +78,7 @@ static void RefreshOSControls(HWND, BOOL);
#endif
static BOOL ValidateUser(HWND);
static void PrintCfgStatus(const ISC_STATUS*, int, HWND);
static void FillSysdbaSPB(char *, char *);
static void FillSysdbaSPB(char*, const char*);
// Define an array of dword pairs,
// where the first of each pair is the control ID,
@ -197,12 +197,10 @@ LRESULT CALLBACK InterbasePage(HWND hDlg, UINT unMsg, WPARAM wParam,
break;
case WM_HELP:
{
LPHELPINFO lphi;
lphi = (LPHELPINFO) lParam;
LPHELPINFO lphi = (LPHELPINFO) lParam;
if (lphi->iContextType == HELPINFO_WINDOW) // must be for a control
{
WinHelp(static_cast < HWND > (lphi->hItemHandle),
WinHelp(static_cast<HWND>(lphi->hItemHandle),
"IBSERVER.HLP",
HELP_WM_HELP, (DWORD) (LPVOID) aMenuHelpIDs1);
}
@ -731,7 +729,7 @@ void PrintCfgStatus(const ISC_STATUS* status_vector, int nErrCode, HWND hDlg)
}
}
void FillSysdbaSPB(char *szSpb, char *szPasswd)
void FillSysdbaSPB(char *szSpb, const char* szPasswd)
{
/**************************************
*

View File

@ -521,7 +521,7 @@ USHORT PatchVersion(const TEXT* filename, DWORD verMS,
// This is a "magic value" that will allow locating the version info.
// Windows itself does something equivalent internally.
BYTE lookup[] = {'V', 0, 'S', 0, '_', 0,
const BYTE lookup[] = {'V', 0, 'S', 0, '_', 0,
'V', 0, 'E', 0, 'R', 0, 'S', 0, 'I', 0, 'O', 0, 'N', 0, '_', 0,
'I', 0, 'N', 0, 'F', 0, 'O', 0, 0, 0, 0, 0, 0xbd, 0x04, 0xef, 0xfe};
BYTE* p = mem; // First byte of mapped file
@ -574,7 +574,7 @@ USHORT PatchVersion(const TEXT* filename, DWORD verMS,
// This patch assumes the original version string has a major version and
// a minor version made of a single digit, like 1.5.x.y. It would need
// to be updated if we want to use versions like 1.51.x.y.
BYTE flookup[] = {'F', 0, 'i', 0, 'l', 0, 'e', 0,
const BYTE flookup[] = {'F', 0, 'i', 0, 'l', 0, 'e', 0,
'V', 0, 'e', 0, 'r', 0, 's', 0, 'i', 0, 'o', 0, 'n', 0, 0, 0};
p = vi;
end = vi + viLength;
@ -606,7 +606,7 @@ USHORT PatchVersion(const TEXT* filename, DWORD verMS,
// This patch assumes the original version string has a major version and
// a minor version made of a single digit, like 1.5.x.y. It would need
// to be updated if we want to use versions like 1.51.x.y.
BYTE plookup[] = {'P', 0, 'r', 0, 'o', 0, 'd', 0, 'u', 0, 'c', 0, 't', 0,
const BYTE plookup[] = {'P', 0, 'r', 0, 'o', 0, 'd', 0, 'u', 0, 'c', 0, 't', 0,
'V', 0, 'e', 0, 'r', 0, 's', 0, 'i', 0, 'o', 0, 'n', 0, 0, 0};
p = vi;
end = vi + viLength;

View File

@ -38,9 +38,9 @@
static USHORT inst_error(ULONG, const TEXT *);
static void usage(void);
static struct
static const struct
{
TEXT* name;
const TEXT* name;
USHORT abbrev;
USHORT code;
} commands[] =
@ -51,9 +51,9 @@ static struct
{NULL, 0, 0}
};
static struct
static const struct
{
TEXT* name;
const TEXT* name;
USHORT abbrev;
USHORT code;
} clients[] =
@ -106,11 +106,11 @@ int CLIB_ROUTINE main( int argc, char **argv)
{
if (sw_command == COMMAND_NONE)
{
TEXT* cmd;
const TEXT* cmd;
int i;
for (i = 0; cmd = commands[i].name; i++)
{
TEXT* q;
const TEXT* q;
for (p = *argv, q = cmd; *p && UPPER(*p) == *q; p++, q++);
if (!*p && commands[i].abbrev <= (USHORT) (q - cmd))
break;
@ -124,11 +124,11 @@ int CLIB_ROUTINE main( int argc, char **argv)
}
else
{
TEXT* cln;
const TEXT* cln;
int i;
for (i = 0; cln = clients[i].name; i++)
{
TEXT* q;
const TEXT* q;
for (p = *argv, q = cln; *p && UPPER(*p) == *q; p++, q++);
if (!*p && clients[i].abbrev <= (USHORT) (q - cln))
break;
@ -269,7 +269,6 @@ static USHORT inst_error(ULONG status, const TEXT * string)
*
**************************************/
TEXT buffer[512];
SSHORT l;
if (status == 0)
{
@ -280,13 +279,13 @@ static USHORT inst_error(ULONG status, const TEXT * string)
{
printf("Error %u occurred during \"%s\".\n", status, string);
if (!(l = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
status,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
buffer,
sizeof(buffer),
NULL)))
NULL))
{
printf("Windows NT error %"SLONGFORMAT"\n", status);
}
@ -340,3 +339,4 @@ static void usage(void)
exit(FINI_ERROR);
}

View File

@ -33,9 +33,9 @@
static USHORT reg_error(SLONG, const TEXT*, HKEY);
static void usage(void);
static struct
static const struct
{
TEXT* name;
const TEXT* name;
USHORT abbrev;
USHORT code;
} commands[] =

View File

@ -39,9 +39,9 @@ static void svc_query(const char*, const char*, SC_HANDLE manager);
static USHORT svc_error(SLONG, const TEXT*, SC_HANDLE);
static void usage(void);
static struct
static const struct
{
TEXT *name;
const TEXT *name;
USHORT abbrev;
USHORT code;
} commands[] =
@ -66,7 +66,6 @@ int CLIB_ROUTINE main( int argc, char **argv)
* Install or remove a Firebird service.
*
**************************************/
TEXT *q, *cmd;
TEXT directory[MAXPATHLEN];
TEXT full_username[128];
TEXT oem_username[128];
@ -106,8 +105,10 @@ int CLIB_ROUTINE main( int argc, char **argv)
{
if (**argv != '-')
{
const TEXT* cmd;
for (i = 0; cmd = commands[i].name; i++)
{
const TEXT* q;
for (p = *argv, q = cmd; *p && UPPER(*p) == *q; p++, q++);
if (!*p && commands[i].abbrev <= (USHORT) (q - cmd))
break;
@ -206,8 +207,8 @@ int CLIB_ROUTINE main( int argc, char **argv)
{
printf("Enter %s user password : ", oem_username);
p = keyb_password;
q = p + sizeof(keyb_password) - 1; // keep room for '\0'
while (p < q && (*p++ = getch()) != '\r')
const TEXT* const end = p + sizeof(keyb_password) - 1; // keep room for '\0'
while (p < end && (*p++ = getch()) != '\r')
putch('*'); // Win32 only
*(p - 1) = '\0'; // Cuts at '\r'
printf("\n");
@ -470,7 +471,6 @@ static USHORT svc_error( SLONG status, const TEXT* string, SC_HANDLE service)
*
**************************************/
TEXT buffer[512];
SSHORT l;
if (service != NULL)
CloseServiceHandle(service);
@ -484,13 +484,13 @@ static USHORT svc_error( SLONG status, const TEXT* string, SC_HANDLE service)
{
printf("Error occurred during \"%s\".\n", string);
if (!(l = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
status,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
buffer,
sizeof(buffer),
NULL)))
NULL))
{
printf("Windows NT error %"SLONGFORMAT"\n", status);
}