mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-23 04:00:05 +02:00
zip: use the unix target
* bring beos patches over to the unix target * fixes attributes support for x86_64
This commit is contained in:
@@ -1,275 +1,81 @@
|
||||
From 6041b90bd0edc53e7596d2e18119cde24987b314 Mon Sep 17 00:00:00 2001
|
||||
From: Kacper Kasper <kacperkasper@gmail.com>
|
||||
Date: Thu, 3 Apr 2014 20:58:47 +0000
|
||||
Subject: Haiku support
|
||||
From 9f5dfd330e7e1c99596813dcee03b691993994ae Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
Date: Sat, 28 Feb 2015 18:07:06 +0000
|
||||
Subject: Haiku patch
|
||||
|
||||
|
||||
diff --git a/beos/Makefile b/beos/Makefile
|
||||
index 1b9e613..d66e6e3 100644
|
||||
--- a/beos/Makefile
|
||||
+++ b/beos/Makefile
|
||||
@@ -22,16 +22,30 @@ BIND = $(CC)
|
||||
AS = $(CC) -c
|
||||
CPP = $(CC) -E
|
||||
diff --git a/tailor.h b/tailor.h
|
||||
index 272f979..b79221c 100644
|
||||
--- a/tailor.h
|
||||
+++ b/tailor.h
|
||||
@@ -68,6 +68,12 @@
|
||||
#include "macos/osdep.h"
|
||||
#endif
|
||||
|
||||
-INSTALL = install
|
||||
+# probably can change this to 'install' if you have it
|
||||
+INSTALL_PROGRAM = cp
|
||||
+# probably can change this to 'install -d' if you have it
|
||||
+# XXX NextStep 3.3 and Openstep 4.x don't know about -p !
|
||||
+INSTALL_D = mkdir -p
|
||||
+CHMOD = chmod
|
||||
+BINFLAGS = 755
|
||||
+MANFLAGS = 644
|
||||
+#ifdef __HAIKU__
|
||||
+#undef local
|
||||
+#include <sys/types.h>
|
||||
+#define local static
|
||||
+#endif
|
||||
+
|
||||
#ifdef NLM
|
||||
#include "novell/osdep.h"
|
||||
#endif
|
||||
diff --git a/unix/Makefile b/unix/Makefile
|
||||
index abd0c44..09b5a4f 100644
|
||||
--- a/unix/Makefile
|
||||
+++ b/unix/Makefile
|
||||
@@ -38,8 +38,8 @@ BINFLAGS = 755
|
||||
MANFLAGS = 644
|
||||
|
||||
# Target directories
|
||||
-prefix = /boot/home/config
|
||||
# target directories - where to install executables and man pages to
|
||||
-prefix = /usr/local
|
||||
-BINDIR = $(prefix)/bin
|
||||
-manext = 1
|
||||
-MANDIR = $(prefix)/man/man$(manext)
|
||||
+PREFIX = `finddir B_COMMON_DIRECTORY`
|
||||
+BINDIR = $(PREFIX)/bin
|
||||
+MANEXT = 1
|
||||
+MANDIR = $(PREFIX)/documentation/man
|
||||
+MANDIRF = $(MANDIR)/man$(MANEXT)
|
||||
+INCLUDEDIR = `finddir B_SYSTEM_DEVELOP_DIRECTORY`/headers
|
||||
+LIBDIR = `finddir B_SYSTEM_LIB_DIRECTORY`
|
||||
ZIPMANUAL = MANUAL
|
||||
-
|
||||
-VERSION = Version 2.3 of __DATE__
|
||||
+ZIPMANUALcloak = zipcloak.txt
|
||||
+ZIPMANUALnote = zipnote.txt
|
||||
+ZIPMANUALsplit = zipsplit.txt
|
||||
+ZIPMANUALs = zip.txt zipcloak.txt zipnote.txt zipsplit.txt
|
||||
+PKGDIR = IZzip
|
||||
+VERSION = Version 3.0
|
||||
|
||||
######################################################################
|
||||
# Things that change:
|
||||
@@ -65,14 +79,14 @@ CC:=gcc
|
||||
|
||||
# Removed -Wconversion and -Wshadow because of the unnecessary warnings
|
||||
# they generate. - Sept. 28, 1999
|
||||
-CFLAGS:=-O3 -mpentiumpro \
|
||||
+CFLAGS:=-O3 \
|
||||
-Wall -Wno-multichar -Wno-ctor-dtor-privacy \
|
||||
-Wbad-function-cast -Woverloaded-virtual \
|
||||
- -I. -I/boot/develop/headers/be/support \
|
||||
- -I/boot/develop/headers/be/storage \
|
||||
+ -I. -I$(INCLUDEDIR)/be/support \
|
||||
+ -I$(INCLUDEDIR)/be/storage \
|
||||
-DHAVE_DIRENT_H -DPASSWD_FROM_STDIN # -DASMV
|
||||
LFLAGS1:=
|
||||
-LFLAGS2:=-L/boot/develop/lib/x86 -lbe -lroot
|
||||
+LFLAGS2:=-L$(LIBDIR) -lbe -lroot
|
||||
OBJA = #match.o
|
||||
TARGET=$(ZIPS)
|
||||
|
||||
@@ -88,44 +102,40 @@ all:
|
||||
######################################################################
|
||||
# Object file lists and other build goodies
|
||||
|
||||
-# Object file lists
|
||||
+# object file lists
|
||||
OBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o crypt.o ttyio.o \
|
||||
- beos.o crc32.o
|
||||
+ beos.o crc32.o zbz2err.o setfiletype.o
|
||||
OBJI = deflate.o trees.o
|
||||
-# OBJA moved into ifeq block above; we'll use assembly for x86
|
||||
-OBJU = zipfile_.o fileio_.o util_.o globals.o beos_.o
|
||||
+OBJA =
|
||||
+OCRCU8 =
|
||||
+OCRCTB = crc32_.o
|
||||
+OBJU = zipfile_.o fileio_.o util_.o globals.o beos_.o setfiletype.o $(OCRCU8)
|
||||
OBJN = zipnote.o $(OBJU)
|
||||
-OBJC = zipcloak.o $(OBJU) crc32_.o crypt_.o ttyio.o
|
||||
+OBJC = zipcloak.o $(OBJU) $(OCRCTB) crypt_.o ttyio.o
|
||||
OBJS = zipsplit.o $(OBJU)
|
||||
|
||||
-# Headers
|
||||
ZIP_H = zip.h ziperr.h tailor.h beos/osdep.h
|
||||
|
||||
-# What to build?
|
||||
-ZIPS = zip zipnote zipsplit zipcloak
|
||||
-
|
||||
# suffix rules
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: _.o .o .c .doc .1
|
||||
.c_.o:
|
||||
- rm -f $*_.c; $(LN) $< $*_.c
|
||||
- $(CC) -c $(CFLAGS) -DUTIL $*_.c
|
||||
- rm -f $*_.c
|
||||
+ $(CC) -c $(CFLAGS) -DUTIL -o $@ $<
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
.1.doc:
|
||||
- groff -man -Tascii $< > $@
|
||||
+ nroff -man $< | col -bx | uniq > $@
|
||||
|
||||
-# rules for zip, zipnote, zipcloak, zipsplit, and the Zip MANUAL.
|
||||
+# rules for zip, zipnote, zipcloak, zipsplit, and the Zip MANUALs.
|
||||
$(OBJZ): $(ZIP_H)
|
||||
$(OBJI): $(ZIP_H)
|
||||
$(OBJN): $(ZIP_H)
|
||||
$(OBJS): $(ZIP_H)
|
||||
$(OBJC): $(ZIP_H)
|
||||
-zip.o crc32.o crypt.o fileio.o zipfile.o zipup.o: crc32.h
|
||||
-zipcloak.o crc32_.o crypt_.o fileio_.o zipfile_.o: crc32.h
|
||||
+zip.o zipup.o zipfile.o fileio.o crc32.o crypt.o: crc32.h
|
||||
+zipcloak.o zipfile_.o fileio_.o crc32_.o crypt_.o: crc32.h
|
||||
zip.o zipup.o crypt.o ttyio.o zipcloak.o crypt_.o: crypt.h
|
||||
zip.o zipup.o zipnote.o zipcloak.o zipsplit.o: revision.h
|
||||
zip.o crypt.o ttyio.o zipcloak.o crypt_.o: ttyio.h
|
||||
@@ -134,42 +144,69 @@ zipup.o: beos/zipup.h
|
||||
match.o: match.S
|
||||
$(CPP) match.S > _match.s
|
||||
$(AS) _match.s
|
||||
- mv -f _match.o match.o
|
||||
+ mv _match.o match.o
|
||||
rm -f _match.s
|
||||
|
||||
+crc_i386.o: crc_i386.S
|
||||
+ $(CPP) crc_i386.S > _crc_i386.s
|
||||
+ $(AS) _crc_i386.s
|
||||
+ mv _crc_i386.o crc_i386.o
|
||||
+ rm -f _crc_i386.s
|
||||
+prefix = $PREFIX
|
||||
+BINDIR ?= $(prefix)/bin
|
||||
MANEXT=1
|
||||
MANDIR = $(prefix)/man/man$(MANEXT)
|
||||
ZIPMANUAL = zip.txt
|
||||
diff --git a/unix/osdep.h b/unix/osdep.h
|
||||
index 10f8ee9..b766e52 100644
|
||||
--- a/unix/osdep.h
|
||||
+++ b/unix/osdep.h
|
||||
@@ -78,3 +78,9 @@
|
||||
#if !defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME)
|
||||
# define USE_EF_UT_TIME
|
||||
#endif
|
||||
+
|
||||
beos.o: beos/beos.c
|
||||
$(CC) -c $(CFLAGS) beos/beos.c
|
||||
+#ifdef __HAIKU__
|
||||
+ #ifndef ZP_NEED_MEMCOMPR
|
||||
+ # define ZP_NEED_MEMCOMPR
|
||||
+ #endif
|
||||
+#endif
|
||||
diff --git a/unix/unix.c b/unix/unix.c
|
||||
index f4d655d..970af5c 100644
|
||||
--- a/unix/unix.c
|
||||
+++ b/unix/unix.c
|
||||
@@ -42,6 +42,13 @@
|
||||
# endif
|
||||
#endif /* HAVE_DIRENT_H || _POSIX_VERSION */
|
||||
|
||||
beos_.o: beos/beos.c
|
||||
- rm -f $*_.c; $(LN) beos/beos.c $*_.c
|
||||
- $(CC) -c $(CFLAGS) -DUTIL $*_.c
|
||||
- rm -f $*_.c
|
||||
+ $(CC) -c $(CFLAGS) -DUTIL -o $@ beos/beos.c
|
||||
+
|
||||
+setfiletype.o: beos/setfiletype.c
|
||||
+ $(CC) -c $(CFLAGS) -o $@ beos/setfiletype.c
|
||||
+#ifdef __HAIKU__
|
||||
+#include <errno.h>
|
||||
+#include <fs_attr.h>
|
||||
+#include <Mime.h>
|
||||
+#include <ByteOrder.h>
|
||||
+#endif
|
||||
+
|
||||
+ZIPS = zip$E zipcloak$E zipnote$E zipsplit$E
|
||||
|
||||
zips: $(ZIPS)
|
||||
-zipsman: $(ZIPS) $(ZIPMANUAL)
|
||||
+zipsman: $(ZIPS) $(ZIPMANUALs)
|
||||
|
||||
-zip: $(OBJZ) $(OBJI) $(OBJA)
|
||||
- $(BIND) -o zip $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
|
||||
-zipnote: $(OBJN)
|
||||
- $(BIND) -o zipnote $(LFLAGS1) $(OBJN) $(LFLAGS2)
|
||||
-zipcloak: $(OBJC)
|
||||
- $(BIND) -o zipcloak $(LFLAGS1) $(OBJC) $(LFLAGS2)
|
||||
-zipsplit: $(OBJS)
|
||||
- $(BIND) -o zipsplit $(LFLAGS1) $(OBJS) $(LFLAGS2)
|
||||
+zip$E: $(OBJZ) $(OBJI) $(OBJA) $(LIB_BZ)
|
||||
+ $(BIND) -o zip$E $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
|
||||
+zipnote$E: $(OBJN)
|
||||
+ $(BIND) -o zipnote$E $(LFLAGS1) $(OBJN) $(LFLAGS2)
|
||||
+zipcloak$E: $(OBJC) $(OCRCTB)
|
||||
+ $(BIND) -o zipcloak$E $(LFLAGS1) $(OBJC) $(LFLAGS2)
|
||||
+zipsplit$E: $(OBJS)
|
||||
+ $(BIND) -o zipsplit$E $(LFLAGS1) $(OBJS) $(LFLAGS2)
|
||||
|
||||
$(ZIPMANUAL): man/zip.1
|
||||
- groff -man -Tascii man/zip.1 > $(ZIPMANUAL)
|
||||
+ nroff -man man/zip.1 | col -bx | uniq > $(ZIPMANUAL)
|
||||
+
|
||||
+$(ZIPMANUALcloak): man/zipcloak.1
|
||||
+ nroff -man man/zipcloak.1 | col -bx | uniq > $(ZIPMANUALcloak)
|
||||
|
||||
+$(ZIPMANUALnote): man/zipnote.1
|
||||
+ nroff -man man/zipnote.1 | col -bx | uniq > $(ZIPMANUALnote)
|
||||
+
|
||||
+$(ZIPMANUALsplit): man/zipsplit.1
|
||||
+ nroff -man man/zipsplit.1 | col -bx | uniq > $(ZIPMANUALsplit)
|
||||
+
|
||||
# install
|
||||
install: $(ZIPS)
|
||||
- $(INSTALL) -m755 $(ZIPS) $(BINDIR)
|
||||
- mkdir -p $(MANDIR)
|
||||
- $(INSTALL) -m644 man/zip.1 $(MANDIR)/zip.$(manext)
|
||||
+ -$(INSTALL_D) $(BINDIR)
|
||||
+ $(INSTALL_PROGRAM) $(ZIPS) $(BINDIR)
|
||||
+ -cd $(BINDIR); $(CHMOD) $(BINFLAGS) $(ZIPS)
|
||||
+ -$(INSTALL_D) $(MANDIRF)
|
||||
+ $(INSTALL_PROGRAM) man/zip.1 $(MANDIRF)/zip.$(MANEXT)
|
||||
+ $(CHMOD) $(MANFLAGS) $(MANDIRF)/zip.$(MANEXT)
|
||||
+ $(INSTALL_PROGRAM) man/zipcloak.1 $(MANDIRF)/zipcloak.$(MANEXT)
|
||||
+ $(CHMOD) $(MANFLAGS) $(MANDIRF)/zipcloak.$(MANEXT)
|
||||
+ $(INSTALL_PROGRAM) man/zipnote.1 $(MANDIRF)/zipnote.$(MANEXT)
|
||||
+ $(CHMOD) $(MANFLAGS) $(MANDIRF)/zipnote.$(MANEXT)
|
||||
+ $(INSTALL_PROGRAM) man/zipsplit.1 $(MANDIRF)/zipsplit.$(MANEXT)
|
||||
+ $(CHMOD) $(MANFLAGS) $(MANDIRF)/zipsplit.$(MANEXT)
|
||||
|
||||
uninstall:
|
||||
-cd $(BINDIR); rm -f $(ZIPS)
|
||||
- -cd $(MANDIR); rm -f zip.$(manext)
|
||||
-
|
||||
+ -cd $(MANDIRF); rm -f \
|
||||
+ zip.$(MANEXT) zipcloak.$(MANEXT) zipnote.$(MANEXT) zipsplit.$(MANEXT)
|
||||
dist: $(ZIPMANUAL)
|
||||
zip -u9T zip`sed -e '/VERSION/!d' -e 's/.*"\(.*\)".*/\1/' \
|
||||
-e s/[.]//g -e q revision.h` \
|
||||
diff --git a/beos/beos.c b/beos/beos.c
|
||||
index d8d16df..d8df5d5 100644
|
||||
--- a/beos/beos.c
|
||||
+++ b/beos/beos.c
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <kernel/fs_attr.h>
|
||||
#include <storage/Mime.h>
|
||||
-#include <support/byteorder.h>
|
||||
+#include <support/ByteOrder.h>
|
||||
|
||||
|
||||
#define PAD 0
|
||||
@@ -851,32 +851,6 @@ int set_extra_field(z, z_utim)
|
||||
return ZE_OK;
|
||||
}
|
||||
#define PATH_END '/'
|
||||
|
||||
-/* ---------------------------------------------------------------------- */
|
||||
-/* Set a file's MIME type. */
|
||||
-void setfiletype( const char *file, const char *type )
|
||||
-{
|
||||
- int fd;
|
||||
- attr_info fa;
|
||||
- ssize_t wrote_bytes;
|
||||
-
|
||||
- fd = open( file, O_RDWR );
|
||||
- if( fd < 0 ) {
|
||||
- zipwarn( "can't open zipfile to write file type", "" );
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- fa.type = B_MIME_STRING_TYPE;
|
||||
- fa.size = (off_t)(strlen( type ) + 1);
|
||||
-
|
||||
- wrote_bytes = fs_write_attr( fd, BE_FILE_TYPE_NAME, fa.type, 0,
|
||||
- type, fa.size );
|
||||
- if( wrote_bytes != (ssize_t)fa.size ) {
|
||||
- zipwarn( "couldn't write complete file type", "" );
|
||||
- }
|
||||
-
|
||||
- close( fd );
|
||||
-}
|
||||
-
|
||||
int deletedir(d)
|
||||
char *d; /* directory to delete */
|
||||
/* Delete the directory *d if it is empty, do nothing otherwise.
|
||||
diff --git a/beos/setfiletype.c b/beos/setfiletype.c
|
||||
new file mode 100644
|
||||
index 0000000..cd8dd2e
|
||||
--- /dev/null
|
||||
+++ b/beos/setfiletype.c
|
||||
@@ -0,0 +1,33 @@
|
||||
+#include <fcntl.h>
|
||||
+#include <string.h>
|
||||
@@ -434,6 +441,355 @@ ulg filetime(f, a, n, t)
|
||||
|
||||
|
||||
#ifndef QLZIP /* QLZIP Unix2QDOS cross-Zip supplies an extended variant */
|
||||
+#ifdef __HAIKU__
|
||||
+
|
||||
+#include <kernel/fs_attr.h>
|
||||
+#include <storage/Mime.h>
|
||||
+
|
||||
+#include "beos/osdep.h"
|
||||
+/* Set a file's MIME type. */
|
||||
+#define BE_FILE_TYPE_NAME "BEOS:TYPE"
|
||||
+
|
||||
+/* ---------------------------------------------------------------------- */
|
||||
+/* Set a file's MIME type. */
|
||||
@@ -296,47 +102,355 @@ index 0000000..cd8dd2e
|
||||
+
|
||||
+ close( fd );
|
||||
+}
|
||||
diff --git a/tailor.h b/tailor.h
|
||||
index 272f979..579609a 100644
|
||||
--- a/tailor.h
|
||||
+++ b/tailor.h
|
||||
@@ -52,7 +52,7 @@
|
||||
#include "atheos/osdep.h"
|
||||
#endif
|
||||
+
|
||||
+/* ----------------------------------------------------------------------
|
||||
+
|
||||
+Return a malloc()'d buffer containing all of the attributes and their names
|
||||
+for the file specified in name. You have to free() this yourself. The length
|
||||
+of the buffer is also returned.
|
||||
+
|
||||
+If get_attr_dir() fails, the buffer will be NULL, total_size will be 0,
|
||||
+and an error will be returned:
|
||||
+
|
||||
+ ZE_OK - no errors occurred
|
||||
+ ZE_LOGIC - attr_buff was pointing at a buffer
|
||||
+ ZE_MEM - insufficient memory for attribute buffer
|
||||
+
|
||||
+Other errors are possible (whatever is returned by the fs_attr.h functions).
|
||||
+
|
||||
+PROBLEMS:
|
||||
+
|
||||
+- pointers are 32-bits; attributes are limited to off_t in size so it's
|
||||
+ possible to overflow... in practice, this isn't too likely... your
|
||||
+ machine will thrash like hell before that happens
|
||||
+
|
||||
+*/
|
||||
+
|
||||
+#define INITIAL_BUFF_SIZE 65536
|
||||
+
|
||||
+int get_attr_dir( const char *name, char **attr_buff, off_t *total_size )
|
||||
+{
|
||||
+ int retval = ZE_OK;
|
||||
+ int fd;
|
||||
+ DIR *fa_dir;
|
||||
+ struct dirent *fa_ent;
|
||||
+ off_t attrs_size;
|
||||
+ off_t this_size;
|
||||
+ char *ptr;
|
||||
+ struct attr_info fa_info;
|
||||
+ struct attr_info big_fa_info;
|
||||
+
|
||||
+ retval = ZE_OK;
|
||||
+ attrs_size = 0; /* gcc still says this is used uninitialized... */
|
||||
+ *total_size = 0;
|
||||
+
|
||||
+ /* ----------------------------------------------------------------- */
|
||||
+ /* Sanity-check. */
|
||||
+ if( *attr_buff != NULL ) {
|
||||
+ return ZE_LOGIC;
|
||||
+ }
|
||||
+
|
||||
+ /* ----------------------------------------------------------------- */
|
||||
+ /* Can we open the file/directory? */
|
||||
+ /* */
|
||||
+ /* linkput is a zip global; it's set to 1 if we're storing symbolic */
|
||||
+ /* links as symbolic links (instead of storing the thing the link */
|
||||
+ /* points to)... if we're storing the symbolic link as a link, we'll */
|
||||
+ /* want the link's file attributes, otherwise we want the target's. */
|
||||
+ if( linkput ) {
|
||||
+ fd = open( name, O_RDONLY | O_NOTRAVERSE );
|
||||
+ } else {
|
||||
+ fd = open( name, O_RDONLY );
|
||||
+ }
|
||||
+ if( fd < 0 ) {
|
||||
+ return errno;
|
||||
+ }
|
||||
+
|
||||
+ /* ----------------------------------------------------------------- */
|
||||
+ /* Allocate an initial buffer; 64k should usually be enough. */
|
||||
+ *attr_buff = (char *)malloc( INITIAL_BUFF_SIZE );
|
||||
+ ptr = *attr_buff;
|
||||
+ if( ptr == NULL ) {
|
||||
+ close( fd );
|
||||
+
|
||||
+ return ZE_MEM;
|
||||
+ }
|
||||
+
|
||||
+ /* ----------------------------------------------------------------- */
|
||||
+ /* Open the attributes directory for this file. */
|
||||
+ fa_dir = fs_fopen_attr_dir( fd );
|
||||
+ if( fa_dir == NULL ) {
|
||||
+ close( fd );
|
||||
+
|
||||
+ free( ptr );
|
||||
+ *attr_buff = NULL;
|
||||
+
|
||||
+ return retval;
|
||||
+ }
|
||||
+
|
||||
+ /* ----------------------------------------------------------------- */
|
||||
+ /* Read all the attributes; the buffer could grow > 64K if there are */
|
||||
+ /* many and/or they are large. */
|
||||
+ fa_ent = fs_read_attr_dir( fa_dir );
|
||||
+ while( fa_ent != NULL ) {
|
||||
+ retval = fs_stat_attr( fd, fa_ent->d_name, &fa_info );
|
||||
+ /* TODO: check retval != ZE_OK */
|
||||
+
|
||||
+ this_size = strlen( fa_ent->d_name ) + 1;
|
||||
+ this_size += sizeof( struct attr_info );
|
||||
+ this_size += fa_info.size;
|
||||
+
|
||||
+ attrs_size += this_size;
|
||||
+
|
||||
+ if( attrs_size > INITIAL_BUFF_SIZE ) {
|
||||
+ unsigned long offset = ptr - *attr_buff;
|
||||
+
|
||||
+ *attr_buff = (char *)realloc( *attr_buff, attrs_size );
|
||||
+ if( *attr_buff == NULL ) {
|
||||
+ retval = fs_close_attr_dir( fa_dir );
|
||||
+ /* TODO: check retval != ZE_OK */
|
||||
+ close( fd );
|
||||
+
|
||||
+ return ZE_MEM;
|
||||
+ }
|
||||
+
|
||||
+ ptr = *attr_buff + offset;
|
||||
+ }
|
||||
+
|
||||
+ /* Now copy the data for this attribute into the buffer. */
|
||||
+ strcpy( ptr, fa_ent->d_name );
|
||||
+ ptr += strlen( fa_ent->d_name );
|
||||
+ *ptr++ = '\0';
|
||||
+
|
||||
+ /* We need to put a big-endian version of the fa_info data into */
|
||||
+ /* the archive. */
|
||||
+ big_fa_info.type = B_HOST_TO_BENDIAN_INT32( fa_info.type );
|
||||
+ big_fa_info.size = B_HOST_TO_BENDIAN_INT64( fa_info.size );
|
||||
+ memcpy( ptr, &big_fa_info, sizeof( struct attr_info ) );
|
||||
+ ptr += sizeof( struct attr_info );
|
||||
+
|
||||
+ if( fa_info.size > 0 ) {
|
||||
+ ssize_t read_bytes;
|
||||
+
|
||||
+ read_bytes = fs_read_attr( fd, fa_ent->d_name, fa_info.type, 0,
|
||||
+ ptr, fa_info.size );
|
||||
+ if( read_bytes != fa_info.size ) {
|
||||
+ /* print a warning about mismatched sizes */
|
||||
+ char buff[80];
|
||||
+
|
||||
+ sprintf( buff, "read %ld, expected %ld",
|
||||
+ (ssize_t)read_bytes, (ssize_t)fa_info.size );
|
||||
+ zipwarn( "attribute size mismatch: ", buff );
|
||||
+ }
|
||||
+
|
||||
+ /* Wave my magic wand... this swaps all the Be types to big- */
|
||||
+ /* endian automagically. */
|
||||
+ (void)swap_data( fa_info.type, ptr, fa_info.size,
|
||||
+ B_SWAP_HOST_TO_BENDIAN );
|
||||
+
|
||||
+ ptr += fa_info.size;
|
||||
+ }
|
||||
+
|
||||
+ fa_ent = fs_read_attr_dir( fa_dir );
|
||||
+ }
|
||||
+
|
||||
+ /* ----------------------------------------------------------------- */
|
||||
+ /* Close the attribute directory. */
|
||||
+ retval = fs_close_attr_dir( fa_dir );
|
||||
+ /* TODO: check retval != ZE_OK */
|
||||
+
|
||||
+ /* ----------------------------------------------------------------- */
|
||||
+ /* If the buffer is too big, shrink it. */
|
||||
+ if( attrs_size < INITIAL_BUFF_SIZE ) {
|
||||
+ *attr_buff = (char *)realloc( *attr_buff, attrs_size );
|
||||
+ if( *attr_buff == NULL ) {
|
||||
+ /* This really shouldn't happen... */
|
||||
+ close( fd );
|
||||
+
|
||||
+ return ZE_MEM;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ *total_size = attrs_size;
|
||||
+
|
||||
+ close( fd );
|
||||
+
|
||||
+ return ZE_OK;
|
||||
+}
|
||||
+
|
||||
+/* ---------------------------------------------------------------------- */
|
||||
+/* Add a 'Be' extra field to the zlist data pointed to by z. */
|
||||
+
|
||||
+#define EB_L_BE_LEN 5 /* min size is an unsigned long and flag */
|
||||
+#define EB_C_BE_LEN 5 /* Length of data in local EF and flag. */
|
||||
+
|
||||
+#define EB_BE_FL_NATURAL 0x01 /* data is 'natural' (not compressed) */
|
||||
+
|
||||
+#define EB_L_BE_SIZE (EB_HEADSIZE + EB_L_BE_LEN) /* + attr size */
|
||||
+#define EB_C_BE_SIZE (EB_HEADSIZE + EB_C_BE_LEN)
|
||||
+
|
||||
+/* maximum memcompress overhead is the sum of the compression header length */
|
||||
+/* (6 = ush compression type, ulg CRC) and the worstcase deflate overhead */
|
||||
+/* when uncompressible data are kept in 2 "stored" blocks (5 per block = */
|
||||
+/* byte blocktype + 2 * ush blocklength) */
|
||||
+#define MEMCOMPRESS_OVERHEAD (EB_MEMCMPR_HSIZ + EB_DEFLAT_EXTRA)
|
||||
+
|
||||
+local int add_Be_ef( struct zlist far *z )
|
||||
+{
|
||||
+ char *l_ef = NULL;
|
||||
+ char *c_ef = NULL;
|
||||
+ char *attrbuff = NULL;
|
||||
+ off_t attrsize = 0;
|
||||
+ char *compbuff = NULL;
|
||||
+ ush compsize = 0;
|
||||
+ uch flags = 0;
|
||||
+
|
||||
+ /* Check to make sure we've got enough room in the extra fields. */
|
||||
+ if( z->ext + EB_L_BE_SIZE > USHRT_MAX ||
|
||||
+ z->cext + EB_C_BE_SIZE > USHRT_MAX ) {
|
||||
+ return ZE_MEM;
|
||||
+ }
|
||||
+
|
||||
+ /* Attempt to load up a buffer full of the file's attributes. */
|
||||
+ {
|
||||
+ int retval;
|
||||
+
|
||||
+ retval = get_attr_dir( z->name, &attrbuff, &attrsize );
|
||||
+ if( retval != ZE_OK ) {
|
||||
+ return ZE_OPEN;
|
||||
+ }
|
||||
+ if( attrsize == 0 ) {
|
||||
+ return ZE_OK;
|
||||
+ }
|
||||
+ if( attrbuff == NULL ) {
|
||||
+ return ZE_LOGIC;
|
||||
+ }
|
||||
+
|
||||
+ /* Check for way too much data. */
|
||||
+ if( attrsize > (off_t)ULONG_MAX ) {
|
||||
+ zipwarn( "uncompressed attributes truncated", "" );
|
||||
+ attrsize = (off_t)(ULONG_MAX - MEMCOMPRESS_OVERHEAD);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if( verbose ) {
|
||||
+ printf( "\t[in=%lu]", (unsigned long)attrsize );
|
||||
+ }
|
||||
+
|
||||
+ /* Try compressing the data */
|
||||
+ compbuff = (char *)malloc( (size_t)attrsize + MEMCOMPRESS_OVERHEAD );
|
||||
+ if( compbuff == NULL ) {
|
||||
+ return ZE_MEM;
|
||||
+ }
|
||||
+ compsize = memcompress( compbuff,
|
||||
+ (size_t)attrsize + MEMCOMPRESS_OVERHEAD,
|
||||
+ attrbuff,
|
||||
+ (size_t)attrsize );
|
||||
+ if( verbose ) {
|
||||
+ printf( " [out=%u]", compsize );
|
||||
+ }
|
||||
+
|
||||
+ /* Attempt to optimise very small attributes. */
|
||||
+ if( compsize > attrsize ) {
|
||||
+ free( compbuff );
|
||||
+ compsize = (ush)attrsize;
|
||||
+ compbuff = attrbuff;
|
||||
+
|
||||
+ flags = EB_BE_FL_NATURAL;
|
||||
+ }
|
||||
+
|
||||
+ /* Check to see if we really have enough room in the EF for the data. */
|
||||
+ if( ( z->ext + compsize + EB_L_BE_LEN ) > USHRT_MAX ) {
|
||||
+ compsize = USHRT_MAX - EB_L_BE_LEN - z->ext;
|
||||
+ }
|
||||
+
|
||||
+ /* Allocate memory for the local and central extra fields. */
|
||||
+ if( z->extra && z->ext != 0 ) {
|
||||
+ l_ef = (char *)realloc( z->extra, z->ext + EB_L_BE_SIZE + compsize );
|
||||
+ } else {
|
||||
+ l_ef = (char *)malloc( EB_L_BE_SIZE + compsize );
|
||||
+ z->ext = 0;
|
||||
+ }
|
||||
+ if( l_ef == NULL ) {
|
||||
+ return ZE_MEM;
|
||||
+ }
|
||||
+ z->extra = l_ef;
|
||||
+ l_ef += z->ext;
|
||||
+
|
||||
+ if( z->cextra && z->cext != 0 ) {
|
||||
+ c_ef = (char *)realloc( z->cextra, z->cext + EB_C_BE_SIZE );
|
||||
+ } else {
|
||||
+ c_ef = (char *)malloc( EB_C_BE_SIZE );
|
||||
+ z->cext = 0;
|
||||
+ }
|
||||
+ if( c_ef == NULL ) {
|
||||
+ return ZE_MEM;
|
||||
+ }
|
||||
+ z->cextra = c_ef;
|
||||
+ c_ef += z->cext;
|
||||
+
|
||||
+ /* Now add the local version of the field. */
|
||||
+ *l_ef++ = 'B';
|
||||
+ *l_ef++ = 'e';
|
||||
+ *l_ef++ = (char)(compsize + EB_L_BE_LEN);
|
||||
+ *l_ef++ = (char)((compsize + EB_L_BE_LEN) >> 8);
|
||||
+ *l_ef++ = (char)((unsigned long)attrsize);
|
||||
+ *l_ef++ = (char)((unsigned long)attrsize >> 8);
|
||||
+ *l_ef++ = (char)((unsigned long)attrsize >> 16);
|
||||
+ *l_ef++ = (char)((unsigned long)attrsize >> 24);
|
||||
+ *l_ef++ = flags;
|
||||
+ memcpy( l_ef, compbuff, (size_t)compsize );
|
||||
+
|
||||
+ z->ext += EB_L_BE_SIZE + compsize;
|
||||
+
|
||||
+ /* And the central version. */
|
||||
+ *c_ef++ = 'B';
|
||||
+ *c_ef++ = 'e';
|
||||
+ *c_ef++ = (char)(EB_C_BE_LEN);
|
||||
+ *c_ef++ = (char)(EB_C_BE_LEN >> 8);
|
||||
+ *c_ef++ = (char)compsize;
|
||||
+ *c_ef++ = (char)(compsize >> 8);
|
||||
+ *c_ef++ = (char)(compsize >> 16);
|
||||
+ *c_ef++ = (char)(compsize >> 24);
|
||||
+ *c_ef++ = flags;
|
||||
+
|
||||
+ z->cext += EB_C_BE_SIZE;
|
||||
+
|
||||
+ return ZE_OK;
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
|
||||
-#ifdef __BEOS__
|
||||
+#if (defined(__BEOS__) || defined(__HAIKU__))
|
||||
#include "beos/osdep.h"
|
||||
#endif
|
||||
int set_new_unix_extra_field(z, s)
|
||||
struct zlist far *z;
|
||||
@@ -568,6 +924,7 @@ int set_extra_field(z, z_utim)
|
||||
/* store full data in local header but just modification time stamp info
|
||||
in central header */
|
||||
{
|
||||
+ int retval;
|
||||
z_stat s;
|
||||
char *name;
|
||||
int len = strlen(z->name);
|
||||
@@ -678,8 +1035,14 @@ int set_extra_field(z, z_utim)
|
||||
#endif /* never */
|
||||
|
||||
diff --git a/ttyio.c b/ttyio.c
|
||||
index 5899fdc..15cc835 100644
|
||||
--- a/ttyio.c
|
||||
+++ b/ttyio.c
|
||||
@@ -52,7 +52,7 @@
|
||||
# define GLOBAL(g) G.g
|
||||
#endif
|
||||
/* new unix extra field */
|
||||
- set_new_unix_extra_field(z, &s);
|
||||
-
|
||||
+ retval = set_new_unix_extra_field(z, &s);
|
||||
+ if (retval != ZE_OK)
|
||||
+ return retval;
|
||||
+
|
||||
+ retval = add_Be_ef(z);
|
||||
+ if (retval != ZE_OK)
|
||||
+ return retval;
|
||||
+
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
-#if (defined(__ATHEOS__) || defined(__BEOS__)) /* why yes, we do */
|
||||
+#if (defined(__ATHEOS__) || defined(__BEOS__) || defined(__HAIKU__)) /* why yes, we do */
|
||||
# define HAVE_TERMIOS_H
|
||||
#endif
|
||||
|
||||
diff --git a/ttyio.h b/ttyio.h
|
||||
index df6a4ed..5180af1 100644
|
||||
--- a/ttyio.h
|
||||
+++ b/ttyio.h
|
||||
@@ -60,7 +60,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
-#if (defined(__ATHEOS__) || defined(__BEOS__) || defined(UNIX))
|
||||
+#if (defined(__ATHEOS__) || defined(__BEOS__) || defined(__HAIKU__) || defined(UNIX))
|
||||
# ifndef ATH_BEO_UNX
|
||||
# define ATH_BEO_UNX
|
||||
# endif
|
||||
diff --git a/zip.c b/zip.c
|
||||
index 439821f..173d922 100644
|
||||
index 439821f..6682e41 100644
|
||||
--- a/zip.c
|
||||
+++ b/zip.c
|
||||
@@ -1845,7 +1845,7 @@ int rename_split(temp_name, out_path)
|
||||
@@ -344,92 +458,72 @@ index 439821f..173d922 100644
|
||||
char *out_path;
|
||||
{
|
||||
-#ifdef __BEOS__
|
||||
+#if (defined(__BEOS__) || defined(__HAIKU__))
|
||||
+#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
/* Set the filetype of the zipfile to "application/zip" */
|
||||
setfiletype( out_path, "application/zip" );
|
||||
#endif
|
||||
diff --git a/zip.h b/zip.h
|
||||
index ba03160..208a0c7 100644
|
||||
--- a/zip.h
|
||||
+++ b/zip.h
|
||||
@@ -78,12 +78,6 @@ freely, subject to the above disclaimer and the following restrictions:
|
||||
--
|
||||
1.8.3.4
|
||||
|
||||
|
||||
From 7b74aa46f01c8a85d493511654a077c0c2df73d3 Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
Date: Mon, 2 Mar 2015 19:27:01 +0000
|
||||
Subject: Haiku x86_64 fixes
|
||||
|
||||
|
||||
diff --git a/unix/unix.c b/unix/unix.c
|
||||
index 970af5c..6a0cbe3 100644
|
||||
--- a/unix/unix.c
|
||||
+++ b/unix/unix.c
|
||||
@@ -562,11 +562,14 @@ int get_attr_dir( const char *name, char **attr_buff, off_t *total_size )
|
||||
/* many and/or they are large. */
|
||||
fa_ent = fs_read_attr_dir( fa_dir );
|
||||
while( fa_ent != NULL ) {
|
||||
+ uint32 attr_type;
|
||||
+ uint64 attr_size;
|
||||
+
|
||||
retval = fs_stat_attr( fd, fa_ent->d_name, &fa_info );
|
||||
/* TODO: check retval != ZE_OK */
|
||||
|
||||
#define ZIP /* for crypt.c: include zip password functions, not unzip */
|
||||
this_size = strlen( fa_ent->d_name ) + 1;
|
||||
- this_size += sizeof( struct attr_info );
|
||||
+ this_size += sizeof(uint32) + sizeof(uint64);
|
||||
this_size += fa_info.size;
|
||||
|
||||
-/* Types centralized here for easy modification */
|
||||
-#define local static /* More meaningful outside functions */
|
||||
-typedef unsigned char uch; /* unsigned 8-bit value */
|
||||
-typedef unsigned short ush; /* unsigned 16-bit value */
|
||||
-typedef unsigned long ulg; /* unsigned 32-bit value */
|
||||
attrs_size += this_size;
|
||||
@@ -591,13 +594,13 @@ int get_attr_dir( const char *name, char **attr_buff, off_t *total_size )
|
||||
ptr += strlen( fa_ent->d_name );
|
||||
*ptr++ = '\0';
|
||||
|
||||
- /* We need to put a big-endian version of the fa_info data into */
|
||||
- /* the archive. */
|
||||
- big_fa_info.type = B_HOST_TO_BENDIAN_INT32( fa_info.type );
|
||||
- big_fa_info.size = B_HOST_TO_BENDIAN_INT64( fa_info.size );
|
||||
- memcpy( ptr, &big_fa_info, sizeof( struct attr_info ) );
|
||||
- ptr += sizeof( struct attr_info );
|
||||
-
|
||||
/* Set up portability */
|
||||
#include "tailor.h"
|
||||
+ /* the attr_info is stored in BigEndian because of PowerPC */
|
||||
+ attr_type = B_HOST_TO_BENDIAN_INT32( fa_info.type );
|
||||
+ attr_size = B_HOST_TO_BENDIAN_INT64( fa_info.size );
|
||||
+
|
||||
+ memcpy( ptr, &attr_type, sizeof(uint32)); ptr += sizeof(uint32);
|
||||
+ memcpy( ptr, &attr_size, sizeof(uint64)); ptr += sizeof(uint64);
|
||||
+
|
||||
if( fa_info.size > 0 ) {
|
||||
ssize_t read_bytes;
|
||||
|
||||
@@ -129,6 +123,13 @@ typedef unsigned long ulg; /* unsigned 32-bit value */
|
||||
# define MATCH shmatch /* Default for pattern matching: UNIX style */
|
||||
#endif
|
||||
@@ -696,9 +699,9 @@ local int add_Be_ef( struct zlist far *z )
|
||||
}
|
||||
|
||||
+/* Types centralized here for easy modification */
|
||||
+#define local static /* More meaningful outside functions */
|
||||
+typedef unsigned char uch; /* unsigned 8-bit value */
|
||||
+typedef unsigned short ush; /* unsigned 16-bit value */
|
||||
+typedef unsigned long ulg; /* unsigned 32-bit value */
|
||||
+
|
||||
+
|
||||
/* Structure carrying extended timestamp information */
|
||||
typedef struct iztimes {
|
||||
time_t atime; /* new access time */
|
||||
diff --git a/zipcloak.c b/zipcloak.c
|
||||
index 37bd414..f3afc36 100644
|
||||
--- a/zipcloak.c
|
||||
+++ b/zipcloak.c
|
||||
@@ -54,7 +54,7 @@ ZCONST uLongf *crc_32_tab;
|
||||
int set_filetype(out_path)
|
||||
char *out_path;
|
||||
{
|
||||
-#ifdef __BEOS__
|
||||
+#if (defined(__BEOS__) || defined(__HAIKU__))
|
||||
/* Set the filetype of the zipfile to "application/zip" */
|
||||
setfiletype( out_path, "application/zip" );
|
||||
#endif
|
||||
diff --git a/zipnote.c b/zipnote.c
|
||||
index 5e02cb6..315a3de 100644
|
||||
--- a/zipnote.c
|
||||
+++ b/zipnote.c
|
||||
@@ -72,7 +72,7 @@ void zipnotewarn(ZCONST char *a, ZCONST char *b);
|
||||
int set_filetype(out_path)
|
||||
char *out_path;
|
||||
{
|
||||
-#ifdef __BEOS__
|
||||
+#if (defined(__BEOS__) || defined(__HAIKU__))
|
||||
/* Set the filetype of the zipfile to "application/zip" */
|
||||
setfiletype( out_path, "application/zip" );
|
||||
#endif
|
||||
diff --git a/zipsplit.c b/zipsplit.c
|
||||
index 8db76a1..ecced0c 100644
|
||||
--- a/zipsplit.c
|
||||
+++ b/zipsplit.c
|
||||
@@ -96,7 +96,7 @@ int talln = 0; /* number of entries in talls[] */
|
||||
int set_filetype(out_path)
|
||||
char *out_path;
|
||||
{
|
||||
-#ifdef __BEOS__
|
||||
+#if (defined(__BEOS__) || defined(__HAIKU__))
|
||||
/* Set the filetype of the zipfile to "application/zip" */
|
||||
setfiletype( out_path, "application/zip" );
|
||||
#endif
|
||||
diff --git a/zipup.c b/zipup.c
|
||||
index 39f7d9c..80c3101 100644
|
||||
--- a/zipup.c
|
||||
+++ b/zipup.c
|
||||
@@ -68,7 +68,7 @@
|
||||
# include "atari/zipup.h"
|
||||
#endif
|
||||
|
||||
-#ifdef __BEOS__
|
||||
+#if (defined(__BEOS__) || defined(__HAIKU__))
|
||||
# include "beos/zipup.h"
|
||||
#endif
|
||||
/* Check for way too much data. */
|
||||
- if( attrsize > (off_t)ULONG_MAX ) {
|
||||
+ if( attrsize > OFF_MAX ) {
|
||||
zipwarn( "uncompressed attributes truncated", "" );
|
||||
- attrsize = (off_t)(ULONG_MAX - MEMCOMPRESS_OVERHEAD);
|
||||
+ attrsize = OFF_MAX - MEMCOMPRESS_OVERHEAD;
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.4
|
||||
|
||||
@@ -11,7 +11,7 @@ REVISION="1"
|
||||
LICENSE="Info-ZIP"
|
||||
COPYRIGHT="1990-2008 Info-ZIP"
|
||||
|
||||
ARCHITECTURES="x86 x86_gcc2"
|
||||
ARCHITECTURES="x86 x86_gcc2 x86_64"
|
||||
|
||||
PATCHES="$portName-$portVersion.patchset"
|
||||
|
||||
@@ -40,12 +40,14 @@ SOURCE_DIR="zip30"
|
||||
|
||||
BUILD()
|
||||
{
|
||||
make $jobArgs -f beos/Makefile
|
||||
sh unix/configure \
|
||||
&& echo LFLAGS2=\"-lbe\" >> flags \
|
||||
&& make -f unix/Makefile generic MANDIR=$manDir
|
||||
}
|
||||
|
||||
INSTALL()
|
||||
{
|
||||
make -f beos/Makefile install \
|
||||
make -f unix/Makefile install PREFIX=$prefix \
|
||||
BINDIR=$binDir \
|
||||
INCLUDEDIR=$includeDir \
|
||||
LIBDIR=$libDir \
|
||||
|
||||
Reference in New Issue
Block a user