#1
|
||||
|
||||
![]()
Hi, everyone
There is an add-on in FreeArc to compile cls libraries How do i add compression algorithm to the simple_codec.cpp file ? I am new to C/C++ programming. Anyone with knowledge of C, please help me out.. Code:
#include "cls.h" int ClsMain (int op, CLS_CALLBACK callback, void* instance) { switch(op) { case CLS_COMPRESS: case CLS_DECOMPRESS: { char param[100]; callback(instance, CLS_GET_PARAMSTR, param, 100); // Get method parameters as single string const int BUFSIZE = 4096; char buf[BUFSIZE]; for (int len; (len=callback(instance, CLS_PARTIAL_READ, buf, BUFSIZE)) != 0; ) { if (len<0) return len; // Return errcode on error int result = callback(instance, CLS_FULL_WRITE, buf, len); if (result != len) return result<0? result : CLS_ERROR_WRITE; } return CLS_OK; } default: return CLS_ERROR_NOT_IMPLEMENTED; } } |
Sponsored Links |
#2
|
||||
|
||||
InnoSetup is make in delphi, but when it comes to C++ as an extension (*.dll) the ideal is to use MSVC since C++ Builder itself uses this compiler as a template to make it compatible. Although initially many avoid using it due to the dependencies of "vcredist (2005..2017)".
But if you develop an executable application could use mingw without problem, since it would only need to instantiate the initialization of it through command lines.
__________________
"There are three things that sages fear... The tormented sea, a moonless night and the wrath of a gentleness man." - The fear of the Sages. Last edited by kassane; 15-07-2018 at 06:39. |
The Following User Says Thank You to kassane For This Useful Post: | ||
TheGeekyGamer (15-07-2018) |
#3
|
||||
|
||||
Alright. But how do i add compression command to the above given code. Can u give me an example ? eg lolz -dto0 - dtd1 -dtm1
|
The Following User Says Thank You to TheGeekyGamer For This Useful Post: | ||
kassane (15-07-2018) |
#4
|
||||
|
||||
Quote:
Yes!
__________________
"There are three things that sages fear... The tormented sea, a moonless night and the wrath of a gentleness man." - The fear of the Sages. |
#5
|
||||
|
||||
Alright. But how do i add compression command under CLS_COMPRESS section? Eg: lolz -dto0 -dtd1
|
#6
|
||||
|
||||
Do u mean like this ?
#include "cls.h" int ClsMain (int op, CLS_CALLBACK callback, void* instance) { switch(op) { case CLS_COMPRESS: { pzlib e -c200m -mc1023 } case CLS_DECOMPRESS: { char param[100]; callback(instance, CLS_GET_PARAMSTR, param, 100); // Get method parameters as single string const int BUFSIZE = 4096; char buf[BUFSIZE]; for (int len; (len=callback(instance, CLS_PARTIAL_READ, buf, BUFSIZE)) != 0; ) { if (len<0) return len; // Return errcode on error int result = callback(instance, CLS_FULL_WRITE, buf, len); if (result != len) return result<0? result : CLS_ERROR_WRITE; } return CLS_OK; } default: return CLS_ERROR_NOT_IMPLEMENTED; } } |
#8
|
||||
|
||||
In which case which compiler will you use?
For example pzlib, ztool and xtools do not require cls-dll. If you are using mingw compile an executable example without necessarily using the cls-dll extension code.
__________________
"There are three things that sages fear... The tormented sea, a moonless night and the wrath of a gentleness man." - The fear of the Sages. |
#9
|
||||
|
||||
I wanted to create cls dll of pzlib for compression as the razor12911s dll did not work. I want to compress an archive using pzlib+lzma in freearc.
|
#10
|
|||
|
|||
just use cmake(check attached archive), i used it with msys2 and msvc
PS: for using the boost in msvc, I have handwritten the paths in CMakeList.txt, you probably have to change it according to your environment, it works just fine with msys2(use pacman) also remember the arc is 32 bit so you have to use 32 bit environment for both msvc and msys2 in C++ you just need to inherit from ClsCompressor class and overwrite compress and decompress function f.e: Code:
class ClsLzhamCompressor : public ClsCompressor { public: template <typename... Types> ClsLzhamCompressor(Types... Args) : ClsCompressor{Args...} {} protected: // overwrite this method for your compression // see ClsCompressor defination in cls.h and use read_exactly(...) and equivalent functions for required operation void decompress() override; }; Code:
extern "C" int __cdecl ClsMain(int operation, CLS_CALLBACK callback, void *instance) { return ClsLzhamCompressor(operation, callback, instance).run(); } Last edited by Gupta; 15-07-2018 at 11:21. |
The Following 2 Users Say Thank You to Gupta For This Useful Post: | ||
Simorq (17-08-2018), TheGeekyGamer (15-07-2018) |
![]() |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inno Setup: Additional Libraries | altef_4 | Conversion Tutorials | 50 | 21-10-2020 10:59 |
ISComponent libraries | Jiva newstone | Conversion Tutorials | 16 | 13-06-2018 06:00 |
Compiling patches to CD | rambai | PC Games | 3 | 17-05-2009 14:05 |
Compiling | jmaverick101 | PC Games | 1 | 04-04-2004 18:34 |
Problem with compiling seperate files.. | esong2k3 | DC Games | 1 | 01-07-2003 09:34 |