diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-04-23 21:52:24 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-04-23 21:52:24 -0700 |
commit | 1f166f0a4ed9ed32ade1ed21a571c9b2d0171ebc (patch) | |
tree | 7e5e3258aaa8b82bcc783f79b7fd7285c34e7a32 /sys/libn/gz.c | |
parent | 04622b678ab6c623b63d1f69c36c22610dc920f2 (diff) |
fix: gzip macro error
Diffstat (limited to 'sys/libn/gz.c')
-rw-r--r-- | sys/libn/gz.c | 90 |
1 files changed, 90 insertions, 0 deletions
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 <u.h> +#include <libn.h> + +#include <vendor/zlib.h> + +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); +} |