View Single Post
  #6  
Old 15-07-2018, 05: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