mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 19:23:03 +01:00
Style.
This commit is contained in:
parent
695e60dd0f
commit
6e61ef99e8
@ -2783,6 +2783,7 @@ void write_collations()
|
||||
MISC_release_request_silent(req_handle1);
|
||||
}
|
||||
|
||||
|
||||
void write_database( const TEXT* dbb_file)
|
||||
{
|
||||
/**************************************
|
||||
@ -3834,6 +3835,7 @@ void write_ref_constraints()
|
||||
MISC_release_request_silent(req_handle1);
|
||||
}
|
||||
|
||||
|
||||
void write_rel_constraints()
|
||||
{
|
||||
/**************************************
|
||||
@ -3874,6 +3876,7 @@ void write_rel_constraints()
|
||||
MISC_release_request_silent(req_handle1);
|
||||
}
|
||||
|
||||
|
||||
void write_relations()
|
||||
{
|
||||
/**************************************
|
||||
@ -4096,6 +4099,7 @@ void write_shadow_files()
|
||||
MISC_release_request_silent(req_handle1);
|
||||
}
|
||||
|
||||
|
||||
void write_sql_roles()
|
||||
{
|
||||
/**************************************
|
||||
@ -4158,6 +4162,7 @@ void write_sql_roles()
|
||||
MISC_release_request_silent(req_handle1);
|
||||
}
|
||||
|
||||
|
||||
void write_mapping()
|
||||
{
|
||||
/**************************************
|
||||
@ -4201,6 +4206,7 @@ void write_mapping()
|
||||
MISC_release_request_silent(req_handle);
|
||||
}
|
||||
|
||||
|
||||
void write_triggers()
|
||||
{
|
||||
/**************************************
|
||||
@ -4400,6 +4406,7 @@ void write_trigger_messages()
|
||||
MISC_release_request_silent(req_handle1);
|
||||
}
|
||||
|
||||
|
||||
void write_types()
|
||||
{
|
||||
/**************************************
|
||||
|
@ -76,10 +76,7 @@ static xdr_t::xdr_ops burp_ops =
|
||||
const int increment = 1024;
|
||||
|
||||
|
||||
ULONG CAN_encode_decode(burp_rel* relation,
|
||||
lstring* buffer,
|
||||
UCHAR* data,
|
||||
bool_t direction)
|
||||
ULONG CAN_encode_decode(burp_rel* relation, lstring* buffer, UCHAR* data, bool_t direction)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -213,11 +210,7 @@ ULONG CAN_encode_decode(burp_rel* relation,
|
||||
}
|
||||
|
||||
|
||||
ULONG CAN_slice(lstring* buffer,
|
||||
lstring* slice,
|
||||
bool_t direction,
|
||||
//USHORT sdl_length,
|
||||
UCHAR* sdl)
|
||||
ULONG CAN_slice(lstring* buffer, lstring* slice, bool_t direction, /*USHORT sdl_length,*/ UCHAR* sdl)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -463,7 +456,6 @@ static bool_t expand_buffer(XDR* xdrs)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool_t xdr_datum(XDR* xdrs, DSC* desc, UCHAR* buffer)
|
||||
{
|
||||
/**************************************
|
||||
@ -564,6 +556,7 @@ static bool_t xdr_datum(XDR* xdrs, DSC* desc, UCHAR* buffer)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static bool_t xdr_quad(XDR* xdrs, SLONG* ip)
|
||||
{
|
||||
/**************************************
|
||||
@ -601,7 +594,6 @@ static bool_t xdr_quad(XDR* xdrs, SLONG* ip)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int xdr_init(XDR* xdrs, lstring* buffer, enum xdr_op x_op)
|
||||
{
|
||||
/**************************************
|
||||
@ -625,11 +617,7 @@ static int xdr_init(XDR* xdrs, lstring* buffer, enum xdr_op x_op)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool_t xdr_slice(XDR* xdrs,
|
||||
lstring* slice,
|
||||
//USHORT sdl_length,
|
||||
const UCHAR* sdl)
|
||||
static bool_t xdr_slice(XDR* xdrs, lstring* slice, /*USHORT sdl_length,*/ const UCHAR* sdl)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -692,7 +680,8 @@ static bool_t xdr_slice(XDR* xdrs,
|
||||
const ULONG n = slice->lstr_length / desc->dsc_length;
|
||||
UCHAR* p = slice->lstr_address;
|
||||
|
||||
for (UCHAR* const end = p + n * desc->dsc_length; p < end; p += desc->dsc_length) {
|
||||
for (UCHAR* const end = p + n * desc->dsc_length; p < end; p += desc->dsc_length)
|
||||
{
|
||||
if (!xdr_datum(xdrs, desc, p)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -96,7 +96,8 @@ void MISC_free_burp( void *free)
|
||||
// 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) {
|
||||
if (*ptr == (UCHAR *) block)
|
||||
{
|
||||
// Found it - remove it from the list
|
||||
*ptr = *block;
|
||||
|
||||
@ -180,14 +181,16 @@ void MISC_terminate(const TEXT* from, TEXT* to, ULONG length, ULONG max_length)
|
||||
**************************************/
|
||||
|
||||
fb_assert(max_length != 0);
|
||||
if (length) {
|
||||
if (length)
|
||||
{
|
||||
length = MIN(length, max_length - 1);
|
||||
do {
|
||||
*to++ = *from++;
|
||||
} while (--length);
|
||||
*to++ = '\0';
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
while (max_length-- && (*to++ = *from++));
|
||||
*--to = '\0';
|
||||
}
|
||||
|
@ -173,10 +173,7 @@ void MVOL_init(ULONG io_buf_size)
|
||||
//
|
||||
// Read init record from backup file
|
||||
//
|
||||
void MVOL_init_read(const char* file_name,
|
||||
USHORT* format,
|
||||
int* cnt,
|
||||
UCHAR** ptr)
|
||||
void MVOL_init_read(const char* file_name, USHORT* format, int* cnt, UCHAR** ptr)
|
||||
{
|
||||
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
|
||||
|
||||
@ -219,9 +216,7 @@ void MVOL_init_read(const char* file_name,
|
||||
//
|
||||
// Write init record to the backup file
|
||||
//
|
||||
void MVOL_init_write(const char* file_name,
|
||||
int* cnt,
|
||||
UCHAR** ptr)
|
||||
void MVOL_init_write(const char* file_name, int* cnt, UCHAR** ptr)
|
||||
{
|
||||
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
|
||||
|
||||
@ -854,7 +849,8 @@ static DESC next_volume( DESC handle, ULONG mode, bool full_buffer)
|
||||
{
|
||||
// We aim to keep our descriptors clean
|
||||
|
||||
if (new_desc != INVALID_HANDLE_VALUE) {
|
||||
if (new_desc != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
close_platf(new_desc);
|
||||
new_desc = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
@ -990,8 +986,8 @@ static void prompt_for_name(SCHAR* name, int length)
|
||||
strcpy(name, tdgbl->mvol_old_file);
|
||||
break;
|
||||
}
|
||||
else // reprompt
|
||||
continue;
|
||||
|
||||
continue; // reprompt
|
||||
}
|
||||
|
||||
// OK, its a file name, strip the carriage return
|
||||
|
@ -2786,8 +2786,7 @@ rec_type get_data(BurpGlobals* tdgbl, burp_rel* relation)
|
||||
{
|
||||
fb_print_blr(blr_buffer, blr_length, NULL, NULL, 0);
|
||||
if (!tdgbl->gbl_sw_incremental)
|
||||
BURP_error_redirect (status_vector, 27);
|
||||
// msg 27 isc_compile_request failed
|
||||
BURP_error_redirect (status_vector, 27); // msg 27 isc_compile_request failed
|
||||
else
|
||||
{
|
||||
BURP_print_status (status_vector);
|
||||
@ -2799,8 +2798,7 @@ rec_type get_data(BurpGlobals* tdgbl, burp_rel* relation)
|
||||
BURP_free (blr_buffer);
|
||||
SSHORT* buffer = NULL;
|
||||
|
||||
BURP_verbose (124, relation->rel_name);
|
||||
// msg 124 restoring data for relation %s
|
||||
BURP_verbose (124, relation->rel_name); // msg 124 restoring data for relation %s
|
||||
|
||||
lstring data;
|
||||
data.lstr_allocated = 0;
|
||||
@ -2813,8 +2811,7 @@ rec_type get_data(BurpGlobals* tdgbl, burp_rel* relation)
|
||||
while (true)
|
||||
{
|
||||
if (get(tdgbl) != att_data_length)
|
||||
BURP_error_redirect (NULL, 39);
|
||||
// msg 39 expected record length
|
||||
BURP_error_redirect (NULL, 39); // msg 39 expected record length
|
||||
USHORT l = (USHORT) get_numeric(tdgbl);
|
||||
if (!tdgbl->gbl_sw_transportable && l != length)
|
||||
{
|
||||
@ -2854,8 +2851,7 @@ rec_type get_data(BurpGlobals* tdgbl, burp_rel* relation)
|
||||
else
|
||||
p = reinterpret_cast<UCHAR*>(buffer);
|
||||
if (get(tdgbl) != att_data_data)
|
||||
BURP_error_redirect (NULL, 41);
|
||||
// msg 41 expected data attribute
|
||||
BURP_error_redirect (NULL, 41); // msg 41 expected data attribute
|
||||
|
||||
if (tdgbl->gbl_sw_compress)
|
||||
decompress (tdgbl, p, l);
|
||||
@ -8495,10 +8491,7 @@ USHORT get_view_base_relation_count(BurpGlobals* tdgbl,
|
||||
}
|
||||
|
||||
|
||||
void store_blr_gen_id(BurpGlobals* tdgbl,
|
||||
const TEXT* gen_name, // TEXT GDS_NAME[GDS_NAME_LEN]
|
||||
SINT64 value,
|
||||
const ISC_QUAD* gen_desc)
|
||||
void store_blr_gen_id(BurpGlobals* tdgbl, const TEXT* gen_name, SINT64 value, const ISC_QUAD* gen_desc)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
|
@ -94,7 +94,7 @@ struct header_rec
|
||||
};
|
||||
|
||||
const size_t header_rec_len = sizeof(header_rec);
|
||||
static const char *header_rec_name = "InterBase/gsplit, ";
|
||||
static const char* const header_rec_name = "InterBase/gsplit, ";
|
||||
|
||||
|
||||
// backup files structure
|
||||
@ -118,7 +118,7 @@ static int final_flush_io_buff(const UCHAR*, SLONG, FILE_DESC);
|
||||
static int final_read_and_write(FILE_DESC, FILE_DESC, const TEXT*, SLONG, UCHAR**, bool*);
|
||||
static int flush_io_buff(const UCHAR*, SLONG, FILE_DESC, SINT64, SLONG*, bool*);
|
||||
static int get_file_name(const SCHAR*, SINT64, b_fil**);
|
||||
static int get_file_size(const SCHAR*, const SCHAR *, SINT64*);
|
||||
static int get_file_size(const SCHAR*, const SCHAR*, SINT64*);
|
||||
static int get_function_option(const SCHAR*, gsplit_option*, const SCHAR*, const Switches&);
|
||||
static int gen_multy_bakup_files(b_fil*, FILE_DESC, SLONG);
|
||||
static int set_hdr_str(TEXT*, const TEXT*, SLONG, SLONG);
|
||||
@ -138,11 +138,12 @@ static int write_header(const b_fil*, header_rec, FILE_DESC, TEXT*);
|
||||
******************************************************
|
||||
*/
|
||||
|
||||
int main( int argc, char *argv[])
|
||||
int main( int argc, char* argv[])
|
||||
{
|
||||
const SCHAR *prog_name = argv[0];
|
||||
const SCHAR* const prog_name = argv[0];
|
||||
|
||||
if (argc < 2) {
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf(stderr, "%s: No Command Line Option Specified\n", argv[0]);
|
||||
print_clo(prog_name);
|
||||
return FB_FAILURE;
|
||||
@ -172,32 +173,38 @@ int main( int argc, char *argv[])
|
||||
while (argv < end)
|
||||
{
|
||||
string = *argv;
|
||||
if (*string == '-') {
|
||||
if (*string == '-')
|
||||
{
|
||||
argv++;
|
||||
ret_cd = get_function_option(prog_name, &sw_replace, string, switches);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
free_file_list(file_list);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
} // end of processing (*string == '-')
|
||||
else { // processing function specific command line options
|
||||
else
|
||||
{ // processing function specific command line options
|
||||
|
||||
switch (sw_replace)
|
||||
{
|
||||
case IN_SW_SPIT_SP:
|
||||
if (!file_nm_sw)
|
||||
{ // process file name
|
||||
{
|
||||
// process file name
|
||||
file_size = 0;
|
||||
file_num = file_num + 1;
|
||||
|
||||
if (file_num > MAX_NUM_OF_FILES) {
|
||||
if (file_num > MAX_NUM_OF_FILES)
|
||||
{
|
||||
fprintf(stderr, "%s: maximum of files is %d\n", prog_name, MAX_NUM_OF_FILES);
|
||||
print_clo(prog_name);
|
||||
free_file_list(file_list);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
|
||||
if (strlen(string) > MAX_FILE_NM_LEN) {
|
||||
if (strlen(string) > MAX_FILE_NM_LEN)
|
||||
{
|
||||
fprintf(stderr, "%s: file name %s is too long\n", prog_name, string);
|
||||
fprintf(stderr, "%s: maximum length of file name is %"SIZEFORMAT" bytes\n",
|
||||
prog_name, MAX_FILE_NM_LEN);
|
||||
@ -208,7 +215,8 @@ int main( int argc, char *argv[])
|
||||
|
||||
ret_cd = get_file_name(string, file_size, &file_ptr);
|
||||
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
free_file_list(file_list);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
@ -218,17 +226,20 @@ int main( int argc, char *argv[])
|
||||
|
||||
if (!file_list)
|
||||
file_list = prev_file = file_ptr;
|
||||
else {
|
||||
else
|
||||
{
|
||||
prev_file->b_fil_next = file_ptr;
|
||||
prev_file = file_ptr;
|
||||
}
|
||||
|
||||
} // processing file name
|
||||
else { // processing file size
|
||||
|
||||
else
|
||||
{
|
||||
// processing file size
|
||||
file_nm_sw = false;
|
||||
ret_cd = get_file_size(prog_name, string, &file_size);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
free_file_list(file_list);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
@ -239,7 +250,8 @@ int main( int argc, char *argv[])
|
||||
case IN_SW_SPIT_JT:
|
||||
ret_cd = get_file_name(string, file_size, &file_ptr);
|
||||
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
free_file_list(file_list);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
@ -249,7 +261,8 @@ int main( int argc, char *argv[])
|
||||
|
||||
if (!file_list)
|
||||
file_list = prev_file = file_ptr;
|
||||
else {
|
||||
else
|
||||
{
|
||||
prev_file->b_fil_next = file_ptr;
|
||||
prev_file = file_ptr;
|
||||
} // end of processing file size specification
|
||||
@ -266,7 +279,8 @@ int main( int argc, char *argv[])
|
||||
} // processing function specific command line options
|
||||
} // while (argv < end)
|
||||
|
||||
if (!file_list && sw_replace != IN_SW_SPIT_0) {
|
||||
if (!file_list && sw_replace != IN_SW_SPIT_0)
|
||||
{
|
||||
fprintf(stderr, "%s: invalid option '%s', rest of parameters is missing\n", prog_name, string);
|
||||
print_clo(prog_name);
|
||||
free_file_list(file_list);
|
||||
@ -279,7 +293,8 @@ int main( int argc, char *argv[])
|
||||
case IN_SW_SPIT_SP:
|
||||
input_file_desc = GBAK_STDIN_DESC;
|
||||
ret_cd = gen_multy_bakup_files(file_list, input_file_desc, file_num);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
fprintf(stderr, "%s: progam fails to generate multi-volumn back-up files\n", prog_name);
|
||||
free_file_list(file_list);
|
||||
return FB_FAILURE;
|
||||
@ -288,7 +303,8 @@ int main( int argc, char *argv[])
|
||||
|
||||
case IN_SW_SPIT_JT:
|
||||
ret_cd = join_multy_bakup_files(file_list);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
fprintf(stderr, "%s: progam fails to join multi-volumn back-up files\n", prog_name);
|
||||
free_file_list(file_list);
|
||||
return FB_FAILURE;
|
||||
@ -325,7 +341,8 @@ static int get_function_option(const SCHAR* prog_name,
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
if (strlen(string) == 1) {
|
||||
if (strlen(string) == 1)
|
||||
{
|
||||
fprintf(stderr, "%s: invalid option '%s'\n", prog_name, string);
|
||||
print_clo(prog_name);
|
||||
return FB_FAILURE;
|
||||
@ -412,11 +429,13 @@ static int get_file_size(const SCHAR* prog_name, const SCHAR* string, SINT64* fi
|
||||
|
||||
if (isdigit(c))
|
||||
*file_size = *file_size * 10 + (c - '0');
|
||||
else {
|
||||
else
|
||||
{
|
||||
if ((isalpha(c)) && (UPPER(c) == 'G' || UPPER(c) == 'K' || UPPER(c) == 'M'))
|
||||
{
|
||||
SLONG size_indicator = 0;
|
||||
switch (UPPER(c)) {
|
||||
switch (UPPER(c))
|
||||
{
|
||||
case 'K':
|
||||
size_indicator = K_BYTES;
|
||||
break;
|
||||
@ -435,7 +454,9 @@ static int get_file_size(const SCHAR* prog_name, const SCHAR* string, SINT64* fi
|
||||
|
||||
*file_size = *file_size * size_indicator;
|
||||
}
|
||||
else { // invalid size indicator
|
||||
else
|
||||
{
|
||||
// invalid size indicator
|
||||
|
||||
fprintf(stderr, "%s: invalid size indicator '%s'\n", prog_name, string);
|
||||
print_clo(prog_name);
|
||||
@ -443,7 +464,9 @@ static int get_file_size(const SCHAR* prog_name, const SCHAR* string, SINT64* 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
|
||||
fprintf(stderr, "%s: invalid option '%s', minimum file size is 1 megabyte\n",
|
||||
prog_name, string);
|
||||
print_clo(prog_name);
|
||||
@ -507,7 +530,8 @@ static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SL
|
||||
//UCHAR* const io_buffer = (UCHAR *) malloc(IO_BUFFER_SIZE);
|
||||
UCHAR* io_buffer = (UCHAR *) malloc(IO_BUFFER_SIZE);
|
||||
|
||||
if (!io_buffer) {
|
||||
if (!io_buffer)
|
||||
{
|
||||
fprintf(stderr, "I/O buffer allocation failed\n");
|
||||
return FB_FAILURE;
|
||||
}
|
||||
@ -542,7 +566,8 @@ static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SL
|
||||
hdr_rec.text2[indx] = BLANK;
|
||||
|
||||
ret_cd = conv_ntoc(file_num, num_arr);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
free(io_buffer);
|
||||
fprintf(stderr, "gsplit could not convert numeric data to character data\n");
|
||||
return FB_FAILURE;
|
||||
@ -573,7 +598,8 @@ static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SL
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (fl_ptr != NULL) {
|
||||
if (fl_ptr != NULL)
|
||||
{
|
||||
byte_read = 0;
|
||||
byte_write = 0;
|
||||
if (!fl_ptr->b_fil_next && (fl_ptr->b_fil_size == 0))
|
||||
@ -585,14 +611,16 @@ static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SL
|
||||
file_name = fl_ptr->b_fil_name;
|
||||
|
||||
output_fl_desc = open(file_name, mode_write, mask);
|
||||
if (output_fl_desc == -1) {
|
||||
if (output_fl_desc == -1)
|
||||
{
|
||||
free(io_buffer);
|
||||
fprintf(stderr, "can not open back up file %s\n", file_name);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
|
||||
ret_cd = write_header(fl_ptr, hdr_rec, output_fl_desc, header_str);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
free(io_buffer);
|
||||
fprintf(stderr, "could not write header record to file %s\n", file_name);
|
||||
return FB_FAILURE;
|
||||
@ -612,12 +640,14 @@ static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SL
|
||||
{
|
||||
ret_cd = final_read_and_write(input_file_desc, output_fl_desc,
|
||||
file_name, io_size, &io_buffer, &end_of_input);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
free(io_buffer);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
|
||||
if (end_of_input) {
|
||||
if (end_of_input)
|
||||
{
|
||||
free(io_buffer);
|
||||
return FB_SUCCESS;
|
||||
}
|
||||
@ -652,13 +682,15 @@ static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SL
|
||||
file_name = fl_ptr->b_fil_name;
|
||||
|
||||
output_fl_desc = open(file_name, mode_write, mask);
|
||||
if (output_fl_desc == -1) {
|
||||
if (output_fl_desc == -1)
|
||||
{
|
||||
free(io_buffer);
|
||||
fprintf(stderr, "can not open back up file %s\n", file_name);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
ret_cd = write_header(fl_ptr, hdr_rec, output_fl_desc, header_str);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
free(io_buffer);
|
||||
fprintf(stderr, "fail to write header rec to file %s\n", file_name);
|
||||
return FB_FAILURE;
|
||||
@ -670,14 +702,17 @@ static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SL
|
||||
ret_cd = final_flush_io_buff(remaining_io,
|
||||
remaining_io_len,
|
||||
output_fl_desc);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
fprintf(stderr, "gsplit could not do backup due");
|
||||
fprintf(stderr, " to lack of space or I/O problem\n");
|
||||
free(io_buffer);
|
||||
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,
|
||||
@ -685,17 +720,20 @@ static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SL
|
||||
file_size,
|
||||
&byte_write,
|
||||
&flush_done);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
fprintf(stderr, "gsplit could not do backup due");
|
||||
fprintf(stderr, " I/O problem\n");
|
||||
free(io_buffer);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
if (flush_done) {
|
||||
if (flush_done)
|
||||
{
|
||||
file_size = file_size - byte_write;
|
||||
byte_write = 0;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
remaining_io = remaining_io + byte_write;
|
||||
remaining_io_len = remaining_io_len - byte_write;
|
||||
}
|
||||
@ -708,7 +746,8 @@ static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SL
|
||||
break;
|
||||
}
|
||||
|
||||
if (end_of_input) {
|
||||
if (end_of_input)
|
||||
{
|
||||
free(io_buffer);
|
||||
return FB_SUCCESS;
|
||||
}
|
||||
@ -751,7 +790,8 @@ static int read_and_write(FILE_DESC input_file_desc,
|
||||
// the current backup file. Otherwise read as mush data
|
||||
// as will fit in the current backup file.
|
||||
|
||||
if (*byte_read + io_size > file_size) {
|
||||
if (*byte_read + io_size > file_size)
|
||||
{
|
||||
last_read_size = (SLONG) (file_size - *byte_read);
|
||||
read_cnt = read(input_file_desc, *io_buffer, last_read_size);
|
||||
}
|
||||
@ -879,9 +919,10 @@ static int join_multy_bakup_files( b_fil* file_list)
|
||||
// See comment near the beginning of gen_multy_bakup_files() as it
|
||||
// also applies to read_and_write_for_join().
|
||||
//UCHAR* const io_buffer = (UCHAR *) malloc(IO_BUFFER_SIZE);
|
||||
UCHAR* io_buffer = (UCHAR *) malloc(IO_BUFFER_SIZE);
|
||||
UCHAR* io_buffer = (UCHAR*) malloc(IO_BUFFER_SIZE);
|
||||
|
||||
if (io_buffer == 0) {
|
||||
if (io_buffer == 0)
|
||||
{
|
||||
fprintf(stderr, "I/O buffer allocation failed\n");
|
||||
return FB_FAILURE;
|
||||
}
|
||||
@ -897,7 +938,8 @@ static int join_multy_bakup_files( b_fil* file_list)
|
||||
|
||||
SLONG ret_cd = read_and_write_for_join(output_fl_desc, file_name, &io_buffer, cnt, &total_int);
|
||||
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
free(io_buffer);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
@ -911,9 +953,9 @@ static int join_multy_bakup_files( b_fil* file_list)
|
||||
|
||||
static int read_and_write_for_join(FILE_DESC output_fl_desc,
|
||||
const TEXT* file_name,
|
||||
UCHAR ** io_buffer,
|
||||
UCHAR** io_buffer,
|
||||
SLONG cnt,
|
||||
SLONG * total_int)
|
||||
SLONG* total_int)
|
||||
{
|
||||
/********************************************************************
|
||||
**
|
||||
@ -934,13 +976,15 @@ static int read_and_write_for_join(FILE_DESC output_fl_desc,
|
||||
|
||||
FILE_DESC input_fl_desc = open(file_name, mode_read);
|
||||
|
||||
if (input_fl_desc == -1) {
|
||||
if (input_fl_desc == -1)
|
||||
{
|
||||
fprintf(stderr, "can not open input file %s\n", file_name);
|
||||
return FB_FAILURE;
|
||||
}
|
||||
|
||||
int read_cnt = read(input_fl_desc, *io_buffer, header_rec_len);
|
||||
if (read_cnt != static_cast<int>(header_rec_len)) {
|
||||
if (read_cnt != static_cast<int>(header_rec_len))
|
||||
{
|
||||
close(input_fl_desc);
|
||||
fprintf(stderr, "progam fails to read gsplit header record in back-up file%s\n", file_name);
|
||||
return FB_FAILURE;
|
||||
@ -948,7 +992,8 @@ static int read_and_write_for_join(FILE_DESC output_fl_desc,
|
||||
|
||||
const TEXT* char_ptr1 = reinterpret_cast<char*>(*io_buffer);
|
||||
SLONG ret_cd = strncmp(char_ptr1, header_rec_name, sizeof(hdr_rec.name) - 1);
|
||||
if (ret_cd != 0) {
|
||||
if (ret_cd != 0)
|
||||
{
|
||||
close(input_fl_desc);
|
||||
fprintf(stderr, "gsplit: expected GSPLIT description record\n");
|
||||
fprintf(stderr, "gsplit: Exiting before completion due to errors\n");
|
||||
@ -961,22 +1006,26 @@ static int read_and_write_for_join(FILE_DESC output_fl_desc,
|
||||
char_ptr1 = reinterpret_cast<char*>(*io_buffer + skip_to_num);
|
||||
const TEXT* char_ptr2 = reinterpret_cast<char*>(*io_buffer + skip_to_total);
|
||||
size_t indx;
|
||||
for (indx = 0; indx < sizeof(hdr_rec.num); indx++) {
|
||||
for (indx = 0; indx < sizeof(hdr_rec.num); indx++)
|
||||
{
|
||||
num_arr[indx] = *char_ptr1;
|
||||
char_ptr1++;
|
||||
if (cnt == 1) {
|
||||
if (cnt == 1)
|
||||
{
|
||||
total_arr[indx] = *char_ptr2;
|
||||
char_ptr2++;
|
||||
}
|
||||
}
|
||||
num_arr[indx] = '\0';
|
||||
const SLONG num_int = atoi(num_arr);
|
||||
if (cnt == 1) {
|
||||
if (cnt == 1)
|
||||
{
|
||||
total_arr[indx] = '\0';
|
||||
*total_int = atoi(total_arr);
|
||||
}
|
||||
|
||||
if ((num_int != cnt) || (num_int > *total_int)) {
|
||||
if ((num_int != cnt) || (num_int > *total_int))
|
||||
{
|
||||
close(input_fl_desc);
|
||||
fprintf(stderr, "gsplit: join backup file is out of sequence\n");
|
||||
fprintf(stderr, "gsplit: Exiting before completion due to errors\n");
|
||||
@ -1085,7 +1134,8 @@ static int write_header(const b_fil* fl_ptr,
|
||||
TEXT num_arr[5];
|
||||
|
||||
SLONG ret_cd = conv_ntoc(fl_ptr->b_fil_number, num_arr);
|
||||
if (ret_cd == FB_FAILURE) {
|
||||
if (ret_cd == FB_FAILURE)
|
||||
{
|
||||
printf("gsplit could not convert numeric data to character data\n");
|
||||
return FB_FAILURE;
|
||||
}
|
||||
@ -1166,7 +1216,9 @@ static int flush_io_buff(const UCHAR* remaining_io,
|
||||
default:
|
||||
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;
|
||||
}
|
||||
@ -1254,7 +1306,8 @@ static int set_hdr_str(TEXT header_str[], const TEXT* in_str, SLONG pos, SLONG l
|
||||
const TEXT* t_str = in_str;
|
||||
const SLONG end = pos + len;
|
||||
|
||||
for (SLONG indx = pos; indx < end; indx++) {
|
||||
for (SLONG indx = pos; indx < end; indx++)
|
||||
{
|
||||
switch (*t_str)
|
||||
{
|
||||
case NEW_LINE:
|
||||
@ -1288,7 +1341,8 @@ static int free_file_list( b_fil* file_list)
|
||||
|
||||
b_fil* next_file = NULL;
|
||||
|
||||
for (b_fil* file_ptr = file_list; file_ptr != NULL; file_ptr = next_file) {
|
||||
for (b_fil* file_ptr = file_list; file_ptr != NULL; file_ptr = next_file)
|
||||
{
|
||||
next_file = file_ptr->b_fil_next;
|
||||
free(file_ptr->b_fil_name);
|
||||
free(file_ptr);
|
||||
|
Loading…
Reference in New Issue
Block a user