From 584532f3ff22943f505042c7bed69b0479393218 Mon Sep 17 00:00:00 2001 From: Guido Draheim Date: Wed, 18 Dec 2002 17:13:17 +0000 Subject: [PATCH] This commit was generated by cvs2svn to compensate for changes in r31, which included commits to RCS files with non-trunk default branches. --- SDL/SDL_rwops_zzcat.c | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 SDL/SDL_rwops_zzcat.c diff --git a/SDL/SDL_rwops_zzcat.c b/SDL/SDL_rwops_zzcat.c new file mode 100644 index 0000000..8df2685 --- /dev/null +++ b/SDL/SDL_rwops_zzcat.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2001 Guido Draheim + * Use freely under the restrictions of the ZLIB License + * + * (this example uses errno which might not be multithreaded everywhere) + */ + +#include +#include /* exit */ + +/* mostly a copy from zzcat.c */ + +int main (int argc, char** argv) +{ + static const char usage[] = + " zzcat ... \n" + " - prints the file to stdout. the file can be a normal file\n" + " or an inflated part of a zip-archive \n" + ; + + int argn; + if (argc <= 1) + { + printf (usage); + exit (0); + } + + for (argn=1; argn < argc; argn++) + { + SDL_RWops* rwops; + + rwops = SDL_RWFromZZIP (argv[argn], "rb"); + if (! rwops) + { + perror (argv[argn]); + continue; + }else{ + char buf[17]; + int n; + + /* read chunks of 16 bytes into buf and print them to stdout */ + while (0 < (n = SDL_RWread(rwops, buf, 16, 1))) + { + buf[n] = '\0'; +# ifdef STDOUT_FILENO + write (STDOUT_FILENO, buf, n); +# else + fwrite (buf, 1, n, stdout); +# endif + } + + if (n == -1) + perror (argv[argn]); + + SDL_RWclose (rwops); + } + } + + return 0; +} + + + -- 2.40.0