From: Alexander P. <ale...@us...> - 2004-12-09 19:20:40
|
Build Version : T2.0.0.9824 Firebird 2.0 UNSTABLE (writeBuildNum.sh,v 1.9828 2004/12/09 19:18:50 alexpeshkoff ) Update of /cvsroot/firebird/firebird2/src/alice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9527/src/alice Modified Files: exe.cpp tdr.cpp Log Message: applied Clumplet* classes to dpb where possible Index: exe.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/alice/exe.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -b -U3 -r1.40 -r1.41 --- exe.cpp 8 Nov 2004 02:57:15 -0000 1.40 +++ exe.cpp 9 Dec 2004 19:18:30 -0000 1.41 @@ -48,9 +48,10 @@ #include "../alice/tdr_proto.h" #include "../jrd/gds_proto.h" #include "../jrd/thd.h" +#include "../common/classes/ClumpletWriter.h" -static USHORT build_dpb(UCHAR*, const ULONG); +static void buildDpb(Firebird::ClumpletWriter&, const ULONG); static void extract_db_info(const UCHAR*); static const TEXT val_errors[] = @@ -60,22 +61,6 @@ isc_info_tpage_errors, isc_info_end }; -static inline void stuff_dpb(UCHAR** d, int blr) -{ - UCHAR *ptr = *d; - *ptr++ = (UCHAR)blr; - *d = ptr; -} - -static inline void stuff_dpb_long(UCHAR** d, int blr) -{ - stuff_dpb(d, blr); - stuff_dpb(d, blr >> 8); - stuff_dpb(d, blr >> 16); - stuff_dpb(d, blr >> 24); -} - - //____________________________________________________________ // @@ -86,7 +71,6 @@ bool error = false; AliceAutoPool newPool(AliceMemoryPool::createPool()); { - UCHAR dpb[128]; AliceGlobals* tdgbl = AliceGlobals::getSpecific(); AliceContextPoolHolder context(tdgbl, newPool); @@ -97,12 +81,13 @@ // generate the database parameter block for the attach, // based on the various switches - - const USHORT dpb_length = build_dpb(dpb, switches); // B.O. + Firebird::ClumpletWriter dpb(true, MAX_DPB_SIZE); + buildDpb(dpb, switches); // B.O. FB_API_HANDLE handle = 0; - isc_attach_database(tdgbl->status, 0, database, &handle, dpb_length, - reinterpret_cast<SCHAR*>(dpb)); + isc_attach_database(tdgbl->status, 0, database, &handle, + dpb.getBufferLength(), + reinterpret_cast<const SCHAR*>(dpb.getBuffer())); tdgbl->service_blk->svc_started(); @@ -153,7 +138,6 @@ bool error = false; AliceAutoPool newPool(AliceMemoryPool::createPool()); { - UCHAR dpb[128]; AliceGlobals* tdgbl = AliceGlobals::getSpecific(); AliceContextPoolHolder context(tdgbl, newPool); @@ -164,12 +148,13 @@ // generate the database parameter block for the attach, // based on the various switches - - const USHORT dpb_length = build_dpb(dpb, switches); // B.O. + Firebird::ClumpletWriter dpb(true, MAX_DPB_SIZE); + buildDpb(dpb, switches); // B.O. FB_API_HANDLE handle = 0; isc_attach_database(tdgbl->status, 0, database, &handle, - dpb_length, reinterpret_cast<char*>(dpb)); + dpb.getBufferLength(), + reinterpret_cast<const SCHAR*>(dpb.getBuffer())); tdgbl->service_blk->svc_started(); @@ -204,183 +189,140 @@ // based on the various switches // -static USHORT build_dpb(UCHAR* dpb, const ULONG switches) +void buildDpb(Firebird::ClumpletWriter& dpb, const ULONG switches) { AliceGlobals* tdgbl = AliceGlobals::getSpecific(); - - UCHAR* dpb2 = dpb; - *dpb2++ = isc_dpb_version1; - *dpb2++ = isc_dpb_gfix_attach; - *dpb2++ = 0; + dpb.reset(isc_dpb_version1); + dpb.insertTag(isc_dpb_gfix_attach); if (switches & sw_sweep) { - *dpb2++ = isc_dpb_sweep; - *dpb2++ = 1; - *dpb2++ = isc_dpb_records; + dpb.insertByte(isc_dpb_sweep, isc_dpb_records); } else if (switches & sw_activate) { - *dpb2++ = isc_dpb_activate_shadow; - *dpb2++ = 0; + dpb.insertTag(isc_dpb_activate_shadow); } else if (switches & sw_validate) { - *dpb2++ = isc_dpb_verify; - *dpb2++ = 1; - *dpb2 = isc_dpb_pages; + UCHAR b = isc_dpb_pages; if (switches & sw_full) - *dpb2 |= isc_dpb_records; + b |= isc_dpb_records; if (switches & sw_no_update) - *dpb2 |= isc_dpb_no_update; + b |= isc_dpb_no_update; if (switches & sw_mend) - *dpb2 |= isc_dpb_repair; + b |= isc_dpb_repair; if (switches & sw_ignore) - *dpb2 |= isc_dpb_ignore; - dpb2++; + b |= isc_dpb_ignore; + dpb.insertByte(isc_dpb_verify, b); } else if (switches & sw_housekeeping) { - *dpb2++ = isc_dpb_sweep_interval; - *dpb2++ = 4; - for (int i = 0; i < 4; i++, (tdgbl->ALICE_data.ua_sweep_interval >>= 8)) - { - // TMN: Here we should really have the following assert - // fb_assert(tdgbl->ALICE_data.ua_sweep_interval <= MAX_UCHAR); - *dpb2++ = (UCHAR) tdgbl->ALICE_data.ua_sweep_interval; - } + dpb.insertInt(isc_dpb_sweep_interval, + tdgbl->ALICE_data.ua_sweep_interval); } else if (switches & sw_begin_log) { - *dpb2++ = isc_dpb_begin_log; - *dpb2++ = strlen(tdgbl->ALICE_data.ua_log_file); - for (const char* q = tdgbl->ALICE_data.ua_log_file; *q;) - *dpb2++ = *q++; + dpb.insertString(isc_dpb_begin_log, + tdgbl->ALICE_data.ua_log_file, + strlen(tdgbl->ALICE_data.ua_log_file)); } else if (switches & sw_buffers) { - *dpb2++ = isc_dpb_set_page_buffers; - *dpb2++ = 4; - for (int i = 0; i < 4; i++, (tdgbl->ALICE_data.ua_page_buffers >>= 8)) - { - // TMN: Here we should really have the following assert - // fb_assert(tdgbl->ALICE_data.ua_page_buffers <= MAX_UCHAR); - *dpb2++ = (UCHAR) tdgbl->ALICE_data.ua_page_buffers; - } + dpb.insertInt(isc_dpb_set_page_buffers, + tdgbl->ALICE_data.ua_page_buffers); } else if (switches & sw_quit_log) { - *dpb2++ = isc_dpb_quit_log; - *dpb2++ = 0; + dpb.insertTag(isc_dpb_quit_log); } else if (switches & sw_kill) { - *dpb2++ = isc_dpb_delete_shadow; - *dpb2++ = 0; + dpb.insertTag(isc_dpb_delete_shadow); } else if (switches & sw_write) { - *dpb2++ = isc_dpb_force_write; - *dpb2++ = 1; - *dpb2++ = tdgbl->ALICE_data.ua_force ? 1 : 0; + dpb.insertByte(isc_dpb_force_write, + tdgbl->ALICE_data.ua_force ? 1 : 0); } else if (switches & sw_use) { - *dpb2++ = isc_dpb_no_reserve; - *dpb2++ = 1; - *dpb2++ = tdgbl->ALICE_data.ua_use ? 1 : 0; + dpb.insertByte(isc_dpb_no_reserve, + tdgbl->ALICE_data.ua_use ? 1 : 0); } else if (switches & sw_mode) { - *dpb2++ = isc_dpb_set_db_readonly; - *dpb2++ = 1; - *dpb2++ = (tdgbl->ALICE_data.ua_read_only) ? 1 : 0; + dpb.insertByte(isc_dpb_set_db_readonly, + tdgbl->ALICE_data.ua_read_only ? 1 : 0); } else if (switches & sw_shut) { - *dpb2++ = isc_dpb_shutdown; - *dpb2++ = 1; - *dpb2 = 0; + char b = 0; if (switches & sw_attach) - *dpb2 |= isc_dpb_shut_attachment; + b |= isc_dpb_shut_attachment; else if (switches & sw_cache) - *dpb2 |= isc_dpb_shut_cache; + b |= isc_dpb_shut_cache; else if (switches & sw_force) - *dpb2 |= isc_dpb_shut_force; + b |= isc_dpb_shut_force; else if (switches & sw_tran) - *dpb2 |= isc_dpb_shut_transaction; + b |= isc_dpb_shut_transaction; switch (tdgbl->ALICE_data.ua_shutdown_mode) { case SHUT_NORMAL: - *dpb2 |= isc_dpb_shut_normal; + b |= isc_dpb_shut_normal; break; case SHUT_SINGLE: - *dpb2 |= isc_dpb_shut_single; + b |= isc_dpb_shut_single; break; case SHUT_MULTI: - *dpb2 |= isc_dpb_shut_multi; + b |= isc_dpb_shut_multi; break; case SHUT_FULL: - *dpb2 |= isc_dpb_shut_full; + b |= isc_dpb_shut_full; break; default: break; } - dpb2++; - *dpb2++ = isc_dpb_shutdown_delay; - *dpb2++ = 2; // Build room for shutdown delay - // TMN: Here we should really have the following assert - // fb_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); + dpb.insertByte(isc_dpb_shutdown, b); + // SSHORT is used for timeouts inside engine, + // therefore convert larger values to MAX_SSHORT + SLONG timeout = tdgbl->ALICE_data.ua_shutdown_delay; + if (timeout > MAX_SSHORT) + { + timeout = MAX_SSHORT; + } + dpb.insertInt(isc_dpb_shutdown_delay, timeout); } else if (switches & sw_online) { - *dpb2++ = isc_dpb_online; - *dpb2++ = 1; - *dpb2 = 0; + char b = 0; switch (tdgbl->ALICE_data.ua_shutdown_mode) { case SHUT_NORMAL: - *dpb2 |= isc_dpb_shut_normal; + b |= isc_dpb_shut_normal; break; case SHUT_SINGLE: - *dpb2 |= isc_dpb_shut_single; + b |= isc_dpb_shut_single; break; case SHUT_MULTI: - *dpb2 |= isc_dpb_shut_multi; + b |= isc_dpb_shut_multi; break; case SHUT_FULL: - *dpb2 |= isc_dpb_shut_full; + b |= isc_dpb_shut_full; break; default: break; } - dpb2++; + dpb.insertByte(isc_dpb_online, b); } else if (switches & sw_disable) { - *dpb2++ = isc_dpb_disable_wal; - *dpb2++ = 0; + dpb.insertTag(isc_dpb_disable_wal); } else if (switches & (sw_list | sw_commit | sw_rollback | sw_two_phase)) { - *dpb2++ = isc_dpb_no_garbage_collect; - *dpb2++ = 0; + dpb.insertTag(isc_dpb_no_garbage_collect); } else if (switches & sw_set_db_dialect) { - stuff_dpb(&dpb2, isc_dpb_set_db_sql_dialect); - stuff_dpb(&dpb2, 4); - stuff_dpb_long(&dpb2, tdgbl->ALICE_data.ua_db_SQL_dialect); + dpb.insertInt(isc_dpb_set_db_sql_dialect, + tdgbl->ALICE_data.ua_db_SQL_dialect); } if (tdgbl->ALICE_data.ua_user) { - *dpb2++ = isc_dpb_user_name; - *dpb2++ = strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_user)); - for (const UCHAR* q = tdgbl->ALICE_data.ua_user; *q;) - *dpb2++ = *q++; + dpb.insertBytes(isc_dpb_user_name, + tdgbl->ALICE_data.ua_user, + strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_user))); } - if (tdgbl->ALICE_data.ua_password) { - if (!tdgbl->sw_service) - *dpb2++ = isc_dpb_password; - else - *dpb2++ = isc_dpb_password_enc; - *dpb2++ = strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_password)); - for (const UCHAR* q = tdgbl->ALICE_data.ua_password; *q;) - *dpb2++ = *q++; + dpb.insertBytes(tdgbl->sw_service ? isc_dpb_password_enc : + isc_dpb_password, + tdgbl->ALICE_data.ua_password, + strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_password))); } - - USHORT dpb_length = dpb2 - dpb; - if (dpb_length == 1) - dpb_length = 0; - - return dpb_length; } Index: tdr.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/alice/tdr.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -b -U3 -r1.42 -r1.43 --- tdr.cpp 7 Oct 2004 08:21:15 -0000 1.42 +++ tdr.cpp 9 Dec 2004 19:18:31 -0000 1.43 @@ -48,6 +48,7 @@ #include "../jrd/isc_proto.h" #include "../jrd/svc_proto.h" #include "../jrd/thd.h" +#include "../common/classes/ClumpletWriter.h" static ULONG ask(void); static void print_description(const tdr*); @@ -182,48 +183,32 @@ TDR trans, const TEXT* pathname) { - UCHAR dpb[128]; AliceGlobals* tdgbl = AliceGlobals::getSpecific(); if (tdgbl->ALICE_data.ua_debug) ALICE_print(68, pathname, 0, 0, 0, 0); // msg 68: ATTACH_DATABASE: attempted attach of %s - UCHAR* d = dpb; - - *d++ = isc_dpb_version1; - *d++ = isc_dpb_no_garbage_collect; - *d++ = 0; - *d++ = isc_dpb_gfix_attach; - *d++ = 0; - + Firebird::ClumpletWriter dpb(true, MAX_DPB_SIZE, isc_dpb_version1); + dpb.insertTag(isc_dpb_no_garbage_collect); + dpb.insertTag(isc_dpb_gfix_attach); if (tdgbl->ALICE_data.ua_user) { - *d++ = isc_dpb_user_name; - *d++ = strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_user)); - for (const UCHAR* q = tdgbl->ALICE_data.ua_user; *q;) - *d++ = *q++; + dpb.insertBytes(isc_dpb_user_name, + tdgbl->ALICE_data.ua_user, + strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_user))); } - if (tdgbl->ALICE_data.ua_password) { - if (!tdgbl->sw_service) - *d++ = isc_dpb_password; - else - *d++ = isc_dpb_password_enc; - *d++ = - strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_password)); - for (const UCHAR* q = tdgbl->ALICE_data.ua_password; *q;) - *d++ = *q++; + dpb.insertBytes(tdgbl->sw_service ? isc_dpb_password_enc : + isc_dpb_password, + tdgbl->ALICE_data.ua_password, + strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_password))); } - USHORT dpb_length = d - dpb; - if (dpb_length == 1) - dpb_length = 0; - trans->tdr_db_handle = 0; isc_attach_database(status_vector, 0, pathname, - &trans->tdr_db_handle, dpb_length, - reinterpret_cast<char*>(dpb)); + &trans->tdr_db_handle, dpb.getBufferLength(), + reinterpret_cast<const char*>(dpb.getBuffer())); if (status_vector[1]) { if (tdgbl->ALICE_data.ua_debug) { |