]> Chaos Git - console/RCOMage.git/commitdiff
Switch to using C code and make the 7z deflate accessor into a C function
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Sun, 9 Jan 2011 11:35:11 +0000 (06:35 -0500)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Sun, 9 Jan 2011 11:37:55 +0000 (06:37 -0500)
7z/7z.h
7z/7zdeflate.cc
7z/Makefile
general.c

diff --git a/7z/7z.h b/7z/7z.h
index 4669615c3000f0270d3fb17c05cf5ed46d4ddc61..69290329df4d236a0ed7b7c53546ba4765d7fa0b 100644 (file)
--- a/7z/7z.h
+++ b/7z/7z.h
@@ -1,15 +1,16 @@
 #ifndef __7Z_H
 #define __7Z_H
 
-/* #ifndef __cplusplus
-extern "C++" {
-#endif */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int compress_deflate_7z(const unsigned char* in_data, unsigned in_size, unsigned char* out_data, unsigned *out_size, unsigned num_passes, unsigned num_fast_bytes);
 
-bool compress_deflate_7z(const unsigned char* in_data, unsigned in_size, unsigned char* out_data, unsigned& out_size, unsigned num_passes, unsigned num_fast_bytes) throw ();
 
-/* #ifndef __cplusplus
+#ifdef __cplusplus
 }
-#endif */
+#endif
 
 #endif
 
index 6572000f6604aa673727f1858d3c6a599b66b0f9..7a33b130237c88b2232d356a326f4ecfdc678c9f 100644 (file)
@@ -2,9 +2,9 @@
 
 #include "DeflateEncoder.h"
 
-bool compress_deflate_7z(const unsigned char* in_data, unsigned in_size, unsigned char* out_data, unsigned& out_size, unsigned num_passes, unsigned num_fast_bytes) throw ()
+extern "C" int compress_deflate_7z(const unsigned char* in_data, unsigned in_size,
+                                   unsigned char* out_data, unsigned *out_size, unsigned num_passes, unsigned num_fast_bytes)
 {
-       try {
                NDeflate::NEncoder::CCoder cc;
 
                if (cc.SetEncoderNumPasses(num_passes) != S_OK)
@@ -14,20 +14,17 @@ bool compress_deflate_7z(const unsigned char* in_data, unsigned in_size, unsigne
                        return false;
 
                ISequentialInStream in(reinterpret_cast<const char*>(in_data), in_size);
-               ISequentialOutStream out(reinterpret_cast<char*>(out_data), out_size);
+               ISequentialOutStream out(reinterpret_cast<char*>(out_data), *out_size);
 
                UINT64 in_size_l = in_size;
 
                if (cc.Code(&in, &out, &in_size_l) != S_OK)
                        return false;
 
-               out_size = out.size_get();
+               *out_size = out.size_get();
 
                if (out.overflow_get())
                        return false;
 
                return true;
-       } catch (...) {
-               return false;
-       }
 }
index 946a3ccff26df038764887b86e44277ed1680bba..f2d4a9c7d09de0b5bffd51015713e533d8e1b49d 100644 (file)
@@ -1,8 +1,8 @@
 
-CC = gcc
+CC = g++
 SRC = 7zdeflate.cc CRC.cc DeflateEncoder.cc HuffmanEncoder.cc IInOutStreams.cc LSBFEncoder.cc OutByte.cc WindowIn.cc
 OBJ = $(SRC:.cc=.o)
 
 all: $(OBJ)
 %.o:%.cc
-       $(CC) -O3 -D__GNU_C__ -c $<
+       $(CC) -O3 -c $<
index 767202f865371f94e8a7c80b19472352e3715c79..1d7c03dc10390d8d2223cf7506bad59523394146 100644 (file)
--- a/general.c
+++ b/general.c
@@ -39,7 +39,7 @@ uint zlib_compress(void* src, uint srcLen, void* dest, uint destLen, int level,
                                break;\r
                }\r
                // limits: passes [1-255], fastbytes [3-257(kMatchMaxLen)]\r
-               if(!compress_deflate_7z((unsigned char*)src, srcLen, destPtr, outSize, passes, fastbytes))\r
+               if(!compress_deflate_7z((unsigned char*)src, srcLen, destPtr, &outSize, passes, fastbytes))\r
                        return 0;\r
                \r
                if(outSize+6 > destLen) return 0;\r