MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / gen_multy_bakup_files

Function gen_multy_bakup_files

src/burp/split/spit.cpp:538–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

536
537
538static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SLONG file_num)
539{
540/********************************************************************
541**
542** g e n _ m u l t y _ b a c k u p _ f i l e s
543**
544*********************************************************************
545**
546** Functional description:
547**
548** processing input data from stdin and splits the data into
549** multiple back-up files.
550**
551** allocates an 16K bytes I/O buffer
552** intilializes header record common fields
553** do forever
554** walk through the backup file chain
555** intilializes header record unique fields
556** open backup file
557** writes out header record to backup file
558** points to the next backup file in the chain
559** calculates the actual file size ( minus header record length )
560** if the actual file size less than 16K bytes
561** set I/O size to actual file size
562** otherwise
563** set I/O size to 16K byte long
564** when it is the last backup file
565** reads data from standard input as much as indicated by I/O size
566** and writes it out to the last backup file until no EOF.
567** issues error message when disk space full condition is detected
568** otherwise reads and writes to backup files util EOF
569** if disk full cobdition is detected
570** flush the remaining data in the I/O buffer to subsequence
571** backup files
572** go back to normal read and write process util EOF
573**
574*********************************************************************
575*/
576
577 SLONG byte_write, ret_cd;
578 TEXT header_str[header_rec_len], num_arr[5];
579 header_rec hdr_rec;
580
581 // CVC: there's a can of worms here. First, this function assumes it can free
582 // the io_buffer's allocated memory without keeping a second copy of that pointer.
583 // However, io_buffer can't be declared UCHAR* const because its address is
584 // passed to final_read_and_write() and read_and_write() and both functions
585 // thus suggest, by taking a UCHAR** that they can change the pointer's address;
586 // but in practice they never affect it, so fixing those functions to take simply
587 // UCHAR* would allow the correct declaration for io_buffer to succeed.
588 //UCHAR* const io_buffer = (UCHAR *) malloc(IO_BUFFER_SIZE);
589 UCHAR* io_buffer = (UCHAR *) malloc(IO_BUFFER_SIZE);
590
591 if (!io_buffer)
592 {
593 fprintf(stderr, "I/O buffer allocation failed\n");
594 return FB_FAILURE;
595 }

Callers 1

mainFunction · 0.85

Calls 8

set_hdr_strFunction · 0.85
conv_ntocFunction · 0.85
open_platfFunction · 0.85
final_read_and_writeFunction · 0.85
read_and_writeFunction · 0.85
final_flush_io_buffFunction · 0.85
flush_io_buffFunction · 0.85
write_headerFunction · 0.70

Tested by

no test coverage detected