| 1010 | |
| 1011 | |
| 1012 | static int read_and_write_for_join(FILE_DESC output_fl_desc, |
| 1013 | const TEXT* file_name, |
| 1014 | UCHAR* io_buffer, |
| 1015 | SLONG cnt, |
| 1016 | SLONG* total_int) |
| 1017 | { |
| 1018 | /******************************************************************** |
| 1019 | ** |
| 1020 | ** r e a d _ a n d _ w r i t e _ f o r _ j o i n |
| 1021 | ** |
| 1022 | ********************************************************************* |
| 1023 | ** |
| 1024 | ** Functional description: |
| 1025 | ** |
| 1026 | ** Reads data from backup files and writes to standard |
| 1027 | ** output file. |
| 1028 | ** |
| 1029 | ********************************************************************* |
| 1030 | */ |
| 1031 | |
| 1032 | TEXT num_arr[5], total_arr[5]; |
| 1033 | header_rec hdr_rec; |
| 1034 | FB_UNUSED_VAR(hdr_rec); // Silence compiler warning |
| 1035 | |
| 1036 | FILE_DESC input_fl_desc = open_platf(file_name, mode_read); |
| 1037 | |
| 1038 | if (input_fl_desc == INVALID_HANDLE_VALUE) |
| 1039 | { |
| 1040 | fprintf(stderr, "can not open input file %s\n", file_name); |
| 1041 | return FB_FAILURE; |
| 1042 | } |
| 1043 | |
| 1044 | int read_cnt = read_platf(input_fl_desc, io_buffer, header_rec_len); |
| 1045 | if (read_cnt != static_cast<int>(header_rec_len)) |
| 1046 | { |
| 1047 | close_platf(input_fl_desc); |
| 1048 | fprintf(stderr, "progam fails to read gsplit header record in back-up file%s\n", file_name); |
| 1049 | return FB_FAILURE; |
| 1050 | } |
| 1051 | |
| 1052 | const TEXT* char_ptr1 = reinterpret_cast<char*>(io_buffer); |
| 1053 | SLONG ret_cd = strncmp(char_ptr1, header_rec_name, sizeof(hdr_rec.name) - 1); |
| 1054 | if (ret_cd != 0) |
| 1055 | { |
| 1056 | close_platf(input_fl_desc); |
| 1057 | fprintf(stderr, "gsplit: expected GSPLIT description record\n"); |
| 1058 | fprintf(stderr, "gsplit: Exiting before completion due to errors\n"); |
| 1059 | return FB_FAILURE; |
| 1060 | } |
| 1061 | |
| 1062 | const SLONG skip_to_num = sizeof(hdr_rec.name) + sizeof(hdr_rec.date_time) + sizeof(hdr_rec.text1); |
| 1063 | const SLONG skip_to_total = skip_to_num + sizeof(hdr_rec.num) + sizeof(hdr_rec.text2); |
| 1064 | |
| 1065 | char_ptr1 = reinterpret_cast<char*>(io_buffer + skip_to_num); |
| 1066 | const TEXT* char_ptr2 = reinterpret_cast<char*>(io_buffer + skip_to_total); |
| 1067 | size_t indx; |
| 1068 | for (indx = 0; indx < sizeof(hdr_rec.num); indx++) |
| 1069 | { |
no test coverage detected