Go Back   FileForums > Game Backup > PC Games > PC Games - CD/DVD Conversions > Conversion Tutorials

Reply
 
Thread Tools Display Modes
  #1  
Old 15-07-2018, 02:00
TheGeekyGamer's Avatar
TheGeekyGamer TheGeekyGamer is offline
Registered User
 
Join Date: Jun 2018
Location: File Forums
Posts: 18
Thanks: 38
Thanked 5 Times in 5 Posts
TheGeekyGamer is on a distinguished road
Question HELP: Compiling CLS libraries using GCC/MSVC

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;
    }
}
Reply With Quote
Sponsored Links
  #2  
Old 15-07-2018, 06:30
kassane's Avatar
kassane kassane is offline
Registered User
 
Join Date: Nov 2011
Location: Somewhere in the World
Posts: 174
Thanks: 578
Thanked 117 Times in 47 Posts
kassane is on a distinguished road
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.
Reply With Quote
The Following User Says Thank You to kassane For This Useful Post:
TheGeekyGamer (15-07-2018)
  #3  
Old 15-07-2018, 06:38
TheGeekyGamer's Avatar
TheGeekyGamer TheGeekyGamer is offline
Registered User
 
Join Date: Jun 2018
Location: File Forums
Posts: 18
Thanks: 38
Thanked 5 Times in 5 Posts
TheGeekyGamer is on a distinguished road
Alright. But how do i add compression command to the above given code. Can u give me an example ? eg lolz -dto0 - dtd1 -dtm1
Reply With Quote
The Following User Says Thank You to TheGeekyGamer For This Useful Post:
kassane (15-07-2018)
  #4  
Old 15-07-2018, 06:40
kassane's Avatar
kassane kassane is offline
Registered User
 
Join Date: Nov 2011
Location: Somewhere in the World
Posts: 174
Thanks: 578
Thanked 117 Times in 47 Posts
kassane is on a distinguished road
Quote:
Originally Posted by TheGeekyGamer View Post
Alright. But how do i add compression command to the above given code. Can u give me an example ? eg lolz -dto0 - dtd1 -dtm1

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.
Reply With Quote
  #5  
Old 15-07-2018, 06:42
TheGeekyGamer's Avatar
TheGeekyGamer TheGeekyGamer is offline
Registered User
 
Join Date: Jun 2018
Location: File Forums
Posts: 18
Thanks: 38
Thanked 5 Times in 5 Posts
TheGeekyGamer is on a distinguished road
Alright. But how do i add compression command under CLS_COMPRESS section? Eg: lolz -dto0 -dtd1
Reply With Quote
  #6  
Old 15-07-2018, 06:46
TheGeekyGamer's Avatar
TheGeekyGamer TheGeekyGamer is offline
Registered User
 
Join Date: Jun 2018
Location: File Forums
Posts: 18
Thanks: 38
Thanked 5 Times in 5 Posts
TheGeekyGamer is on a distinguished road
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;
}
}
Reply With Quote
  #7  
Old 15-07-2018, 06:56
kassane's Avatar
kassane kassane is offline
Registered User
 
Join Date: Nov 2011
Location: Somewhere in the World
Posts: 174
Thanks: 578
Thanked 117 Times in 47 Posts
kassane is on a distinguished road
See this!
__________________
"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.
Reply With Quote
  #8  
Old 15-07-2018, 07:01
kassane's Avatar
kassane kassane is offline
Registered User
 
Join Date: Nov 2011
Location: Somewhere in the World
Posts: 174
Thanks: 578
Thanked 117 Times in 47 Posts
kassane is on a distinguished road
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.
Reply With Quote
  #9  
Old 15-07-2018, 09:02
TheGeekyGamer's Avatar
TheGeekyGamer TheGeekyGamer is offline
Registered User
 
Join Date: Jun 2018
Location: File Forums
Posts: 18
Thanks: 38
Thanked 5 Times in 5 Posts
TheGeekyGamer is on a distinguished road
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.
Reply With Quote
  #10  
Old 15-07-2018, 09:16
Gupta Gupta is offline
Banned
 
Join Date: Aug 2016
Location: https://t.me/pump_upp
Posts: 399
Thanks: 139
Thanked 714 Times in 231 Posts
Gupta is on a distinguished road
Send a message via ICQ to Gupta Send a message via AIM to Gupta Send a message via Yahoo to Gupta
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;

};
your main will look like:
Code:
extern "C" int __cdecl ClsMain(int operation, CLS_CALLBACK callback,
                               void *instance) {
  return ClsLzhamCompressor(operation, callback, instance).run();
}
Attached Files
File Type: 7z _CLS.7z (6.7 KB, 15 views)

Last edited by Gupta; 15-07-2018 at 11:21.
Reply With Quote
The Following 2 Users Say Thank You to Gupta For This Useful Post:
Simorq (17-08-2018), TheGeekyGamer (15-07-2018)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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



All times are GMT -7. The time now is 13:18.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright 2000-2020, FileForums @ https://fileforums.com