summaryrefslogtreecommitdiffstats
path: root/app-arch/unzip/files/unzip-ds-lazyrcc.patch
diff options
context:
space:
mode:
Diffstat (limited to 'app-arch/unzip/files/unzip-ds-lazyrcc.patch')
-rw-r--r--app-arch/unzip/files/unzip-ds-lazyrcc.patch146
1 files changed, 146 insertions, 0 deletions
diff --git a/app-arch/unzip/files/unzip-ds-lazyrcc.patch b/app-arch/unzip/files/unzip-ds-lazyrcc.patch
new file mode 100644
index 0000000..e2fbfa7
--- /dev/null
+++ b/app-arch/unzip/files/unzip-ds-lazyrcc.patch
@@ -0,0 +1,146 @@
+diff -dPNur unzip-5.52/dsrecode.h unzip-5.52-new/dsrecode.h
+--- unzip-5.52/dsrecode.h 1970-01-01 01:00:00.000000000 +0100
++++ unzip-5.52-new/dsrecode.h 2007-04-04 21:20:31.000000000 +0200
+@@ -0,0 +1,115 @@
++#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;
++
++#ifdef RCC_LAZY
++#include <dlfcn.h>
++# define RCC_LIBRARY "librcc.so.0"
++int (*rccInit2)();
++int (*rccFree2)();
++int (*rccInitDefaultContext2)(const char *locale_variable, unsigned int max_languages, unsigned int max_classes, rcc_class_ptr defclasses, rcc_init_flags flags);
++int (*rccInitDb42)(rcc_context ctx, const char *name, rcc_db4_flags flags);
++char* (*rccSizedRecode2)(rcc_context ctx, rcc_class_id from, rcc_class_id to, const char *buf, size_t len, size_t *rlen);
++
++static char *rccRecode2(rcc_context ctx, rcc_class_id from, rcc_class_id to, const char *buf) {
++ rccSizedRecode2(ctx, from, to, buf, 0, NULL);
++}
++
++void *rcc_handle;
++#else /* RCC_LAZY */
++#define rccInit2 rccInit
++#define rccFree2 rccFree
++#define rccInitDefaultContext2 rccInitDefaultContext
++#define rccInitDb42 rccInitDb4
++#define rccRecode2 rccRecode
++
++#endif /* RCC_LAZY */
++
++static void rccUnzipFree() {
++ if (initialized > 0) {
++ rccFree2();
++#ifdef RCC_LAZY
++ dlclose(rcc_handle);
++#endif /* RCC_LAZY */
++ initialized = 0;
++ }
++}
++
++
++static int rccUnzipInit() {
++ if (initialized) return 0;
++
++#ifdef RCC_LAZY
++ rcc_handle = dlopen("/usr/lib/" RCC_LIBRARY, RTLD_NOW);
++ if (!rcc_handle) rcc_handle = dlopen("/usr/local/lib/" RCC_LIBRARY, RTLD_NOW);
++ if (!rcc_handle) {
++ initialized = -1;
++ return 1;
++ }
++
++ rccInit2 = dlsym(rcc_handle, "rccInit");
++ rccFree2 = dlsym(rcc_handle, "rccFree");
++ rccInitDefaultContext2 = dlsym(rcc_handle, "rccInitDefaultContext");
++ rccInitDb42 = dlsym(rcc_handle, "rccInitDb4");
++ rccSizedRecode2 = dlsym(rcc_handle, "rccSizedRecode");
++
++ if ((!rccInit2)||(!rccFree2)||(!rccInitDefaultContext2)||(!rccInitDb42)||(!rccSizedRecode2)) {
++ dlclose(rcc_handle);
++ initialized = -1;
++ return 1;
++ }
++#endif /* RCC_LAZY */
++
++ rccInit2();
++ rccInitDefaultContext2(NULL, 0, 0, classes, 0);
++ rccInitDb42(NULL, NULL, 0);
++ atexit(rccUnzipFree);
++ initialized = 1;
++ return 0;
++}
++
++
++
++void _DS_OEM_INTERN(char *string) {
++ char *str;
++ rccUnzipInit();
++ if (initialized>0) {
++ str = rccRecode2(NULL, OEM_CLASS, OUT_CLASS, string);
++ if (str) {
++ strncpy(string,str,FILNAMSIZ);
++ free(str);
++ }
++ }
++}
++
++void _DS_ISO_INTERN(char *string) {
++ char *str;
++ rccUnzipInit();
++ if (initialized>0) {
++ str = rccRecode2(NULL, ISO_CLASS, OUT_CLASS, string);
++ if (str) {
++ strncpy(string,str,FILNAMSIZ);
++ free(str);
++ }
++ }
++}
+diff -dPNur unzip-5.52/fileio.c unzip-5.52-new/fileio.c
+--- unzip-5.52/fileio.c 2005-02-27 03:10:12.000000000 +0100
++++ unzip-5.52-new/fileio.c 2007-04-04 21:16:58.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.52/unzpriv.h unzip-5.52-new/unzpriv.h
+--- unzip-5.52/unzpriv.h 2005-02-04 00:26:42.000000000 +0100
++++ unzip-5.52-new/unzpriv.h 2007-04-04 21:16:58.000000000 +0200
+@@ -2564,9 +2564,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
+