Use custom streams with microtar
masterInstead of reading from or writing to a file, you can manually initialize the mtar_t struct to work with custom streams.
Steps to use a custom stream:
- Manually initialize the
mtar_tstruct. - Set the
streampointer. - Provide the required callback functions.
- Ensure all unused fields are zero-initialized.
- Do not call
mtar_openif you have initialized the struct manually.
Required Callbacks for Reading
| Name | Arguments | Description |
|---|---|---|
read | mtar_t *tar, void *data, unsigned size | Read data from the stream |
seek | mtar_t *tar, unsigned pos | Set the position indicator |
close | mtar_t *tar | Close the stream |
Required Callbacks for Writing
| Name | Arguments | Description |
|---|---|---|
write | mtar_t *tar, const void *data, unsigned size | Write data to the stream |
All callbacks must return MTAR_ESUCCESS on success or a negative integer on error.