Go to the source code of this file.
Functions | |
| int | bin_open (char *binfile, int flags, struct FHeader *fh, int options) |
| Open a MacBinary file for reading or writing. | |
| int | bin_close (int keepflag) |
| Close the active MacBinary file. | |
| const char * | bin_path (void) |
| ssize_t | bin_read (int fork, char *buffer, size_t length) |
| Read data from a MacBinary fork. | |
| ssize_t | bin_write (int fork, char *buffer, size_t length) |
| Write data to a MacBinary fork. | |
| int | bin_header_read (struct FHeader *fh, int revision) |
| Read a MacBinary header into a file header. | |
| int | bin_header_write (struct FHeader *fh) |
| Write a file header as a MacBinary header. | |
| int | test_header (void) |
| Test the input header for a supported MacBinary revision. | |
| int bin_close | ( | int | keepflag | ) |
Close the active MacBinary file.
This must be called before opening another file with bin_open(). KEEP closes the file and preserves it. TRASH closes the file and removes incomplete output.
| int bin_header_read | ( | struct FHeader * | fh, |
| int | revision ) |
Read a MacBinary header into a file header.
This is called by bin_open() before any fork data is read. It validates the MacBinary revision, decodes header fields, and initializes fork lengths.
| [out] | fh | file header to populate |
| [in] | revision | MacBinary revision returned by test_header() |
| int bin_header_write | ( | struct FHeader * | fh | ) |
Write a file header as a MacBinary header.
This is called by bin_open() before any fork data is written. It encodes the file header as a MacBinary III header and initializes fork lengths.
| [in] | fh | file header to write |
| int bin_open | ( | char * | binfile, |
| int | flags, | ||
| struct FHeader * | fh, | ||
| int | options ) |
Open a MacBinary file for reading or writing.
This must be called before other MacBinary operations. When opening for reading, it validates and reads the MacBinary header. When opening for writing, it initializes output state and writes the header.
| [in] | binfile | 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 * bin_path | ( | void | ) |
| ssize_t bin_read | ( | int | fork, |
| char * | buffer, | ||
| size_t | length ) |
Read data from a MacBinary fork.
Call this until it returns zero for each fork. When the data fork is complete, it skips MacBinary padding before the resource fork begins.
| [in] | fork | fork selector, DATA or RESOURCE |
| [out] | buffer | destination buffer |
| [in] | length | maximum number of bytes to read |
| ssize_t bin_write | ( | int | fork, |
| char * | buffer, | ||
| size_t | length ) |
Write data to a MacBinary fork.
Data must be written in fork order. The resource fork cannot be written until the data fork is complete. Padding is written when each fork is finished.
| [in] | fork | fork selector, DATA or RESOURCE |
| [in] | buffer | source buffer |
| [in] | length | number of bytes to write |
| int test_header | ( | void | ) |
Test the input header for a supported MacBinary revision.
Reads the first 128 bytes and determines whether the file is MacBinary, MacBinary II, MacBinary III, or not a MacBinary file.