summaryrefslogtreecommitdiffstats
path: root/app-arch/unzip/files/unzip-ds-rcc.patch
blob: 6b70685b3c3a005a73e06191afc7b59ec04501a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
diff -dPNur unzip-5.51/dsrecode.h unzip-5.51-new/dsrecode.h
--- unzip-5.51/dsrecode.h	1970-01-01 01:00:00.000000000 +0100
+++ unzip-5.51-new/dsrecode.h	2005-07-19 05:03:50.000000000 +0200
@@ -0,0 +1,62 @@
+#include <librcc.h>
+
+static rcc_class_default_charset default_oem[] = {
+    { "ru", "IBM866" },
+    { NULL, NULL }
+};
+
+static rcc_class_default_charset default_iso[] = {
+    { "ru", "CP1251" },
+    { NULL, NULL }
+};
+
+#define OEM_CLASS 0
+#define ISO_CLASS 1
+#define OUT_CLASS 2
+static rcc_class classes[] = {
+    { "oem", RCC_CLASS_STANDARD, NULL, default_oem, "OEM_INTERN", 0 },
+    { "iso", RCC_CLASS_STANDARD, NULL, default_iso, "ISO_INTERN", 0 },
+    { "out", RCC_CLASS_STANDARD, "LC_CTYPE", NULL, "Output", 0 },
+    { NULL }
+};
+
+int initialized = 0;
+
+static void rccUnzipFree() {
+    if (initialized) {
+	rccFree();
+	initialized = 0;
+    }
+}
+
+static int rccUnzipInit() {
+    if (initialized) return 0;
+    rccInit();
+    rccInitDefaultContext(NULL, 0, 0, classes, 0);
+    rccInitDb4(NULL, NULL, 0);
+    atexit(rccUnzipFree);
+    initialized = 1;
+    return 0;
+}
+
+
+
+void _DS_OEM_INTERN(char *string) {
+    char *str;
+    rccUnzipInit();
+    str = rccRecode(NULL, OEM_CLASS, OUT_CLASS, string);
+    if (str) {
+	strncpy(string,str,FILNAMSIZ);
+	free(str);
+    }
+}
+
+void _DS_ISO_INTERN(char *string) {
+    char *str;
+    rccUnzipInit();
+    str = rccRecode(NULL, ISO_CLASS, OUT_CLASS, string);
+    if (str) {
+	strncpy(string,str,FILNAMSIZ);
+	free(str);
+    }
+}
diff -dPNur unzip-5.51/fileio.c unzip-5.51-new/fileio.c
--- unzip-5.51/fileio.c	2004-05-23 03:01:20.000000000 +0200
+++ unzip-5.51-new/fileio.c	2005-04-19 17:19:25.000000000 +0200
@@ -78,7 +78,7 @@
 #  endif
 #endif
 #include "ebcdic.h"   /* definition/initialization of ebcdic[] */
-
+#include "dsrecode.h"
 
 /*
    Note: Under Windows, the maximum size of the buffer that can be used
diff -dPNur unzip-5.51/unix/Makefile unzip-5.51-new/unix/Makefile
--- unzip-5.51/unix/Makefile	2004-03-01 18:37:24.000000000 +0100
+++ unzip-5.51-new/unix/Makefile	2005-07-19 04:03:11.000000000 +0200
@@ -43,7 +43,7 @@
 
 # UnZip flags
 CC = cc#	try using "gcc" target rather than changing this (CC and LD
-LD = $(CC)#	must match, else "unresolved symbol:  ___main" is possible)
+LD = $(CC) -lrcc#	must match, else "unresolved symbol:  ___main" is possible)
 AS = as
 LOC = $(LOCAL_UNZIP)
 AF = $(LOC)
diff -dPNur unzip-5.51/unzpriv.h unzip-5.51-new/unzpriv.h
--- unzip-5.51/unzpriv.h	2004-03-01 19:09:04.000000000 +0100
+++ unzip-5.51-new/unzpriv.h	2005-04-19 17:19:25.000000000 +0200
@@ -2521,9 +2521,9 @@
            ((hostver) == 25 || (hostver) == 26 || (hostver) == 40))) || \
         (hostnum) == FS_HPFS_ || \
         ((hostnum) == FS_NTFS_ && (hostver) == 50)) { \
-        _OEM_INTERN((string)); \
+        _DS_OEM_INTERN((string)); \
     } else { \
-        _ISO_INTERN((string)); \
+        _DS_ISO_INTERN((string)); \
     }
 #endif