OSDN Git Service

* src/header.c, src/lha.h, src/lha_macro.h, src/lhadd.c: refined.
authorarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Sun, 7 Jul 2002 08:21:12 +0000 (08:21 +0000)
committerarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Sun, 7 Jul 2002 08:21:12 +0000 (08:21 +0000)
* src/lharc.c, src/prototypes.h, src/slide.c: refined.

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/lha/lha/trunk@314 6a8cc165-1e22-0410-a132-eb4e3f353aba

src/header.c
src/lha.h
src/lha_macro.h
src/lhadd.c
src/lharc.c
src/prototypes.h
src/slide.c

index 3c7314b..f392bfe 100644 (file)
 /* ------------------------------------------------------------------------ */
 #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
@@ -99,6 +94,7 @@ put_longword(v)
        put_byte(v >> 24);
 }
 
+#if 0   /* no use */
 /* ------------------------------------------------------------------------ */
 static void
 msdos_to_unix_filename(name, len)
@@ -201,6 +197,7 @@ unix_to_generic_filename(name, len)
                        name[i] = toupper(name[i]);
        }
 }
+#endif /* 0 */
 
 /* added by Koji Arai */
 static void
@@ -431,7 +428,7 @@ gettz()
 }
 #endif
 #endif                         /* defined(HAVE_FTIME) || defined(HAVE_GETTIMEOFDAY) ||
-                                * defined(HAVE_TZSET) */
+                     * defined(HAVE_TZSET) */
 
 /* ------------------------------------------------------------------------ */
 #ifdef NOT_USED
@@ -1000,7 +997,7 @@ write_header(nafp, hdr)
                      "\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);
@@ -1072,7 +1069,7 @@ write_header(nafp, hdr)
                     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;
@@ -1098,7 +1095,7 @@ write_header(nafp, hdr)
                        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;
index 82b6e40..860e9a3 100644 (file)
--- a/src/lha.h
+++ b/src/lha.h
 #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
@@ -45,6 +58,55 @@ typedef int uid_t;
 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 {
@@ -72,6 +134,8 @@ struct decode_option {
 /* ------------------------------------------------------------------------ */
 /*     LHa File Type Definition                                                                                                */
 /* ------------------------------------------------------------------------ */
+typedef int boolean;            /* TRUE or FALSE */
+
 struct string_pool {
        int             used;
        int             size;
@@ -161,21 +225,13 @@ EXTERN char               *archive_name;
 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 */
index f3b8597..223b022 100644 (file)
 /* 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))
@@ -115,6 +48,7 @@ typedef int                          boolean;
 #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
@@ -261,8 +195,6 @@ typedef int                         boolean;
 
 #define MAX_INDICATOR_COUNT            64
 
-typedef short                                  node;
-
 /* ------------------------------------------------------------------------ */
 /*     Slide relation                                                                                                                  */
 /* ------------------------------------------------------------------------ */
index d478fb2..1ec0fc1 100644 (file)
@@ -21,7 +21,6 @@ add_one(fp, nafp, hdr)
 {
        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;
index 95d6674..5d78a17 100644 (file)
@@ -51,6 +51,7 @@ static int      cmd = CMD_UNKNOWN;
 static void     sort_files();
 static void            print_version();
 
+/* ------------------------------------------------------------------------ */
 static void
 init_variable()                /* Added N.Watazaki */
 {
@@ -152,6 +153,7 @@ commands:                           options:\n\
        exit(1);
 }
 
+/* ------------------------------------------------------------------------ */
 int
 main(argc, argv)
        int             argc;
@@ -428,6 +430,12 @@ work:
        return 0;
 }
 
+
+/* ------------------------------------------------------------------------ */
+/* */
+/* ------------------------------------------------------------------------ */
+
+/* ------------------------------------------------------------------------ */
 static void
 print_version()
 {
@@ -457,6 +465,7 @@ message(fmt, va_alist)
     errno =  errno_sv;
 }
 
+/* ------------------------------------------------------------------------ */
 void
 #if STDC_HEADERS
 warning(char *fmt, ...)
@@ -480,6 +489,7 @@ warning(fmt, va_alist)
     errno =  errno_sv;
 }
 
+/* ------------------------------------------------------------------------ */
 void
 #if STDC_HEADERS
 error(char *fmt, ...)
@@ -535,6 +545,7 @@ fatal_error(fmt, va_alist)
     exit(1);
 }
 
+/* ------------------------------------------------------------------------ */
 void
 interrupt(signo)
        int             signo;
@@ -557,6 +568,9 @@ interrupt(signo)
        kill(getpid(), signo);
 }
 
+/* ------------------------------------------------------------------------ */
+/*                                                                                                                                                     */
+/* ------------------------------------------------------------------------ */
 static int
 sort_by_ascii(a, b)
        char          **a, **b;
@@ -586,6 +600,7 @@ sort_by_ascii(a, b)
        }
 }
 
+/* ------------------------------------------------------------------------ */
 static void
 sort_files()
 {
@@ -593,6 +608,7 @@ sort_files()
                qsort(cmd_filev, cmd_filec, sizeof(char *), sort_by_ascii);
 }
 
+/* ------------------------------------------------------------------------ */
 void *
 xmalloc(size)
        int             size;
@@ -603,6 +619,7 @@ xmalloc(size)
        return p;
 }
 
+/* ------------------------------------------------------------------------ */
 void *
 xrealloc(old, size)
        void *old;
@@ -642,6 +659,7 @@ xstrdup(str)
        ^ malloc base      returned
 */
 
+/* ------------------------------------------------------------------------ */
 void
 init_sp(sp)
        struct string_pool *sp;
@@ -652,6 +670,7 @@ init_sp(sp)
        sp->buffer = (char *) xmalloc(sp->size * sizeof(char));
 }
 
+/* ------------------------------------------------------------------------ */
 void
 add_sp(sp, name, len)
        struct string_pool *sp;
@@ -667,6 +686,7 @@ add_sp(sp, name, len)
        sp->n++;
 }
 
+/* ------------------------------------------------------------------------ */
 void
 finish_sp(sp, v_count, v_vector)
        register struct string_pool *sp;
@@ -689,6 +709,7 @@ finish_sp(sp, v_count, v_vector)
        }
 }
 
+/* ------------------------------------------------------------------------ */
 void
 free_sp(vector)
        char          **vector;
@@ -713,6 +734,7 @@ include_path_p(path, name)
        return (*n == '/' || (n != name && path[-1] == '/' && n[-1] == '/'));
 }
 
+/* ------------------------------------------------------------------------ */
 void
 cleaning_files(v_filec, v_filev)
        int            *v_filec;
@@ -797,6 +819,7 @@ cleaning_files(v_filec, v_filev)
        free(flags);
 }
 
+/* ------------------------------------------------------------------------ */
 #ifdef NODIRECTORY
 /* please need your imprementation */
 boolean
@@ -808,6 +831,7 @@ find_files(name, v_filec, v_filev)
        return FALSE;           /* DUMMY */
 }
 
+/* ------------------------------------------------------------------------ */
 void
 free_files(filec, filev)
        int             filec;
@@ -815,6 +839,7 @@ free_files(filec, filev)
 {
        /* do nothing */
 }
+/* ------------------------------------------------------------------------ */
 #else
 boolean
 find_files(name, v_filec, v_filev)
@@ -880,6 +905,7 @@ find_files(name, v_filec, v_filev)
        return TRUE;
 }
 
+/* ------------------------------------------------------------------------ */
 void
 free_files(filec, filev)
        int             filec;
@@ -888,7 +914,9 @@ free_files(filec, filev)
        free_sp(filev);
 }
 #endif
-
+/* ------------------------------------------------------------------------ */
+/*                                                                                                                                                     */
+/* ------------------------------------------------------------------------ */
 /* Build temporary file name and store to TEMPORARY_NAME */
 int
 build_temporary_name()
@@ -934,6 +962,7 @@ build_temporary_name()
 #endif
 }
 
+/* ------------------------------------------------------------------------ */
 static void
 modify_filename_extention(buffer, ext)
        char           *buffer;
@@ -954,6 +983,7 @@ modify_filename_extention(buffer, ext)
        strcpy(p, ext);
 }
 
+/* ------------------------------------------------------------------------ */
 /* build backup file name */
 void
 build_backup_name(buffer, original)
@@ -964,6 +994,7 @@ build_backup_name(buffer, original)
        modify_filename_extention(buffer, BACKUPNAME_EXTENTION);        /* ".bak" */
 }
 
+/* ------------------------------------------------------------------------ */
 void
 build_standard_archive_name(buffer, orginal)
        char           *buffer;
@@ -973,6 +1004,9 @@ build_standard_archive_name(buffer, orginal)
        modify_filename_extention(buffer, ARCHIVENAME_EXTENTION);       /* ".lzh" */
 }
 
+/* ------------------------------------------------------------------------ */
+/*                                                                                                                                                     */
+/* ------------------------------------------------------------------------ */
 boolean
 need_file(name)
        char           *name;
@@ -1002,6 +1036,9 @@ xfopen(name, mode)
        return fp;
 }
 
+/* ------------------------------------------------------------------------ */
+/*                                                                                                                                                     */
+/* ------------------------------------------------------------------------ */
 static          boolean
 open_old_archive_1(name, v_fp)
        char           *name;
@@ -1024,6 +1061,7 @@ open_old_archive_1(name, v_fp)
        return FALSE;
 }
 
+/* ------------------------------------------------------------------------ */
 FILE           *
 open_old_archive()
 {
@@ -1082,6 +1120,7 @@ open_old_archive()
        return NULL;
 }
 
+/* ------------------------------------------------------------------------ */
 int
 inquire(msg, name, selective)
        char           *msg, *name, *selective;
@@ -1102,6 +1141,7 @@ inquire(msg, name, selective)
        /* NOTREACHED */
 }
 
+/* ------------------------------------------------------------------------ */
 void
 write_archive_tail(nafp)
        FILE           *nafp;
@@ -1109,6 +1149,7 @@ write_archive_tail(nafp)
        putc(0x00, nafp);
 }
 
+/* ------------------------------------------------------------------------ */
 void
 copy_old_one(oafp, nafp, hdr)
        FILE           *oafp, *nafp;
index 703a2b3..6e7b0d1 100644 (file)
@@ -70,8 +70,8 @@ void message P_((char *fmt, ...));
 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));
index a718b30..14cff86 100644 (file)
@@ -168,7 +168,6 @@ static void init_slide()
 static void update()
 {
        unsigned int i, j;
-       unsigned int k;
        long n;
 
 #if 0