-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adler crc hash #444
Adler crc hash #444
Changes from 4 commits
2aadbc6
1310090
a84e174
ef9c7ed
6b38426
2b3743e
40fe9f3
212986a
2d8a7b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,16 @@ | |
#include "../../libqb.h" | ||
#include "miniz.h" | ||
|
||
uint32_t func__adler32(qbs *text) { | ||
if (!text->len) return 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it return |
||
return (uint32) adler32(1, text->chr, text->len); | ||
} | ||
|
||
uint32_t func__crc32(qbs *text) { | ||
if (!text->len) return 0; | ||
return (uint32) crc32(0, text->chr, text->len); | ||
} | ||
|
||
qbs *func__deflate(qbs *text) { | ||
uLongf filesize = (uint32_t)text->len; // length of the text | ||
uLongf compsize = compressBound(filesize); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ | |
#include <cstdio> | ||
#include <ft2build.h> | ||
#include FT_FREETYPE_H | ||
extern "C" { | ||
#include "freetype/md5.h" | ||
} | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
|
@@ -1006,6 +1009,27 @@ bool FontRenderTextASCII(int32_t fh, const uint8_t *codepoint, int32_t codepoint | |
return false; | ||
} | ||
|
||
/// @brief Expose freetype's MD5 procedure for public use | ||
/// @param text The message to build the MD5 hash of | ||
/// @return The generated MD5 hash as hexadecimal string | ||
qbs *func__md5(qbs *text) { | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not that it really matters, but we can get rid of the extra braces. |
||
MD5_CTX ctx; | ||
unsigned char md5[16]; | ||
qbs *res; | ||
int i; | ||
|
||
MD5_Init(&ctx); | ||
if (text->len) MD5_Update(&ctx, text->chr, text->len); | ||
MD5_Final(md5,&ctx); | ||
|
||
res = qbs_new(32, 1); | ||
for (i = 0; i < 16; i++) sprintf((char*)&res->chr[i*2], "%02X", md5[i]); | ||
|
||
return res; | ||
} | ||
} | ||
|
||
/// @brief Return the true font height in pixel | ||
/// @param qb64_fh A QB64 font handle (this can be a builtin font as well) | ||
/// @param passed Optional arguments flag | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1411,6 +1411,18 @@ id.ret = LONGTYPE - ISPOINTER | |
id.hr_syntax = "_FONT[(imageHandle&)]" | ||
regid | ||
|
||
clearid | ||
id.n = qb64prefix$ + "Md5" | ||
id.Dependency=DEPENDENCY_LOADFONT | ||
id.musthave = "$" | ||
id.subfunc = 1 | ||
id.callname = "func__md5" | ||
id.args = 1 | ||
id.arg = MKL$(STRINGTYPE - ISPOINTER) | ||
id.ret = STRINGTYPE - ISPOINTER | ||
id.hr_syntax = "_MD5$(dataString$)" | ||
regid | ||
|
||
clearid | ||
id.n = qb64prefix$ + "PrintString" | ||
id.subfunc = 2 | ||
|
@@ -3814,6 +3826,28 @@ id.hr_syntax = "_ROR(numericalVariable, numericalValue)" | |
regid | ||
' a740g: end of ROR & ROL additions | ||
|
||
clearid | ||
id.n = qb64prefix$ + "Adler32" | ||
id.Dependency=DEPENDENCY_ZLIB | ||
id.subfunc = 1 | ||
id.callname = "func__adler32" | ||
id.args = 1 | ||
id.arg = MKL$(STRINGTYPE - ISPOINTER) | ||
id.ret = LONGTYPE - ISPOINTER | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The return type for these functions should be |
||
id.hr_syntax = "_ADLER32(dataString$)" | ||
regid | ||
|
||
clearid | ||
id.n = qb64prefix$ + "Crc32" | ||
id.Dependency=DEPENDENCY_ZLIB | ||
id.subfunc = 1 | ||
id.callname = "func__crc32" | ||
id.args = 1 | ||
id.arg = MKL$(STRINGTYPE - ISPOINTER) | ||
id.ret = LONGTYPE - ISPOINTER | ||
id.hr_syntax = "_CRC32(dataString$)" | ||
regid | ||
|
||
clearid | ||
id.n = qb64prefix$ + "Deflate" | ||
id.Dependency=DEPENDENCY_ZLIB | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than put them in
font.h
andcompression.h
I think it would make more sense to add a newhashing.h
and put them in there.