From 1f166f0a4ed9ed32ade1ed21a571c9b2d0171ebc Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Thu, 23 Apr 2020 21:52:24 -0700 Subject: fix: gzip macro error --- sys/libn/gz.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 sys/libn/gz.c (limited to 'sys/libn/gz.c') diff --git a/sys/libn/gz.c b/sys/libn/gz.c new file mode 100644 index 0000000..86face4 --- /dev/null +++ b/sys/libn/gz.c @@ -0,0 +1,90 @@ +#include +#include + +#include + +gz·Stream* +gz·open(byte *path, byte *mode) +{ + return gzopen(path, mode); +} + +error +gz·close(gz·Stream* s) +{ + return gzclose(s); +} + +int +gz·read(gz·Stream *s, int sz, int n, void* buf) +{ + return gzread(s, buf, n*sz); +} + +int +gz·readln(gz·Stream *s, int n, byte *buf) +{ + byte* b; + b = gzgets(s, buf, n); + + return strlen(b); +} + +byte +gz·getbyte(gz·Stream *s) +{ + // NOTE: Can't call macro + byte b[2]; + gzread(s, b, 1); + + return b[0]; +} + +error +gz·ungetbyte(gz·Stream *s, byte c) +{ + return gzungetc(c, s); +} + +int +gz·write(gz·Stream *s, int sz, int n, void* buf) +{ + return gzwrite(s, buf, n*sz); +} + +error +gz·putbyte(gz·Stream *s, byte c) +{ + return gzputc(s, c); +} + +error +gz·putstring(gz·Stream *s, byte *str) +{ + return gzputs(s, str); +} + +int +gz·printf(gz·Stream *s, byte *fmt, ...) +{ + error err; + + va_list args; + va_start(args, fmt); + err = gzprintf(s, fmt, args); + va_end(args); + + return err; +} + +error +gz·flush(gz·Stream *s) +{ + return gzflush(s, Z_FINISH); +} + +vlong +gz·seek(gz·Stream *s, long off, enum SeekPos whence) +{ + return gzseek(s, off, whence); +} -- cgit v1.2.1