Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/* $Id: jartool.c,v 1.4 2000/12/28 21:47:37 robertl Exp $
+/* $Id: jartool.c,v 1.7 2001/08/27 23:09:37 tromey Exp $
$Log: jartool.c,v $
+ Revision 1.7 2001/08/27 23:09:37 tromey
+ * jartool.c (jarfile): Remove length limitation.
+ (main): Use jt_strdup when initializing jarfile.
+
+ Revision 1.6 2001/07/04 18:33:53 tromey
+ Modified from patch by Julian Hall <jules@acris.co.uk>:
+ * jartool.c (errno): Conditionally declare.
+ (O_BINARY): Conditionally define.
+ (main): Use open, not creat. Use O_BINARY everywhere.
+ (make_manifest): Use O_BINARY.
+ (add_to_jar): Likewise.
+
+ Revision 1.5 2001/05/03 21:40:47 danglin
+ * jartool.c (jt_strdup): New function.
+ (get_next_arg): Use jt_strdup instead of strdup.
+
Revision 1.4 2000/12/28 21:47:37 robertl
2000-12-28 Robert Lipe <robertl@sco.com>
static char version_string[] = VERSION;
+#ifndef errno
extern int errno;
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
void usage(const char*);
void add_entry(struct zipentry *);
int do_compress;
int seekable;
int verbose;
-char jarfile[256];
+char *jarfile;
/* If non zero, then don't recurse in directory. Instead, add the
directory entry and relie on an explicit list of files to populate
if(i >= argc)
usage(argv[0]);
- strncpy(jarfile, argv[i++], 256);
+ jarfile = jt_strdup (argv[i++]);
}
if(manifest_file){
if(i >= argc)
if(i >= argc)
usage(argv[0]);
- strncpy(jarfile, argv[i++], 256);
+ jarfile = jt_strdup (argv[i++]);
}
/* create the jarfile */
if(action == ACTION_CREATE){
if(file){
- jarfd = creat(jarfile, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
+ jarfd = open(jarfile, O_CREAT | O_BINARY | O_WRONLY | O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
if(jarfd < 0){
fprintf(stderr, "Error opening %s for writing!\n", jarfile);
perror(jarfile);
} else if(action == ACTION_LIST || action == ACTION_EXTRACT){
if(file){
- jarfd = open(jarfile, O_RDONLY);
+ jarfd = open(jarfile, O_RDONLY | O_BINARY);
if(jarfd < 0){
fprintf(stderr, "Error opening %s for reading!\n", jarfile);
init_headers();
if((action == ACTION_UPDATE) && file) {
- if((jarfd = open(jarfile, O_RDWR)) < 0) {
+ if((jarfd = open(jarfile, O_RDWR | O_BINARY)) < 0) {
fprintf(stderr, "Error opening %s for reading!\n", jarfile);
perror(jarfile);
exit(1);
exit(1);
}
- mfd = open(mf_name, O_RDONLY);
+ mfd = open(mf_name, O_RDONLY | O_BINARY);
if(mfd < 0){
fprintf(stderr, "Error opening %s.\n", mf_name);
if(stat_return == -1){
perror(file);
+ return 1;
} else if(S_ISDIR(statbuf.st_mode)){
char *fullname;
char *t_ptr;
} else if(S_ISREG(statbuf.st_mode)){
int add_fd;
- add_fd = open(file, O_RDONLY);
+ add_fd = open(file, O_RDONLY | O_BINARY);
if(add_fd < 0){
fprintf(stderr, "Error opening %s.\n", file);
return 0;