diff -dPNur p7zip_9.13/C/rccrecode.c p7zip_9.13-rusxmms/C/rccrecode.c --- p7zip_9.13/C/rccrecode.c 1970-01-01 01:00:00.000000000 +0100 +++ p7zip_9.13-rusxmms/C/rccrecode.c 2010-07-31 20:32:27.000000000 +0200 @@ -0,0 +1,73 @@ +#include +#include + +static rcc_class_default_charset default_oem[] = { + { "ru", "IBM866" }, + { NULL, NULL } +}; + +static rcc_class_default_charset default_iso[] = { + { "ru", "CP1251" }, + { NULL, NULL } +}; + +#define ARC_CLASS 0 +#define OUT_CLASS 1 +#define ARCOUT_CLASS 0 +static rcc_class classes[] = { + { "oem", RCC_CLASS_STANDARD, NULL, default_oem, "OEM Encoding", 0 }, + { "out", RCC_CLASS_STANDARD, "LC_CTYPE", NULL, "Output", 0 }, + { NULL, RCC_CLASS_STANDARD, NULL, NULL, NULL, 0 } +}; + +static int initialized = 0; +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +void *rcc_init() { + rcc_context ctx; + + pthread_mutex_lock(&mutex); + if (!initialized) { + rccInit(); +// rccInitDefaultContext(NULL, 0, 0, classes, 0); +// rccInitDb4(NULL, NULL, 0); +// rccLoad(NULL, "zip"); + } + initialized++; + pthread_mutex_unlock(&mutex); + + ctx = rccCreateContext(NULL, 0, 0, classes, 0); + if (ctx) { + rccInitDb4(ctx, NULL, 0); + rccLoad(ctx, "zip"); + } + + return ctx; +} + + +void rcc_free(void *ctx) { + if (ctx) rccFreeContext((rcc_context)ctx); + + pthread_mutex_lock(&mutex); + if (initialized == 1) rccFree(); + initialized--; + pthread_mutex_unlock(&mutex); +} + + +char *rcc_read(void *ctx, const char *string, size_t size) { + if (!initialized) { + rcc_init(); + if (!initialized) return NULL; + } + return rccSizedRecode((rcc_context)ctx, ARC_CLASS, OUT_CLASS, string, size, NULL); +} + +char *rcc_write(void *ctx, const char *string, size_t size) { + if (!initialized) { + rcc_init(); + if (!initialized) return NULL; + } + return rccSizedRecode((rcc_context)ctx, OUT_CLASS, ARCOUT_CLASS, string, size, NULL); +} diff -dPNur p7zip_9.13/C/rccrecode.h p7zip_9.13-rusxmms/C/rccrecode.h --- p7zip_9.13/C/rccrecode.h 1970-01-01 01:00:00.000000000 +0100 +++ p7zip_9.13-rusxmms/C/rccrecode.h 2010-07-31 14:07:34.000000000 +0200 @@ -0,0 +1,17 @@ +#ifndef _RCC_RECODE_H +#define _RCC_RECODE_H + +# ifdef __cplusplus +extern "C" { +# endif + + void *rcc_init(); + void rcc_free(void *ctx); + char *rcc_read(void *ctx, const char *string, size_t size); + char *rcc_write(void *ctx, const char *string, size_t size); + +# ifdef __cplusplus +} +# endif + +#endif /* _RCC_RECODE_H */ diff -dPNur p7zip_9.13/CPP/7zip/Archive/Zip/ZipIn.cpp p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipIn.cpp --- p7zip_9.13/CPP/7zip/Archive/Zip/ZipIn.cpp 2010-04-25 17:14:42.000000000 +0200 +++ p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipIn.cpp 2010-07-31 20:33:42.000000000 +0200 @@ -9,6 +9,8 @@ #include "../../Common/LimitedStreams.h" #include "../../Common/StreamUtils.h" +#include "../../../../C/rccrecode.h" + #include "ZipIn.h" #define Get16(p) GetUi16(p) @@ -17,7 +19,17 @@ namespace NArchive { namespace NZip { - + +CInArchive::CInArchive() +{ + rccctx = rcc_init(); +} + +CInArchive::~CInArchive() +{ + rcc_free(rccctx); +} + HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit) { _inBufMode = false; @@ -200,12 +212,20 @@ void CInArchive::ReadFileName(UInt32 nameSize, AString &dest) { + char *rccrec; + if (nameSize == 0) dest.Empty(); char *p = dest.GetBuffer((int)nameSize); SafeReadBytes(p, nameSize); p[nameSize] = 0; dest.ReleaseBuffer(); + + rccrec = rcc_read(rccctx, (LPCSTR)dest, 0); + if (rccrec) { + dest = rccrec; + free(rccrec); + } } void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock, diff -dPNur p7zip_9.13/CPP/7zip/Archive/Zip/ZipIn.cpp.orig p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipIn.cpp.orig diff -dPNur p7zip_9.13/CPP/7zip/Archive/Zip/ZipIn.h p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipIn.h --- p7zip_9.13/CPP/7zip/Archive/Zip/ZipIn.h 2010-04-25 17:14:27.000000000 +0200 +++ p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipIn.h 2010-07-31 20:33:42.000000000 +0200 @@ -117,6 +117,10 @@ ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size); IInStream* CreateStream(); + void *rccctx; + CInArchive(); + ~CInArchive(); + bool IsOpen() const { return m_Stream != NULL; } }; diff -dPNur p7zip_9.13/CPP/7zip/Archive/Zip/ZipIn.h.orig p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipIn.h.orig diff -dPNur p7zip_9.13/CPP/7zip/Archive/Zip/ZipOut.cpp p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipOut.cpp --- p7zip_9.13/CPP/7zip/Archive/Zip/ZipOut.cpp 2010-04-25 17:14:42.000000000 +0200 +++ p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipOut.cpp 2010-07-31 20:33:42.000000000 +0200 @@ -6,9 +6,24 @@ #include "ZipOut.h" +#include "../../../../C/rccrecode.h" + namespace NArchive { namespace NZip { +COutArchive::COutArchive() { + rccctx = rcc_init(); +} + +COutArchive::~COutArchive() { + rcc_free(rccctx); +} + +void COutArchive::Recode(CItem &item) { + char *rccrec = rcc_write(rccctx, (const char *)item.Name, item.Name.Length()); + if (rccrec) item.Name = rccrec; +} + void COutArchive::Create(IOutStream *outStream) { if (!m_OutBuffer.Create(1 << 16)) diff -dPNur p7zip_9.13/CPP/7zip/Archive/Zip/ZipOut.cpp.orig p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipOut.cpp.orig diff -dPNur p7zip_9.13/CPP/7zip/Archive/Zip/ZipOut.h p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipOut.h --- p7zip_9.13/CPP/7zip/Archive/Zip/ZipOut.h 2010-04-25 17:14:27.000000000 +0200 +++ p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipOut.h 2010-07-31 20:33:42.000000000 +0200 @@ -49,6 +49,11 @@ void CreateStreamForCompressing(IOutStream **outStream); void CreateStreamForCopying(ISequentialOutStream **outStream); void SeekToPackedDataPosition(); + + void *rccctx; + COutArchive(); + ~COutArchive(); + void Recode(CItem &item); }; }} diff -dPNur p7zip_9.13/CPP/7zip/Archive/Zip/ZipUpdate.cpp p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipUpdate.cpp --- p7zip_9.13/CPP/7zip/Archive/Zip/ZipUpdate.cpp 2010-04-25 17:25:47.000000000 +0200 +++ p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipUpdate.cpp 2010-07-31 20:33:42.000000000 +0200 @@ -86,6 +86,7 @@ item.NtfsATime = ui.NtfsATime; item.NtfsCTime = ui.NtfsCTime; item.NtfsTimeIsDefined = ui.NtfsTimeIsDefined; + archive.Recode(item); } else isDir = item.IsDir(); @@ -358,9 +359,11 @@ item.NtfsCTime = ui.NtfsCTime; item.NtfsTimeIsDefined = ui.NtfsTimeIsDefined; + archive.Recode(item); + item.CentralExtra.RemoveUnknownSubBlocks(); item.LocalExtra.RemoveUnknownSubBlocks(); - + archive.PrepareWriteCompressedData2((UInt16)item.Name.Length(), item.UnPackSize, item.PackSize, item.LocalExtra.HasWzAesField()); item.LocalHeaderPosition = archive.GetCurrentPosition(); archive.SeekToPackedDataPosition(); diff -dPNur p7zip_9.13/CPP/7zip/Archive/Zip/ZipUpdate.cpp.orig p7zip_9.13-rusxmms/CPP/7zip/Archive/Zip/ZipUpdate.cpp.orig diff -dPNur p7zip_9.13/CPP/7zip/Bundles/Alone/makefile p7zip_9.13-rusxmms/CPP/7zip/Bundles/Alone/makefile --- p7zip_9.13/CPP/7zip/Bundles/Alone/makefile 2010-03-16 20:15:59.000000000 +0100 +++ p7zip_9.13-rusxmms/CPP/7zip/Bundles/Alone/makefile 2010-07-31 20:33:42.000000000 +0200 @@ -251,6 +251,7 @@ OBJS=\ +rccrecode.o \ myGetTickCount.o \ wine_date_and_time.o \ myAddExeFlag.o \ diff -dPNur p7zip_9.13/CPP/7zip/Bundles/Alone/makefile.list p7zip_9.13-rusxmms/CPP/7zip/Bundles/Alone/makefile.list --- p7zip_9.13/CPP/7zip/Bundles/Alone/makefile.list 2010-03-16 20:17:05.000000000 +0100 +++ p7zip_9.13-rusxmms/CPP/7zip/Bundles/Alone/makefile.list 2010-07-31 20:33:42.000000000 +0200 @@ -194,6 +194,7 @@ ../../Crypto/ZipStrong.cpp SRCS_C=\ + ../../../../C/rccrecode.c \ ../../../../C/Aes.c \ ../../../../C/7zStream.c \ ../../../../C/Alloc.c \ diff -dPNur p7zip_9.13/CPP/7zip/Bundles/Alone/makefile.list.orig p7zip_9.13-rusxmms/CPP/7zip/Bundles/Alone/makefile.list.orig diff -dPNur p7zip_9.13/CPP/7zip/Bundles/Alone/makefile.orig p7zip_9.13-rusxmms/CPP/7zip/Bundles/Alone/makefile.orig diff -dPNur p7zip_9.13/CPP/7zip/Bundles/Format7zFree/makefile p7zip_9.13-rusxmms/CPP/7zip/Bundles/Format7zFree/makefile --- p7zip_9.13/CPP/7zip/Bundles/Format7zFree/makefile 2010-03-16 20:49:21.000000000 +0100 +++ p7zip_9.13-rusxmms/CPP/7zip/Bundles/Format7zFree/makefile 2010-07-31 20:33:42.000000000 +0200 @@ -298,6 +298,7 @@ OBJS = \ + rccrecode.o \ wine_date_and_time.o \ myGetTickCount.o \ $(COMMON_OBJS) \ diff -dPNur p7zip_9.13/CPP/7zip/Bundles/Format7zFree/makefile.list p7zip_9.13-rusxmms/CPP/7zip/Bundles/Format7zFree/makefile.list --- p7zip_9.13/CPP/7zip/Bundles/Format7zFree/makefile.list 2010-03-16 20:50:11.000000000 +0100 +++ p7zip_9.13-rusxmms/CPP/7zip/Bundles/Format7zFree/makefile.list 2010-07-31 20:33:42.000000000 +0200 @@ -224,6 +224,7 @@ ../../Crypto/ZipStrong.cpp SRCS_C=\ + ../../../../C/rccrecode.c \ ../../../../C/7zBuf2.c \ ../../../../C/7zStream.c \ ../../../../C/Aes.c \ diff -dPNur p7zip_9.13/CPP/7zip/Bundles/Format7zFree/makefile.list.orig p7zip_9.13-rusxmms/CPP/7zip/Bundles/Format7zFree/makefile.list.orig diff -dPNur p7zip_9.13/CPP/7zip/Bundles/Format7zFree/makefile.orig p7zip_9.13-rusxmms/CPP/7zip/Bundles/Format7zFree/makefile.orig diff -dPNur p7zip_9.13/makefile.machine p7zip_9.13-rusxmms/makefile.machine --- p7zip_9.13/makefile.machine 2010-05-30 10:33:48.000000000 +0200 +++ p7zip_9.13-rusxmms/makefile.machine 2010-07-31 20:33:42.000000000 +0200 @@ -15,7 +15,7 @@ CC_SHARED=-fPIC LINK_SHARED=-fPIC -shared -LOCAL_LIBS=-lpthread +LOCAL_LIBS=-lpthread -lrcc LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl OBJ_CRC32=$(OBJ_CRC32_C) diff -dPNur p7zip_9.13/makefile.machine.orig p7zip_9.13-rusxmms/makefile.machine.orig diff -dPNur p7zip_9.13/makefile.rules p7zip_9.13-rusxmms/makefile.rules --- p7zip_9.13/makefile.rules 2010-03-16 20:18:44.000000000 +0100 +++ p7zip_9.13-rusxmms/makefile.rules 2010-07-31 20:33:42.000000000 +0200 @@ -655,3 +655,5 @@ LangUtils.o : ../../UI/FileManager/LangUtils.cpp $(CXX) $(CXXFLAGS) ../../UI/FileManager/LangUtils.cpp +rccrecode.o : ../../../../C/rccrecode.c + $(CC) $(CFLAGS) ../../../../C/rccrecode.c diff -dPNur p7zip_9.13/makefile.rules.orig p7zip_9.13-rusxmms/makefile.rules.orig diff -dPNur p7zip_9.13/p7zip_9.04-ds-rusxmms.patch p7zip_9.13-rusxmms/p7zip_9.04-ds-rusxmms.patch