diff --git a/lib/hio-tar.h b/lib/hio-tar.h index 6c05eea..3be3902 100644 --- a/lib/hio-tar.h +++ b/lib/hio-tar.h @@ -71,6 +71,8 @@ typedef struct hio_tar_hdr_t hio_tar_hdr_t; #define HIO_TAR_BLKSIZE (512) +typedef struct hio_tar_t hio_tar_t; + enum hio_tar_state_t { HIO_TAR_STATE_START, @@ -79,6 +81,12 @@ enum hio_tar_state_t }; typedef enum hio_tar_state_t hio_tar_state_t; +typedef void (*hio_tar_xcb_t) ( + hio_tar_t* tar, + const hio_bch_t* filename, + void* ctx +); + struct hio_tar_t { hio_t* hio; @@ -86,6 +94,8 @@ struct hio_tar_t struct { hio_bch_t root[2048]; + hio_tar_xcb_t xcb; + void* xcb_ctx; hio_tar_state_t state; struct @@ -105,7 +115,6 @@ struct hio_tar_t } hi; } x; /* extract */ }; -typedef struct hio_tar_t hio_tar_t; #if defined(__cplusplus) extern "C" { @@ -129,7 +138,16 @@ HIO_EXPORT void hio_tar_fini ( hio_tar_t* tar ); -#define hio_tar_endxfeed(tar) hio_tar_xfeed(tar, HIO_NULL, 0) +HIO_EXPORT void hio_tar_setxrootwithbcstr ( + hio_tar_t* tar, + const hio_bch_t* root +); + +HIO_EXPORT void hio_tar_setxcb ( + hio_tar_t* tar, + hio_tar_xcb_t xcb, + void* ctx +); HIO_EXPORT int hio_tar_xfeed ( hio_tar_t* tar, @@ -137,10 +155,7 @@ HIO_EXPORT int hio_tar_xfeed ( hio_oow_t len ); -HIO_EXPORT void hio_tar_setxrootwithbcstr ( - hio_tar_t* tar, - const hio_bch_t* root -); +#define hio_tar_endxfeed(tar) hio_tar_xfeed(tar, HIO_NULL, 0) #if defined(__cplusplus) } diff --git a/lib/tar.c b/lib/tar.c index dbe57b8..c2db731 100644 --- a/lib/tar.c +++ b/lib/tar.c @@ -101,7 +101,18 @@ void hio_tar_fini (hio_tar_t* tar) } } -/* extraction - the implementation is still far from completion */ +/* extraction - the implementation is still far from complete */ + +void hio_tar_setxrootwithbcstr (hio_tar_t* tar, const hio_bch_t* root) +{ + hio_copy_bcstr (tar->x.root, HIO_COUNTOF(tar->x.root), root); /* TOOD: handle truncation. make tar->x.root dyanmic? */ +} + +void hio_tar_setxcb (hio_tar_t* tar, hio_tar_xcb_t xcb, void* ctx) +{ + tar->x.xcb = xcb; + tar->x.xcb_ctx = ctx; +} static int x_process_header (hio_tar_t* tar) { @@ -275,7 +286,3 @@ int hio_tar_xfeed (hio_tar_t* tar, const void* ptr, hio_oow_t len) return 0; } -void hio_tar_setxrootwithbcstr (hio_tar_t* tar, const hio_bch_t* root) -{ - hio_copy_bcstr (tar->x.root, HIO_COUNTOF(tar->x.root), root); /* TOOD: handle truncation. make tar->x.root dyanmic? */ -} \ No newline at end of file