3 * SOFTWARE COPYRIGHT NOTICE AGREEMENT
4 * This software and its documentation are copyright 2008 by the
5 * Broad Institute/Massachusetts Institute of Technology. All rights are reserved.
7 * This software is supplied without any warranty or guaranteed support whatsoever.
8 * Neither the Broad Institute nor MIT can be responsible for its use, misuse,
21 //typedef int8_t bool;
25 char open_mode; // 'r' or 'w'
28 int uncompressed_block_size;
29 int compressed_block_size;
30 void* uncompressed_block;
31 void* compressed_block;
32 int64_t block_address;
43 * Open an existing file descriptor for reading or writing.
44 * Mode must be either "r" or "w".
45 * A subsequent bgzf_close will not close the file descriptor.
46 * Returns null on error.
48 BGZF* bgzf_fdopen(int fd, const char* __restrict mode);
51 * Open the specified file for reading or writing.
52 * Mode must be either "r" or "w".
53 * Returns null on error.
55 BGZF* bgzf_open(const char* path, const char* __restrict mode);
58 * Close the BGZ file and free all associated resources.
59 * Does not close the underlying file descriptor if created with bgzf_fdopen.
60 * Returns zero on success, -1 on error.
62 int bgzf_close(BGZF* fp);
65 * Read up to length bytes from the file storing into data.
66 * Returns the number of bytes actually read.
67 * Returns zero on end of file.
68 * Returns -1 on error.
70 int bgzf_read(BGZF* fp, void* data, int length);
73 * Write length bytes from data to the file.
74 * Returns the number of bytes written.
75 * Returns -1 on error.
77 int bgzf_write(BGZF* fp, const void* data, int length);
80 * Return a virtual file pointer to the current location in the file.
81 * No interpetation of the value should be made, other than a subsequent
82 * call to bgzf_seek can be used to position the file at the same point.
83 * Return value is non-negative on success.
84 * Returns -1 on error.
86 int64_t bgzf_tell(BGZF* fp);
89 * Set the file to read from the location specified by pos, which must
90 * be a value previously returned by bgzf_tell for this file (but not
91 * necessarily one returned by this file handle).
92 * The where argument must be SEEK_SET.
93 * Seeking on a file opened for write is not supported.
94 * Returns zero on success, -1 on error.
96 int64_t bgzf_seek(BGZF* fp, int64_t pos, int where);