2 * Copyright (c) 2003 Guido Draheim <guidod@gmx.de>
3 * Use freely under the restrictions of the ZLIB license.
5 * This file is used as an example to clarify zzip api usage.
6 * (the write-api is work in progress, beware)
9 #define _ZZIP_WRITE_SOURCE
11 #include <zzip/write.h>
15 #ifdef ZZIP_HAVE_UNISTD_H
26 static const char usage
[] =
28 "zzip <dir> files... \n"
29 " - zzip the files into a zip area."
33 main (int argc
, char ** argv
)
39 if (argc
<= 1 || ! strcmp (argv
[1], "--help"))
44 if (! strcmp (argv
[1], "--version"))
46 printf (__FILE__
" version "ZZIP_PACKAGE
" "ZZIP_VERSION
"\n");
50 dir
= zzip_dir_creat(argv
[1], 0755);
53 fprintf (stderr
, "did not creat %s: \n", argv
[1]);
58 fprintf (stderr
, "(ignored)\n");
61 for (argn
=2; argn
< argc
; argn
++)
63 int input
= open (argv
[argn
], O_RDONLY
);
71 char buf
[17]; zzip_ssize_t n
;
72 ZZIP_FILE
* output
= zzip_file_creat (dir
, argv
[argn
], 0755);
75 fprintf (stderr
, "|did not open %s: \n", argv
[argn
]);
76 fprintf (stderr
, "|%s: %s\n", argv
[argn
],
77 zzip_strerror_of(dir
));
81 while ((n
= read (input
, buf
, 16)))
83 zzip_write (output
, buf
, n
);
96 * c-file-style: "stroustrup"