From: Jim S. <jim...@us...> - 2005-09-02 19:11:23
|
Update of /cvsroot/firebird/vulcan/src/burp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31050/src/burp Modified Files: backup.epp burp.cpp burp.h burp.vcproj burp_proto.h mvol.cpp restore.epp Log Message: Work in progress on Services provider Index: backup.epp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/burp/backup.epp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -b -U3 -r1.1.1.1 -r1.2 --- backup.epp 20 Jan 2005 19:36:53 -0000 1.1.1.1 +++ backup.epp 2 Sep 2005 19:11:10 -0000 1.2 @@ -476,17 +476,21 @@ put(tdgbl, (UCHAR) (rec_end)); UINT64 cumul_count = MVOL_fini_write(&tdgbl->io_cnt, &tdgbl->io_ptr); - if (cumul_count <= MAX_SLONG) { + + if (cumul_count <= MAX_SLONG) + { SLONG tempcount = cumul_count; - BURP_verbose(176, (void*) (long) tempcount, NULL, NULL, NULL, NULL); + BURP_verbose(176, tempcount); // msg 176 closing file, committing, and finishing. %ld bytes written } - else { + 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 } + COMMIT; ON_ERROR general_on_error(); @@ -1190,23 +1194,29 @@ ISC_STATUS_ARRAY status_vector; ULONG return_length = 0; + if (isc_get_slice(status_vector, &DB, &gds_trans, blob_id, blr_length, (const char*) blr_buffer, 0, // param length for subset of an array handling NULL, // param for subset of an array handling - slice_length, slice, (SLONG*) &return_length)) + slice_length, slice, (ISC_LONG*) &return_length)) { BURP_print(81, field->fld_name, NULL, NULL, NULL, NULL); // msg 81 error accessing blob field %s -- continuing BURP_print_status(status_vector); + #ifdef DEBUG PRETTY_print_sdl(blr_buffer, NULL, NULL, 0); #endif + // CVC: At this point I would expected calls to deallocate memory // See the end of this function. + BURP_free(slice); + if (xdr_buffer.lstr_allocated) BURP_free(xdr_buffer.lstr_address); + return; } @@ -1301,7 +1311,7 @@ **************************************/ TGBL tdgbl = GET_THREAD_DATA; - ULONG l = strlen(string); + ULONG l = (ULONG) strlen(string); put(tdgbl, (UCHAR) (attribute)); put(tdgbl, (UCHAR) (l)); @@ -1383,7 +1393,7 @@ break; default: - BURP_error_redirect(NULL, 21, (void*) (long) item, NULL); + BURP_error_redirect(NULL, 21, (void*) (IPTR) item, NULL); // msg 21 don't understand blob info item %ld } } @@ -1489,7 +1499,7 @@ break; default: - BURP_print(79, (void *) (long) item, NULL, NULL, NULL, NULL); + BURP_print(79, (void *) (IPTR) item, NULL, NULL, NULL, NULL); // msg 79 don't understand blob info item %ld return false; } @@ -1668,7 +1678,7 @@ break; default: - BURP_error_redirect(NULL, 26, (void *) (long) field->fld_type, NULL); + BURP_error_redirect(NULL, 26, (void *) (IPTR) field->fld_type, NULL); // msg 26 datatype %ld not understood break; } @@ -1813,7 +1823,7 @@ records++; // Verbose records if ((records % BACKUP_VERBOSE_INTERVAL) == 0) - BURP_verbose(108, (void *) (long) records, NULL, NULL, NULL, NULL); + BURP_verbose(108, (void *) (IPTR) records, NULL, NULL, NULL, NULL); put(tdgbl, (UCHAR) (rec_data)); put_numeric(att_data_length, record_length); @@ -1864,7 +1874,7 @@ if (xdr_buffer.lstr_address) BURP_free(xdr_buffer.lstr_address); - BURP_verbose(108, (void *) (long) records, NULL, NULL, NULL, NULL); + BURP_verbose(108, (void *) (IPTR) records, NULL, NULL, NULL, NULL); // msg 108 %ld records written if (isc_release_request(status_vector, &request)) @@ -1923,8 +1933,7 @@ if (count != (ULONG) X.RDB$SEGMENT_COUNT) { - BURP_print(180, X.RDB$INDEX_NAME, (void*) (long) count, - (void*)(long) X.RDB$SEGMENT_COUNT, NULL, NULL); + BURP_print(180, X.RDB$INDEX_NAME, count, X.RDB$SEGMENT_COUNT); continue; } @@ -2000,8 +2009,7 @@ if (count != (ULONG) X.RDB$SEGMENT_COUNT) { - BURP_print(180, X.RDB$INDEX_NAME, (void*) (long) count, - (void*)(long) X.RDB$SEGMENT_COUNT, NULL, NULL); + BURP_print(180, X.RDB$INDEX_NAME, count,X.RDB$SEGMENT_COUNT); continue; } @@ -2404,7 +2412,7 @@ break; default: - BURP_print(79, (void *) (long) item, NULL, NULL, NULL, NULL); + BURP_print(79, item); // msg 79 don't understand blob info item %ld return false; } @@ -2772,7 +2780,7 @@ put_asciz(att_file_name, dbb_file); - BURP_verbose(77, dbb_file, (void *) (long) page_size, NULL, NULL, NULL); + BURP_verbose(77, dbb_file, page_size); // msg 77 database %s has a page size of %ld bytes. put(tdgbl, (UCHAR) (att_end)); @@ -3120,14 +3128,16 @@ put(tdgbl, rec_generator); const SSHORT l = PUT_TEXT (att_gen_generator, X.RDB$GENERATOR_NAME); SINT64 value = 0; - if (!tdgbl->gbl_sw_meta) { + + if (!tdgbl->gbl_sw_meta) + { value = get_gen_id (X.RDB$GENERATOR_NAME, l); put_int64 (att_gen_value_int64, value); } + put(tdgbl, att_end); MISC_terminate (X.RDB$GENERATOR_NAME, temp, l, sizeof(temp)); -#pragma FB_COMPILER_MESSAGE("BRS: casting SINT64 to SLONG") - BURP_verbose (165, temp, (void*) (long) value, NULL, NULL, NULL); + BURP_verbose (165, temp, value); // msg 165 writing generator %s value %ld END_FOR; ON_ERROR Index: burp.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/burp/burp.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -b -U3 -r1.2 -r1.3 --- burp.cpp 18 Apr 2005 20:45:55 -0000 1.2 +++ burp.cpp 2 Sep 2005 19:11:10 -0000 1.3 @@ -35,10 +35,7 @@ #include <stdlib.h> #include <string.h> #include <signal.h> -#include <stdarg.h> #include "../jrd/ibase.h" -//#include "../jrd/common.h" -//#include "../jrd/y_ref.h" #include "iberror.h" #include "../jrd/ibsetjmp.h" #include "../jrd/msg_encode.h" @@ -54,9 +51,14 @@ #include "../burp/backu_proto.h" #include "../burp/mvol_proto.h" #include "../burp/resto_proto.h" -//#include "../jrd/gds_proto.h" #include "../jrd/why_proto.h" #include "../jrd/gdsassert.h" +#include "MsgFormat.h" + +#ifndef va_copy +#define va_copy(to,from) to = from +#endif + #ifdef HAVE_CTYPE_H #include <ctype.h> @@ -177,7 +179,8 @@ } #ifdef SUPERSERVER -int BURP_main(Service* service) +//int BURP_main(Service* service) +THREAD_ENTRY_DECLARE BURP_main(THREAD_ENTRY_PARAM arg) { /************************************** * @@ -189,6 +192,8 @@ * Entrypoint for GBAK via services manager. * **************************************/ + + Service *service = (Service*) arg; const int exit_code = common_main(service->svc_argc, service->svc_argv, SVC_output, service); @@ -381,20 +386,20 @@ tgbl ldgbl; tgbl* tdgbl = &ldgbl; SET_THREAD_DATA; - memset((void *) tdgbl, 0, sizeof(tgbl)); + memset(tdgbl, 0, sizeof(tgbl)); tdgbl->output_proc = output_main; const TEXT* usr = (user) ? user : getenv ("ISC_USER"); const TEXT* pswd = (password) ? password : getenv("ISC_PASSWORD"); + size_t usrLen = (usr) ? strlen(usr) : 0; + size_t pswdLen = (usr) ? strlen(pswd) : 0; /*** char *const spb = (char *) gds__alloc((SLONG) (2 + 2 + ((usr) ? strlen(usr) : 0) + 2 + ((pswd) ? strlen(pswd) : 0)) + 2 + length); ***/ - char *spb = (char *) new char((2 + 2 + ((usr) ? strlen(usr) : 0) + - 2 + ((pswd) ? strlen(pswd) : 0)) + - 2 + length); + char *spb = new char[2 + 2 + usrLen + 2 + pswdLen + 2 + length]; /* 'isc_spb_version' 'isc_spb_current_version' 'isc_spb_user_name' @@ -407,17 +412,6 @@ 'length' "options" */ ISC_STATUS_ARRAY status; - - if (spb == NULL) - { - status[0] = isc_arg_gds; - status[1] = isc_virmemexh; - status[2] = isc_arg_end; - BURP_print_status(status); - BURP_print(83, 0, 0, 0, 0, 0); // msg 83 Exiting before completion due to errors - return FINI_ERROR; - } - char* spb_ptr = spb; *spb_ptr++ = isc_spb_version; *spb_ptr++ = isc_spb_current_version; @@ -425,9 +419,9 @@ if (usr) { *spb_ptr++ = isc_spb_user_name; - *spb_ptr++ = strlen(usr); - MEMMOVE(usr, spb_ptr, strlen(usr)); - spb_ptr += strlen(usr); + *spb_ptr++ = usrLen; + memcpy(spb_ptr, usr, usrLen); + spb_ptr += usrLen; if (user) *user = '\0'; } @@ -435,34 +429,25 @@ if (pswd) { *spb_ptr++ = isc_spb_password; - *spb_ptr++ = strlen(pswd); - MEMMOVE(pswd, spb_ptr, strlen(pswd)); - spb_ptr += strlen(pswd); + *spb_ptr++ = pswdLen; + memcpy(spb_ptr, pswd, pswdLen); + spb_ptr += pswdLen; if (password) *password = '\0'; } char *svc_name = new char [strlen(service) + 1]; - if (svc_name == NULL) - { - status[0] = isc_arg_gds; - status[1] = isc_virmemexh; - status[2] = isc_arg_end; - BURP_print_status(status); - delete [] spb; - BURP_print(83, 0, 0, 0, 0, 0); // msg 83 Exiting before completion due to errors - return FINI_ERROR; - } - if (service) { strcpy(svc_name, service); *service = '\0'; } + else + svc_name[0] = 0; -// Fill command line options + // Fill command line options *spb_ptr++ = isc_spb_command_line; TEXT **begin = argv; @@ -624,8 +609,8 @@ if (tdgbl == NULL) { - SVC service; - service = (SVC) output_data; + Service *service; + service = (Service*) output_data; SVC_STARTED(service); return FINI_ERROR; } @@ -677,7 +662,7 @@ { tdgbl->gbl_sw_service_gbak = TRUE; tdgbl->gbl_sw_service_thd = TRUE; - tdgbl->service_blk = (SVC) output_data; + tdgbl->service_blk = output_data; tdgbl->status = tdgbl->service_blk->svc_status; argv++; argc--; @@ -736,9 +721,11 @@ const TEXT* const* const end = argv + argc; ++argv; - while (argv < end) { + while (argv < end) + { TEXT* string = *argv; - int temp = strlen(string) - 1; + int temp = (int) strlen(string) - 1; + if (string[temp] == ',') string[temp] = '\0'; // Modifying argv elements @@ -847,19 +834,22 @@ // password parameter missing tdgbl->gbl_sw_password = *argv++; } - else if (in_sw_tab->in_sw == IN_SW_BURP_USER) { + else if (in_sw_tab->in_sw == IN_SW_BURP_USER) + { if (argv >= end) BURP_error(188, true, 0, 0, 0, 0, 0); // user name parameter missing tdgbl->gbl_sw_user = *argv++; } - else if (in_sw_tab->in_sw == IN_SW_BURP_ROLE) { + else if (in_sw_tab->in_sw == IN_SW_BURP_ROLE) + { if (argv >= end) BURP_error(253, true, 0, 0, 0, 0, 0); // SQL role parameter missing tdgbl->gbl_sw_sql_role = *argv++; } - else if (in_sw_tab->in_sw == IN_SW_BURP_FA) { + else if (in_sw_tab->in_sw == IN_SW_BURP_FA) + { if (argv >= end) BURP_error(182, true, 0, 0, 0, 0, 0); // msg 182 blocking factor parameter missing @@ -869,11 +859,12 @@ // msg 183 expected blocking factor, encountered "%s" argv++; } - else if (in_sw_tab->in_sw == IN_SW_BURP_SE) { - if (argv >= end) { + else if (in_sw_tab->in_sw == IN_SW_BURP_SE) + { + if (argv >= end) BURP_error(273, true, 0, 0, 0, 0, 0); // msg 273: service name parameter missing - } + in_sw_tab->in_sw_state = FALSE; ++argv; // skip a service specification } @@ -888,31 +879,37 @@ ++argv; if (!redirect) BURP_error(4, true, 0, 0, 0, 0, 0); + // msg 4 redirect location for output is not specified const TEXT *p = redirect; TEXT c; const TEXT* q = output_suppress; tdgbl->sw_redirect = NOOUTPUT; - while (c = *p++) { - if (UPPER(c) != *q++) { + + while (c = *p++) + if (UPPER(c) != *q++) + { tdgbl->sw_redirect = REDIRECT; break; } - } - if (tdgbl->sw_redirect == REDIRECT) { // not NOREDIRECT, and not NOOUTPUT + + 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); - if (tmp_outfile) { + + if (tmp_outfile) + { BURP_print(66, redirect, 0, 0, 0, 0); // msg 66 can't open status and error output file %s ib_fclose(tmp_outfile); exit_local(FINI_ERROR, const_cast<tgbl*>(tdgbl)); } - if (! - (tdgbl->output_file = - ib_fopen(redirect, fopen_write_type))) { + + if (! (tdgbl->output_file = 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)); @@ -952,28 +949,36 @@ } // Initialize 'dpb' and 'dpb_length' and cast away volatile + UCHAR* dpb = const_cast<UCHAR*>(tdgbl->dpb_string); *dpb++ = isc_dpb_version1; *dpb++ = isc_dpb_gbak_attach; - *dpb++ = strlen(GDS_VERSION); + *dpb++ = (UCHAR) strlen(GDS_VERSION); + for (const TEXT* gvp = GDS_VERSION; *gvp;) *dpb++ = *gvp++; + tdgbl->dpb_length = dpb - tdgbl->dpb_string; - for (in_sw_tab = burp_in_sw_table; in_sw_tab->in_sw_name; in_sw_tab++) { - if (in_sw_tab->in_sw_state) { - switch (in_sw_tab->in_sw) { + for (in_sw_tab = burp_in_sw_table; in_sw_tab->in_sw_name; in_sw_tab++) + if (in_sw_tab->in_sw_state) + switch (in_sw_tab->in_sw) + { case (IN_SW_BURP_B): if (sw_replace) BURP_error(5, true, 0, 0, 0, 0, 0); + // msg 5 conflicting switches for backup/restore + sw_replace = IN_SW_BURP_B; break; case (IN_SW_BURP_C): if (sw_replace == IN_SW_BURP_B) BURP_error(5, true, 0, 0, 0, 0, 0); + // msg 5 conflicting switches for backup/restore + if (sw_replace != IN_SW_BURP_R) sw_replace = IN_SW_BURP_C; break; @@ -989,6 +994,7 @@ case (IN_SW_BURP_G): if (!tdgbl->dpb_length) *dpb++ = isc_dpb_version1; + *dpb++ = isc_dpb_no_garbage_collect; *dpb++ = 0; tdgbl->dpb_length = dpb - tdgbl->dpb_string; @@ -1001,6 +1007,7 @@ case (IN_SW_BURP_IG): if (!tdgbl->dpb_length) *dpb++ = isc_dpb_version1; + *dpb++ = isc_dpb_damaged; *dpb++ = 1; *dpb++ = 1; @@ -1042,13 +1049,17 @@ case (IN_SW_BURP_PASS): if (!tdgbl->dpb_length) *dpb++ = isc_dpb_version1; + if (!tdgbl->gbl_sw_service_gbak) *dpb++ = isc_dpb_password; else *dpb++ = isc_dpb_password_enc; - *dpb++ = strlen(tdgbl->gbl_sw_password); + + *dpb++ = (UCHAR) strlen(tdgbl->gbl_sw_password); + for (q = tdgbl->gbl_sw_password; *q;) *dpb++ = *q++; + tdgbl->dpb_length = dpb - tdgbl->dpb_string; break; @@ -1076,7 +1087,7 @@ if (!tdgbl->dpb_length) *dpb++ = isc_dpb_version1; *dpb++ = isc_dpb_sql_role_name; - *dpb++ = strlen(tdgbl->gbl_sw_sql_role); + *dpb++ = (UCHAR) strlen(tdgbl->gbl_sw_sql_role); for (q = tdgbl->gbl_sw_sql_role; *q;) *dpb++ = *q++; tdgbl->dpb_length = dpb - tdgbl->dpb_string; @@ -1086,7 +1097,7 @@ if (!tdgbl->dpb_length) *dpb++ = isc_dpb_version1; *dpb++ = isc_dpb_user_name; - *dpb++ = strlen(tdgbl->gbl_sw_user); + *dpb++ = (UCHAR) strlen(tdgbl->gbl_sw_user); for (q = tdgbl->gbl_sw_user; *q;) *dpb++ = *q++; tdgbl->dpb_length = dpb - tdgbl->dpb_string; @@ -1105,8 +1116,6 @@ default: break; } - } - } if (!sw_replace) sw_replace = IN_SW_BURP_B; @@ -1115,55 +1124,62 @@ { if (sw_replace == IN_SW_BURP_B) BURP_error(8, true, 0, 0, 0, 0, 0); + // msg 8 page size is allowed only on restore or create + int temp = tdgbl->gbl_sw_page_size; + { int curr_pg_size = 1024; - while (curr_pg_size <= MAX_PAGE_SIZE) { - if (temp <= curr_pg_size) { + while (curr_pg_size <= MAX_PAGE_SIZE) + { + if (temp <= curr_pg_size) + { temp = curr_pg_size; break; } curr_pg_size <<= 1; } } + if (temp > MAX_PAGE_SIZE) - { BURP_error(3, true, isc_arg_number, reinterpret_cast<void*>(tdgbl->gbl_sw_page_size), 0, NULL, 0, NULL, 0, NULL, 0, NULL); // msg 3 Page size specified (%ld) greater than limit (MAX_PAGE_SIZE bytes) - } - if (temp != tdgbl->gbl_sw_page_size) { - BURP_print(103, (void*)(ULONG) tdgbl->gbl_sw_page_size, - (void*)(SLONG) temp, 0, 0, 0); + + if (temp != tdgbl->gbl_sw_page_size) + { + BURP_print(103, tdgbl->gbl_sw_page_size,temp); // msg 103 page size specified (%ld bytes) rounded up to %ld bytes tdgbl->gbl_sw_page_size = temp; } } - if (tdgbl->gbl_sw_page_buffers) { + if (tdgbl->gbl_sw_page_buffers) if (sw_replace == IN_SW_BURP_B) BURP_error(260, true, 0, 0, 0, 0, 0); // msg 260 page buffers is allowed only on restore or create - } if (!tdgbl->gbl_sw_blk_factor || sw_replace != IN_SW_BURP_B) tdgbl->gbl_sw_blk_factor = 1; if (!file2) BURP_error(10, true, 0, 0, 0, 0, 0); + // msg 10 requires both input and output filenames if (!strcmp(file1, file2)) BURP_error(11, true, 0, 0, 0, 0, 0); + // msg 11 input and output have the same name. Disallowed. time_t clock = time(NULL); strcpy(const_cast<char*>(tdgbl->gbl_backup_start_time), ctime(&clock)); TEXT *nlp = const_cast<char*>(tdgbl->gbl_backup_start_time + strlen(const_cast<const char*>(tdgbl->gbl_backup_start_time)) - 1); + if (*nlp == '\n') *nlp = 0; @@ -1172,14 +1188,14 @@ tdgbl->action->act_file = NULL; tdgbl->action->act_action = ACT_unknown; - action = - open_files(file1, &file2, tdgbl->gbl_sw_verbose, sw_replace, sw_tape); + action = open_files(file1, &file2, tdgbl->gbl_sw_verbose, sw_replace, sw_tape); MVOL_init(tdgbl->io_buffer_size); int result; - switch (action) { + switch (action) + { case (RESTORE): SVC_STARTED(tdgbl->service_blk); result = RESTORE_restore(file1, file2); @@ -1195,6 +1211,7 @@ BURP_abort(); break; } + if (result != FINI_OK && result != FINI_DB_NOT_ONLINE) BURP_abort(); @@ -1210,39 +1227,40 @@ int exit_code = tdgbl->exit_code; // Close the gbak file handles if they still open + for (FIL file = tdgbl->gbl_sw_backup_files; file; file = file->fil_next) { if (file->fil_fd != INVALID_HANDLE_VALUE) close_platf(file->fil_fd); - if (exit_code != 0 - && (tdgbl->action->act_action == ACT_backup_split - || tdgbl->action->act_action == ACT_backup)) - { + + if (exit_code != 0 && + (tdgbl->action->act_action == ACT_backup_split || tdgbl->action->act_action == ACT_backup)) unlink_platf(file->fil_name); } - } // Detach from database to release system resources - if (tdgbl->db_handle != 0) { - close_out_transaction(action, - const_cast<isc_tr_handle*>(&tdgbl->tr_handle)); - close_out_transaction(action, - const_cast<isc_tr_handle*>(&tdgbl->global_trans)); + + if (tdgbl->db_handle != 0) + { + close_out_transaction(action, const_cast<isc_tr_handle*>(&tdgbl->tr_handle)); + close_out_transaction(action, const_cast<isc_tr_handle*>(&tdgbl->global_trans)); if (isc_detach_database(const_cast<ISC_STATUS*>(tdgbl->status_vector), const_cast<isc_db_handle*>(&tdgbl->db_handle))) - { BURP_print_status((ISC_STATUS*) tdgbl->status_vector); } - } // Close the status output file - if (tdgbl->sw_redirect == REDIRECT && tdgbl->output_file != NULL) { + + if (tdgbl->sw_redirect == REDIRECT && tdgbl->output_file != NULL) + { ib_fclose(tdgbl->output_file); tdgbl->output_file = NULL; } // Free all unfreed memory used by Gbak itself - while (tdgbl->head_of_mem_list != NULL) { + + while (tdgbl->head_of_mem_list != NULL) + { UCHAR *mem = tdgbl->head_of_mem_list; tdgbl->head_of_mem_list = *((UCHAR **) tdgbl->head_of_mem_list); gds__free(mem); @@ -1309,6 +1327,7 @@ * Functional description * **************************************/ + #ifdef SUPERSERVER TGBL tdgbl = GET_THREAD_DATA; @@ -1320,8 +1339,10 @@ SVC_STARTED(tdgbl->service_blk); #endif + BURP_msg_partial(256, 0, 0, 0, 0, 0); // msg 256: gbak: ERROR: BURP_msg_put(errcode, arg1, arg2, arg3, arg4, arg5); + if (abort) BURP_abort(); } @@ -1371,12 +1392,14 @@ } -void BURP_msg_partial( USHORT number, +void BURP_msg_partial( USHORT number, ...) + /*** const void* arg1, const void* arg2, const void* arg3, const void* arg4, const void* arg5) + ***/ { /************************************** * @@ -1389,24 +1412,33 @@ * format it, and print it without a newline. * **************************************/ + + va_list args; + va_start (args, number); TEXT buffer[256]; + /*** 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), static_cast<const char*>(arg4), static_cast<const char*>(arg5)); + ***/ + + MsgFormat::format(burp_msg_fac, number, args, sizeof(buffer), buffer); burp_output("%s", buffer); } -void BURP_msg_put( USHORT number, +void BURP_msg_put( USHORT number, ...) + /*** const void* arg1, const void* arg2, const void* arg3, const void* arg4, const void* arg5) + ***/ { /************************************** * @@ -1418,26 +1450,33 @@ * Retrieve a message from the error file, format it, and print it. * **************************************/ + va_list args; + va_start (args, number); TEXT buffer[256]; + /*** 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), static_cast<const char*>(arg4), static_cast<const char*>(arg5)); + ***/ + + MsgFormat::format(burp_msg_fac, number, args, sizeof(buffer), buffer); translate_cp(buffer); burp_output("%s\n", buffer); } -void BURP_msg_get( USHORT number, - TEXT* output_msg, +void BURP_msg_get( USHORT number, TEXT* output_msg, ...) + /*** const void* arg1, const void* arg2, const void* arg3, const void* arg4, const void* arg5) + ***/ { /************************************** * @@ -1449,14 +1488,19 @@ * Retrieve a message from the error file, format it and copy it to the buffer * **************************************/ + va_list args; + va_start (args, output_msg); TEXT buffer[128]; + /*** 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), static_cast<const char*>(arg4), static_cast<const char*>(arg5)); + ***/ + MsgFormat::format(burp_msg_fac, number, args, sizeof(buffer), buffer); strcpy(output_msg, buffer); } @@ -1480,12 +1524,35 @@ } -void BURP_print(USHORT number, + +void BURP_print(USHORT number, ...) + /*** const void* arg1, const void* arg2, const void* arg3, const void* arg4, const void* arg5) + ***/ +{ +/************************************** + * + * B U R P _ p r i n t + * + ************************************** + * + * Functional description + * Display a formatted error message + * in a way that VMS or civilized systems + * will accept. + * + **************************************/ + + va_list args; + va_start (args, number); + BURP_print(args, number); +} + +void BURP_print(va_list stuff, USHORT number) { /************************************** * @@ -1500,8 +1567,15 @@ * **************************************/ - BURP_msg_partial(169, 0, 0, 0, 0, 0); // msg 169: gbak: - BURP_msg_put(number, arg1, arg2, arg3, arg4, arg5); + va_list args; + va_copy (args, stuff); + + BURP_msg_partial(169); // msg 169: gbak: + //BURP_msg_put(number, arg1, arg2, arg3, arg4, arg5); + TEXT buffer[128]; + MsgFormat::format(burp_msg_fac, number, args, sizeof(buffer), buffer); + translate_cp(buffer); + burp_output("%s\n", buffer); } @@ -1518,12 +1592,17 @@ * to allow redirecting output. * **************************************/ - if (status_vector) { + + if (status_vector) + { ISC_STATUS* vector = status_vector; + #ifdef SUPERSERVER TGBL tdgbl = GET_THREAD_DATA; ISC_STATUS* status = tdgbl->service_blk->svc_status; - if (status != status_vector) { + + if (status != status_vector) + { int i = 0; while (*status && (++i < ISC_STATUS_LENGTH)) status++; @@ -1533,11 +1612,15 @@ #endif SCHAR s[1024]; - if (isc_interprete(s, &vector)) { + + if (isc_interprete(s, &vector)) + { translate_cp(s); BURP_msg_partial(256, 0, 0, 0, 0, 0); // msg 256: gbak: ERROR: burp_output("%s\n", s); - while (isc_interprete(s, &vector)) { + + while (isc_interprete(s, &vector)) + { translate_cp(s); BURP_msg_partial(256, 0, 0, 0, 0, 0); // msg 256: gbak: ERROR: burp_output(" %s\n", s); @@ -1560,18 +1643,27 @@ * to allow redirecting output. * **************************************/ - if (status_vector) { + + if (status_vector) + { // skip the error, assert that one does not exist + fb_assert(status_vector[0] == isc_arg_gds); fb_assert(status_vector[1] == 0); + // print the warning message + ISC_STATUS* vector = &status_vector[2]; SCHAR s[1024]; - if (isc_interprete(s, &vector)) { + + if (isc_interprete(s, &vector)) + { translate_cp(s); BURP_msg_partial(255, 0, 0, 0, 0, 0); // msg 255: gbak: WARNING: burp_output("%s\n", s); - while (isc_interprete(s, &vector)) { + + while (isc_interprete(s, &vector)) + { translate_cp(s); BURP_msg_partial(255, 0, 0, 0, 0, 0); // msg 255: gbak: WARNING: burp_output(" %s\n", s); @@ -1581,12 +1673,14 @@ } -void BURP_verbose(USHORT number, +void BURP_verbose(USHORT number, ...) + /*** const void* arg1, const void* arg2, const void* arg3, const void* arg4, const void* arg5) + ***/ { /************************************** * @@ -1600,10 +1694,13 @@ * user defined yieding function. * **************************************/ + + va_list args; + va_start (args, number); TGBL tdgbl = GET_THREAD_DATA; if (tdgbl->gbl_sw_verbose) - BURP_print(number, arg1, arg2, arg3, arg4, arg5); + BURP_print(args, number); else burp_output("%s",""); } @@ -1704,7 +1801,7 @@ TGBL tdgbl = GET_THREAD_DATA; ISC_STATUS* status_vector = tdgbl->status; -// try to attach the database using the first file_name + // try to attach the database using the first file_name if (sw_replace != IN_SW_BURP_C && sw_replace != IN_SW_BURP_R) if (!(isc_attach_database(status_vector, @@ -1717,29 +1814,35 @@ if (sw_replace != IN_SW_BURP_B) { // msg 13 REPLACE specified, but the first file %s is a database BURP_error(13, true, file1, 0, 0, 0, 0); - if (isc_detach_database(status_vector, &tdgbl->db_handle)) { + + if (isc_detach_database(status_vector, &tdgbl->db_handle)) BURP_print_status(status_vector); - } return QUIT; } - if (tdgbl->gbl_sw_version) { + + if (tdgbl->gbl_sw_version) + { // msg 139 Version(s) for database "%s" BURP_print(139, file1, 0, 0, 0, 0); isc_version(&tdgbl->db_handle, BURP_output_version, (void*) "\t%s\n"); } + if (sw_verbose) BURP_print(166, file1, 0, 0, 0, 0); // msg 166: readied database %s for backup } else if (sw_replace == IN_SW_BURP_B || (status_vector[1] != isc_io_error - && status_vector[1] != isc_bad_db_format)) { + && status_vector[1] != isc_bad_db_format)) + { BURP_print_status(status_vector); return QUIT; } FIL fil = 0; - if (sw_replace == IN_SW_BURP_B) { + + if (sw_replace == IN_SW_BURP_B) + { // Now it is safe to skip a db file tdgbl->gbl_sw_backup_files = tdgbl->gbl_sw_files->fil_next; @@ -1748,6 +1851,7 @@ gbak_action flag = BACKUP; tdgbl->action->act_action = ACT_backup; + for (fil = tdgbl->gbl_sw_files; fil; fil = fil->fil_next) { // adjust the file size first @@ -1774,13 +1878,11 @@ } if ((fil->fil_seq = ++(tdgbl->action->act_total)) >= 2) - { tdgbl->action->act_action = ACT_backup_split; - } + if (sw_verbose) - { BURP_print(75, fil->fil_name, 0, 0, 0, 0); // msg 75 creating file %s - } + if (!strcmp(fil->fil_name, "stdout")) { if (tdgbl->action->act_total >= 2 || fil->fil_next) @@ -1790,6 +1892,7 @@ flag = QUIT; break; } + /* We ignore SIGPIPE so that we can report an IO error when we * try to write to the broken pipe. */ @@ -1810,7 +1913,6 @@ #endif // WIN_NT { - BURP_error(65, false, isc_arg_string, fil->fil_name, 0, NULL, 0, NULL, 0, NULL, 0, NULL); // msg 65 can't open backup file %s @@ -1829,18 +1931,17 @@ break; } else - { fil->fil_length = MAX_LENGTH; // Write as much as possible to the last file } - } + if (fil->fil_length < MIN_SPLIT_SIZE) { BURP_error(271, true, isc_arg_number, - reinterpret_cast<void*>(fil->fil_length), + (void*)(IPTR) fil->fil_length, //reinterpret_cast<void*>(fil->fil_length), isc_arg_number, - reinterpret_cast<void*>(MIN_SPLIT_SIZE), + (void*)(IPTR) MIN_SPLIT_SIZE, //reinterpret_cast<void*>(MIN_SPLIT_SIZE), 0, NULL, 0, NULL, 0, NULL); // msg file size given (%d) is less than minimum allowed (%d) flag = QUIT; @@ -1856,10 +1957,8 @@ else { if (isc_detach_database(status_vector, &tdgbl->db_handle)) - { BURP_print_status(status_vector); } - } return flag; } Index: burp.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/burp/burp.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -b -U3 -r1.1.1.1 -r1.2 --- burp.h 20 Jan 2005 19:36:20 -0000 1.1.1.1 +++ burp.h 2 Sep 2005 19:11:10 -0000 1.2 @@ -818,9 +818,9 @@ int exit_code; UCHAR* head_of_mem_list; pfn_svc_output output_proc; - svc* output_data; + Service *output_data; IB_FILE* output_file; - SVC service_blk; + Service *service_blk; /* * Link list of global fields that were converted from V3 sub_type * to V4 char_set_id/collate_id. Needed for local fields conversion. Index: burp.vcproj =================================================================== RCS file: /cvsroot/firebird/vulcan/src/burp/burp.vcproj,v retrieving revision 1.3 retrieving revision 1.4 diff -b -U3 -r1.3 -r1.4 --- burp.vcproj 20 Jul 2005 17:26:57 -0000 1.3 +++ burp.vcproj 2 Sep 2005 19:11:10 -0000 1.4 @@ -223,6 +223,9 @@ </FileConfiguration> </File> <File + RelativePath="..\jrd\MsgFormat.cpp"> + </File> + <File RelativePath="..\jrd\Mutex.cpp"> </File> <File @@ -355,6 +358,9 @@ RelativePath="misc_proto.h"> </File> <File + RelativePath="..\jrd\MsgFormat.h"> + </File> + <File RelativePath="..\jrd\Mutex.h"> </File> <File Index: burp_proto.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/burp/burp_proto.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -b -U3 -r1.1.1.1 -r1.2 --- burp_proto.h 20 Jan 2005 19:36:42 -0000 1.1.1.1 +++ burp_proto.h 2 Sep 2005 19:11:10 -0000 1.2 @@ -24,8 +24,11 @@ #ifndef BURP_BURP_PROTO_H #define BURP_BURP_PROTO_H +#include <stdarg.h> + #ifdef SUPERSERVER -int BURP_main(Service* service); +//int BURP_main(Service* service); +THREAD_ENTRY_DECLARE BURP_main(THREAD_ENTRY_PARAM arg); #endif void BURP_abort(void); @@ -34,16 +37,22 @@ void BURP_error(USHORT, bool, const void*, const void*, const void*, const void*, const void*); void BURP_print_status(ISC_STATUS*); void BURP_error_redirect(ISC_STATUS*, USHORT, const void*, const void*); -void BURP_msg_partial(USHORT, const void*, const void*, const void*, - const void*, const void*); -void BURP_msg_put(USHORT, const void*, const void*, const void*, - const void*, const void*); -void BURP_msg_get(USHORT, TEXT*, const void*, const void*, const void*, - const void*, const void*); + +//void BURP_msg_partial(USHORT, const void*, const void*, const void*, const void*, const void*); +//void BURP_msg_put(USHORT, const void*, const void*, const void*, const void*, const void*); +//void BURP_msg_get(USHORT, TEXT*, const void*, const void*, const void*, const void*, const void*); +//void BURP_print(USHORT, const void*, const void*, const void*, const void*, const void*); +//void BURP_verbose(USHORT, const void*, const void*, const void*, const void*, const void*); + +void BURP_msg_partial(USHORT, ...); +void BURP_msg_put(USHORT, ...); +void BURP_msg_get(USHORT, TEXT*, ...); +void BURP_print(USHORT, ...); +void BURP_print(va_list stuff, USHORT); +void BURP_verbose(USHORT, ...); + void BURP_output_version(void*, const TEXT*); -void BURP_print(USHORT, const void*, const void*, const void*, const void*, const void*); void BURP_print_warning(ISC_STATUS*); -void BURP_verbose(USHORT, const void*, const void*, const void*, const void*, const void*); #endif // BURP_BURP_PROTO_H Index: mvol.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/burp/mvol.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -b -U3 -r1.1.1.1 -r1.2 --- mvol.cpp 20 Jan 2005 19:36:23 -0000 1.1.1.1 +++ mvol.cpp 2 Sep 2005 19:11:10 -0000 1.2 @@ -617,9 +617,8 @@ tdgbl->action->act_file->fil_fd = INVALID_HANDLE_VALUE; BURP_print(272, tdgbl->action->act_file->fil_name, - (void*) tdgbl->action->act_file->fil_length, - tdgbl->action->act_file->fil_next->fil_name, - 0, 0); // msg 272 Warning -- free disk space exhausted for file %s, the rest of the bytes (%d) will be written to file %s + tdgbl->action->act_file->fil_length, + tdgbl->action->act_file->fil_next->fil_name); // msg 272 Warning -- free disk space exhausted for file %s, the rest of the bytes (%d) will be written to file %s tdgbl->action->act_file->fil_next->fil_length += tdgbl->action->act_file->fil_length; tdgbl->action->act_file = @@ -755,7 +754,7 @@ TGBL tdgbl = GET_THREAD_DATA; gds__msg_format(0, 12, type, sizeof(name), name, 0, 0, 0, 0, 0); - BURP_print(80, name, (void*) (ULONG) attribute, NULL, NULL, NULL); + BURP_print(80, name, attribute); // msg 80 don't recognize %s attribute %ld -- continuing SSHORT l = get(tdgbl); if (l) @@ -910,8 +909,7 @@ } else { - BURP_msg_put(261, (void*) (SLONG) (tdgbl->mvol_volume_count), - new_file, 0, 0, 0); + BURP_msg_put(261, tdgbl->mvol_volume_count,new_file); // Starting with volume #vol_count, new_file BURP_verbose(75, new_file, 0, 0, 0, 0); // msg 75 creating file %s } @@ -929,8 +927,7 @@ } else { - BURP_msg_put(261, (void*) (SLONG) (tdgbl->mvol_volume_count), - new_file, 0, 0, 0); + BURP_msg_put(261, tdgbl->mvol_volume_count, new_file); // Starting with volume #vol_count, new_file BURP_verbose(100, new_file, 0, 0, 0, 0); // msg 100 opened file %s } @@ -977,21 +974,20 @@ if (strlen(tdgbl->mvol_old_file) > 0) { - BURP_msg_get(225, msg, (void*) (SLONG) (tdgbl->mvol_volume_count - 1), - tdgbl->mvol_old_file, 0, 0, 0); + BURP_msg_get(225, msg, tdgbl->mvol_volume_count - 1, tdgbl->mvol_old_file); ib_fprintf(term_out, msg); - BURP_msg_get(226, msg, 0, 0, 0, 0, 0); + BURP_msg_get(226, msg); // \tPress return to reopen that file, or type a new\n\tname // followed by return to open a different file.\n ib_fprintf(term_out, msg); } else // First volume { - BURP_msg_get(227, msg, 0, 0, 0, 0, 0); + BURP_msg_get(227, msg); // Type a file name to open and hit return ib_fprintf(term_out, msg); } - BURP_msg_get(228, msg, 0, 0, 0, 0, 0); // " Name: " + BURP_msg_get(228, msg); // " Name: " ib_fprintf(term_out, msg); if (tdgbl->gbl_sw_service_gbak) @@ -1208,11 +1204,10 @@ case att_backup_volume: temp = get_numeric(); + if (temp != tdgbl->mvol_volume_count) { - BURP_msg_get(232, msg, - (void*) (SLONG) (tdgbl->mvol_volume_count), - (void*) (SLONG) temp, 0, 0, 0); + BURP_msg_get(232, msg, tdgbl->mvol_volume_count, temp); // Expected volume number %d, found volume %d\n ib_printf(msg); return false; Index: restore.epp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/burp/restore.epp,v retrieving revision 1.3 retrieving revision 1.4 diff -b -U3 -r1.3 -r1.4 --- restore.epp 27 Apr 2005 01:52:01 -0000 1.3 +++ restore.epp 2 Sep 2005 19:11:10 -0000 1.4 @@ -678,15 +678,14 @@ general_on_error (); END_ERROR; MISC_release_request_silent(req_handle1); - BURP_verbose (57, file->fil_name, (void*) (long) start, NULL, NULL, NULL); + BURP_verbose (57, file->fil_name, start); // msg 57 adding file %s, starting at page %ld } else if (((signed long )file->fil_length) >= start - 1) file->fil_length -= start - 1; else { - BURP_print (96, (void*) (long) file->fil_length, (void*) (long) (start - 1), NULL, - NULL, NULL); + BURP_print (96, file->fil_length, start - 1); // msg 96 length given for initial file (%ld) is less than minimum (%ld) file->fil_length = 0; } @@ -754,13 +753,13 @@ { skip_count = tdgbl->gbl_sw_skip_count; get_skip(tdgbl, skip_count); - BURP_print (203, (void*) (long) skip_count, (void*) (long) bad_attr, NULL, NULL, NULL); + BURP_print (203, skip_count, bad_attr); //msg 203: skipped %d bytes after reading a bad attribute %d } else { ++skip_count; - BURP_print (205, (void*) (long) skip_count, (void*) (long) bad_attr, NULL, NULL, NULL); + BURP_print (205, skip_count, bad_attr); // msg 205: skipped %d bytes looking for next valid attribute, encountered attribute %d } scan_next_attr = AFTER_SKIP; @@ -891,8 +890,7 @@ if (tdgbl->gbl_sw_page_size && (tdgbl->gbl_sw_page_size < page_size)) { - BURP_print (110, (void*) (long) page_size, - (void*) (long) tdgbl->gbl_sw_page_size, NULL, NULL, NULL); + BURP_print (110, page_size, tdgbl->gbl_sw_page_size); // msg 110 Reducing the database page size from %ld bytes to %ld bytes } @@ -1021,7 +1019,7 @@ isc_version(&DB, BURP_output_version, (void*) "\t%s\n"); } - BURP_verbose (74, file_name, (void*) (long) page_size, NULL, NULL, NULL); + BURP_verbose (74, file_name, page_size); // msg 74 created database %s, page_size %ld bytes } @@ -1054,8 +1052,7 @@ { if (end - p < count) { - BURP_print (202, (void*) (long) count, - (void*) (long) (end - p), NULL, NULL, NULL); + BURP_print (202, count, end - p); // msg 202: adjusting a decompression length error: invalid length %d was adjusted to %d count = end - p; } @@ -1065,8 +1062,7 @@ { if (end + count < p) { - BURP_print(202, (void*) (long) count, - (void*) (long) (p - end), NULL, NULL, NULL); + BURP_print(202, count, p - end); // msg 202: adjusting a decompression length error: invalid length %d was adjusted to %d count = p - end; } @@ -1237,7 +1233,7 @@ default: // msg 79 don't understand blob info item %ld - BURP_print (79, (void*) (long) item, NULL, NULL, NULL, NULL); + BURP_print (79, item); // CVC: do you return, without closing the blob, dear function??? if (isc_close_blob (status_vector, &blob)) BURP_error_redirect (status_vector, 23, NULL, NULL); @@ -1288,7 +1284,7 @@ const SLONG id_person_len = (SLONG) *from; const UCHAR* c_1 = (UCHAR*) owner_nm; - const UCHAR owner_nm_len = strlen(owner_nm); + const UCHAR owner_nm_len = (UCHAR) strlen(owner_nm); UCHAR* new_buffer = BURP_alloc (length - id_person_len + owner_nm_len); @@ -2393,7 +2389,7 @@ break; default: - BURP_error (26, true, isc_arg_number, (void*) (long) field->fld_type, + BURP_error (26, true, isc_arg_number, (void*) (IPTR) field->fld_type, 0, NULL, 0, NULL, 0, NULL, 0, NULL); // msg 26 datatype %ld not understood break; @@ -2509,8 +2505,8 @@ old_length = recompute_length (relation); if (l != old_length) { - BURP_error(40, true, isc_arg_number, (void*)(long)length, - isc_arg_number, (void*) (long) l, + BURP_error(40, true, isc_arg_number, (void*)(IPTR)length, + isc_arg_number, (void*) (IPTR) l, 0, NULL, 0, NULL, 0, NULL); // msg 40 wrong length record, expected %ld encountered %ld } @@ -2560,7 +2556,7 @@ records++; if ((records % RESTORE_VERBOSE_INTERVAL) == 0) - BURP_verbose(107, (void*) (long) records, NULL, NULL, NULL, NULL); + BURP_verbose(107, records); for (field = relation->rel_fields; field; field = field->fld_next) if ((field->fld_type == blr_blob) || (field->fld_flags & FLD_array)) @@ -2684,7 +2680,7 @@ if (gds_status[1]) EXEC SQL SET TRANSACTION; } - BURP_verbose (107, (void*) (long) records, NULL, NULL, NULL, NULL); + BURP_verbose (107, records); // msg 107 %ld records restored return record; @@ -6142,7 +6138,7 @@ break; } - BURP_verbose (106, (void*) (long) records, NULL, NULL, NULL, NULL); + BURP_verbose (106, records); // msg 106 %ld records ignored return record; @@ -6312,7 +6308,7 @@ if (tdgbl->RESTORE_format < 1 || tdgbl->RESTORE_format > ATT_BACKUP_FORMAT) { - BURP_error(44, true, isc_arg_number, (void*)(long)tdgbl->RESTORE_format, + BURP_error(44, true, isc_arg_number, (void*)(IPTR)tdgbl->RESTORE_format, 0, NULL, 0, NULL, 0, NULL, 0, NULL); // msg 44 Expected backup version 1, 2, or 3. Found %ld } @@ -6333,7 +6329,7 @@ USHORT db_version = check_db_version(); if (db_version < DB_VERSION_CURRENT) { - BURP_error(51, true, isc_arg_number, (void*) (long) db_version, + BURP_error(51, true, isc_arg_number, (void*) (IPTR) db_version, 0, NULL, 0, NULL, 0, NULL, 0, NULL); // msg 51 database format %ld is too old to restore to } @@ -6679,7 +6675,7 @@ if (!value) { #pragma FB_COMPILER_MESSAGE("BRS: casting SINT64 to SLONG") - BURP_verbose (185, gen_name, (void*) (long) value, NULL, NULL, NULL); + BURP_verbose (185, gen_name, value); // msg 185 restoring generator %s value: %ld return; } @@ -6759,7 +6755,7 @@ } #pragma FB_COMPILER_MESSAGE("BRS: casting SINT64 to SLONG") - BURP_verbose (185, gen_name, (void*) (long) value, NULL, NULL, NULL); + BURP_verbose (185, gen_name, value); // msg 185 restoring generator %s value: %ld isc_release_request (status_vector, &gen_id_reqh); @@ -6778,7 +6774,7 @@ * Stuff a name input a BLR string -- byte count first. * **************************************/ - stuff(ptr, strlen (string)); + stuff(ptr, (UCHAR) strlen (string)); while (*string) stuff(ptr, *string++); |