2006-10-02 Koji Arai <arai@users.sourceforge.jp>
+ * src/header.c, src/lha.h, src/lha_macro.h, src/lhadd.c, src/lharc.c, src/lhext.c, src/lhlist.c, src/vsnprintf.c, tests/lha-test.in, tests/lha-test11, tests/lha-test12:
+ applied the patch for the DJGPP. Thanks to Doug Kaufman.
+
* 00readme.autoconf, configure.ac: changed mail address.
2006-09-11 Koji Arai <jca02266@nifty.com>
# Process this file with autoconf to produce a configure script.
-AC_INIT([LHa for UNIX], 1.14i-ac20060911, arai@users.sourceforge.jp, lha)
+AC_INIT([LHa for UNIX], 1.14i-ac20061002, arai@users.sourceforge.jp, lha)
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE
hdr->name[i] = '\0';
/* defaults for other type */
- hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW;
+ hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW;
hdr->unix_gid = 0;
hdr->unix_uid = 0;
hdr->has_crc = FALSE;
return TRUE;
- }
+ }
error("Unkonwn header (lha file?)");
exit(1);
hdr->name[i] = '\0';
/* defaults for other type */
- hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW;
+ hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW;
hdr->unix_gid = 0;
hdr->unix_uid = 0;
hdr->header_level = get_byte();
/* defaults for other type */
- hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW;
+ hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW;
hdr->unix_gid = 0;
hdr->unix_uid = 0;
hdr->header_level = get_byte();
/* defaults for other type */
- hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW;
+ hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW;
hdr->unix_gid = 0;
hdr->unix_uid = 0;
system_kanji_code,
archive_delim, system_delim, filename_case);
- if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) {
+ if (S_ISLNK(hdr->unix_mode)) {
char *p;
/* split symbolic link */
p = strchr(hdr->name, '|');
}
}
-#ifdef S_IFLNK
+#if defined(S_IFLNK) && !defined(__DJGPP__)
if (is_symlink(v_stat)) {
memcpy(hdr->method, LZHDIRS_METHOD, METHOD_TYPE_STORAGE);
hdr->attribute = GENERIC_DIRECTORY_ATTRIBUTE;
archive_delim = "\\";
}
- if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) {
+ if (S_ISLNK(hdr->unix_mode)) {
char *p;
p = strchr(hdr->name, '|');
if (p) {
#include <applefile.h>
#endif
+#ifdef __DJGPP__
+#include <io.h>
+#endif /* __DJGPP__ */
+
#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
#define LZHEADER_STORAGE 4096
+#ifndef S_IFREG
+#define S_IFREG UNIX_FILE_REGULAR
+#endif
+
+#ifndef S_IFDIR
+#define S_IFDIR UNIX_FILE_DIRECTORY
+#endif
+
+#ifndef S_IFLNK
+#define S_IFLNK UNIX_FILE_SYMLINK
+#endif
+
+#ifndef S_ISREG
+#define S_ISREG(m) (((m) & UNIX_FILE_TYPEMASK) == S_IFREG)
+#endif
+
+#ifndef S_ISDIR
+#define S_ISDIR(m) (((m) & UNIX_FILE_TYPEMASK) == S_IFDIR)
+#endif
+
+#ifndef S_ISLNK
+#ifdef __DJGPP__
+#define S_ISLNK(m) 0
+#else
+#define S_ISLNK(m) (((m) & UNIX_FILE_TYPEMASK) == S_IFLNK)
+#endif
+#endif
+
/* ------------------------------------------------------------------------ */
/* FILE Attribute */
/* ------------------------------------------------------------------------ */
header_pos = ftello(nafp);
write_header(nafp, hdr);/* DUMMY */
- if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) {
+ if (S_ISLNK(hdr->unix_mode)) {
if (!quiet)
printf("%s -> %s\t- Symbolic Link\n", hdr->name, hdr->realname);
}
init_sp(&sp);
while (get_header(oafp, &hdr)) {
- if ((hdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_REGULAR) {
+ if (S_ISREG(hdr.unix_mode)) {
if (stat(hdr.name, &stbuf) >= 0) /* exist ? */
add_sp(&sp, hdr.name, strlen(hdr.name) + 1);
}
- else if ((hdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY) {
+ else if (S_ISDIR(hdr.unix_mode)) {
strcpy(name, hdr.name); /* ok */
len = strlen(name);
if (len > 0 && name[len - 1] == '/')
if (need_file(ahdr.name)) { /* skip */
fseeko(oafp, ahdr.packed_size, SEEK_CUR);
if (noexec || !quiet) {
- if ((ahdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK)
+ if (S_ISLNK(ahdr.unix_mode))
message("delete %s -> %s", ahdr.name, ahdr.realname);
else
message("delete %s", ahdr.name);
if (!strcmp(new_archive_name, "-")) {
nafp = stdout;
- writing_filename = "starndard output";
-#if __MINGW32__
+ writing_filename = "standard output";
+#if defined(__MINGW32__) || defined(__DJGPP__)
setmode(fileno(stdout), O_BINARY);
#endif
}
print_tiny_usage()
{
#if HAVE_LIBAPPLEFILE
- fprintf(stderr, "\
+ fprintf(stdout, "\
usage: lha [-]<commands>[<options>] [-<options> ...] archive_file [file...]\n\
commands: [axelvudmcpt]\n\
options: [q[012]vnfto[567]dizg012eb[w=<dir>|x=<pattern>]]\n\
--help\n\
--version\n");
#else
- fprintf(stderr, "\
+ fprintf(stdout, "\
usage: lha [-]<commands>[<options>] [-<options> ...] archive_file [file...]\n\
commands: [axelvudmcpt]\n\
options: [q[012]vnfto[567]dizg012e[w=<dir>|x=<pattern>]]\n\
static void
print_usage()
{
- fprintf(stderr, "\
+ fprintf(stdout, "\
LHarc for UNIX V 1.02 Copyright(C) 1989 Y.Tagawa\n\
LHx for MSDOS V C2.01 Copyright(C) 1990 H.Yoshizaki\n\
LHx(arc) for OSK V 2.01 Modified 1990 Momozou\n\
print_tiny_usage();
- fprintf(stderr, "\
+ fprintf(stdout, "\
commands: options:\n\
a Add(or replace) to archive q{num} quiet (num:quiet mode)\n\
x,e EXtract from archive v verbose\n\
u Update newer files to archive f force (over write at extract)\n\
d Delete from archive t FILES are TEXT file\n");
#ifdef SUPPORT_LH7
- fprintf(stderr, "\
+ fprintf(stdout, "\
m Move to archive (means 'ad') o[567] compression method (a/u/c)\n\
");
#endif
#ifndef SUPPORT_LH7
- fprintf(stderr, "\
+ fprintf(stdout, "\
m Move to archive (means 'ad') o use LHarc compatible method (a/u/c)\n\
");
#endif
- fprintf(stderr, "\
+ fprintf(stdout, "\
c re-Construct new archive d delete FILES after (a/u/c)\n\
p Print to STDOUT from archive i ignore directory path (x/e)\n\
t Test file CRC in archive z files not compress (a/u/c)\n\
0/1/2 header level (a/u/c)\n\
");
#ifdef EUC
- fprintf(stderr, "\
+ fprintf(stdout, "\
e TEXT code convert from/to EUC\n\
");
#endif
#if HAVE_LIBAPPLEFILE
- fprintf(stderr, "\
+ fprintf(stdout, "\
b decode MacBinary (x/e)\n\
");
#endif
- fprintf(stderr, "\
+ fprintf(stdout, "\
w=<dir> specify extract directory (x/e)\n\
x=<pattern> eXclude files (a/u/c)\n\
");
#if IGNORE_DOT_FILES /* experimental feature */
- fprintf(stderr, "\
+ fprintf(stdout, "\
X ignore dot files (a/u/c)\n\
");
#endif
if (!strcmp(archive_name, "-")) {
if (cmd == CMD_EXTRACT || cmd == CMD_LIST) {
-#if __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
setmode(fileno(stdin), O_BINARY);
#endif
return stdin;
/* adjust file stamp */
utimebuf.actime = utimebuf.modtime = hdr->unix_last_modified_stamp;
- if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK)
+ if (!(S_ISLNK(hdr->unix_mode)))
utime(name, &utimebuf);
if (hdr->extend_type == EXTEND_UNIX
#ifdef NOT_COMPATIBLE_MODE
Please need your modification in this space.
#else
- if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK)
+ if (!(S_ISLNK(hdr->unix_mode)))
chmod(name, hdr->unix_mode);
#endif
if (!getuid()){
break;
}
- if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_REGULAR
+ if (S_ISREG(hdr->unix_mode)
&& method != LZHDIRS_METHOD_NUM) {
extract_regular:
#if 0
verbose = TRUE;
}
-#if __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
{
int old_mode;
fflush(stdout);
hdr->original_size, hdr->packed_size,
name, method, &read_size);
#endif /* HAVE_LIBAPPLEFILE */
-#if __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
fflush(stdout);
setmode(fileno(stdout), old_mode);
}
if (hdr->has_crc && crc != hdr->crc)
error("CRC error: \"%s\"", name);
}
- else if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY
- || (hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK
+ else if (S_ISDIR(hdr->unix_mode)
+ || S_ISLNK(hdr->unix_mode)
|| method == LZHDIRS_METHOD_NUM) {
/* ¢¬¤³¤ì¤Ç¡¢Symbolic Link ¤Ï¡¢Âç¾æÉפ«¡© */
if (!ignore_directory && !verify_mode) {
return read_size;
}
/* NAME has trailing SLASH '/', (^_^) */
- if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) {
+ if (S_ISLNK(hdr->unix_mode)) {
int l_code;
#ifdef S_IFLNK
name, hdr->realname);
return read_size;
#endif
- } else { /* make directory */
+ }
+ else { /* make directory */
if (!output_to_stdout && !make_parent_path(name))
return read_size;
/* save directory information */
char modebits[11];
if (verbose) {
- if ((hdr->unix_mode & UNIX_FILE_SYMLINK) != UNIX_FILE_SYMLINK)
+ if (S_ISLNK(hdr->unix_mode))
printf("%s\n", hdr->name);
else
printf("%s -> %s\n", hdr->name, hdr->realname);
case EXTEND_UNIX:
mode = hdr->unix_mode;
- if (mode & UNIX_FILE_DIRECTORY)
+ if (S_ISDIR(mode))
modebits[0] = 'd';
- else if ((mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK)
+ else if (S_ISLNK(mode))
modebits[0] = 'l';
else
modebits[0] = '-';
print_stamp(hdr->unix_last_modified_stamp);
if (!verbose) {
- if ((hdr->unix_mode & UNIX_FILE_SYMLINK) != UNIX_FILE_SYMLINK)
+ if (!(S_ISLNK(hdr->unix_mode)))
printf(" %s", hdr->name);
else {
printf(" %s -> %s", hdr->name, hdr->realname);
#endif
-#if defined(__hpux) && !defined(__GNUC__) || defined(__DECC)
+#if defined(__hpux) && !defined(__GNUC__) || defined(__DECC) || defined(__DJGPP__)
#include <string.h>
#endif
testsuite lha-test12
testsuite lha-test13
case `$lha --version 2>&1` in
-*-pc-mingw*)
+*djgpp* | *-pc-mingw*)
+ # No symlink support on DJGPP and MinGW
message testing to handle symbolic links ... skip
;;
*)
#
mkdir test-tmp1
case $(uname) in
-CYGWIN*)
+MS-DOS* | CYGWIN*)
# 190 bytes
file=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 ;;
*)
# on Cygwin/MinGW, skip this test.
# the length of pathname does not amount to the limit of level 0 header.
case $(uname) in
-CYGWIN*) true ;;
+MS-DOS* | CYGWIN*) true ;;
*) test -s test-stderr ;;
esac
check $? $LINENO
# on Cygwin/MinGW, skip this test.
# the length of pathname does not amount to the limit of level 0 header.
case $(uname) in
-CYGWIN*) true ;;
+MS-DOS* | CYGWIN*) true ;;
*) test -s test-stderr ;;
esac
check $? $LINENO
# -*- shell-script -*-
message testing the end of line conversion.
-# NL to CR NL in archive
-$lha ct test-tmp-crnl.lzh test-a test-b test-c
+# LF to CR LF in archive
+$lha ct test-tmp-crlf.lzh test-a test-b test-c
check $? $LINENO
# no convert
-$lha xw=test-tmp-crnl test-tmp-crnl.lzh
+$lha xw=test-tmp-crlf test-tmp-crlf.lzh
check $? $LINENO
-diff -r test-1 test-tmp-crnl
+# use GNU diff option --binary for DJGPP.
+diff -r --binary test-1 test-tmp-crlf
test $? -ne 0
check $? $LINENO
sed -e 's/$/
-/' < test-a | diff test-tmp-crnl/test-a -
+/' < test-a | diff test-tmp-crlf/test-a -
check $? $LINENO
sed -e 's/$/
-/' < test-b | diff test-tmp-crnl/test-b -
+/' < test-b | diff test-tmp-crlf/test-b -
check $? $LINENO
sed -e 's/$/
-/' < test-c | diff test-tmp-crnl/test-c -
+/' < test-c | diff test-tmp-crlf/test-c -
check $? $LINENO
-# CR NL to NL
-$lha xtw=test-tmp-nl test-tmp-crnl.lzh
+# CR LF to LF
+$lha xtw=test-tmp-nl test-tmp-crlf.lzh
check $? $LINENO
diff -r test-1 test-tmp-nl
check $? $LINENO
# no convert
$lha c test-tmp-nl.lzh test-a test-b test-c
check $? $LINENO
-# CR NL to NL (cannot convert)
+# CR LF to LF (cannot convert)
$lha xtw=test-tmp-nl2 test-tmp-nl.lzh
check $? $LINENO
diff -r test-1 test-tmp-nl2