X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fzip-reader.c;h=4672a1079f96ae12367670c7a1d4a760425c251b;hb=23c5ab34eec1b2c2fef34155620c7cab670175f0;hp=bee7e2f240ff2affad679c5a50f1bef916d638a6;hpb=551202adbc334f9c33f8290a4e407b422651bbd5;p=pspp diff --git a/src/libpspp/zip-reader.c b/src/libpspp/zip-reader.c index bee7e2f240..4672a1079f 100644 --- a/src/libpspp/zip-reader.c +++ b/src/libpspp/zip-reader.c @@ -26,6 +26,7 @@ #include #include +#include #include #include "inflate.h" @@ -160,9 +161,28 @@ get_bytes (FILE *f, void *x, size_t n) /* Read a 32 bit value from F */ static void -get_u32 (FILE *f, uint32_t *x) +get_u32 (FILE *f, uint32_t *v) { - get_bytes (f, x, sizeof *x); + uint32_t x; + get_bytes (f, &x, sizeof x); +#ifdef WORDS_BIGENDIAN + *v = bswap_32 (x); +#else + *v = x; +#endif +} + +/* Read a 16 bit value from F */ +static void +get_u16 (FILE *f, uint16_t *v) +{ + uint16_t x; + get_bytes (f, &x, sizeof x); +#ifdef WORDS_BIGENDIAN + *v = bswap_16 (x); +#else + *v = x; +#endif } @@ -187,13 +207,6 @@ check_magic (FILE *f, uint32_t expected, struct string *err) } -/* Read a 16 bit value from F */ -static void -get_u16 (FILE *f, uint16_t *x) -{ - get_bytes (f, x, sizeof *x); -} - /* Reads upto BYTES bytes from ZM and puts them in BUF. Returns the number of bytes read, or -1 on error */ int