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

Function join_multy_bakup_files

src/burp/split/spit.cpp:956–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

954
955
956static int join_multy_bakup_files( b_fil* file_list)
957{
958/********************************************************************
959**
960** j o i n _ m u l t y _ b a c k u p _ f i l e s
961**
962*********************************************************************
963**
964** Functional description:
965**
966** allocates I/O buffer and walks through backup files` chain.
967** calls read_and_write_for_join routine to read data from
968** backup file and to write data to standard output file
969** which later to be processed by gbak. Finally frees up
970** I/O buffer
971**
972*********************************************************************
973*/
974
975 FILE_DESC output_fl_desc = GBAK_STDOUT_DESC();
976
977 // See comment near the beginning of gen_multy_bakup_files() as it
978 // also applies to read_and_write_for_join().
979 UCHAR* const io_buffer = (UCHAR*) malloc(IO_BUFFER_SIZE);
980 //UCHAR* io_buffer = (UCHAR*) malloc(IO_BUFFER_SIZE);
981
982 if (io_buffer == 0)
983 {
984 fprintf(stderr, "I/O buffer allocation failed\n");
985 return FB_FAILURE;
986 }
987
988 SLONG cnt = 0, total_int = 0;
989 // Why two variables to achieve this simple loop?
990 const b_fil* next_fl = NULL;
991 for (const b_fil* fl_ptr = file_list; fl_ptr; fl_ptr = next_fl)
992 {
993 cnt++;
994 next_fl = fl_ptr->b_fil_next;
995 const TEXT* file_name = fl_ptr->b_fil_name;
996
997 SLONG ret_cd = read_and_write_for_join(output_fl_desc, file_name, io_buffer, cnt, &total_int);
998
999 if (ret_cd == FB_FAILURE)
1000 {
1001 free(io_buffer);
1002 return FB_FAILURE;
1003 }
1004
1005 } // end of for loop
1006
1007 free(io_buffer);
1008 return FB_SUCCESS;
1009}
1010
1011
1012static int read_and_write_for_join(FILE_DESC output_fl_desc,

Callers 1

mainFunction · 0.85

Calls 2

GBAK_STDOUT_DESCFunction · 0.85
read_and_write_for_joinFunction · 0.85

Tested by

no test coverage detected