#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "cmaplib.h"
#include "cmap_data.h"
#include "cmap_stats.h"
#include "cmap_errno.h"
Functions | |
int | number_sections (CMMFile *mfile) |
int | ccp4_cmap_seek_section (CMMFile *mfile, int sec, unsigned int whence) |
int | ccp4_cmap_write_section (CMMFile *mfile, const void *section) |
int | ccp4_cmap_read_section (CMMFile *mfile, void *section) |
int | ccp4_cmap_read_section_header (const CMMFile *mfile, char *header) |
int | ccp4_cmap_write_section_header (CMMFile *mfile, const char *header) |
int | ccp4_cmap_seek_row (CMMFile *mfile, int row, unsigned int whence) |
int | ccp4_cmap_write_row (CMMFile *mfile, const void *row) |
int | ccp4_cmap_read_row (CMMFile *mfile, void *row) |
int | ccp4_cmap_seek_data (CMMFile *mfile, int offset, unsigned int whence) |
int | ccp4_cmap_write_data (CMMFile *mfile, const void *items, int n_items) |
int | ccp4_cmap_read_data (const CMMFile *mfile, void *items, int n_items) |
int ccp4_cmap_read_data | ( | const CMMFile * | mfile, | |
void * | items, | |||
int | n_items | |||
) |
raw read of nelements items from file according to the datamode at current location
mfile | (const CMMFile *) | |
items | (void *) values read to here, so should have enough space for nelements items | |
n_items | (int) number of items to be read |
References ccp4_file_is_read(), ccp4_file_read(), and ccp4_signal().
int ccp4_cmap_read_row | ( | CMMFile * | mfile, | |
void * | row | |||
) |
read current map section from file to section. Some checking is performed to ensure we are at the start of a legitimate map row.
mfile | (CMMFile *) | |
row | (void *) array large enough to hold the map row |
References ccp4_file_is_read(), ccp4_file_itemsize(), ccp4_file_raw_seek(), ccp4_file_read(), ccp4_file_tell(), and ccp4_signal().
int ccp4_cmap_read_section | ( | CMMFile * | mfile, | |
void * | section | |||
) |
read current map section from file to section. Some checking is performed to ensure we are at the start of a legitimate map section.
mfile | (CMMFile *) | |
section | (void *) array large enough to hold the map section |
References ccp4_file_is_read(), ccp4_file_raw_seek(), ccp4_file_read(), ccp4_file_tell(), and ccp4_signal().
int ccp4_cmap_read_section_header | ( | const CMMFile * | mfile, | |
char * | header | |||
) |
read current section header (character array) After reading we are at the end of the local header
mfile | (CMMFile *) | |
header | (char *) character array large enough to hold the local header (raw read so not string) |
References ccp4_errno, ccp4_file_is_read(), ccp4_file_raw_seek(), ccp4_file_readchar(), ccp4_file_tell(), and ccp4_signal().
int ccp4_cmap_seek_data | ( | CMMFile * | mfile, | |
int | offset, | |||
unsigned int | whence | |||
) |
raw seek in items
mfile | (CMMFile *) | |
offset | (int) number of items | |
whence | (unsigned int) SEEK_SET, SEEK_CUR, SEEK_END; |
References ccp4_errno, ccp4_file_seek(), and ccp4_signal().
int ccp4_cmap_seek_row | ( | CMMFile * | mfile, | |
int | row, | |||
unsigned int | whence | |||
) |
seek a row within a map section
mfile | (CMMFile *) | |
row | (int) | |
whence | (unsigned int) SEEK_SET, SEEK_END, SEEK_CUR |
References ccp4_file_itemsize(), ccp4_file_raw_seek(), ccp4_file_tell(), and ccp4_signal().
int ccp4_cmap_seek_section | ( | CMMFile * | mfile, | |
int | sec, | |||
unsigned int | whence | |||
) |
seek among the map sections. The units are of size block_size.
mfile | (CMMFile *) | |
sec | (int) section number | |
whence | (unsigned int) SEEK_SET, SEEK_CUR or SEEK_END |
References ccp4_file_is_read(), ccp4_file_raw_seek(), ccp4_file_tell(), and ccp4_signal().
int ccp4_cmap_write_data | ( | CMMFile * | mfile, | |
const void * | items, | |||
int | n_items | |||
) |
raw write of nelements items to file, according to the datamode, at current location
mfile | (const CMMFile *) | |
items | (void *) values written, should contain at least n_items items | |
n_items | (int) number of items to be written |
References ccp4_file_is_write(), ccp4_file_write(), and ccp4_signal().
int ccp4_cmap_write_row | ( | CMMFile * | mfile, | |
const void * | row | |||
) |
write map row to file. Note: this wraps a raw write, with no location checking. It is therefore the responsibility of the calling program to ensure that everything is correct. Effectively assume appending to file.
mfile | (CMMFile *) | |
row | (const void *) data to be written |
References ccp4_file_is_write(), ccp4_file_write(), and ccp4_signal().
int ccp4_cmap_write_section | ( | CMMFile * | mfile, | |
const void * | section | |||
) |
write map section to file. Note: this wraps a raw write, with no location checking. It is therefore the responsibility of the calling program to ensure that everything is correct. Effectively assume appending to file.
mfile | (CMMFile *) | |
section | (const void *) |
References ccp4_file_is_write(), ccp4_file_write(), and ccp4_signal().
int ccp4_cmap_write_section_header | ( | CMMFile * | mfile, | |
const char * | header | |||
) |
write the local section header to the file. This must be of size mfile->data.header.size. Note: no checking is done so it is up to the calling program to ensure that the file is in the correct location. As seeking is turned off, this assumes we are appending to the file.
mfile | (CMMFile *) | |
header | (const char *) the local header character array (not necessarily a string) |
References ccp4_errno, ccp4_file_is_write(), ccp4_file_writechar(), and ccp4_signal().
int number_sections | ( | CMMFile * | mfile | ) |
Internal: return the an estimate of the number of sections in the map file based upon the length. Update mfile->data.number as a side effect.
mfile | (CMMFile *) |
References ccp4_file_length().