tar.h (1157B)
1 #ifndef KIT_DIST_TAR_H 2 #define KIT_DIST_TAR_H 3 4 #include <kit/core.h> 5 #include <stddef.h> 6 #include <stdint.h> 7 8 #include "dist.h" 9 10 /* Minimal ustar reader/writer. Real, not a stub: this is plain container 11 * framing, not security-sensitive. Regular files only; names < 100 bytes 12 * (the ustar `name` field). Used both for the payload archive and for the 13 * outer `.kpkg` bag. */ 14 15 /* Append one regular-file member. Returns DIST_OK / DIST_ERR (name too long 16 * or writer error). */ 17 int dist_tar_append(KitWriter* out, const char* name, const uint8_t* data, 18 size_t size); 19 20 /* Write the end-of-archive marker (two zero blocks). */ 21 int dist_tar_finish(KitWriter* out); 22 23 typedef struct DistTarEntry { 24 char name[DIST_PATH_MAX + 1]; 25 const uint8_t* data; /* aliases into the input buffer */ 26 size_t size; 27 } DistTarEntry; 28 29 /* Parse `data`/`len` into up to `cap` entries, storing the count in *count. 30 * Returns DIST_OK on a well-formed archive, DIST_ERR on truncation, a bad 31 * checksum, or more than `cap` members. */ 32 int dist_tar_iter(const uint8_t* data, size_t len, DistTarEntry* out, 33 size_t cap, size_t* count); 34 35 #endif