From owner-freebsd-ports Fri Oct 13 16:40:22 2000 Delivered-To: freebsd-ports@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id A801037B66F for ; Fri, 13 Oct 2000 16:40:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id QAA33658; Fri, 13 Oct 2000 16:40:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from mailgw3.netvision.net.il (mailgw3.netvision.net.il [194.90.1.11]) by hub.freebsd.org (Postfix) with ESMTP id 53C5437B502 for ; Fri, 13 Oct 2000 16:36:49 -0700 (PDT) Received: from alchemy.oven.org (shiva2.ksl.co.il [199.203.25.37]) by mailgw3.netvision.net.il (8.9.3/8.9.3) with ESMTP id BAA24571 for ; Sat, 14 Oct 2000 01:35:53 +0200 (IST) Received: (from mapc@localhost) by alchemy.oven.org (8.11.0/8.11.0) id e9DMaOx56081; Sat, 14 Oct 2000 01:36:24 +0300 (IDT) (envelope-from mapc) Message-Id: <200010132236.e9DMaOx56081@alchemy.oven.org> Date: Sat, 14 Oct 2000 01:36:24 +0300 (IDT) From: roman@xpert.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: ports/21964: [PATCH] for archivers/unarj - create subdirs + multi-volume hndl. Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 21964 >Category: ports >Synopsis: unarj doesn't create directories nor handle multi-volumes >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 13 16:40:01 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Roman Shterenzon >Release: FreeBSD 4.1.1-STABLE i386 >Organization: >Environment: Version 2.43 of unarj. AFAIK version 2.41 which was then downloaded from sunsite had the create directory patch applied. >Description: The archivers/unarj port doesn't create subdirectories listed in archives, nor does it handle multi-volume archives making it useful to very limited degree. I was facing it when I tried to back up a bunch of old diskettes. It was nearly unusable in it's current state. I contacted ache@freebsd.org but had no reply from him since then. >How-To-Repeat: Try to extract arj file with directories or try to extract a multivolume archive. >Fix: The RedHat's Linux distribution ships with unarj patched for creating directories. (I include the patch). The multivolume issue was fixed by some other person, and it's hosted here: http://www.home.unix-ag.org/arne/unarj/ (I attach it as well). All theses changes were tested by me on multiple archives and were found to be ok. Included also patch-aa and patch-ad - for direct inclusion in the ports. (I merged them). This is the patch for subdirectory creation: diff -urN unarj-2.43/unarj.c unarj-2.43.new/unarj.c --- unarj-2.43/unarj.c Mon Sep 29 14:00:24 1997 +++ unarj-2.43.new/unarj.c Tue Aug 8 15:57:58 2000 @@ -42,7 +42,8 @@ * 02/17/93 R. Jung Added archive modified date support. * 01/22/94 R. Jung Changed copyright message. * 07/29/96 R. Jung Added "/" to list of path separators. - * + * 08/08/00 P. Knirsch Added subdirectory creation for the x command. Also + * fixed some compiler warnings. */ #include "unarj.h" @@ -51,6 +52,10 @@ #include #include #include +#include +#include +#include +#include #else /* !MODERN */ extern void free(); extern void exit(); @@ -712,6 +717,8 @@ extract() { char name[FNAME_MAX]; + char dir[FNAME_MAX]; + char *pos; if (check_flags()) { @@ -730,6 +737,21 @@ if (host_os != OS) default_case_path(name); + + + /* + 8/8/2000 Phil Knirsch: Bugfix to create subdirectories. Unarj didn't + do this for a long time, so it's finally fixed. + */ + pos = strchr(name, PATH_CHAR); + + while (pos != NULL) + { + strncpy(dir, name, pos-name); + dir[pos-name] = '\0'; + mkdir(dir, 0777); + pos = strchr(pos+1, PATH_CHAR); + } if (file_exists(name)) { diff -urN unarj-2.43/unarj.h unarj-2.43.new/unarj.h --- unarj-2.43/unarj.h Mon Sep 29 14:00:24 1997 +++ unarj-2.43.new/unarj.h Tue Aug 8 15:19:33 2000 @@ -198,90 +198,90 @@ /* end of environmental defines */ /* ********************************************************* */ -/* ********************************************************* */ -/* -/* Structure of archive main header (low order byte first): -/* -/* 2 header id (comment and local file) = 0x60, 0xEA -/* 2 basic header size (from 'first_hdr_size' thru 'comment' below) -/* = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1 -/* = 0 if end of archive -/* -/* 1 first_hdr_size (size up to 'extra data') -/* 1 archiver version number -/* 1 minimum archiver version to extract -/* 1 host OS (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MACDOS) -/* (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT) -/* (9 = VAX VMS) -/* 1 arj flags (0x01 = GARBLED_FLAG, 0x02 = OLD_SECURED_FLAG) -/* (0x04 = VOLUME_FLAG, 0x08 = EXTFILE_FLAG) -/* (0x10 = PATHSYM_FLAG, 0x20 = BACKUP_FLAG) -/* (0x40 = SECURED_FLAG) -/* 1 arj security version (2 = current) -/* 1 file type (2 = comment header) -/* 1 ? ] -/* 4 date time stamp created -/* 4 date time stamp modified -/* 4 archive size up to the end of archive marker -/* 4 file position of security envelope data -/* 2 entryname position in filename -/* 2 length in bytes of trailing security data -/* 2 host data -/* ? extra data -/* -/* ? archive filename (null-terminated) -/* ? archive comment (null-terminated) -/* -/* 4 basic header CRC -/* -/* 2 1st extended header size (0 if none) -/* ? 1st extended header -/* 4 1st extended header's CRC -/* ... -/* -/* -/* Structure of archive file header (low order byte first): -/* -/* 2 header id (comment and local file) = 0x60, 0xEA -/* 2 basic header size (from 'first_hdr_size' thru 'comment' below) -/* = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1 -/* = 0 if end of archive -/* -/* 1 first_hdr_size (size up to 'extra data') -/* 1 archiver version number -/* 1 minimum archiver version to extract -/* 1 host OS (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MACDOS) -/* (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT) -/* (9 = VAX VMS) -/* 1 arj flags (0x01 = GARBLED_FLAG, 0x02 = NOT USED) -/* (0x04 = VOLUME_FLAG, 0x08 = EXTFILE_FLAG) -/* (0x10 = PATHSYM_FLAG, 0x20 = BACKUP_FLAG) -/* (0x40 = NOT USED) -/* 1 method (0 = stored, 1 = compressed most ... 4 compressed fastest) -/* 1 file type (0 = binary, 1 = text, 2 = comment header, 3 = directory) -/* (4 = label) -/* 1 garble password modifier -/* 4 date time stamp modified -/* 4 compressed size -/* 4 original size -/* 4 original file's CRC -/* 2 entryname position in filename -/* 2 file access mode -/* 2 host data -/* ? extra data -/* 4 bytes for extended file position -/* -/* ? filename (null-terminated) -/* ? comment (null-terminated) -/* -/* 4 basic header CRC -/* -/* 2 1st extended header size (0 if none) -/* ? 1st extended header -/* 4 1st extended header's CRC -/* ... -/* ? compressed file /* + * + * Structure of archive main header (low order byte first): + * + * 2 header id (comment and local file) = 0x60, 0xEA + * 2 basic header size (from 'first_hdr_size' thru 'comment' below) + * = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1 + * = 0 if end of archive + * + * 1 first_hdr_size (size up to 'extra data') + * 1 archiver version number + * 1 minimum archiver version to extract + * 1 host OS (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MACDOS) + * (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT) + * (9 = VAX VMS) + * 1 arj flags (0x01 = GARBLED_FLAG, 0x02 = OLD_SECURED_FLAG) + * (0x04 = VOLUME_FLAG, 0x08 = EXTFILE_FLAG) + * (0x10 = PATHSYM_FLAG, 0x20 = BACKUP_FLAG) + * (0x40 = SECURED_FLAG) + * 1 arj security version (2 = current) + * 1 file type (2 = comment header) + * 1 ? ] + * 4 date time stamp created + * 4 date time stamp modified + * 4 archive size up to the end of archive marker + * 4 file position of security envelope data + * 2 entryname position in filename + * 2 length in bytes of trailing security data + * 2 host data + * ? extra data + * + * ? archive filename (null-terminated) + * ? archive comment (null-terminated) + * + * 4 basic header CRC + * + * 2 1st extended header size (0 if none) + * ? 1st extended header + * 4 1st extended header's CRC + * ... + * + * + * Structure of archive file header (low order byte first): + * + * 2 header id (comment and local file) = 0x60, 0xEA + * 2 basic header size (from 'first_hdr_size' thru 'comment' below) + * = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1 + * = 0 if end of archive + * + * 1 first_hdr_size (size up to 'extra data') + * 1 archiver version number + * 1 minimum archiver version to extract + * 1 host OS (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MACDOS) + * (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT) + * (9 = VAX VMS) + * 1 arj flags (0x01 = GARBLED_FLAG, 0x02 = NOT USED) + * (0x04 = VOLUME_FLAG, 0x08 = EXTFILE_FLAG) + * (0x10 = PATHSYM_FLAG, 0x20 = BACKUP_FLAG) + * (0x40 = NOT USED) + * 1 method (0 = stored, 1 = compressed most ... 4 compressed fastest) + * 1 file type (0 = binary, 1 = text, 2 = comment header, 3 = directory) + * (4 = label) + * 1 garble password modifier + * 4 date time stamp modified + * 4 compressed size + * 4 original size + * 4 original file's CRC + * 2 entryname position in filename + * 2 file access mode + * 2 host data + * ? extra data + * 4 bytes for extended file position + * + * ? filename (null-terminated) + * ? comment (null-terminated) + * + * 4 basic header CRC + * + * 2 1st extended header size (0 if none) + * ? 1st extended header + * 4 1st extended header's CRC + * ... + * ? compressed file + */ /* ********************************************************* */ /* ********************************************************* */ /* */ --------------------------------end of subdir patch--------------------------- ----------------------------begin of multivolume patch------------------------ diff -ur unarj241a.orig/unarj.c unarj241a/unarj.c --- unarj241a.orig/unarj.c Sun Apr 10 12:00:56 1994 +++ unarj241a/unarj.c Mon Oct 9 02:47:30 2000 @@ -18,29 +18,30 @@ * structural point of view. * * Modification history: - * Date Programmer Description of modification. - * 04/05/91 R. Jung Rewrote code. - * 04/23/91 M. Adler Portabilized. - * 04/29/91 R. Jung Added l command. Removed 16 bit dependency in - * fillbuf(). - * 05/19/91 R. Jung Fixed extended header skipping code. - * 05/25/91 R. Jung Improved find_header(). - * 06/03/91 R. Jung Changed arguments in get_mode_str() and - * set_ftime_mode(). - * 06/19/81 R. Jung Added two more %c in printf() in list_arc(). - * 07/07/91 R. Jung Added default_case_path() to extract(). - * Added strlower(). - * 07/20/91 R. Jung Changed uint ratio() to static uint ratio(). - * 07/21/91 R. Jung Added #ifdef VMS. - * 08/28/91 R. Jung Changed M_DIFFHOST message. - * 08/31/91 R. Jung Added changes to support MAC THINK_C compiler - * per Eric Larson. - * 10/07/91 R. Jung Added missing ; to THINK_C additions. - * 11/11/91 R. Jung Added host_os test to fwrite_txt_crc(). - * 11/24/91 R. Jung Added more error_count processing. - * 12/03/91 R. Jung Added backup file processing. - * 02/17/93 R. Jung Added archive modified date support. - * 940410 aeb@cwi.nl Added automatic directory creation for x mode. + * Date Programmer Description of modification. + * 04/05/91 R. Jung Rewrote code. + * 04/23/91 M. Adler Portabilized. + * 04/29/91 R. Jung Added l command. Removed 16 bit dependency in + * fillbuf(). + * 05/19/91 R. Jung Fixed extended header skipping code. + * 05/25/91 R. Jung Improved find_header(). + * 06/03/91 R. Jung Changed arguments in get_mode_str() and + * set_ftime_mode(). + * 06/19/81 R. Jung Added two more %c in printf() in list_arc(). + * 07/07/91 R. Jung Added default_case_path() to extract(). + * Added strlower(). + * 07/20/91 R. Jung Changed uint ratio() to static uint ratio(). + * 07/21/91 R. Jung Added #ifdef VMS. + * 08/28/91 R. Jung Changed M_DIFFHOST message. + * 08/31/91 R. Jung Added changes to support MAC THINK_C compiler + * per Eric Larson. + * 10/07/91 R. Jung Added missing ; to THINK_C additions. + * 11/11/91 R. Jung Added host_os test to fwrite_txt_crc(). + * 11/24/91 R. Jung Added more error_count processing. + * 12/03/91 R. Jung Added backup file processing. + * 02/17/93 R. Jung Added archive modified date support. + * 940410 aeb@cwi.nl Added automatic directory creation for x mode. + * 980525 arne@unix-ag.org Added handling of multiple volume archives. * */ @@ -119,7 +120,7 @@ NULL }; -char M_VERSION [] = "UNARJ (Demo version) 2.41a Copyright (c) 1991-93 Robert K Jung\n\n"; +char M_VERSION [] = "UNARJ (Demo version) 2.41b Copyright (c) 1991-93 Robert K Jung\n\n"; char M_ARCDATE [] = "Archive created: %s"; char M_ARCDATEM[] = ", modified: %s"; @@ -137,6 +138,7 @@ char M_ERRORCNT[] = "%sFound %5d error(s)!"; char M_EXTRACT [] = "Extracting %-25s"; char M_FEXISTS [] = "%-25s exists, "; +char M_FNEXISTS[] = "%-25s doesn't exist, unable to extend, "; char M_HEADRCRC[] = "Header CRC error!"; char M_NBRFILES[] = "%5d file(s)\n"; char M_NOMEMORY[] = "Out of memory"; @@ -148,6 +150,7 @@ char M_UNKNMETH[] = "Unsupported method: %d, "; char M_UNKNTYPE[] = "Unsupported file type: %d, "; char M_UNKNVERS[] = "Unsupported version: %d, "; +char M_WRONGPOS[] = "%-25s wrong position to continue, "; #define get_crc() get_longword() #define fget_crc(f) fget_longword(f) @@ -215,6 +218,7 @@ static uchar *get_ptr; static UCRC file_crc; static UCRC header_crc; +static ulong ext_file_pos; static long first_hdr_pos; static long torigsize; @@ -223,6 +227,7 @@ static int clock_inx; static char *writemode[2] = { "wb", "w" }; +static char *appendmode[2] = { "ab", "a" }; static UCRC crctable[UCHAR_MAX + 1]; @@ -622,6 +627,7 @@ entry_pos = get_word(); file_mode = get_word(); host_data = get_word(); + ext_file_pos = get_longword(); hdr_filename = (char *)&header[first_hdr_size]; strncopy(filename, hdr_filename, sizeof(filename)); @@ -752,7 +758,7 @@ if (host_os != OS) default_case_path(name); - if (file_exists(name)) + if (file_exists(name) && !(arj_flags & EXTFILE_FLAG)) { printf(M_FEXISTS, name); printf(M_SKIPPED, name); @@ -760,11 +766,22 @@ error_count++; return 0; } + if (!file_exists(name) && (arj_flags & EXTFILE_FLAG)) + { + printf(M_FNEXISTS, name); + printf(M_SKIPPED, name); + skip(); + error_count++; + return 0; + } #ifdef UNIX if (command == 'X') create_required_dirs(name); #endif - outfile = file_open(name, writemode[file_type & 1]); + if(arj_flags & EXTFILE_FLAG) + outfile = file_open(name, appendmode[file_type & 1]); + else + outfile = file_open(name, writemode[file_type & 1]); if (outfile == NULL) { printf(M_CANTOPEN, name); @@ -773,9 +790,21 @@ error_count++; return 0; } + if( (arj_flags & EXTFILE_FLAG) && (ftell(outfile)!=ext_file_pos) ) { + printf(M_WRONGPOS, name); + printf(M_SKIPPED, name); + skip(); + error_count++; + return 0; + } + printf(M_EXTRACT, name); if (host_os != OS && file_type == BINARY_TYPE) printf(M_DIFFHOST); + if(arj_flags & EXTFILE_FLAG) + printf(" (continued)"); + if(arj_flags & VOLUME_FLAG) + printf(" (cont'd in next .arj)"); printf(" "); crc = CRC_MASK; ----------------------------end of multivolume patch-------------------------- ----------------------------begin of patch-aa -------------------------------- --- unarj.h.orig Mon Oct 9 03:36:29 2000 +++ unarj.h Mon Oct 9 03:31:26 2000 @@ -106,8 +106,12 @@ #endif typedef unsigned char uchar; /* 8 bits or more */ +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) typedef unsigned int uint; /* 16 - 32 bits or more */ typedef unsigned short ushort; /* 16 bits or more */ +#else +# include +#endif typedef unsigned long ulong; /* 32 bits or more */ #define USHRT_BIT (CHAR_BIT * sizeof(ushort)) @@ -198,90 +202,90 @@ /* end of environmental defines */ /* ********************************************************* */ -/* ********************************************************* */ -/* -/* Structure of archive main header (low order byte first): -/* -/* 2 header id (comment and local file) = 0x60, 0xEA -/* 2 basic header size (from 'first_hdr_size' thru 'comment' below) -/* = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1 -/* = 0 if end of archive -/* -/* 1 first_hdr_size (size up to 'extra data') -/* 1 archiver version number -/* 1 minimum archiver version to extract -/* 1 host OS (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MACDOS) -/* (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT) -/* (9 = VAX VMS) -/* 1 arj flags (0x01 = GARBLED_FLAG, 0x02 = OLD_SECURED_FLAG) -/* (0x04 = VOLUME_FLAG, 0x08 = EXTFILE_FLAG) -/* (0x10 = PATHSYM_FLAG, 0x20 = BACKUP_FLAG) -/* (0x40 = SECURED_FLAG) -/* 1 arj security version (2 = current) -/* 1 file type (2 = comment header) -/* 1 ? ] -/* 4 date time stamp created -/* 4 date time stamp modified -/* 4 archive size up to the end of archive marker -/* 4 file position of security envelope data -/* 2 entryname position in filename -/* 2 length in bytes of trailing security data -/* 2 host data -/* ? extra data -/* -/* ? archive filename (null-terminated) -/* ? archive comment (null-terminated) -/* -/* 4 basic header CRC -/* -/* 2 1st extended header size (0 if none) -/* ? 1st extended header -/* 4 1st extended header's CRC -/* ... -/* -/* -/* Structure of archive file header (low order byte first): -/* -/* 2 header id (comment and local file) = 0x60, 0xEA -/* 2 basic header size (from 'first_hdr_size' thru 'comment' below) -/* = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1 -/* = 0 if end of archive -/* -/* 1 first_hdr_size (size up to 'extra data') -/* 1 archiver version number -/* 1 minimum archiver version to extract -/* 1 host OS (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MACDOS) -/* (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT) -/* (9 = VAX VMS) -/* 1 arj flags (0x01 = GARBLED_FLAG, 0x02 = NOT USED) -/* (0x04 = VOLUME_FLAG, 0x08 = EXTFILE_FLAG) -/* (0x10 = PATHSYM_FLAG, 0x20 = BACKUP_FLAG) -/* (0x40 = NOT USED) -/* 1 method (0 = stored, 1 = compressed most ... 4 compressed fastest) -/* 1 file type (0 = binary, 1 = text, 2 = comment header, 3 = directory) -/* (4 = label) -/* 1 garble password modifier -/* 4 date time stamp modified -/* 4 compressed size -/* 4 original size -/* 4 original file's CRC -/* 2 entryname position in filename -/* 2 file access mode -/* 2 host data -/* ? extra data -/* 4 bytes for extended file position -/* -/* ? filename (null-terminated) -/* ? comment (null-terminated) -/* -/* 4 basic header CRC -/* -/* 2 1st extended header size (0 if none) -/* ? 1st extended header -/* 4 1st extended header's CRC -/* ... -/* ? compressed file /* + * + * Structure of archive main header (low order byte first): + * + * 2 header id (comment and local file) = 0x60, 0xEA + * 2 basic header size (from 'first_hdr_size' thru 'comment' below) + * = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1 + * = 0 if end of archive + * + * 1 first_hdr_size (size up to 'extra data') + * 1 archiver version number + * 1 minimum archiver version to extract + * 1 host OS (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MACDOS) + * (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT) + * (9 = VAX VMS) + * 1 arj flags (0x01 = GARBLED_FLAG, 0x02 = OLD_SECURED_FLAG) + * (0x04 = VOLUME_FLAG, 0x08 = EXTFILE_FLAG) + * (0x10 = PATHSYM_FLAG, 0x20 = BACKUP_FLAG) + * (0x40 = SECURED_FLAG) + * 1 arj security version (2 = current) + * 1 file type (2 = comment header) + * 1 ? ] + * 4 date time stamp created + * 4 date time stamp modified + * 4 archive size up to the end of archive marker + * 4 file position of security envelope data + * 2 entryname position in filename + * 2 length in bytes of trailing security data + * 2 host data + * ? extra data + * + * ? archive filename (null-terminated) + * ? archive comment (null-terminated) + * + * 4 basic header CRC + * + * 2 1st extended header size (0 if none) + * ? 1st extended header + * 4 1st extended header's CRC + * ... + * + * + * Structure of archive file header (low order byte first): + * + * 2 header id (comment and local file) = 0x60, 0xEA + * 2 basic header size (from 'first_hdr_size' thru 'comment' below) + * = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1 + * = 0 if end of archive + * + * 1 first_hdr_size (size up to 'extra data') + * 1 archiver version number + * 1 minimum archiver version to extract + * 1 host OS (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MACDOS) + * (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT) + * (9 = VAX VMS) + * 1 arj flags (0x01 = GARBLED_FLAG, 0x02 = NOT USED) + * (0x04 = VOLUME_FLAG, 0x08 = EXTFILE_FLAG) + * (0x10 = PATHSYM_FLAG, 0x20 = BACKUP_FLAG) + * (0x40 = NOT USED) + * 1 method (0 = stored, 1 = compressed most ... 4 compressed fastest) + * 1 file type (0 = binary, 1 = text, 2 = comment header, 3 = directory) + * (4 = label) + * 1 garble password modifier + * 4 date time stamp modified + * 4 compressed size + * 4 original size + * 4 original file's CRC + * 2 entryname position in filename + * 2 file access mode + * 2 host data + * ? extra data + * 4 bytes for extended file position + * + * ? filename (null-terminated) + * ? comment (null-terminated) + * + * 4 basic header CRC + * + * 2 1st extended header size (0 if none) + * ? 1st extended header + * 4 1st extended header's CRC + * ... + * ? compressed file + */ /* ********************************************************* */ /* ********************************************************* */ /* */ ----------------------------end of patch-aa ---------------------------------- ----------------------------begin of patch-ad -------------------------------- --- unarj.c.orig Mon Oct 9 03:34:19 2000 +++ unarj.c Mon Oct 9 03:35:58 2000 @@ -42,7 +42,8 @@ * 02/17/93 R. Jung Added archive modified date support. * 01/22/94 R. Jung Changed copyright message. * 07/29/96 R. Jung Added "/" to list of path separators. - * + * 08/08/00 P. Knirsch Added subdirectory creation for the x command. Also + * fixed some compiler warnings. */ #include "unarj.h" @@ -51,6 +52,12 @@ #include #include #include +#ifdef UNIX +#include +#include +#include +#include +#endif #else /* !MODERN */ extern void free(); extern void exit(); @@ -137,6 +144,7 @@ char M_ERRORCNT[] = "%sFound %5d error(s)!"; char M_EXTRACT [] = "Extracting %-25s"; char M_FEXISTS [] = "%-25s exists, "; +char M_FNEXISTS[] = "%-25s doesn't exist, unable to extend, "; char M_HEADRCRC[] = "Header CRC error!"; char M_NBRFILES[] = "%5d file(s)\n"; char M_NOMEMORY[] = "Out of memory"; @@ -148,6 +156,7 @@ char M_UNKNMETH[] = "Unsupported method: %d, "; char M_UNKNTYPE[] = "Unsupported file type: %d, "; char M_UNKNVERS[] = "Unsupported version: %d, "; +char M_WRONGPOS[] = "%-25s wrong position to continue, "; #define get_crc() get_longword() #define fget_crc(f) fget_longword(f) @@ -215,6 +224,7 @@ static uchar *get_ptr; static UCRC file_crc; static UCRC header_crc; +static ulong ext_file_pos; static long first_hdr_pos; static long torigsize; @@ -223,6 +233,7 @@ static int clock_inx; static char *writemode[2] = { "wb", "w" }; +static char *appendmode[2] = { "ab", "a" }; static UCRC crctable[UCHAR_MAX + 1]; @@ -622,6 +633,7 @@ entry_pos = get_word(); file_mode = get_word(); host_data = get_word(); + ext_file_pos = get_longword(); hdr_filename = (char *)&header[first_hdr_size]; strncopy(filename, hdr_filename, sizeof(filename)); @@ -712,6 +724,8 @@ extract() { char name[FNAME_MAX]; + char dir[FNAME_MAX]; + char *pos; if (check_flags()) { @@ -731,7 +745,22 @@ if (host_os != OS) default_case_path(name); - if (file_exists(name)) + + /* + 8/8/2000 Phil Knirsch: Bugfix to create subdirectories. Unarj didn't + do this for a long time, so it's finally fixed. + */ + pos = strchr(name, PATH_CHAR); + + while (pos != NULL) + { + strncpy(dir, name, pos-name); + dir[pos-name] = '\0'; + mkdir(dir, 0777); + pos = strchr(pos+1, PATH_CHAR); + } + + if (file_exists(name) && !(arj_flags & EXTFILE_FLAG)) { printf(M_FEXISTS, name); printf(M_SKIPPED, name); @@ -739,7 +768,10 @@ error_count++; return 0; } - outfile = file_open(name, writemode[file_type & 1]); + if(arj_flags & EXTFILE_FLAG) + outfile = file_open(name, appendmode[file_type & 1]); + else + outfile = file_open(name, writemode[file_type & 1]); if (outfile == NULL) { printf(M_CANTOPEN, name); @@ -748,9 +780,21 @@ error_count++; return 0; } + if( (arj_flags & EXTFILE_FLAG) && (ftell(outfile)!=ext_file_pos) ) { + printf(M_WRONGPOS, name); + printf(M_SKIPPED, name); + skip(); + error_count++; + return 0; + } + printf(M_EXTRACT, name); if (host_os != OS && file_type == BINARY_TYPE) printf(M_DIFFHOST); + if(arj_flags & EXTFILE_FLAG) + printf(" (continued)"); + if(arj_flags & VOLUME_FLAG) + printf(" (cont'd in next .arj)"); printf(" "); crc = CRC_MASK; ---------------------------- end of patch-ad ---------------------------------- >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message