aboutsummaryrefslogtreecommitdiff
path: root/gzip.h
diff options
context:
space:
mode:
Diffstat (limited to 'gzip.h')
-rw-r--r--gzip.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/gzip.h b/gzip.h
new file mode 100644
index 0000000..e5d5947
--- /dev/null
+++ b/gzip.h
@@ -0,0 +1,77 @@
+#ifndef GZIP_H
+#define GZIP_H
+
+#include <stdint.h>
+
+/* RFC 1952 */
+
+#define ID1 31
+#define ID2 139
+
+enum compression_method {
+ DEFLATE = 8,
+};
+
+enum flag {
+ FTEXT = 1 << 0,
+ FHCRC = 1 << 1,
+ FEXTRA = 1 << 2,
+ FNAME = 1 << 3,
+ FCOMMENT = 1 << 4,
+};
+
+const char *flag_str (enum flag f) {
+ switch (f) {
+ case FTEXT: return "Content is probably text";
+ case FHCRC: return "CRC16 is present";
+ case FEXTRA: return "Extra field is populated";
+ case FNAME: return "A file name is present";
+ case FCOMMENT: return "A comment is present";
+ default: return "unknown flag";
+ }
+}
+
+enum operating_system {
+ FAT = 0,
+ AMIGA,
+ VMS,
+ UNIX,
+ CMS,
+ ATARI_TOS,
+ HPFS,
+ MACINTOSH,
+ Z_SYSTEM,
+ CP_M,
+ TOPS20,
+ NTFS,
+ QDOS,
+ ACORN_RISCOS,
+};
+
+const char *os_str(enum operating_system os) {
+ switch (os) {
+ case FAT: return "FAT filesystem (MS-DOS, OS/2, NT/Win32)";
+ case AMIGA: return "Amiga";
+ case VMS: return "VMS (or OpenVMS)";
+ case UNIX: return "Unix";
+ case CMS: return "VM/CMS";
+ case ATARI_TOS: return "Atari TOS";
+ case HPFS: return "HPFS filesystem (OS/2, NT)";
+ case MACINTOSH: return "Macintosh";
+ case Z_SYSTEM: return "Z-System";
+ case CP_M: return "CP/M";
+ case TOPS20: return "TOPS-20";
+ case NTFS: return "NTFS filesystem (NT)";
+ case QDOS: return "QDOS";
+ case ACORN_RISCOS: return "Acorn RISCOS";
+ default: return "unknown";
+ }
+}
+
+struct member {
+ uint8_t id1, id2, cm, flg;
+ uint32_t mtime;
+ uint8_t xfl, os;
+} __attribute__((packed));
+
+#endif /* GZIP_H */