From: Alexander P. <ale...@us...> - 2004-12-09 19:20:26
|
Update of /cvsroot/firebird/firebird2/src/utilities In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9527/src/utilities Modified Files: create_db.cpp nbackup.cpp Log Message: applied Clumplet* classes to dpb where possible Index: create_db.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/utilities/create_db.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -b -U3 -r1.8 -r1.9 --- create_db.cpp 3 Dec 2003 08:19:24 -0000 1.8 +++ create_db.cpp 9 Dec 2004 19:19:41 -0000 1.9 @@ -3,6 +3,7 @@ #include "../jrd/ibase.h" #include "../jrd/common.h" +#include "../common/classes/ClumpletWriter.h" #include <stdio.h> int main(int argc, char** argv) @@ -13,14 +14,6 @@ return -1; } - UCHAR dpb[128]; - UCHAR* d = dpb; - *d++ = (UCHAR) isc_dpb_version1; - *d++ = (UCHAR) isc_dpb_set_db_readonly; - *d++ = 1; - *d++ = TRUE; - const SSHORT len = d - dpb; - ISC_STATUS_ARRAY sv; isc_db_handle db = 0; isc_tr_handle tr = 0; @@ -50,7 +43,11 @@ isc_print_status(sv); return -3; } - isc_attach_database(sv, 0, argv[1], &db, len, (char*) dpb); + + Firebird::ClumpletWriter dpb(true, MAX_DPB_SIZE, isc_dpb_version1); + dpb.insertByte(isc_dpb_set_db_readonly, TRUE); + isc_attach_database(sv, 0, argv[1], &db, dpb.getBufferLength(), + reinterpret_cast<const char*>(dpb.getBuffer())); if (sv[0] == 1 && sv[1] > 0) { isc_print_status(sv); Index: nbackup.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/utilities/nbackup.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -b -U3 -r1.42 -r1.43 --- nbackup.cpp 30 Nov 2004 06:18:32 -0000 1.42 +++ nbackup.cpp 9 Dec 2004 19:19:41 -0000 1.43 @@ -43,6 +43,7 @@ #include "../jrd/os/guid.h" #include "../jrd/ibase.h" #include "../common/classes/array.h" +#include "../common/classes/ClumpletWriter.h" #include <typeinfo> #ifdef HAVE_UNISTD_H @@ -432,33 +433,21 @@ if (username.length() > 255 || password.length() > 255) b_error::raise("Username or password is too long"); + Firebird::ClumpletWriter dpb(true, MAX_DPB_SIZE, isc_dpb_version1); - Firebird::HalfStaticArray<char, 100> dpbArray; - - char *dpb = dpbArray.getBuffer( - 1 + // isc_dpb_version1 - 1 + 1 + // isc_dpb_user_name + length - username.length() + - 1 + 1 + // isc_dpb_password + length - password.length()); - - *dpb++ = isc_dpb_version1; if (!username.isEmpty()) { - *dpb++ = isc_dpb_user_name; - *dpb++ = username.length(); - memcpy(dpb, username.c_str(), username.length()); - dpb += username.length(); + dpb.insertString(isc_dpb_user_name, username); } if (!password.isEmpty()) { - *dpb++ = isc_dpb_password; - *dpb++ = password.length(); - memcpy(dpb, password.c_str(), password.length()); - dpb += password.length(); + dpb.insertString(isc_dpb_password, password); } - if (isc_attach_database(status, 0, database.c_str(), &newdb, dpb - dpbArray.begin(), dpbArray.begin())) + if (isc_attach_database(status, 0, database.c_str(), &newdb, + dpb.getBufferLength(), reinterpret_cast<const char*>(dpb.getBuffer()))) + { pr_error(status, "attach database"); + } } void nbackup::detach_database() |