Debian Codegraph @

libs/zziplib/zziplib-src/SDL/SDL_rwops_zzcat.c

raw
1 /*
2 * Copyright (c) 2001 Guido Draheim <[email protected]>
3 * Use freely under the restrictions of the ZLIB License
4 *
5 * (this example uses errno which might not be multithreaded everywhere)
6 */
7
8 #include <SDL_rwops_zzip.h>
9 #include <stdlib.h> /* exit */
10
11 /* mostly a copy from zzcat.c */
12
13 int main (int argc, char** argv)
14 {
15 static const char usage[] =
16 " zzcat <file>... \n"
17 " - prints the file to stdout. the file can be a normal file\n"
18 " or an inflated part of a zip-archive \n"
19 ;
20
21 int argn;
22 if (argc <= 1)
23 {
24 printf (usage);
25 exit (0);
26 }
27
28 for (argn=1; argn < argc; argn++)
29 {
30 SDL_RWops* rwops;
31
32 rwops = SDL_RWFromZZIP (argv[argn], "rb");
33 if (! rwops)
34 {
35 perror (argv[argn]);
36 continue;
37 }else{
38 char buf[17];
39 int n;
40
41 /* read chunks of 16 bytes into buf and print them to stdout */
42 while (0 < (n = SDL_RWread(rwops, buf, 1, 16)))
43 {
44 buf[n] = '\0';
45 # ifdef STDOUT_FILENO
46 write (STDOUT_FILENO, buf, n);
47 # else
48 fwrite (buf, 1, n, stdout);
49 # endif
50 }
51
52 if (n == -1)
53 perror (argv[argn]);
54
55 SDL_RWclose (rwops);
56 }
57 }
58
59 return 0;
60 }
61
62
63