/* Ver. 1.13b Symbolic Link Bug Fix 1994.08.22 N.Watazaki */
/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */
/* Ver. 1.14i bug fixed 2000.10.06 t.okamoto */
+/* Ver. 1.14i Contributed UTF-8 convertion for Mac OS X */
+/* 2002.06.29 Hiroto Sakai */
/* Ver. 1.14i autoconfiscated & rewritten 2003.02.23 Koji Arai */
/* ------------------------------------------------------------------------ */
#include "lha.h"
}
/*
- * Generic (MS-DOS style) time stamp format:
+ * Generic (MS-DOS style) time stamp format (localtime):
*
* 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
- * |<------- year ----->|<- month ->|<--- day ---->|
+ * |<---- year-1980 --->|<- month ->|<--- day ---->|
*
* 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- * |<--- hour --->|<---- minute --->|<- second*2 ->|
+ * |<--- hour --->|<---- minute --->|<- second/2 ->|
*
*/
generic_to_unix_stamp(t)
long t;
{
- struct tm dostm;
+ struct tm tm;
- /*
- * special case: if MSDOS format date and time were zero, then we
- * set time to be zero here too.
- */
- if (t == 0)
- return 0;
+#define subbits(n, off, len) (((n) >> (off)) & ((1 << (len))-1))
- dostm.tm_sec = (t & 0x1f) * 2;
- dostm.tm_min = t >> 5 & 0x3f;
- dostm.tm_hour = t >> 11 & 0x1f;
- dostm.tm_mday = t >> 16 & 0x1f;
- dostm.tm_mon = (t >> (16+5) & 0x0f) - 1; /* 0..11 */
- dostm.tm_year = (t >> (16+9) & 0x7f) + 80;
- dostm.tm_isdst = -1;
+ tm.tm_sec = subbits(t, 0, 5) * 2;
+ tm.tm_min = subbits(t, 5, 6);
+ tm.tm_hour = subbits(t, 11, 5);
+ tm.tm_mday = subbits(t, 16, 5);
+ tm.tm_mon = subbits(t, 21, 4) - 1;
+ tm.tm_year = subbits(t, 25, 7) + 80;
+ tm.tm_isdst = -1;
#if HAVE_MKTIME
- return mktime(&dostm);
+ return mktime(&tm);
#else
- return timelocal(&dostm);
+ return timelocal(&tm);
#endif
}
if (generic_format)
filename_case = TO_UPPER;
- if (hdr->header_level == HEADER_LEVEL0) {
+ if (hdr->header_level == 0) {
archive_delim = "\\";
}
/* Added N.Watazaki ..^ */
#define LZHUFF0_DICBIT 0 /* no compress */
-#define LZHUFF1_DICBIT 12 /* 2^12 = 4k sliding dictionary */
-#define LZHUFF2_DICBIT 13 /* 2^13 = 8k sliding dictionary */
-#define LZHUFF3_DICBIT 13 /* 2^13 = 8k sliding dictionary */
-#define LZHUFF4_DICBIT 12 /* 2^12 = 4k sliding dictionary */
-#define LZHUFF5_DICBIT 13 /* 2^13 = 8k sliding dictionary */
-#define LZHUFF6_DICBIT 15 /* 2^15 = 32k sliding dictionary */
-#define LZHUFF7_DICBIT 16 /* 2^16 = 64k sliding dictionary */
-#define LARC_DICBIT 11 /* 2^11 = 2k sliding dictionary */
-#define LARC5_DICBIT 12 /* 2^12 = 4k sliding dictionary */
+#define LZHUFF1_DICBIT 12 /* 2^12 = 4KB sliding dictionary */
+#define LZHUFF2_DICBIT 13 /* 2^13 = 8KB sliding dictionary */
+#define LZHUFF3_DICBIT 13 /* 2^13 = 8KB sliding dictionary */
+#define LZHUFF4_DICBIT 12 /* 2^12 = 4KB sliding dictionary */
+#define LZHUFF5_DICBIT 13 /* 2^13 = 8KB sliding dictionary */
+#define LZHUFF6_DICBIT 15 /* 2^15 = 32KB sliding dictionary */
+#define LZHUFF7_DICBIT 16 /* 2^16 = 64KB sliding dictionary */
+#define LARC_DICBIT 11 /* 2^11 = 2KB sliding dictionary */
+#define LARC5_DICBIT 12 /* 2^12 = 4KB sliding dictionary */
#define LARC4_DICBIT 0 /* no compress */
#ifdef SUPPORT_LH7
#define GENERIC_ATTRIBUTE 0x20
#define GENERIC_DIRECTORY_ATTRIBUTE 0x10
-#define HEADER_LEVEL0 0x00
-#define HEADER_LEVEL1 0x01
-#define HEADER_LEVEL2 0x02
#define CURRENT_UNIX_MINOR_VERSION 0x00
/* bitio.c */
#define peekbits(n) (bitbuf >> (sizeof(bitbuf)*8 - (n)))
-/* from crcio.c */
+/* crcio.c */
#define CRCPOLY 0xA001 /* CRC-16 (x^16+x^15+x^2+1) */
#define INITIALIZE_CRC(crc) ((crc) = 0)
#define UPDATE_CRC(crc, c) \
*/
/* slide.c */
-#define MATCHBIT 8 /* bits for MAXMATCH - THRESHOLD */
#define MAXMATCH 256 /* formerly F (not more than UCHAR_MAX + 1) */
#define THRESHOLD 3 /* choose optimal value */
compress_method = DEFAULT_LZHUFF_METHOD; /* defined in config.h */
- header_level = HEADER_LEVEL2;
+ header_level = 2; /* level 2 */
quiet_mode = 0;
#ifdef EUC
}
break;
case '0':
- header_level = HEADER_LEVEL0;
+ header_level = 0;
break;
case '1':
- header_level = HEADER_LEVEL1;
+ header_level = 1;
break;
case '2':
- header_level = HEADER_LEVEL2;
+ header_level = 2;
break;
default:
error("Unknown option '%c'.", p[-1]);