archives.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef ARCHIVES_H
  2. #define ARCHIVES_H
  3. #include <metalang99.h>
  4. #ifdef TAR_H
  5. # define FROM_TAR ML99_TRUE()
  6. #else
  7. # define FROM_TAR ML99_FALSE()
  8. #endif
  9. #include "archive.h"
  10. #include "archives/7z.h"
  11. #include "archives/xz.h"
  12. #include "archives/zip.h"
  13. #include "archives/rar.h"
  14. #include "archives/tar.h"
  15. #include "archives/lz4.h"
  16. #include "archives/lzo.h"
  17. #include "archives/zst.h"
  18. #include "archives/lzma.h"
  19. #include "archives/gzip.h"
  20. #include "archives/bzip2.h"
  21. #define LIST(X) ML99_list(ML99_untuple(v(X)))
  22. #define NEW_ARITY 1
  23. #define NEW_IMPL(NAME) v(DYN(NAME, Archive, &(NAME){ 0 }))
  24. #define ALL_OR_TAR(NOT_TAR, TAR) \
  25. ML99_IF(FROM_TAR, LIST(TAR), ML99_listAppend(LIST(NOT_TAR), LIST(TAR)))
  26. /* building with tcc fails if array size not explicitly specified */
  27. #define NEW(ALL_NAME, TAR_NAME, NOT_TAR, TAR) \
  28. ML99_IF(FROM_TAR, TAR_NAME, ALL_NAME) \
  29. [ML99_EVAL(ML99_listLen(ALL_OR_TAR(NOT_TAR, TAR)))] = { \
  30. ML99_LIST_EVAL_COMMA_SEP( \
  31. ML99_listMap(v(NEW), ALL_OR_TAR(NOT_TAR, TAR))) \
  32. }
  33. #define ARCHIVES (Tar /* tar should be first */, Zip, Rar, SevenZip)
  34. #define TAR (GZip, BZip2, XZ, LZMA, LZ4, LZO, ZST)
  35. ML99_GCC_PRAGMA("GCC diagnostic push")
  36. /* ignore: initializer element is not constant */
  37. ML99_GCC_PRAGMA("GCC diagnostic ignored \"-Wpedantic\"")
  38. static Archive NEW(archives, tar_compressors, ARCHIVES, TAR);
  39. ML99_GCC_PRAGMA("GCC diagnostic pop")
  40. #endif /* ARCHIVES_H */