#include <string.h>
#include <limits.h>
#include <fcntl.h>
#include "library_file.h"
#include "ccp4_errno.h"
#include "ccp4_file_err.h"
Functions | |
int | ccp4_file_raw_read (CCP4File *cfile, char *buffer, size_t n_items) |
int | ccp4_file_raw_write (CCP4File *cfile, const char *buffer, size_t n_items) |
int | ccp4_file_raw_seek (CCP4File *cfile, long offset, int whence) |
int | ccp4_file_is_write (const CCP4File *cfile) |
int | ccp4_file_is_read (const CCP4File *cfile) |
int | ccp4_file_is_append (const CCP4File *cfile) |
int | ccp4_file_is_scratch (const CCP4File *cfile) |
int | ccp4_file_is_buffered (const CCP4File *cfile) |
int | ccp4_file_status (const CCP4File *cfile) |
int | ccp4_file_raw_setstamp (CCP4File *cfile, const size_t offset) |
int | ccp4_file_setstamp (CCP4File *cfile, const size_t offset) |
int | ccp4_file_setmode (CCP4File *cfile, const int mode) |
int | ccp4_file_mode (const CCP4File *cfile) |
int | ccp4_file_itemsize (const CCP4File *cfile) |
const char * | ccp4_file_name (CCP4File *cfile) |
int | ccp4_file_setbyte (CCP4File *cfile, const int byte_order) |
int | ccp4_file_byte (CCP4File *cfile) |
CCP4File * | ccp4_file_open_file (const FILE *file, const int flag) |
CCP4File * | ccp4_file_open_fd (const int fd, const int flag) |
CCP4File * | ccp4_file_open (const char *filename, const int flag) |
int | ccp4_file_close (CCP4File *cfile) |
int | ccp4_file_rarch (CCP4File *cfile) |
int | ccp4_file_warch (CCP4File *cfile) |
int | ccp4_file_read (CCP4File *cfile, uint8 *buffer, size_t nitems) |
int | ccp4_file_readcomp (CCP4File *cfile, uint8 *buffer, size_t nitems) |
int | ccp4_file_readshortcomp (CCP4File *cfile, uint8 *buffer, size_t nitems) |
int | ccp4_file_readfloat (CCP4File *cfile, uint8 *buffer, size_t nitems) |
int | ccp4_file_readint (CCP4File *cfile, uint8 *buffer, size_t nitems) |
int | ccp4_file_readshort (CCP4File *cfile, uint8 *buffer, size_t nitems) |
int | ccp4_file_readchar (CCP4File *cfile, uint8 *buffer, size_t nitems) |
int | ccp4_file_write (CCP4File *cfile, const uint8 *buffer, size_t nitems) |
int | ccp4_file_writecomp (CCP4File *cfile, const uint8 *buffer, size_t nitems) |
int | ccp4_file_writeshortcomp (CCP4File *cfile, const uint8 *buffer, size_t nitems) |
int | ccp4_file_writefloat (CCP4File *cfile, const uint8 *buffer, size_t nitems) |
int | ccp4_file_writeint (CCP4File *cfile, const uint8 *buffer, size_t nitems) |
int | ccp4_file_writeshort (CCP4File *cfile, const uint8 *buffer, size_t nitems) |
int | ccp4_file_writechar (CCP4File *cfile, const uint8 *buffer, size_t nitems) |
int | ccp4_file_seek (CCP4File *cfile, long offset, int whence) |
void | ccp4_file_rewind (CCP4File *cfile) |
long | ccp4_file_length (CCP4File *cfile) |
long | ccp4_file_tell (CCP4File *cfile) |
int | ccp4_file_feof (CCP4File *cfile) |
void | ccp4_file_clearerr (CCP4File *cfile) |
void | ccp4_file_fatal (CCP4File *cfile, char *message) |
int | ccp4_file_error (CCP4File *cfile) |
void | ccp4_file_flush (CCP4File *cfile) |
char * | ccp4_file_print (CCP4File *cfile, char *msg_start, char *msg_end) |
int ccp4_file_byte | ( | CCP4File * | cfile | ) |
ccp4_file_byte:
cfile | (CCP4File *) |
void ccp4_file_clearerr | ( | CCP4File * | cfile | ) |
ccp4_file_clearerr:
cfile | (CCP4File *) |
Referenced by ccp4_file_rewind(), and ccp4_file_seek().
int ccp4_file_close | ( | CCP4File * | cfile | ) |
ccp4_file_close:
cfile | (CCP4File *) |
References ccp4_signal().
Referenced by ccp4_cmap_close(), ccp4_cmap_open(), MtzFree(), MtzGet(), and MtzPut().
int ccp4_file_error | ( | CCP4File * | cfile | ) |
ccp4_file_error:
cfile | (CCP4File *) |
References ccp4_strerror().
void ccp4_file_fatal | ( | CCP4File * | cfile, | |
char * | message | |||
) |
ccp4_file_fatal:
cfile | (CCP4File *) | |
message | message to output. Die with error message based on cfile error status. |
References ccp4_fatal(), and ccp4_signal().
int ccp4_file_feof | ( | CCP4File * | cfile | ) |
ccp4_file_feof:
cfile | (CCP4File *) |
References ccp4_signal().
void ccp4_file_flush | ( | CCP4File * | cfile | ) |
ccp4_file_flush:
cfile | (CCP4File *) |
int ccp4_file_is_append | ( | const CCP4File * | cfile | ) |
ccp4_file_is_append:
cfile | (CCP4File *) |
int ccp4_file_is_buffered | ( | const CCP4File * | cfile | ) |
ccp4_file_is_buffered:
cfile | (CCP4File *) |
int ccp4_file_is_read | ( | const CCP4File * | cfile | ) |
ccp4_file_is_read:
cfile | (CCP4File *) |
Referenced by ccp4_cmap_read_data(), ccp4_cmap_read_row(), ccp4_cmap_read_section(), ccp4_cmap_read_section_header(), ccp4_cmap_seek_section(), and ccp4_cmap_seek_symop().
int ccp4_file_is_scratch | ( | const CCP4File * | cfile | ) |
ccp4_file_is_scratch:
cfile | (CCP4File *) |
int ccp4_file_is_write | ( | const CCP4File * | cfile | ) |
ccp4_file_is_write:
cfile | (CCP4File *) |
Referenced by ccp4_cmap_close(), ccp4_cmap_get_mapstats(), ccp4_cmap_set_cell(), ccp4_cmap_set_datamode(), ccp4_cmap_set_dim(), ccp4_cmap_set_grid(), ccp4_cmap_set_label(), ccp4_cmap_set_local_header(), ccp4_cmap_set_mapstats(), ccp4_cmap_set_order(), ccp4_cmap_set_origin(), ccp4_cmap_set_spacegroup(), ccp4_cmap_set_symop(), ccp4_cmap_write_data(), ccp4_cmap_write_row(), ccp4_cmap_write_section(), and ccp4_cmap_write_section_header().
int ccp4_file_itemsize | ( | const CCP4File * | cfile | ) |
ccp4_file_itemsize:
cfile | (CCP4File *) |
References ccp4_signal().
Referenced by ccp4_cmap_read_row(), ccp4_cmap_seek_row(), ccp4_cmap_set_datamode(), ccp4_cmap_set_dim(), and parse_mapheader().
long ccp4_file_length | ( | CCP4File * | cfile | ) |
ccp4_file_length:
cfile | (CCP4File *) |
References ccp4_signal().
Referenced by number_sections().
int ccp4_file_mode | ( | const CCP4File * | cfile | ) |
ccp4_file_mode:
cfile | (CCP4File *) |
References ccp4_signal().
const char* ccp4_file_name | ( | CCP4File * | cfile | ) |
ccp4_file_name:
cfile | (CCP4File *) |
CCP4File* ccp4_file_open | ( | const char * | filename, | |
const int | flag | |||
) |
ccp4_file_open:
filename | (const char *) filename | |
flag | (const int) i/o mode, possible values are O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, O_TMP, O_CREAT, O_TRUNC - see ccp4_sysdep.h |
flag
. If !buffered use open(), otherwise fopen() The struct stat is check to determine if file is a regular file, if it is, and is not stdin, it is assumed to be direct access.
References ccp4_signal().
Referenced by ccp4_cmap_open(), MtzGet(), and MtzOpenForWrite().
CCP4File* ccp4_file_open_fd | ( | const int | fd, | |
const int | flag | |||
) |
ccp4_file_open_fd:
fd | (const int) file descriptor | |
flag | (const int) io mode (O_RDONLY =0, O_WRONLY =1, O_RDWR =2, O_TMP =, O_APPEND =) |
fd
and mode flag
The struct stat is check to determine if file is a regular file, if it is, and is not stdin, it is assumed to be direct access. References ccp4_signal().
CCP4File* ccp4_file_open_file | ( | const FILE * | file, | |
const int | flag | |||
) |
ccp4_file_open_file:
file | (const FILE *) FILE struct | |
flag | (const int) io mode (O_RDONLY =0, O_WRONLY =1, O_RDWR =2, O_TMP =, O_APPEND =) |
flag
. The struct stat is check to determine if file is a regular file, if it is, and is not stdin, it is assumed to be direct access. References ccp4_signal().
char* ccp4_file_print | ( | CCP4File * | cfile, | |
char * | msg_start, | |||
char * | msg_end | |||
) |
ccp4_file_print:
cfile | (CCP4File *) | |
msg_start | pointer to start position in string | |
msg_end | pointer to end position in string |
int ccp4_file_rarch | ( | CCP4File * | cfile | ) |
ccp4_file_rarch:
cfile | (CCP4File *) |
References ccp4_file_raw_read(), ccp4_file_raw_seek(), and ccp4_signal().
Referenced by ccp4_cmap_open(), and MtzGet().
int ccp4_file_raw_read | ( | CCP4File * | cfile, | |
char * | buffer, | |||
size_t | n_items | |||
) |
ccp4_file_raw_read:
cfile | * (CCP4File *) | |
buffer | * (char *) input array | |
n_items | (size_t) number of items |
References ccp4_signal().
Referenced by ccp4_file_rarch(), ccp4_file_readchar(), ccp4_file_readcomp(), ccp4_file_readfloat(), ccp4_file_readint(), ccp4_file_readshort(), and ccp4_file_readshortcomp().
int ccp4_file_raw_seek | ( | CCP4File * | cfile, | |
long | offset, | |||
int | whence | |||
) |
ccp4_file_raw_seek:
cfile | (CCP4File *) | |
offset | (long) offset in bytes | |
whence | (int) SEEK_SET, SEEK_CUR, or SEEK_END |
References ccp4_signal().
Referenced by ccp4_cmap_read_row(), ccp4_cmap_read_section(), ccp4_cmap_read_section_header(), ccp4_cmap_seek_row(), ccp4_cmap_seek_section(), ccp4_cmap_seek_symop(), ccp4_file_rarch(), ccp4_file_readchar(), ccp4_file_readcomp(), ccp4_file_readfloat(), ccp4_file_readint(), ccp4_file_readshort(), ccp4_file_readshortcomp(), ccp4_file_rewind(), ccp4_file_seek(), ccp4_file_warch(), ccp4_file_writechar(), ccp4_file_writecomp(), ccp4_file_writefloat(), ccp4_file_writeint(), ccp4_file_writeshort(), ccp4_file_writeshortcomp(), is_cmap(), and parse_maplabels().
int ccp4_file_raw_setstamp | ( | CCP4File * | cfile, | |
const size_t | offset | |||
) |
Set file offset
cfile | (CCP4File *) | |
offset | stamp location |
Referenced by ccp4_cmap_open(), and ccp4_file_setstamp().
int ccp4_file_raw_write | ( | CCP4File * | cfile, | |
const char * | buffer, | |||
size_t | n_items | |||
) |
ccp4_file_raw_write:
cfile | (CCP4File *) | |
buffer | (char *) output array | |
n_items | (size_t) number of items |
n_items
bytes from buffer to cfile via FILE struct cfile->stream(fwrite) or file desc cfile->fd(write/_write). Increments cfile->loc on success, or resets on failure, which is then used to determine the file length. On failure cfile->iostat is set. References ccp4_file_tell(), ccp4_signal(), and MAX.
Referenced by ccp4_file_warch(), ccp4_file_writechar(), ccp4_file_writecomp(), ccp4_file_writefloat(), ccp4_file_writeint(), ccp4_file_writeshort(), and ccp4_file_writeshortcomp().
int ccp4_file_read | ( | CCP4File * | cfile, | |
uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_read:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_signal().
Referenced by ccp4_cmap_read_data(), ccp4_cmap_read_row(), ccp4_cmap_read_section(), MtzGet(), and MtzRrefl().
int ccp4_file_readchar | ( | CCP4File * | cfile, | |
uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_readchar:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_read(), ccp4_file_raw_seek(), and ccp4_signal().
Referenced by ccp4_cmap_get_symop(), ccp4_cmap_read_section_header(), is_cmap(), MtzGet(), parse_mapheader(), and parse_maplabels().
int ccp4_file_readcomp | ( | CCP4File * | cfile, | |
uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_readcomp:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_read(), ccp4_file_raw_seek(), and ccp4_signal().
int ccp4_file_readfloat | ( | CCP4File * | cfile, | |
uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_readfloat:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_read(), ccp4_file_raw_seek(), and ccp4_signal().
Referenced by parse_mapheader().
int ccp4_file_readint | ( | CCP4File * | cfile, | |
uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_readint:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_read(), ccp4_file_raw_seek(), and ccp4_signal().
Referenced by parse_mapheader().
int ccp4_file_readshort | ( | CCP4File * | cfile, | |
uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_readshort:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_read(), ccp4_file_raw_seek(), and ccp4_signal().
int ccp4_file_readshortcomp | ( | CCP4File * | cfile, | |
uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_readshortcomp:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_read(), ccp4_file_raw_seek(), and ccp4_signal().
void ccp4_file_rewind | ( | CCP4File * | cfile | ) |
ccp4_file_rewind:
cfile | (CCP4File *) |
References ccp4_file_clearerr(), ccp4_file_raw_seek(), and ccp4_signal().
Referenced by is_cmap(), and parse_mapheader().
int ccp4_file_seek | ( | CCP4File * | cfile, | |
long | offset, | |||
int | whence | |||
) |
ccp4_file_seek:
cfile | (CCP4File *) | |
offset | (long) offset in items | |
whence | (int) SEEK_SET, SEEK_CUR, or SEEK_END |
References ccp4_file_clearerr(), ccp4_file_raw_seek(), and ccp4_signal().
Referenced by ccp4_cmap_seek_data(), MtzGet(), MtzOpenForWrite(), MtzPut(), and write_mapheader().
int ccp4_file_setbyte | ( | CCP4File * | cfile, | |
const int | byte_order | |||
) |
ccp4_file_setbyte:
cfile | (CCP4File *) | |
byte_order | (int) |
References ccp4_signal().
int ccp4_file_setmode | ( | CCP4File * | cfile, | |
const int | mode | |||
) |
ccp4_file_setmode:
cfile | (CCP4File *) | |
mode | (int) io_mode |
References ccp4_signal().
Referenced by ccp4_cmap_set_datamode(), MtzGet(), MtzOpenForWrite(), MtzPut(), MtzRrefl(), and parse_mapheader().
int ccp4_file_setstamp | ( | CCP4File * | cfile, | |
const size_t | offset | |||
) |
ccp4_file_setstamp:
cfile | (CCP4File *) | |
offset | (size_t) offset in items |
References ccp4_file_raw_setstamp(), and ccp4_signal().
Referenced by MtzGet(), and MtzOpenForWrite().
int ccp4_file_status | ( | const CCP4File * | cfile | ) |
ccp4_file_status:
cfile | (CCP4File *) |
long ccp4_file_tell | ( | CCP4File * | cfile | ) |
ccp4_file_tell:
cfile | (CCP4File *) |
References ccp4_signal().
Referenced by ccp4_cmap_get_symop(), ccp4_cmap_read_row(), ccp4_cmap_read_section(), ccp4_cmap_read_section_header(), ccp4_cmap_seek_row(), ccp4_cmap_seek_section(), ccp4_cmap_seek_symop(), and ccp4_file_raw_write().
int ccp4_file_warch | ( | CCP4File * | cfile | ) |
ccp4_file_warch:
cfile | (CCP4File *) |
References ccp4_file_raw_seek(), ccp4_file_raw_write(), and ccp4_signal().
Referenced by ccp4_cmap_close(), and MtzOpenForWrite().
int ccp4_file_write | ( | CCP4File * | cfile, | |
const uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_write:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_signal().
Referenced by ccp4_cmap_write_data(), ccp4_cmap_write_row(), ccp4_cmap_write_section(), MtzOpenForWrite(), MtzPut(), and MtzWrefl().
int ccp4_file_writechar | ( | CCP4File * | cfile, | |
const uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_writechar:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_seek(), ccp4_file_raw_write(), and ccp4_signal().
Referenced by ccp4_cmap_set_symop(), ccp4_cmap_write_section_header(), MtzOpenForWrite(), MtzWhdrLine(), write_mapheader(), and write_maplabels().
int ccp4_file_writecomp | ( | CCP4File * | cfile, | |
const uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_writecomp:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_seek(), ccp4_file_raw_write(), and ccp4_signal().
int ccp4_file_writefloat | ( | CCP4File * | cfile, | |
const uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_writefloat:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
Returns number of floats written on success, EOF on failure
References ccp4_file_raw_seek(), ccp4_file_raw_write(), and ccp4_signal().
Referenced by write_mapheader().
int ccp4_file_writeint | ( | CCP4File * | cfile, | |
const uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_writeint:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_seek(), ccp4_file_raw_write(), and ccp4_signal().
Referenced by write_mapheader().
int ccp4_file_writeshort | ( | CCP4File * | cfile, | |
const uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_writeshort:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_seek(), ccp4_file_raw_write(), and ccp4_signal().
int ccp4_file_writeshortcomp | ( | CCP4File * | cfile, | |
const uint8 * | buffer, | |||
size_t | nitems | |||
) |
ccp4_file_writeshortcomp:
cfile | (CCP4File *) | |
buffer | (uint8 *) buffer | |
nitems | (size_t) number of items |
References ccp4_file_raw_seek(), ccp4_file_raw_write(), and ccp4_signal().