Go to the source code of this file.
Functions | |
| int | skip_junk (int line) |
| Skip non-BinHex text until encoded data is found. | |
| int | hqx_open (char *hqxfile, int flags, struct FHeader *fh, int options) |
| Open a BinHex file for reading or writing. | |
| int | hqx_close (int keepflag) |
| Close the active BinHex file. | |
| const char * | hqx_path (void) |
| ssize_t | hqx_read (int fork, char *buffer, size_t length) |
| Read decoded data from a BinHex fork. | |
| ssize_t | hqx_write (int fork, char *buffer, size_t length) |
| int | hqx_header_read (struct FHeader *fh) |
| Read and validate a BinHex header. | |
| int | hqx_header_write (struct FHeader *fh) |
| Encode and write a BinHex header. | |
| size_t | hqx_7tobin (char *outbuf, size_t datalen) |
| Decode BinHex text data to binary. | |
| ssize_t | hqx7_fill (unsigned char *hqx7_ptr) |
| Fill the BinHex text input buffer. | |
| ssize_t hqx7_fill | ( | unsigned char * | hqx7_ptr | ) |
Fill the BinHex text input buffer.
This is called from skip_junk() and hqx_7tobin(). It reads from the BinHex file into the hqx7 buffer and updates hqx7_first and hqx7_last to delimit valid data.
| [in] | hqx7_ptr | pointer within hqx7_buf where reading should start |
| size_t hqx_7tobin | ( | char * | outbuf, |
| size_t | datalen ) |
Decode BinHex text data to binary.
This is called by hqx_header_read() for header data and by hqx_read() for fork data and CRC fields. It buffers decoded data so callers get the requested length unless end of file is reached.
| [out] | outbuf | destination buffer for decoded bytes |
| [in] | datalen | number of decoded bytes requested |
outbuf | int hqx_close | ( | int | keepflag | ) |
Close the active BinHex file.
This must be called before opening another file with hqx_open(). In write mode, KEEP finishes any remaining fork data, flushes the encoder, and writes the BinHex terminator. TRASH closes the output and removes the incomplete file.
| int hqx_header_read | ( | struct FHeader * | fh | ) |
Read and validate a BinHex header.
This is called by hqx_open() before any fork data is read. It decodes the header fields, initializes fork lengths and CRC state, and verifies the header CRC.
| [out] | fh | file header to populate |
| int hqx_header_write | ( | struct FHeader * | fh | ) |
Encode and write a BinHex header.
| [in] | fh | file header to write |
| int hqx_open | ( | char * | hqxfile, |
| int | flags, | ||
| struct FHeader * | fh, | ||
| int | options ) |
Open a BinHex file for reading or writing.
This must be called before other hqx operations. When opening for reading, it skips the preamble and reads the BinHex header. When opening for writing, it initializes output state and writes the BinHex preamble and header.
| [in] | hqxfile | input file path, or - for standard input |
| [in] | flags | open flags; O_RDONLY selects read mode |
| [in,out] | fh | file header to read or write |
| [in] | options | output options, such as OPTION_STDOUT |
| const char * hqx_path | ( | void | ) |
| ssize_t hqx_read | ( | int | fork, |
| char * | buffer, | ||
| size_t | length ) |
Read decoded data from a BinHex fork.
Call this until it returns zero for each fork. When no fork data remains, the stored fork CRC is read and compared with the calculated CRC before returning zero.
| [in] | fork | fork selector, DATA or RESOURCE |
| [out] | buffer | destination buffer |
| [in] | length | maximum number of bytes to read |
| ssize_t hqx_write | ( | int | fork, |
| char * | buffer, | ||
| size_t | length ) |
| int skip_junk | ( | int | line | ) |
Skip non-BinHex text until encoded data is found.
This is called from hqx_open() to find the first valid BinHex line, and from hqx_7tobin() to find subsequent encoded lines.