diff options
author | Sylvain Beucler <beuc@beuc.net> | 2012-12-16 20:18:29 (GMT) |
---|---|---|
committer | Sylvain Beucler <beuc@beuc.net> | 2012-12-18 01:21:16 (GMT) |
commit | 5e33afc27765c638700f9ca061468bcf65192339 (patch) | |
tree | 205331bb02cfafcb594142a23b5007fec3a52da9 /src/libzip-test.c | |
parent | 6124d1a06e4113b1fcd0bdfb7ce5f042aae9c779 (diff) | |
download | mxe-5e33afc27765c638700f9ca061468bcf65192339.zip mxe-5e33afc27765c638700f9ca061468bcf65192339.tar.gz mxe-5e33afc27765c638700f9ca061468bcf65192339.tar.bz2 |
Add build file for libzip
- Build against latest stable release
- Cross-compilation broke somewhere between 0.9 and 0.10, we could
recommend
http://www.sourceware.org/autobook/autobook/autobook_255.html
to upstream so they fix 'zip.h'.
Provided quick patch meanwhile.
- Added 'Requires: zlib' in the pkg-config file, we could suggest the
improvement to upstream
- _UPDATE rule implemented
- Test case included
Coded while hacking GNU FreeDink :)
Diffstat (limited to 'src/libzip-test.c')
-rw-r--r-- | src/libzip-test.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/libzip-test.c b/src/libzip-test.c new file mode 100644 index 0000000..e23b325 --- /dev/null +++ b/src/libzip-test.c @@ -0,0 +1,42 @@ +/* + * This file is part of MXE. + * See index.html for further information. + */ + +#include <zip.h> +#include <stdlib.h> + +/* Adapted from freedink/src/SDL_rwops_libzip.c */ +int main(int argc, char* argv[]) +{ + struct zip* zarchive; + int errorp = 0; + + (void)argc; + (void)argv; + + zarchive = zip_open("idontexist.zip", ZIP_CHECKCONS, &errorp); + if (errorp != 0) + { + char *errorbuf = NULL; + int len = 1; + errorbuf = malloc(len); + len = zip_error_to_str(errorbuf, len, errorp, errno); + errorbuf = realloc(errorbuf, len + 1); + len = zip_error_to_str(errorbuf, len, errorp, errno); + fprintf(stderr, "zip_open: %s\n", errorbuf); + free(errorbuf); + } + else + { + struct zip_file* zfile; + zfile = zip_fopen(zarchive, "fichier.txt", 0); + if (zfile == NULL) + { + fprintf(stderr, "zip_open: %s\n", zip_strerror(zarchive)); + zip_close(zarchive); + } + } + + return 0; +} |