2 * Copyright (c) 2000,2001,2002 Guido Draheim <guidod@gmx.de>
3 * Use freely under the restrictions of the ZLIB License
14 static const char usage
[] =
16 " zzipself <file>... \n"
17 " - prints the file to stdout, so you may want to redirect the output; \n"
18 " the file can be a normal file or an inflated part of a zip-archive, \n"
19 " however in this case the zip-archive happens to be the executed\n"
20 " binary itself, as if this program is a self-extract header of a zip. \n"
21 " zzipself README # same as # zzcat zzipself/README \n"
25 main (int argc
, char ** argv
)
35 for (argn
=1; argn
< argc
; argn
++)
37 /* ZZIP_FILE* fp = zzip_fopen (argv[0]+"/"+argv[argn], "rbi"); */
38 /* .... = zzip_open (argv[0]+"/"+argv[argn], O_RDONLY|O_BINARY,
39 * ZZIP_CASELESS|ZZIP_ONLYZIP, ext, 0); */
41 static const char* ext
[] = { "", ".exe", ".EXE", 0 };
43 ZZIP_DIR
* zip
= zzip_opendir_ext_io (argv
[0],
44 ZZIP_CASELESS
|ZZIP_ONLYZIP
, ext
, 0);
46 if (! zip
) { perror(argv
[0]); break; }
48 fp
= zzip_file_open (zip
, argv
[argn
], ZZIP_CASELESS
);
58 /* read chunks of 16 bytes into buf and print them to stdout */
59 while (0 < (n
= zzip_read(fp
, buf
, 16)))
63 write (STDOUT_FILENO
, buf
, n
);
65 fwrite (buf
, 1, n
, stdout
);
85 * c-file-style: "stroustrup"