/* ------------------------------------------------------------------------ */
#include "lha.h"
-#ifdef __APPLE__
-static int ConvertEncodingToUTF8(const char* inCStr, char* outUTF8Buffer, int outUTF8BufferLength, unsigned long scriptEncoding, unsigned long flags);
-static int ConvertUTF8ToEncoding(const char* inUTF8Buf, int inUTF8BufLength, char* outCStrBuffer, int outCStrBufferLength, unsigned long scriptEncoding, unsigned long flags);
-#endif /* __APPLE__ */
-
#if !STRCHR_8BIT_CLEAN
/* should use 8 bit clean version */
#undef strchr
put_byte(v >> 24);
}
+#if 0 /* no use */
/* ------------------------------------------------------------------------ */
static void
msdos_to_unix_filename(name, len)
name[i] = toupper(name[i]);
}
}
+#endif /* 0 */
/* added by Koji Arai */
static void
}
#endif
#endif /* defined(HAVE_FTIME) || defined(HAVE_GETTIMEOFDAY) ||
- * defined(HAVE_TZSET) */
+ * defined(HAVE_TZSET) */
/* ------------------------------------------------------------------------ */
#ifdef NOT_USED
"\xff\\/", "\xff\xff\xff", NONE);
if (hdr->header_level != HEADER_LEVEL2) {
- if (p = (char *) strrchr(lzname, LHA_PATHSEP))
+ if (p = strrchr(lzname, LHA_PATHSEP))
name_length = strlen(++p);
else
name_length = strlen(lzname);
put_byte(hdr->user[i]);
}
- if (p = (char *) strrchr(lzname, LHA_PATHSEP)) {
+ if (p = strrchr(lzname, LHA_PATHSEP)) {
int i;
name_length = p - lzname + 1;
data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size);
} else { /* header level 2 */
int i;
- if (p = (char *) strrchr(lzname, LHA_PATHSEP))
+ if (p = strrchr(lzname, LHA_PATHSEP))
name_length = strlen(++p);
else {
p = lzname;
#include <signal.h>
#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if STDC_HEADERS
# include <stdarg.h>
# define va_init(a,b) va_start(a,b)
#else
typedef int gid_t;
#endif
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#if HAVE_UTIME_H
+#include <utime.h>
+#endif
+
+#ifndef NODIRECTORY
+#if HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# if HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+# include <ndir.h>
+# endif
+# ifdef NONSYSTEM_DIR_LIBRARY /* no use ?? */
+# include "lhdir.h"
+# endif
+#endif
+#endif /* NODIRECTORY */
+
+#ifdef __APPLE__ /* On MacOS X, use CoreFoundation for utf8 conversion */
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFStringEncodingExt.h>
+#endif /* __APPLE__ */
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif /* SEEK_SET */
+
+
#include "lha_macro.h"
struct encode_option {
/* ------------------------------------------------------------------------ */
/* LHa File Type Definition */
/* ------------------------------------------------------------------------ */
+typedef int boolean; /* TRUE or FALSE */
+
struct string_pool {
int used;
int size;
EXTERN char temporary_name[FILENAME_LENGTH];
EXTERN char backup_archive_name[FILENAME_LENGTH];
-extern char *extract_directory;
+EXTERN char *extract_directory;
EXTERN char *reading_filename, *writting_filename;
-/* 1996.8.13 t.okamoto */
-#if 0
-EXTERN boolean remove_temporary_at_error;
-EXTERN boolean recover_archive_when_interrupt;
-EXTERN boolean remove_extracting_file_when_interrupt;
-#endif
-
EXTERN int archive_file_mode;
EXTERN int archive_file_gid;
EXTERN struct interfacing interface;
-EXTERN node *next;
/* EXTERN unsigned short crc; */ /* 1996.8.13 t.okamoto */
EXTERN int noconvertcase; /* 2000.10.6 */
/* macro VERSION and PLATFORM are defined in config.h by configure script */
#define LHA_VERSION "LHa for UNIX version " VERSION " (" PLATFORM ")"
-#ifdef __APPLE__
-#include <CoreFoundation/CFString.h>
-#include <CoreFoundation/CFStringEncodingExt.h>
-#endif /* __APPLE__ */
-
-/* Most of System V, define TM_IN_SYS_TIME */
-#if TM_IN_SYS_TIME
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif /* TM_IN_SYS_TIME */
-
-/* ------------------------------------------------------------------------ */
-/* Directory Access Stuff */
-/* ------------------------------------------------------------------------ */
-#ifndef NODIRECTORY
-#if HAVE_DIRENT_H
-# include <dirent.h>
-# define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
-# if HAVE_SYS_NDIR_H
-# include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-# include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-# include <ndir.h>
-# endif
-# ifdef NONSYSTEM_DIR_LIBRARY /* no use ?? */
-# include "lhdir.h"
-# endif
-#endif
-
-#define DIRENTRY struct dirent
-
-#endif /* NODIRECTORY */
-
-/* ------------------------------------------------------------------------ */
-/* Other Define */
-/* ------------------------------------------------------------------------ */
-/* Not support 'void' */
-#ifdef NOVOID
-#define void
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
-#endif /* SEEK_SET
-
-
-/* non-integral functions */
-extern struct tm *localtime();
-extern char *getenv();
-
-extern char *xmalloc();
-extern char *xrealloc();
-extern char *xstrdup();
-
-/* external variables */
-extern int errno;
-
#define FALSE 0
#define TRUE 1
-typedef int boolean;
/* used by qsort() for alphabetic-sort */
#define STRING_COMPARE(a,b) strcmp((a),(b))
#define X0201_KANA_P(c)\
(0xa0 < (unsigned char)(c) && (unsigned char)(c) < 0xe0)
+/* for filename conversion */
#define NONE 0
#define CODE_EUC 1
#define CODE_SJIS 2
#define MAX_INDICATOR_COUNT 64
-typedef short node;
-
/* ------------------------------------------------------------------------ */
/* Slide relation */
/* ------------------------------------------------------------------------ */
{
long header_pos, next_pos, org_pos, data_pos;
long v_original_size, v_packed_size;
- int mode;
reading_filename = hdr->name;
writting_filename = temporary_name;
static void sort_files();
static void print_version();
+/* ------------------------------------------------------------------------ */
static void
init_variable() /* Added N.Watazaki */
{
exit(1);
}
+/* ------------------------------------------------------------------------ */
int
main(argc, argv)
int argc;
return 0;
}
+
+/* ------------------------------------------------------------------------ */
+/* */
+/* ------------------------------------------------------------------------ */
+
+/* ------------------------------------------------------------------------ */
static void
print_version()
{
errno = errno_sv;
}
+/* ------------------------------------------------------------------------ */
void
#if STDC_HEADERS
warning(char *fmt, ...)
errno = errno_sv;
}
+/* ------------------------------------------------------------------------ */
void
#if STDC_HEADERS
error(char *fmt, ...)
exit(1);
}
+/* ------------------------------------------------------------------------ */
void
interrupt(signo)
int signo;
kill(getpid(), signo);
}
+/* ------------------------------------------------------------------------ */
+/* */
+/* ------------------------------------------------------------------------ */
static int
sort_by_ascii(a, b)
char **a, **b;
}
}
+/* ------------------------------------------------------------------------ */
static void
sort_files()
{
qsort(cmd_filev, cmd_filec, sizeof(char *), sort_by_ascii);
}
+/* ------------------------------------------------------------------------ */
void *
xmalloc(size)
int size;
return p;
}
+/* ------------------------------------------------------------------------ */
void *
xrealloc(old, size)
void *old;
^ malloc base returned
*/
+/* ------------------------------------------------------------------------ */
void
init_sp(sp)
struct string_pool *sp;
sp->buffer = (char *) xmalloc(sp->size * sizeof(char));
}
+/* ------------------------------------------------------------------------ */
void
add_sp(sp, name, len)
struct string_pool *sp;
sp->n++;
}
+/* ------------------------------------------------------------------------ */
void
finish_sp(sp, v_count, v_vector)
register struct string_pool *sp;
}
}
+/* ------------------------------------------------------------------------ */
void
free_sp(vector)
char **vector;
return (*n == '/' || (n != name && path[-1] == '/' && n[-1] == '/'));
}
+/* ------------------------------------------------------------------------ */
void
cleaning_files(v_filec, v_filev)
int *v_filec;
free(flags);
}
+/* ------------------------------------------------------------------------ */
#ifdef NODIRECTORY
/* please need your imprementation */
boolean
return FALSE; /* DUMMY */
}
+/* ------------------------------------------------------------------------ */
void
free_files(filec, filev)
int filec;
{
/* do nothing */
}
+/* ------------------------------------------------------------------------ */
#else
boolean
find_files(name, v_filec, v_filev)
return TRUE;
}
+/* ------------------------------------------------------------------------ */
void
free_files(filec, filev)
int filec;
free_sp(filev);
}
#endif
-
+/* ------------------------------------------------------------------------ */
+/* */
+/* ------------------------------------------------------------------------ */
/* Build temporary file name and store to TEMPORARY_NAME */
int
build_temporary_name()
#endif
}
+/* ------------------------------------------------------------------------ */
static void
modify_filename_extention(buffer, ext)
char *buffer;
strcpy(p, ext);
}
+/* ------------------------------------------------------------------------ */
/* build backup file name */
void
build_backup_name(buffer, original)
modify_filename_extention(buffer, BACKUPNAME_EXTENTION); /* ".bak" */
}
+/* ------------------------------------------------------------------------ */
void
build_standard_archive_name(buffer, orginal)
char *buffer;
modify_filename_extention(buffer, ARCHIVENAME_EXTENTION); /* ".lzh" */
}
+/* ------------------------------------------------------------------------ */
+/* */
+/* ------------------------------------------------------------------------ */
boolean
need_file(name)
char *name;
return fp;
}
+/* ------------------------------------------------------------------------ */
+/* */
+/* ------------------------------------------------------------------------ */
static boolean
open_old_archive_1(name, v_fp)
char *name;
return FALSE;
}
+/* ------------------------------------------------------------------------ */
FILE *
open_old_archive()
{
return NULL;
}
+/* ------------------------------------------------------------------------ */
int
inquire(msg, name, selective)
char *msg, *name, *selective;
/* NOTREACHED */
}
+/* ------------------------------------------------------------------------ */
void
write_archive_tail(nafp)
FILE *nafp;
putc(0x00, nafp);
}
+/* ------------------------------------------------------------------------ */
void
copy_old_one(oafp, nafp, hdr)
FILE *oafp, *nafp;
void warning P_((char *fmt, ...));
void error P_((char *fmt, ...));
void fatal_error P_((char *fmt, ...));
-char *xmalloc P_((int size));
-char *xrealloc P_((char *old, int size));
+void *xmalloc P_((int size));
+void *xrealloc P_((void *old, int size));
char *xstrdup P_((char *str));
void init_sp P_((struct string_pool *sp));
void add_sp P_((struct string_pool *sp, char *name, int len));
static void update()
{
unsigned int i, j;
- unsigned int k;
long n;
#if 0