12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef ARCHIVE_H
- #define ARCHIVE_H
- #include <fcntl.h>
- #include <stdint.h>
- #include <interface99.h>
- #include "util.h"
- #define EXT(EXT) "." #EXT
- #define CREATE_RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
- struct Config {
- uint8_t verbose;
- uint8_t dry_run;
- char *out_dir;
- char *out_file;
- char *custom_ext;
- char *threads;
- char *memory_limit;
- char **files;
- int files_count;
- };
- #define SELF_CFG(S, C) \
- struct Config *C; \
- SAFE_ASSIGN(C, S)
- #define FUNC_ARGS void *self, char *const file //, const struct Config *cfg
- #define Match_IFACE vfunc(uint8_t, match, void *self, char *const file)
- interface(Match);
- #define List_IFACE vfunc(int, list, FUNC_ARGS)
- interface(List);
- #define Extract_IFACE vfunc(int, extract, FUNC_ARGS)
- interface(Extract);
- #define Create_IFACE vfunc(int, create, FUNC_ARGS)
- interface(Create);
- #define Archive_IFACE
- #define Archive_EXTENDS (Match, List, Extract, Create)
- interface(Archive);
- #define DEF_EXTRACTOR(NAME) \
- typedef struct { \
- char /* unused */ _; \
- } NAME; \
- declImplExtern(Archive, NAME)
- #define DEF_TAR_COMPRESSOR(NAME, PROG) \
- static int NAME##_list(void *self, char *const file) \
- { \
- return tar_compressor_list(#PROG, file, self, &NAME##_ctx); \
- } \
- impl(List, NAME); \
- static int NAME##_extract(void *self, char *const file) \
- { \
- return tar_compressor_extract(#PROG, \
- file, \
- self, \
- &NAME##_ctx); \
- } \
- impl(Extract, NAME); \
- static int NAME##_create(void *self, char *const file) \
- { \
- return tar_compressor_create(#PROG, file, self, &NAME##_ctx); \
- } \
- impl(Create, NAME)
- #endif /* ARCHIVE_H */
|