OSDN Git Service

support PMA file decoding
[lha/lha.git] / src / lharc.c
index 1124026..dc90c66 100644 (file)
@@ -106,6 +106,9 @@ init_variable()     /* Added N.Watazaki */
 
     extract_broken_archive = FALSE;
     decode_macbinary_contents = FALSE;
+    sort_contents = TRUE;
+    recursive_archiving = TRUE;
+    dump_lzss = FALSE;
 }
 
 /* ------------------------------------------------------------------------ */
@@ -154,6 +157,7 @@ LHx(arc) for OSK   V 2.01  Modified     1990  Momozou\n\
 LHa      for UNIX  V 1.00  Copyright(C) 1992  Masaru Oki\n\
 LHa      for UNIX  V 1.14  Modified     1995  Nobutaka Watazaki\n\
 LHa      for UNIX  V 1.14i Modified     2000  Tsugio Okamoto\n\
+LHA-PMA  for UNIX  V 2     PMA added    2000  Maarten ter Huurne\n\
                    Autoconfiscated 2001-2008  Koji Arai\n\
 ");
 
@@ -214,6 +218,7 @@ parse_suboption(int argc, char **argv)
         ARCHIVE_KANJI_CODE_OPTION,
         TRADITIONAL_BEHAVIOR,
         IGNORE_MAC_FILES,
+        DEBUG_OPTION,
     };
 
     struct option long_options[] = {
@@ -227,6 +232,7 @@ parse_suboption(int argc, char **argv)
         {"convert-filename-case", no_argument, &convertcase, TRUE},
         {"traditional", no_argument, 0, TRADITIONAL_BEHAVIOR},
         {"ignore-mac-files", no_argument, 0, IGNORE_MAC_FILES},
+        {"debug", required_argument, 0, DEBUG_OPTION},
         {0, 0, 0, 0}
     };
     int i;
@@ -444,6 +450,29 @@ parse_suboption(int argc, char **argv)
             exclude_files[i+3] = 0;
             break;
 
+        case DEBUG_OPTION:
+            if (!optarg) {
+                error("debugging item is not specified for --%s",
+                      long_options[option_index].name);
+                return -1;
+            }
+            if (strcmp(optarg, "nosort") == 0) {
+                sort_contents = FALSE;
+            }
+            else if (strcmp(optarg, "norecursion") == 0) {
+                recursive_archiving = FALSE;
+            }
+            else if (strcmp(optarg, "dumplzss") == 0) {
+                dump_lzss = TRUE;
+                quiet = TRUE;
+            }
+            else {
+                error("unknown debugging item \"%s\" for --%s",
+                      optarg, long_options[option_index].name);
+                return -1;
+            }
+            break;
+
         default:
             error("unknown option `-%c'.", c);
             return -1;
@@ -845,7 +874,7 @@ sort_by_ascii(a, b)
 static void
 sort_files()
 {
-    if (cmd_filec > 1)
+    if (cmd_filec > 1 && sort_contents)
         qsort(cmd_filev, cmd_filec, sizeof(char *), sort_by_ascii);
 }
 
@@ -1139,7 +1168,7 @@ find_files(name, v_filec, v_filev)
     }
     closedir(dirp);
     finish_sp(&sp, v_filec, v_filev);
-    if (*v_filec > 1)
+    if (*v_filec > 1 && sort_contents)
         qsort(*v_filev, *v_filec, sizeof(char *), sort_by_ascii);
     cleaning_files(v_filec, v_filev);