preparing to add hio_tar_setxcb()

This commit is contained in:
hyung-hwan 2022-12-14 16:14:29 +00:00
parent f917a0ec69
commit c608ae9246
2 changed files with 33 additions and 11 deletions

View File

@ -71,6 +71,8 @@ typedef struct hio_tar_hdr_t hio_tar_hdr_t;
#define HIO_TAR_BLKSIZE (512) #define HIO_TAR_BLKSIZE (512)
typedef struct hio_tar_t hio_tar_t;
enum hio_tar_state_t enum hio_tar_state_t
{ {
HIO_TAR_STATE_START, HIO_TAR_STATE_START,
@ -79,6 +81,12 @@ enum hio_tar_state_t
}; };
typedef enum hio_tar_state_t 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 struct hio_tar_t
{ {
hio_t* hio; hio_t* hio;
@ -86,6 +94,8 @@ struct hio_tar_t
struct struct
{ {
hio_bch_t root[2048]; hio_bch_t root[2048];
hio_tar_xcb_t xcb;
void* xcb_ctx;
hio_tar_state_t state; hio_tar_state_t state;
struct struct
@ -105,7 +115,6 @@ struct hio_tar_t
} hi; } hi;
} x; /* extract */ } x; /* extract */
}; };
typedef struct hio_tar_t hio_tar_t;
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
@ -129,7 +138,16 @@ HIO_EXPORT void hio_tar_fini (
hio_tar_t* tar 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_EXPORT int hio_tar_xfeed (
hio_tar_t* tar, hio_tar_t* tar,
@ -137,10 +155,7 @@ HIO_EXPORT int hio_tar_xfeed (
hio_oow_t len hio_oow_t len
); );
HIO_EXPORT void hio_tar_setxrootwithbcstr ( #define hio_tar_endxfeed(tar) hio_tar_xfeed(tar, HIO_NULL, 0)
hio_tar_t* tar,
const hio_bch_t* root
);
#if defined(__cplusplus) #if defined(__cplusplus)
} }

View File

@ -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) 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; 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? */
}