diff options
Diffstat (limited to 'src/lib/tng_io.c')
-rw-r--r-- | src/lib/tng_io.c | 1490 |
1 files changed, 541 insertions, 949 deletions
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c index 954d1d7..099d88c 100644 --- a/src/lib/tng_io.c +++ b/src/lib/tng_io.c @@ -580,14 +580,11 @@ static tng_function_status tng_block_header_read return(TNG_CRITICAL); } - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + &block->header_contents_size) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - &block->header_contents_size) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } /* Move the reading position to the beginning of the header. */ @@ -626,25 +623,19 @@ static tng_function_status tng_block_header_read /* Copy the respective parameters from the header contents block */ memcpy(&block->block_contents_size, block->header_contents+offset, sizeof(block->block_contents_size)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &block->block_contents_size) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &block->block_contents_size) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(block->block_contents_size); memcpy(&block->id, block->header_contents+offset, sizeof(block->id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &block->id) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &block->id) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(block->id); @@ -672,14 +663,11 @@ static tng_function_status tng_block_header_read memcpy(&block->block_version, block->header_contents+offset, sizeof(block->block_version)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &block->block_version) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &block->block_version) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(block->block_version); @@ -777,42 +765,33 @@ static tng_function_status tng_block_header_write * the whole block at once. */ memcpy(block->header_contents, &block->header_contents_size, sizeof(block->header_contents_size)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->header_contents)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->header_contents)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(block->header_contents_size); memcpy(block->header_contents+offset, &block->block_contents_size, sizeof(block->block_contents_size)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->header_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->header_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(block->block_contents_size); memcpy(block->header_contents+offset, &block->id, sizeof(block->id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->header_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->header_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(block->id); @@ -824,15 +803,12 @@ static tng_function_status tng_block_header_write memcpy(block->header_contents+offset, &block->block_version, sizeof(block->block_version)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->header_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->header_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(block->block_version); @@ -1017,13 +993,10 @@ static tng_function_status tng_general_info_block_read memcpy(&tng_data->time, block->block_contents+offset, sizeof(tng_data->time)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &tng_data->time) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &tng_data->time) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->time); @@ -1033,29 +1006,23 @@ static tng_function_status tng_general_info_block_read memcpy(&tng_data->frame_set_n_frames, block->block_contents+offset, sizeof(tng_data->frame_set_n_frames)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &tng_data->frame_set_n_frames) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &tng_data->frame_set_n_frames) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->frame_set_n_frames); memcpy(&tng_data->first_trajectory_frame_set_input_file_pos, block->block_contents+offset, sizeof(tng_data->first_trajectory_frame_set_input_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + &tng_data->first_trajectory_frame_set_input_file_pos) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - &tng_data->first_trajectory_frame_set_input_file_pos) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->first_trajectory_frame_set_input_file_pos); tng_data->current_trajectory_frame_set.next_frame_set_file_pos = @@ -1065,41 +1032,32 @@ static tng_function_status tng_general_info_block_read memcpy(&tng_data->last_trajectory_frame_set_input_file_pos, block->block_contents+offset, sizeof(tng_data->last_trajectory_frame_set_input_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + &tng_data->last_trajectory_frame_set_input_file_pos) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - &tng_data->last_trajectory_frame_set_input_file_pos) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->last_trajectory_frame_set_input_file_pos); memcpy(&tng_data->medium_stride_length, block->block_contents+offset, sizeof(tng_data->medium_stride_length)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &tng_data->medium_stride_length) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &tng_data->medium_stride_length) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->medium_stride_length); memcpy(&tng_data->long_stride_length, block->block_contents+offset, sizeof(tng_data->long_stride_length)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &tng_data->long_stride_length) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &tng_data->long_stride_length) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } return(TNG_SUCCESS); @@ -1323,15 +1281,12 @@ static tng_function_status tng_general_info_block_write memcpy(block->block_contents+offset, &tng_data->time, sizeof(tng_data->time)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->time); @@ -1341,73 +1296,58 @@ static tng_function_status tng_general_info_block_write memcpy(block->block_contents+offset, &tng_data->frame_set_n_frames, sizeof(tng_data->frame_set_n_frames)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->frame_set_n_frames); memcpy(block->block_contents+offset, &tng_data->first_trajectory_frame_set_input_file_pos, sizeof(tng_data->first_trajectory_frame_set_input_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->first_trajectory_frame_set_input_file_pos); memcpy(block->block_contents+offset, &tng_data->last_trajectory_frame_set_input_file_pos, sizeof(tng_data->last_trajectory_frame_set_input_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->last_trajectory_frame_set_input_file_pos); memcpy(block->block_contents+offset, &tng_data->medium_stride_length, sizeof(tng_data->medium_stride_length)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->medium_stride_length); memcpy(block->block_contents+offset, &tng_data->long_stride_length, sizeof(tng_data->long_stride_length)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } @@ -1503,14 +1443,11 @@ static tng_function_status tng_molecules_block_read memcpy(&tng_data->n_molecules, block->block_contents, sizeof(tng_data->n_molecules)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &tng_data->n_molecules) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &tng_data->n_molecules) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->n_molecules); @@ -1555,13 +1492,10 @@ static tng_function_status tng_molecules_block_read memcpy(&molecule->id, block->block_contents+offset, sizeof(molecule->id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &molecule->id) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &molecule->id) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->id); @@ -1573,13 +1507,10 @@ static tng_function_status tng_molecules_block_read memcpy(&molecule->quaternary_str, block->block_contents+offset, sizeof(molecule->quaternary_str)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &molecule->quaternary_str) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &molecule->quaternary_str) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->quaternary_str); @@ -1588,14 +1519,11 @@ static tng_function_status tng_molecules_block_read memcpy(&tng_data->molecule_cnt_list[i], block->block_contents+offset, sizeof(int64_t)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + &tng_data->molecule_cnt_list[i]) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - &tng_data->molecule_cnt_list[i]) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(int64_t); } @@ -1603,40 +1531,31 @@ static tng_function_status tng_molecules_block_read memcpy(&molecule->n_chains, block->block_contents+offset, sizeof(molecule->n_chains)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &molecule->n_chains) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &molecule->n_chains) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->n_chains); memcpy(&molecule->n_residues, block->block_contents+offset, sizeof(molecule->n_residues)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &molecule->n_residues) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &molecule->n_residues) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->n_residues); memcpy(&molecule->n_atoms, block->block_contents+offset, sizeof(molecule->n_atoms)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &molecule->n_atoms) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &molecule->n_atoms) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->n_atoms); @@ -1685,13 +1604,10 @@ static tng_function_status tng_molecules_block_read memcpy(&chain->id, block->block_contents+offset, sizeof(chain->id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &chain->id) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &chain->id) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(chain->id); @@ -1704,14 +1620,11 @@ static tng_function_status tng_molecules_block_read memcpy(&chain->n_residues, block->block_contents+offset, sizeof(chain->n_residues)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &chain->n_residues) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &chain->n_residues) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(chain->n_residues); @@ -1721,13 +1634,10 @@ static tng_function_status tng_molecules_block_read residue->chain = chain; memcpy(&residue->id, block->block_contents+offset, sizeof(residue->id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &residue->id) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &residue->id) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(residue->id); @@ -1740,14 +1650,11 @@ static tng_function_status tng_molecules_block_read memcpy(&residue->n_atoms, block->block_contents+offset, sizeof(residue->n_atoms)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &residue->n_atoms) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &residue->n_atoms) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(residue->n_atoms); @@ -1758,13 +1665,10 @@ static tng_function_status tng_molecules_block_read memcpy(&atom->id, block->block_contents+offset, sizeof(atom->id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &atom->id) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &atom->id) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(atom->id); @@ -1791,14 +1695,11 @@ static tng_function_status tng_molecules_block_read memcpy(&molecule->n_bonds, block->block_contents+offset, sizeof(molecule->n_bonds)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &molecule->n_bonds) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &molecule->n_bonds) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->n_bonds); @@ -1818,27 +1719,21 @@ static tng_function_status tng_molecules_block_read { memcpy(&bond->from_atom_id, block->block_contents+offset, sizeof(bond->from_atom_id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &bond->from_atom_id) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &bond->from_atom_id) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(bond->from_atom_id); memcpy(&bond->to_atom_id, block->block_contents+offset, sizeof(bond->to_atom_id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &bond->to_atom_id) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &bond->to_atom_id) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(bond->to_atom_id); @@ -2014,15 +1909,12 @@ static tng_function_status tng_molecules_block_write memcpy(block->block_contents+offset, &tng_data->n_molecules, sizeof(tng_data->n_molecules)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(tng_data->n_molecules); @@ -2032,15 +1924,12 @@ static tng_function_status tng_molecules_block_write // printf("i=%d\n", i); memcpy(block->block_contents+offset, &molecule->id, sizeof(molecule->id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->id); @@ -2051,15 +1940,12 @@ static tng_function_status tng_molecules_block_write memcpy(block->block_contents+offset, &molecule->quaternary_str, sizeof(molecule->quaternary_str)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->quaternary_str); @@ -2067,58 +1953,46 @@ static tng_function_status tng_molecules_block_write { memcpy(block->block_contents+offset, &tng_data->molecule_cnt_list[i], sizeof(int64_t)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(int64_t); } memcpy(block->block_contents+offset, &molecule->n_chains, sizeof(molecule->n_chains)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->n_chains); memcpy(block->block_contents+offset, &molecule->n_residues, sizeof(molecule->n_residues)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->n_residues); memcpy(block->block_contents+offset, &molecule->n_atoms, sizeof(molecule->n_atoms)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->n_atoms); @@ -2126,15 +2000,12 @@ static tng_function_status tng_molecules_block_write for(j = molecule->n_chains; j--;) { memcpy(block->block_contents+offset, &chain->id, sizeof(chain->id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(chain->id); @@ -2144,15 +2015,12 @@ static tng_function_status tng_molecules_block_write memcpy(block->block_contents+offset, &chain->n_residues, sizeof(chain->n_residues)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(chain->n_residues); @@ -2160,15 +2028,12 @@ static tng_function_status tng_molecules_block_write for(k = chain->n_residues; k--;) { memcpy(block->block_contents+offset, &residue->id, sizeof(residue->id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(residue->id); @@ -2178,15 +2043,12 @@ static tng_function_status tng_molecules_block_write memcpy(block->block_contents+offset, &residue->n_atoms, sizeof(residue->n_atoms)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(residue->n_atoms); @@ -2195,15 +2057,12 @@ static tng_function_status tng_molecules_block_write { // printf("j=%d\n", j); memcpy(block->block_contents+offset, &atom->id, sizeof(atom->id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(atom->id); @@ -2224,15 +2083,12 @@ static tng_function_status tng_molecules_block_write memcpy(block->block_contents+offset, &molecule->n_bonds, sizeof(molecule->n_bonds)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(molecule->n_bonds); @@ -2241,28 +2097,22 @@ static tng_function_status tng_molecules_block_write { memcpy(block->block_contents+offset, &bond->from_atom_id, sizeof(bond->from_atom_id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(bond->from_atom_id); memcpy(block->block_contents+offset, &bond->to_atom_id, sizeof(bond->to_atom_id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(bond->to_atom_id); @@ -2382,27 +2232,21 @@ static tng_function_status tng_frame_set_block_read memcpy(&frame_set->first_frame, block->block_contents, sizeof(frame_set->first_frame)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &frame_set->first_frame) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &frame_set->first_frame) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->first_frame); memcpy(&frame_set->n_frames, block->block_contents + offset, sizeof(frame_set->n_frames)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &frame_set->n_frames) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &frame_set->n_frames) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->n_frames); @@ -2430,15 +2274,12 @@ static tng_function_status tng_frame_set_block_read memcpy(&frame_set->molecule_cnt_list[i], block->block_contents + offset, sizeof(int64_t)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + &frame_set->molecule_cnt_list[i]) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - &frame_set->molecule_cnt_list[i]) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(int64_t); frame_set->n_particles += tng_data->molecules[i].n_atoms * @@ -2453,90 +2294,72 @@ static tng_function_status tng_frame_set_block_read memcpy(&frame_set->next_frame_set_file_pos, block->block_contents + offset, sizeof(frame_set->next_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + &frame_set->next_frame_set_file_pos) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - &frame_set->next_frame_set_file_pos) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->next_frame_set_file_pos); memcpy(&frame_set->prev_frame_set_file_pos, block->block_contents + offset, sizeof(frame_set->prev_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + &frame_set->prev_frame_set_file_pos) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - &frame_set->prev_frame_set_file_pos) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->prev_frame_set_file_pos); memcpy(&frame_set->medium_stride_next_frame_set_file_pos, block->block_contents + offset, sizeof(frame_set->medium_stride_next_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &frame_set-> + medium_stride_next_frame_set_file_pos) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &frame_set-> - medium_stride_next_frame_set_file_pos) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->medium_stride_next_frame_set_file_pos); memcpy(&frame_set->medium_stride_prev_frame_set_file_pos, block->block_contents + offset, sizeof(frame_set->medium_stride_prev_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &frame_set-> + medium_stride_prev_frame_set_file_pos) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &frame_set-> - medium_stride_prev_frame_set_file_pos) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->medium_stride_prev_frame_set_file_pos); memcpy(&frame_set->long_stride_next_frame_set_file_pos, block->block_contents + offset, sizeof(frame_set->long_stride_next_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &frame_set-> + long_stride_next_frame_set_file_pos) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &frame_set-> - long_stride_next_frame_set_file_pos) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->long_stride_next_frame_set_file_pos); memcpy(&frame_set->long_stride_prev_frame_set_file_pos, block->block_contents + offset, sizeof(frame_set->long_stride_prev_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &frame_set-> + long_stride_prev_frame_set_file_pos) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &frame_set-> - long_stride_prev_frame_set_file_pos) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->long_stride_prev_frame_set_file_pos); @@ -2605,29 +2428,23 @@ static tng_function_status tng_frame_set_block_write memcpy(block->block_contents, &frame_set->first_frame, sizeof(frame_set->first_frame)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->first_frame); memcpy(block->block_contents+offset, &frame_set->n_frames, sizeof(frame_set->n_frames)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->n_frames); @@ -2638,15 +2455,12 @@ static tng_function_status tng_frame_set_block_write memcpy(block->block_contents+offset, &frame_set->molecule_cnt_list[i], sizeof(int64_t)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(int64_t); } @@ -2655,89 +2469,71 @@ static tng_function_status tng_frame_set_block_write memcpy(block->block_contents+offset, &frame_set->next_frame_set_file_pos, sizeof(frame_set->next_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->next_frame_set_file_pos); memcpy(block->block_contents+offset, &frame_set->prev_frame_set_file_pos, sizeof(frame_set->prev_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->prev_frame_set_file_pos); memcpy(block->block_contents+offset, &frame_set->medium_stride_next_frame_set_file_pos, sizeof(frame_set->medium_stride_next_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->medium_stride_next_frame_set_file_pos); memcpy(block->block_contents+offset, &frame_set->medium_stride_prev_frame_set_file_pos, sizeof(frame_set->medium_stride_prev_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->medium_stride_prev_frame_set_file_pos); memcpy(block->block_contents+offset, &frame_set->long_stride_next_frame_set_file_pos, sizeof(frame_set->long_stride_next_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->long_stride_next_frame_set_file_pos); memcpy(block->block_contents+offset, &frame_set->long_stride_prev_frame_set_file_pos, sizeof(frame_set->long_stride_prev_frame_set_file_pos)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(frame_set->long_stride_prev_frame_set_file_pos); @@ -2835,27 +2631,21 @@ static tng_function_status tng_trajectory_mapping_block_read memcpy(&mapping->num_first_particle, block->block_contents+offset, sizeof(mapping->num_first_particle)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &mapping->num_first_particle) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &mapping->num_first_particle) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(mapping->num_first_particle); memcpy(&mapping->n_particles, block->block_contents+offset, sizeof(mapping->n_particles)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &mapping->n_particles) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &mapping->n_particles) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(mapping->n_particles); @@ -2873,15 +2663,12 @@ static tng_function_status tng_trajectory_mapping_block_read memcpy(&mapping->real_particle_numbers[i], block->block_contents + offset, sizeof(int64_t)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + &mapping->real_particle_numbers[i]) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - &mapping->real_particle_numbers[i]) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(int64_t); } @@ -2946,29 +2733,23 @@ static tng_function_status tng_trajectory_mapping_block_write memcpy(block->block_contents, &mapping->num_first_particle, sizeof(mapping->num_first_particle)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(mapping->num_first_particle); memcpy(block->block_contents+offset, &mapping->n_particles, sizeof(mapping->n_particles)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(mapping->n_particles); @@ -2976,15 +2757,12 @@ static tng_function_status tng_trajectory_mapping_block_write { memcpy(block->block_contents+offset, &mapping->real_particle_numbers[i], sizeof(int64_t)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(int64_t); } @@ -3279,15 +3057,12 @@ static tng_function_status tng_particle_data_read memcpy(&second_dim_values[k].f, block->block_contents+*offset, size); - if(tng_data->endianness_32 != TNG_BIG_ENDIAN_32) + if(tng_swap_byte_order_32(tng_data, + (int32_t *) &second_dim_values[k]) != TNG_SUCCESS) { - if(tng_swap_byte_order_32(tng_data, - (int32_t *) &second_dim_values[k]) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } *offset += size; } @@ -3307,15 +3082,12 @@ static tng_function_status tng_particle_data_read memcpy(&second_dim_values[k].i, block->block_contents+*offset, size); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *) &second_dim_values[k].i) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *) &second_dim_values[k].i) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } *offset += size; } @@ -3366,15 +3138,12 @@ static tng_function_status tng_particle_data_read memcpy(&second_dim_values[k].d, block->block_contents+*offset, size); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *) &second_dim_values[k].d) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *) &second_dim_values[k].d) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } *offset += size; } @@ -3546,29 +3315,23 @@ static tng_function_status tng_particle_data_block_write memcpy(block->block_contents+offset, &data->n_values_per_frame, sizeof(data->n_values_per_frame)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents + offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents + offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(data->n_values_per_frame); memcpy(block->block_contents+offset, &data->codec_id, sizeof(data->codec_id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents + offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents + offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(data->codec_id); @@ -3576,15 +3339,12 @@ static tng_function_status tng_particle_data_block_write { memcpy(block->block_contents+offset, &data->compression_multiplier, sizeof(data->compression_multiplier)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents + offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents + offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(data->compression_multiplier); } @@ -3593,29 +3353,23 @@ static tng_function_status tng_particle_data_block_write { memcpy(block->block_contents+offset, &data->first_frame_with_data, sizeof(data->first_frame_with_data)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents + offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents + offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(data->first_frame_with_data); memcpy(block->block_contents+offset, &data->stride_length, sizeof(data->stride_length)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents + offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents + offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(data->stride_length); } @@ -3623,28 +3377,22 @@ static tng_function_status tng_particle_data_block_write memcpy(block->block_contents+offset, &num_first_particle, sizeof(num_first_particle)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(num_first_particle); memcpy(block->block_contents+offset, &n_particles, sizeof(n_particles)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents+offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents+offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(n_particles); @@ -3664,17 +3412,8 @@ static tng_function_status tng_particle_data_block_write memcpy(block->block_contents+offset, &second_dim_values[k].f, size); - if(tng_data->endianness_32 != TNG_BIG_ENDIAN_32) - { - if(tng_swap_byte_order_32(tng_data, - (int32_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } - } + tng_swap_byte_order_32(tng_data, + (int32_t *)(block->block_contents+offset)); offset += sizeof(size); } } @@ -3694,17 +3433,8 @@ static tng_function_status tng_particle_data_block_write memcpy(block->block_contents+offset, &second_dim_values[k].i, size); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) - { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } - } + tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)); offset += sizeof(size); } } @@ -3742,17 +3472,8 @@ static tng_function_status tng_particle_data_block_write memcpy(block->block_contents+offset, &second_dim_values[k].d, size); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) - { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } - } + tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)); offset += sizeof(size); } } @@ -4023,15 +3744,12 @@ static tng_function_status tng_data_read(tng_trajectory_t tng_data, { memcpy(&data->values[i][j].f, block->block_contents+*offset, size); - if(tng_data->endianness_32 != TNG_BIG_ENDIAN_32) + if(tng_swap_byte_order_32(tng_data, + (int32_t *) &data->values[i][j]) != TNG_SUCCESS) { - if(tng_swap_byte_order_32(tng_data, - (int32_t *) &data->values[i][j]) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } *offset += size; } @@ -4044,15 +3762,12 @@ static tng_function_status tng_data_read(tng_trajectory_t tng_data, { memcpy(&data->values[i][j].i, block->block_contents+*offset, size); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *) &data->values[i][j].i) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *) &data->values[i][j].i) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } *offset += size; } @@ -4090,15 +3805,12 @@ static tng_function_status tng_data_read(tng_trajectory_t tng_data, { memcpy(&data->values[i][j].d, block->block_contents+*offset, size); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + (int64_t *) &data->values[i][j].d) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - (int64_t *) &data->values[i][j].d) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } *offset += size; } @@ -4256,31 +3968,25 @@ static tng_function_status tng_data_block_write(tng_trajectory_t tng_data, memcpy(block->block_contents+offset, &data->n_values_per_frame, sizeof(data->n_values_per_frame)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents + offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents + offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } offset += sizeof(data->n_values_per_frame); memcpy(block->block_contents+offset, &data->codec_id, sizeof(data->codec_id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents + offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents + offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } offset += sizeof(data->codec_id); @@ -4288,16 +3994,13 @@ static tng_function_status tng_data_block_write(tng_trajectory_t tng_data, { memcpy(block->block_contents+offset, &data->compression_multiplier, sizeof(data->compression_multiplier)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents + offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents + offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } offset += sizeof(data->compression_multiplier); } @@ -4306,31 +4009,25 @@ static tng_function_status tng_data_block_write(tng_trajectory_t tng_data, { memcpy(block->block_contents+offset, &data->first_frame_with_data, sizeof(data->first_frame_with_data)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents + offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents + offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } offset += sizeof(data->first_frame_with_data); memcpy(block->block_contents+offset, &data->stride_length, sizeof(data->stride_length)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + (block->block_contents + offset)) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - (block->block_contents + offset)) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. " + "%s: %d\n", + __FILE__, __LINE__); } offset += sizeof(data->stride_length); } @@ -4344,17 +4041,8 @@ static tng_function_status tng_data_block_write(tng_trajectory_t tng_data, { memcpy(block->block_contents+offset, &data->values[i][j].f, size); - if(tng_data->endianness_32 != TNG_BIG_ENDIAN_32) - { - if(tng_swap_byte_order_32(tng_data, - (int32_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } - } + tng_swap_byte_order_32(tng_data, + (int32_t *)(block->block_contents+offset)); offset += size; } } @@ -4366,17 +4054,8 @@ static tng_function_status tng_data_block_write(tng_trajectory_t tng_data, { memcpy(block->block_contents+offset, &data->values[i][j].i, size); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) - { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } - } + tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)); offset += size; } } @@ -4401,17 +4080,8 @@ static tng_function_status tng_data_block_write(tng_trajectory_t tng_data, { memcpy(block->block_contents+offset, &data->values[i][j].d, size); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) - { - if(tng_swap_byte_order_64(tng_data, - (int64_t *)(block->block_contents+offset)) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. " - "%s: %d\n", - __FILE__, __LINE__); - } - } + tng_swap_byte_order_64(tng_data, + (int64_t *)(block->block_contents+offset)); offset += size; } } @@ -4511,25 +4181,19 @@ static tng_function_status tng_data_block_contents_read memcpy(&n_values, block->block_contents+offset, sizeof(n_values)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &n_values) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &n_values) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(n_values); memcpy(&codec_id, block->block_contents+offset, sizeof(codec_id)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &codec_id) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &codec_id) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(codec_id); @@ -4537,14 +4201,11 @@ static tng_function_status tng_data_block_contents_read { memcpy(&multiplier, block->block_contents+offset, sizeof(multiplier)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *)&multiplier) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *)&multiplier) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(multiplier); } @@ -4559,27 +4220,21 @@ static tng_function_status tng_data_block_contents_read { memcpy(&first_frame_with_data, block->block_contents+offset, sizeof(first_frame_with_data)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &first_frame_with_data) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &first_frame_with_data) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(first_frame_with_data); memcpy(&steps_between_data, block->block_contents+offset, sizeof(steps_between_data)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &steps_between_data) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &steps_between_data) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(steps_between_data); } @@ -4601,27 +4256,21 @@ static tng_function_status tng_data_block_contents_read { memcpy(&num_first_particle, block->block_contents+offset, sizeof(num_first_particle)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &num_first_particle) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &num_first_particle) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(num_first_particle); memcpy(&block_n_particles, block->block_contents+offset, sizeof(block_n_particles)); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &block_n_particles) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &block_n_particles) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } offset += sizeof(block_n_particles); } @@ -4720,13 +4369,10 @@ static tng_function_status tng_header_pointers_update pos = tng_data->first_trajectory_frame_set_output_file_pos; - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &pos) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &pos) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } if(fwrite(&pos, sizeof(int64_t), 1, tng_data->output_file) != 1) @@ -4740,13 +4386,10 @@ static tng_function_status tng_header_pointers_update pos = tng_data->last_trajectory_frame_set_output_file_pos; - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &pos) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &pos) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } if(fwrite(&pos, @@ -4819,13 +4462,10 @@ static tng_function_status tng_frame_set_pointers_update pos = tng_data->current_trajectory_frame_set_output_file_pos; - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &pos) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &pos) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } if(fwrite(&pos, sizeof(int64_t), 1, tng_data->output_file) != 1) @@ -4868,13 +4508,10 @@ static tng_function_status tng_frame_set_pointers_update pos = tng_data->current_trajectory_frame_set_output_file_pos; - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &pos) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &pos) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } if(fwrite(&pos, sizeof(int64_t), 1, tng_data->output_file) != 1) @@ -4916,13 +4553,10 @@ static tng_function_status tng_frame_set_pointers_update pos = tng_data->current_trajectory_frame_set_output_file_pos; - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &pos) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &pos) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } if(fwrite(&pos, sizeof(int64_t), 1, tng_data->output_file) != 1) @@ -7181,16 +6815,13 @@ tng_function_status tng_frame_set_new(tng_trajectory_t tng_data, return(TNG_CRITICAL); } - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + &frame_set-> + medium_stride_prev_frame_set_file_pos) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - &frame_set-> - medium_stride_prev_frame_set_file_pos) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } tng_block_destroy(&block); @@ -7240,16 +6871,13 @@ tng_function_status tng_frame_set_new(tng_trajectory_t tng_data, return(TNG_CRITICAL); } - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, + &frame_set-> + long_stride_prev_frame_set_file_pos) + != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, - &frame_set-> - long_stride_prev_frame_set_file_pos) - != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } } @@ -7863,39 +7491,30 @@ tng_function_status tng_frame_data_write(tng_trajectory_t tng_data, fread(&data.n_values_per_frame, sizeof(data.n_values_per_frame), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &data.n_values_per_frame) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &data.n_values_per_frame) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } fread(&data.codec_id, sizeof(data.codec_id), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &data.codec_id) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &data.codec_id) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } if(data.codec_id != TNG_UNCOMPRESSED) { fread(&data.compression_multiplier, sizeof(data.compression_multiplier), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + &data.compression_multiplier) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - &data.compression_multiplier) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } } else @@ -7907,26 +7526,20 @@ tng_function_status tng_frame_data_write(tng_trajectory_t tng_data, { fread(&data.first_frame_with_data, sizeof(data.first_frame_with_data), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &data.first_frame_with_data) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &data.first_frame_with_data) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } fread(&data.stride_length, sizeof(data.stride_length), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &data.stride_length) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &data.stride_length) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } } else @@ -8281,39 +7894,30 @@ tng_function_status tng_frame_particle_data_write(tng_trajectory_t tng_data, fread(&data.n_values_per_frame, sizeof(data.n_values_per_frame), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &data.n_values_per_frame) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &data.n_values_per_frame) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } fread(&data.codec_id, sizeof(data.codec_id), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &data.codec_id) != TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &data.codec_id) != TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } if(data.codec_id != TNG_UNCOMPRESSED) { fread(&data.compression_multiplier, sizeof(data.compression_multiplier), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, (int64_t *) + &data.compression_multiplier) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, (int64_t *) - &data.compression_multiplier) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } } else @@ -8325,26 +7929,20 @@ tng_function_status tng_frame_particle_data_write(tng_trajectory_t tng_data, { fread(&data.first_frame_with_data, sizeof(data.first_frame_with_data), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &data.first_frame_with_data) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &data.first_frame_with_data) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } fread(&data.stride_length, sizeof(data.stride_length), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &data.stride_length) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &data.stride_length) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } } else @@ -8355,25 +7953,19 @@ tng_function_status tng_frame_particle_data_write(tng_trajectory_t tng_data, data.n_frames = tng_data->current_trajectory_frame_set.n_frames; fread(&num_first_particle, sizeof(num_first_particle), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &num_first_particle) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &num_first_particle) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } fread(&block_n_particles, sizeof(block_n_particles), 1, tng_data->input_file); - if(tng_data->endianness_64 != TNG_BIG_ENDIAN_64) + if(tng_swap_byte_order_64(tng_data, &block_n_particles) != + TNG_SUCCESS) { - if(tng_swap_byte_order_64(tng_data, &block_n_particles) != - TNG_SUCCESS) - { - printf("Cannot swap byte order to get big endian. %s: %d\n", - __FILE__, __LINE__); - } + printf("Cannot swap byte order to get big endian. %s: %d\n", + __FILE__, __LINE__); } |