From afb5710ffc61e47401e633f654c99e186e5121fb Mon Sep 17 00:00:00 2001 From: polar wu Date: Thu, 17 Jul 2025 13:37:27 +0800 Subject: [PATCH 1/2] fix: compile conflict with openSSL --- lib/md5/md5.c | 6 +++--- lib/md5/md5.h | 6 +++--- lib/md5/pbmd5.h | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/md5/md5.c b/lib/md5/md5.c index 5805298b..57e2006d 100644 --- a/lib/md5/md5.c +++ b/lib/md5/md5.c @@ -194,7 +194,7 @@ static void const* body(MD5_CTX *ctx, void const* data, unsigned long size) return ptr; } -void MD5_Init(MD5_CTX *ctx) +void MD5_Init_(MD5_CTX *ctx) { ctx->a = 0x67452301; ctx->b = 0xefcdab89; @@ -205,7 +205,7 @@ void MD5_Init(MD5_CTX *ctx) ctx->hi = 0; } -void MD5_Update(MD5_CTX *ctx, void const *data, unsigned long size) +void MD5_Update_(MD5_CTX *ctx, void const *data, unsigned long size) { MD5_u32plus saved_lo; unsigned long used, free; @@ -239,7 +239,7 @@ void MD5_Update(MD5_CTX *ctx, void const *data, unsigned long size) memcpy(ctx->buffer, data, size); } -void MD5_Final(unsigned char *result, MD5_CTX *ctx) +void MD5_Final_(unsigned char *result, MD5_CTX *ctx) { unsigned long used, free; diff --git a/lib/md5/md5.h b/lib/md5/md5.h index 69aca4a5..53da293d 100644 --- a/lib/md5/md5.h +++ b/lib/md5/md5.h @@ -36,8 +36,8 @@ typedef struct { MD5_u32plus block[16]; } MD5_CTX; -extern void MD5_Init(MD5_CTX *ctx); -extern void MD5_Update(MD5_CTX *ctx, void const *data, unsigned long size); -extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); +extern void MD5_Init_(MD5_CTX *ctx); +extern void MD5_Update_(MD5_CTX *ctx, void const *data, unsigned long size); +extern void MD5_Final_(unsigned char *result, MD5_CTX *ctx); #endif diff --git a/lib/md5/pbmd5.h b/lib/md5/pbmd5.h index 76d92679..753c6d55 100644 --- a/lib/md5/pbmd5.h +++ b/lib/md5/pbmd5.h @@ -32,14 +32,14 @@ /** Initializes the MD5 context for a new calculation. @param x Pointer to a MD5 context */ -#define pbmd5_init(x) MD5_Init(x) +#define pbmd5_init(x) MD5_Init_(x) /** Update the MD5 context with the "next part of the message". @param x Pointer to a MD5 context @param m Pointer to the start of the "next part of the message" @param l Length (in bytes) of the "next part of the message" */ -#define pbmd5_update(x, m, l) MD5_Update((x), (m), (l)) +#define pbmd5_update(x, m, l) MD5_Update_((x), (m), (l)) /** Update the MD5 context with the "next part of the message". Assumes it is an ASCIIZ string. @@ -47,22 +47,22 @@ @param x Pointer to a MD5 context @param str String being the "next part of the message" */ -#define pbmd5_update_str(x, str) MD5_Update((x), (str), strlen(str)) +#define pbmd5_update_str(x, str) MD5_Update_((x), (str), strlen(str)) /** Does the final calculations of the MD5 on context @p x and stores the digest to @p d. @param x Pointer to a MD5 context @param d Pointer to an array of (at least) 16 bytes */ -#define pbmd5_final(x, d) MD5_Final((d), (x)) +#define pbmd5_final(x, d) MD5_Final_((d), (x)) /** This helper macro will calculate the MD5 on the message in @p m, having the length @p l and store it in @p d. */ #define pbmd5_digest(m, l, d) do { MD5_CTX M_ctx_; \ - MD5_Init(&M_ctx_); \ - MD5_Update(&M_ctx_, (m), (l)); \ - MD5_Final((d), &M_ctx); \ + MD5_Init_(&M_ctx_); \ + MD5_Update_(&M_ctx_, (m), (l)); \ + MD5_Final_((d), &M_ctx); \ } while (0) /** This helper macro will calculate the MD5 on the message in @p str, @@ -70,9 +70,9 @@ @warning This macro uses @p str twice! */ #define pbmd5_digest_str(str, d) do { MD5_CTX M_ctx_; \ - MD5_Init(&M_ctx_); \ - MD5_Update(&M_ctx_, (str), strlen(str)); \ - MD5_Final((d), &M_ctx); \ + MD5_Init_(&M_ctx_); \ + MD5_Update_(&M_ctx_, (str), strlen(str)); \ + MD5_Final_((d), &M_ctx); \ } while (0) #endif /* !defined INC_PBMD5 */ From f9d3f2242453ba1c8124f2b647b079b6cf27615c Mon Sep 17 00:00:00 2001 From: polar wu Date: Thu, 17 Jul 2025 13:37:57 +0800 Subject: [PATCH 2/2] fix: compile error on Windows platform for v5.1.3 --- core/samples/pubnub_objects_api_sample.c | 6 +++++- core/samples/pubnub_sync_sample.c | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/samples/pubnub_objects_api_sample.c b/core/samples/pubnub_objects_api_sample.c index e5076f35..be2122c6 100644 --- a/core/samples/pubnub_objects_api_sample.c +++ b/core/samples/pubnub_objects_api_sample.c @@ -7,8 +7,12 @@ #include "core/pubnub_objects_api.h" #include #include -#include +#ifdef _WIN32 +#include +#else +#include +#endif // This sample demo is split into 4 sections: // 1. UUID metadata section // 2. Channels metadata section diff --git a/core/samples/pubnub_sync_sample.c b/core/samples/pubnub_sync_sample.c index 8ab8176e..3ae46655 100644 --- a/core/samples/pubnub_sync_sample.c +++ b/core/samples/pubnub_sync_sample.c @@ -14,8 +14,13 @@ #include #include -#include +#ifdef _WIN32 +#include +#define sleep(x) Sleep(1000 * (x)) +#else +#include +#endif static void generate_user_id(pubnub_t* pbp) {