1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-03 12:21:20 +00:00

Adds stubs for _INFLATE$ and DEFLATE$ for OSes other than Windows.

These will return the unchanged text$ passed for now.
This commit is contained in:
FellippeHeitor 2020-01-02 17:25:04 -03:00
parent fdf3fe9a02
commit 114bd7b5a8
4 changed files with 67 additions and 62 deletions

View file

@ -16452,15 +16452,13 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){
#include "parts/audio/decode/src.c"
#endif
#ifdef QB64_WINDOWS
#ifdef DEPENDENCY_ZLIB
#ifdef QB64_BACKSLASH_FILESYSTEM //change slashes depending on OS, I guess? Included by copying audio template, and it works. (SMcNeill comment)
#include "parts\\zlib-1.2.11\\src.c"
#else
#include "parts/zlib-1.2.11/src.c"
#endif
#ifdef DEPENDENCY_ZLIB
#ifdef QB64_BACKSLASH_FILESYSTEM //change slashes depending on OS, I guess? Included by copying audio template, and it works. (SMcNeill comment)
#include "parts\\zlib-1.2.11\\src.c"
#else
#include "parts/zlib-1.2.11/src.c"
#endif
#endif
#endif

View file

@ -1,39 +1,47 @@
#ifdef DEPENDENCY_ZLIB
#include "download\zlib.h"
#ifdef QB64_WINDOWS
#include "download\zlib.h"
#endif
qbs *func__deflate(qbs *text){
uLongf filesize = (uint32)text->len; //length of the text
uLongf compsize = compressBound(filesize);
unsigned char *dest = (unsigned char *)malloc(compsize);
int32 result = compress(dest, &compsize, text->chr, filesize);
qbs *ret = qbs_new(compsize,1);
memcpy(ret->chr, dest, compsize);
free(dest);
return ret;
#ifdef QB64_WINDOWS
uLongf filesize = (uint32)text->len; //length of the text
uLongf compsize = compressBound(filesize);
unsigned char *dest = (unsigned char *)malloc(compsize);
int32 result = compress(dest, &compsize, text->chr, filesize);
qbs *ret = qbs_new(compsize,1);
memcpy(ret->chr, dest, compsize);
free(dest);
return ret;
#else
return text;
#endif
}
qbs *func__inflate(qbs *text, int64 originalsize, int32 passed){
int32 result=0;
if (passed==1){
uLongf uncompsize = originalsize;
unsigned char *dest = (unsigned char *)malloc(originalsize);
int32 result = uncompress(dest, &uncompsize, text->chr, text->len);
qbs *ret = qbs_new(uncompsize,1);
memcpy(ret->chr, dest, uncompsize);
free(dest);
return ret;
}else{
uLongf uncompsize = 0;
unsigned char *dest;
do {
uncompsize = uncompsize + 10000000; //10 mb original buffer, resized by 10 mb each pass until it's large enough to hold the uncompressed data.
dest = (unsigned char *)malloc(uncompsize);
result = uncompress(dest, &uncompsize, text->chr, text->len);
if (result==Z_BUF_ERROR)free(dest); //if the buffer is too small, free the old buffer
} while(result==Z_BUF_ERROR); // and try again with a larger buffer
qbs *ret = qbs_new(uncompsize,1);
memcpy(ret->chr, dest, uncompsize);
free(dest);
return ret;
#ifdef QB64_WINDOWS
int32 result=0;
if (passed==1){
uLongf uncompsize = originalsize;
unsigned char *dest = (unsigned char *)malloc(originalsize);
int32 result = uncompress(dest, &uncompsize, text->chr, text->len);
qbs *ret = qbs_new(uncompsize,1);
memcpy(ret->chr, dest, uncompsize);
free(dest);
return ret;
}else{
uLongf uncompsize = 0;
unsigned char *dest;
do {
uncompsize = uncompsize + 10000000; //10 mb original buffer, resized by 10 mb each pass until it's large enough to hold the uncompressed data.
dest = (unsigned char *)malloc(uncompsize);
result = uncompress(dest, &uncompsize, text->chr, text->len);
if (result==Z_BUF_ERROR)free(dest); //if the buffer is too small, free the old buffer
} while(result==Z_BUF_ERROR); // and try again with a larger buffer
qbs *ret = qbs_new(uncompsize,1);
memcpy(ret->chr, dest, uncompsize);
free(dest);
return ret;
}
}
#endif
#else
return text;
#endif
}

View file

@ -12,11 +12,13 @@
extern void CFont(qbs* FontName, int FontSize);
extern void sub__console_cursor(int32 visible, int32 cursorsize, int32 passed);
extern int32 func__getconsoleinput();
#ifdef DEPENDENCY_ZLIB
qbs *func__deflate(qbs *text);
qbs *func__inflate(qbs *text, int64 originalsize, int32 passed);
#include "parts\zlib-1.2.11\download\zlib.h"
#endif
#ifdef DEPENDENCY_ZLIB
qbs *func__deflate(qbs *text);
qbs *func__inflate(qbs *text, int64 originalsize, int32 passed);
#ifdef QB64_WINDOWS
#include "parts\zlib-1.2.11\download\zlib.h"
#endif
#endif

View file

@ -12037,21 +12037,6 @@ IF DEPENDENCY(DEPENDENCY_GL) THEN
defines$ = defines$ + defines_header$ + "DEPENDENCY_GL"
END IF
IF DEPENDENCY(DEPENDENCY_ZLIB) THEN
IF win THEN 'ZLIB is only supported for windows versions so far
defines$ = defines$ + defines_header$ + "DEPENDENCY_ZLIB"
d$ = "internal\c\parts\zlib-1.2.11\"
'rebuild?
IF _FILEEXISTS(d$ + "os\" + o$ + "\src.a") = 0 THEN
Build d$ + "os\" + o$
END IF
defines$ = defines$ + defines_header$ + "DEPENDENCY_ZLIB"
libs$ = libs$ + " " + "parts\zlib-1.2.11\os\" + o$ + "\src.a -lz"
END IF
END IF
IF DEPENDENCY(DEPENDENCY_SCREENIMAGE) THEN
DEPENDENCY(DEPENDENCY_IMAGE_CODEC) = 1 'used by OSX to read in screen capture files
END IF
@ -12160,6 +12145,18 @@ IF DEPENDENCY(DEPENDENCY_AUDIO_OUT) THEN
libs$ = libs$ + " " + d2$ + "\src.a"
END IF
IF DEPENDENCY(DEPENDENCY_ZLIB) THEN
defines$ = defines$ + defines_header$ + "DEPENDENCY_ZLIB"
IF win THEN 'ZLIB is only supported for windows versions so far
d$ = "internal\c\parts\zlib-1.2.11\"
'rebuild?
IF _FILEEXISTS(d$ + "os\" + o$ + "\src.a") = 0 THEN
Build d$ + "os\" + o$
END IF
libs$ = libs$ + " " + "parts\zlib-1.2.11\os\" + o$ + "\src.a -lz"
END IF
END IF
'finalize libs$ and defines$ strings
IF LEN(libs$) THEN libs$ = libs$ + " "
PATH_SLASH_CORRECT libs$