void BufferedFile::init(Buffer *data, int buffer_size, int file_size, int buffer_count) { // initialize the buffer init(); set_file_pos(buffer_count); set_count(buffer_count); set_data_buffer(data); set_buffer_size(buffer_size); set_file_size(file_size); }
static void extract_phone_book(phone_book_t* pb, char* buffer, int buffer_len) { set_data_buffer(buffer); set_read_pos(0); set_data_pos(buffer_len * 8); read_alpha(g_alpha_buf); read_number_length(&pb->number_length); read_internate_code(&pb->code); read_number(g_number_buf, pb->number_length); strcpy(pb->alpha, g_alpha_buf); strcpy(pb->number, g_number_buf); }
static void convert_phone_book(phone_book_t* pb, char* buffer) { int force = 0; if (is_empty_alpha(pb->alpha)) { int len = strlen(pb->number); if (len > 13) len = 13; copy_number_to_alpha(pb->alpha, pb->number, len); force = 1; } set_data_buffer(buffer); set_data_pos(0); write_alpha(pb->alpha, force);; set_data_pos(28 * 8); write_number_length((strlen(pb->number) + 1) / 2 + 1); set_data_pos(30 * 8); write_internat_code(pb->code); set_data_pos(32 * 8); write_number(pb->number); }