Antonio Linares wrote:
Dear Richard,
https://x.com/i/grok/share/CMlzU3PRIPGQoS0LtGuoRgN2E
Dear Antonio,
I compile below my source code and got error message
Compiling...
Harbour 3.2.0dev (r2503251254)
Copyright (c) 1999-2024, https://harbour.github.io/
Compiling 'testbrot.prg' and generating preprocessed output to 'testbrot.ppo'...
Lines 5091, Functions/Procedures 1
Generating C source output to 'testbrot.c'... Done.
Embarcadero C++ 7.70 for Win32 Copyright (c) 1993-2023 Embarcadero Technologies, Inc.
testbrot.c:
Error E2141 testbrot.prg 21: Declaration syntax error
Error E2356 testbrot.prg 22: Type mismatch in redeclaration of 'WINAPI'
Error E2344 testbrot.prg 21: Earlier declaration of 'WINAPI'
Error E2141 testbrot.prg 22: Declaration syntax error
*** 4 errors in Compile ***
* Linking errors *
# INCLUDE "FIVEWIN.CH"
FUNCTION MAIN()
LOCAL cRES:='{"sams":[{"samId":"901000000046","hospitalId":"9999999999","hospitalName":"測試ζ©ζ§","hospitalShortName":"測試ζ©ζ§","comport":"COM1"},{"samId":"901000001234","hospitalId":"0532110002","hospitalName":"ηζ₯ι«ι’","hospitalShortName":"ηζ₯ι«ι’","comport":"COM1"}],"statusCode":0}'
LOCAL nSize:=BROTLIENCODERCOMPRESSEDSIZE(200)
LOCAL SOUT:=SPACE(nSize)
LOCAL nResult
nResult:=BROTLIENCODERCOMPRESS(5,22,1,LEN(cRES),cRES,nSize,@sout)
IF nResult == 1
? "Compression successful, compressed size:", LEN(sOut)
ELSE
? "Compression failed"
ENDIF
RETURN Nil
#pragma BEGINDUMP
#include <brotli/encode.h>
#include <brotli/types.h>
#include "hbapi.h"
size_t WINAPI BrotliEncoderMaxCompressedSize(size_t input_size);
BROTLI_BOOL WINAPI BrotliEncoderCompress(int quality,int lgwin,BrotliEncoderMode mode,size_t input_size, const uint8_t input_buffer[],size_t *encoded_size, uint8_t encoded_buffer[]);
HB_FUNC(BROTLIENCODERCOMPRESSEDSIZE)
{
size_t inp_size = (size_t)hb_parni(1);
size_t size=BrotliEncoderMaxCompressedSize(inp_size);
hb_retnl((long)size);
}
HB_FUNC(BROTLIENCODERCOMPRESS)
{
int quality = hb_parni(1);
int lgwin = hb_parni(2);
BrotliEncoderMode mode = (BrotliEncoderMode)hb_parni(3);
size_t input_size = (size_t)hb_parni(4);
const char *input_buffer = hb_parc(5);
size_t encoded_size = (size_t)hb_parni(6);
char *encoded_buffer = (char *)hb_parc(7);
BROTLI_BOOL result = BrotliEncoderCompress(quality, lgwin, mode,
input_size, (const uint8_t *)input_buffer,
&encoded_size, (uint8_t *)encoded_buffer);
hb_retni(result);
}
#pragma BEGINDUMP
I have brotlienc DLL file and Convert to LIB file.
If you want to test it, I will send to you mail box.