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)
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)
}

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