From 5575298e96a3601ea934ceca8ccea5cb08f444e0 Mon Sep 17 00:00:00 2001 From: Mateusz Dahlke <39696234+Xavrax@users.noreply.github.com> Date: Mon, 20 Nov 2023 11:02:33 +0100 Subject: [PATCH] Provide `PUBNUB_EXTERN` macro to extern C functions (#169) --- .pubnub.yml | 21 +++++++----- CHANGELOG.md | 6 ++++ core/pubnub_actions_api.h | 17 +++++----- core/pubnub_advanced_history.h | 9 ++--- core/pubnub_alloc.h | 5 +-- core/pubnub_assert.h | 11 +++--- core/pubnub_auto_heartbeat.h | 13 ++++--- core/pubnub_blocking_io.h | 6 ++-- core/pubnub_callback_subscribe_loop.h | 9 ++--- core/pubnub_ccore.h | 29 ++++++++-------- core/pubnub_coreapi.h | 33 +++++++++--------- core/pubnub_coreapi_ex.c | 2 +- core/pubnub_coreapi_ex.h | 24 ++++++------- core/pubnub_create.h | 3 +- core/pubnub_crypto.h | 41 +++++++++++----------- core/pubnub_dns_servers.h | 29 +++++++++------- core/pubnub_fetch_history.h | 7 ++-- core/pubnub_free_with_timeout.h | 5 ++- core/pubnub_generate_uuid.h | 13 +++---- core/pubnub_grant_token_api.h | 9 ++--- core/pubnub_helper.h | 13 +++---- core/pubnub_keep_alive.h | 3 +- core/pubnub_memory_block.h | 3 +- core/pubnub_ntf_callback.h | 9 ++--- core/pubnub_ntf_sync.h | 3 +- core/pubnub_objects_api.h | 31 +++++++++-------- core/pubnub_proxy.h | 17 +++++----- core/pubnub_proxy_wpad.h | 5 +-- core/pubnub_pubsubapi.h | 49 ++++++++++++++------------- core/pubnub_revoke_token_api.h | 12 +++++-- core/pubnub_ssl.h | 13 +++---- core/pubnub_subscribe_v2.h | 9 +++-- core/pubnub_subscribe_with_state.h | 4 ++- core/pubnub_sync_subscribe_loop.h | 5 +-- core/pubnub_timer_list.h | 13 +++---- core/pubnub_timers.h | 9 ++--- core/pubnub_url_encode.h | 4 ++- core/pubnub_version.h | 9 ++--- core/pubnub_version_internal.h | 2 +- core/srand_from_pubnub_time.h | 3 +- lib/pb_extern.h | 11 ++++++ 41 files changed, 294 insertions(+), 225 deletions(-) create mode 100644 lib/pb_extern.h diff --git a/.pubnub.yml b/.pubnub.yml index de2d99af..c987cc00 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,8 +1,13 @@ name: c-core schema: 1 -version: "4.6.2" +version: "4.7.0" scm: github.com/pubnub/c-core changelog: + - date: 2023-11-20 + version: v4.7.0 + changes: + - type: feature + text: "Provided `PUBNUB_EXTERN` macro to extern C functions." - date: 2023-11-14 version: v4.6.2 changes: @@ -758,7 +763,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.6.2 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 requires: - name: "miniz" @@ -824,7 +829,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.6.2 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 requires: - name: "miniz" @@ -890,7 +895,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.6.2 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 requires: - name: "miniz" @@ -952,7 +957,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.6.2 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 requires: - name: "miniz" @@ -1013,7 +1018,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.6.2 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 requires: - name: "miniz" @@ -1069,7 +1074,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.6.2 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 requires: - name: "miniz" @@ -1122,7 +1127,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.6.2 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 requires: - name: "miniz" diff --git a/CHANGELOG.md b/CHANGELOG.md index f29422db..03bf4650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v4.7.0 +November 20 2023 + +#### Added +- Provided `PUBNUB_EXTERN` macro to extern C functions. + ## v4.6.2 November 14 2023 diff --git a/core/pubnub_actions_api.h b/core/pubnub_actions_api.h index eafa7c1f..f72dac0c 100644 --- a/core/pubnub_actions_api.h +++ b/core/pubnub_actions_api.h @@ -2,6 +2,7 @@ #if !defined INC_PUBNUB_ACTIONS_API #define INC_PUBNUB_ACTIONS_API +#include "lib/pb_extern.h" #include "pbcc_actions_api.h" #include @@ -22,7 +23,7 @@ @param value Json string describing the action that is to be added @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_add_message_action(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_add_message_action(pubnub_t* pb, char const* channel, char const* message_timetoken, enum pubnub_action_type actype, @@ -39,7 +40,7 @@ enum pubnub_res pubnub_add_message_action(pubnub_t* pb, @return Structured pointer to memory block containing message timetoken value(including its quotation marks) within the context response buffer */ -pubnub_chamebl_t pubnub_get_message_timetoken(pubnub_t* pb); +PUBNUB_EXTERN pubnub_chamebl_t pubnub_get_message_timetoken(pubnub_t* pb); /** Searches the response(if previous transaction on the @p pb context had been @@ -51,7 +52,7 @@ pubnub_chamebl_t pubnub_get_message_timetoken(pubnub_t* pb); @return Structured pointer to memory block containing action timetoken value(including its quotation marks) within the context response buffer */ -pubnub_chamebl_t pubnub_get_message_action_timetoken(pubnub_t* pb); +PUBNUB_EXTERN pubnub_chamebl_t pubnub_get_message_action_timetoken(pubnub_t* pb); /** Initiates transaction that deletes(removes) previously added action on a published message. @@ -67,7 +68,7 @@ pubnub_chamebl_t pubnub_get_message_action_timetoken(pubnub_t* pb); marks at both ends) @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_remove_message_action(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_remove_message_action(pubnub_t* pb, char const* channel, pubnub_chamebl_t message_timetoken, pubnub_chamebl_t action_timetoken); @@ -91,7 +92,7 @@ enum pubnub_res pubnub_remove_message_action(pubnub_t* pb, Any value greater than 100 is considered an error. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_get_message_actions(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_get_message_actions(pubnub_t* pb, char const* channel, char const* start, char const* end, @@ -112,7 +113,7 @@ enum pubnub_res pubnub_get_message_actions(pubnub_t* pb, @retval PNR_GOT_ALL_ACTIONS transaction successfully finished. @retval corresponding error otherwise */ -enum pubnub_res pubnub_get_message_actions_more(pubnub_t* pb); +PUBNUB_EXTERN enum pubnub_res pubnub_get_message_actions_more(pubnub_t* pb); /** Initiates transaction that returns all actions added on a given @p channel between @p start @@ -133,7 +134,7 @@ enum pubnub_res pubnub_get_message_actions_more(pubnub_t* pb); was 100. Any value greater than 100 is considered an error. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_history_with_message_actions(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_history_with_message_actions(pubnub_t* pb, char const* channel, char const* start, char const* end, @@ -155,7 +156,7 @@ enum pubnub_res pubnub_history_with_message_actions(pubnub_t* pb, @retval PNR_GOT_ALL_ACTIONS transaction successfully finished. @retval corresponding error otherwise */ -enum pubnub_res pubnub_history_with_message_actions_more(pubnub_t* pb); +PUBNUB_EXTERN enum pubnub_res pubnub_history_with_message_actions_more(pubnub_t* pb); #endif /* !defined INC_PUBNUB_ACTIONS_API */ diff --git a/core/pubnub_advanced_history.h b/core/pubnub_advanced_history.h index 79537f42..c7c18969 100644 --- a/core/pubnub_advanced_history.h +++ b/core/pubnub_advanced_history.h @@ -2,6 +2,7 @@ #if !defined INC_PUBNUB_ADVANCED_HISTORY #define INC_PUBNUB_ADVANCED_HISTORY +#include "lib/pb_extern.h" #include "pbcc_advanced_history.h" /** Structure containing channel name as char memory block and field with @@ -20,7 +21,7 @@ struct pubnub_chan_msg_count { /** If successful returns number of members(key:value pairs) of JSON object 'channels', or -1 on error(transaction still in progress, or so) */ -int pubnub_get_chan_msg_counts_size(pubnub_t* pb); +PUBNUB_EXTERN int pubnub_get_chan_msg_counts_size(pubnub_t* pb); /** Starts the transaction 'pubnub_message_counts' on the context @p pb for the list of channels @p channel for unread messages counts starting from @p timeoken @@ -31,7 +32,7 @@ int pubnub_get_chan_msg_counts_size(pubnub_t* pb); in progress(hasn't finished yet) @retval otherwise a result with the same meaning as for any other transaction */ -enum pubnub_res pubnub_message_counts(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_message_counts(pubnub_t* pb, char const* channel, char const* timetoken); @@ -42,7 +43,7 @@ enum pubnub_res pubnub_message_counts(pubnub_t* pb, @retval 0 on success @retval -1 on error(transaction in progress, or format error) */ -int pubnub_get_chan_msg_counts(pubnub_t* pb, +PUBNUB_EXTERN int pubnub_get_chan_msg_counts(pubnub_t* pb, size_t* io_count, struct pubnub_chan_msg_count* chan_msg_counters); @@ -57,7 +58,7 @@ int pubnub_get_chan_msg_counts(pubnub_t* pb, @retval 0 on success @retval -1 on error(transaction in progress, or format error) */ -int pubnub_get_message_counts(pubnub_t* pb, char const*channel, int* o_count); +PUBNUB_EXTERN int pubnub_get_message_counts(pubnub_t* pb, char const*channel, int* o_count); #endif /* !defined INC_PUBNUB_ADVANCED_HISTORY */ diff --git a/core/pubnub_alloc.h b/core/pubnub_alloc.h index 167eab85..d6e1b5f9 100644 --- a/core/pubnub_alloc.h +++ b/core/pubnub_alloc.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" /** Returns an allocated context. After successful allocation, please @@ -14,7 +15,7 @@ @return Context pointer on success, NULL on error */ -pubnub_t *pubnub_alloc(void); +PUBNUB_EXTERN pubnub_t *pubnub_alloc(void); /** Frees a previously allocated context, if it is not in a transaction. If a context is in a transaction, it will cancel it @@ -30,7 +31,7 @@ pubnub_t *pubnub_alloc(void); @param pb Pointer to a context which to free @return 0: OK, context freed; else: not freed, transaction cancel started */ -int pubnub_free(pubnub_t *pb); +PUBNUB_EXTERN int pubnub_free(pubnub_t *pb); #endif /* !defined INC_PUBNUB_ALLOC */ diff --git a/core/pubnub_assert.h b/core/pubnub_assert.h index ffe2fb77..0506f250 100644 --- a/core/pubnub_assert.h +++ b/core/pubnub_assert.h @@ -3,6 +3,7 @@ #define INC_PUBNUB_ASSERT #include +#include "lib/pb_extern.h" /** The Pubnub ASSERT macros. There are several layers: @@ -204,7 +205,7 @@ /** This will invoke the installed assert handler. The default behavior is pubnub_assert_handler_abort(). */ -void PUBNUB_NORETURN pubnub_assert_failed(char const* s, char const* file, long line); +PUBNUB_EXTERN void PUBNUB_NORETURN pubnub_assert_failed(char const* s, char const* file, long line); /** Prototype of a Pubnub assertion failure handler. There are several standard handlers, but you can also provide your own. @@ -222,19 +223,19 @@ typedef void PUBNUB_NORETURN (*pubnub_assert_handler_t)(char const* s, @param handler The handler to install. If NULL, will install pubnub_assert_handler_abort() */ -void pubnub_assert_set_handler(pubnub_assert_handler_t handler); +PUBNUB_EXTERN void pubnub_assert_set_handler(pubnub_assert_handler_t handler); /** This handler will print a message formed from the parameters and then go to infinite loop. Useful for debugging. */ -void PUBNUB_NORETURN pubnub_assert_handler_loop(char const* s, +PUBNUB_EXTERN void PUBNUB_NORETURN pubnub_assert_handler_loop(char const* s, char const* file, long line); /** This handler will print a message formed from the parameters and then abort (exit, end) the process. Useful for testing. */ -void PUBNUB_NORETURN pubnub_assert_handler_abort(char const* s, +PUBNUB_EXTERN void PUBNUB_NORETURN pubnub_assert_handler_abort(char const* s, char const* file, long line); @@ -250,7 +251,7 @@ void PUBNUB_NORETURN pubnub_assert_handler_abort(char const* s, "noreturn" attribute (and we know that and use it), you'll get a warning or error and will need to ignore or disable it. */ -void pubnub_assert_handler_printf(char const* s, char const* file, long line); +PUBNUB_EXTERN void pubnub_assert_handler_printf(char const* s, char const* file, long line); #define PUBNUB_CTASRT2(pre, post, lex) pre##post##lex diff --git a/core/pubnub_auto_heartbeat.h b/core/pubnub_auto_heartbeat.h index a948bc3e..d01479b1 100644 --- a/core/pubnub_auto_heartbeat.h +++ b/core/pubnub_auto_heartbeat.h @@ -3,6 +3,9 @@ #define INC_PUBNUB_AUTO_HEARTBEAT #if PUBNUB_USE_AUTO_HEARTBEAT + +#include "lib/pb_extern.h" + /** Enables periodical heartbeats that keep presence on subscribed channels and channel groups for user id provided in @p pb context and sets chosen heartbeat period. Initially auto heartbeat on @p pb context is disabled. @@ -20,7 +23,7 @@ @param period_sec Auto heartbeat thumping period in seconds @return 0 on success, -1 otherwise */ -int pubnub_enable_auto_heartbeat(pubnub_t* pb, size_t period_sec); +PUBNUB_EXTERN int pubnub_enable_auto_heartbeat(pubnub_t* pb, size_t period_sec); /** Changes auto heartbeat thumping period. If auto heartbeat is desabled on the @p pb context the period wan't be changed and function returns error. @@ -28,19 +31,19 @@ int pubnub_enable_auto_heartbeat(pubnub_t* pb, size_t period_sec); @param period_sec Auto heartbeat thumping period in seconds @return 0 on success, -1 otherwise */ -int pubnub_set_heartbeat_period(pubnub_t* pb, size_t period_sec); +PUBNUB_EXTERN int pubnub_set_heartbeat_period(pubnub_t* pb, size_t period_sec); /** Disables auto heartbeat on the @p pb context. */ -void pubnub_disable_auto_heartbeat(pubnub_t* pb); +PUBNUB_EXTERN void pubnub_disable_auto_heartbeat(pubnub_t* pb); /** Returns if auto heartbeat is enabled on the @p pb context. */ -bool pubnub_is_auto_heartbeat_enabled(pubnub_t* pb); +PUBNUB_EXTERN bool pubnub_is_auto_heartbeat_enabled(pubnub_t* pb); /** Releases all allocated heartbeat thumpers. */ -void pubnub_heartbeat_free_thumpers(void); +PUBNUB_EXTERN void pubnub_heartbeat_free_thumpers(void); #else #define pubnub_enable_auto_heartbeat(pb, period_sec) -1 #define pubnub_set_heartbeat_period(pb, period_sec) -1 diff --git a/core/pubnub_blocking_io.h b/core/pubnub_blocking_io.h index 73d7ef8a..78de9fa4 100644 --- a/core/pubnub_blocking_io.h +++ b/core/pubnub_blocking_io.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" #include @@ -50,7 +51,7 @@ @return 0: OK, otherwise: error, non-blocking I/O not supported */ -int pubnub_set_non_blocking_io(pubnub_t *p); +PUBNUB_EXTERN int pubnub_set_non_blocking_io(pubnub_t *p); /** Sets the usage of blocking I/O for a context. If blocking @@ -83,8 +84,7 @@ int pubnub_set_non_blocking_io(pubnub_t *p); @return 0: OK, otherwise: error, blocking I/O not supported */ -int pubnub_set_blocking_io(pubnub_t *p); - +PUBNUB_EXTERN int pubnub_set_blocking_io(pubnub_t *p); #endif /* defined INC_PUBNUB_BLOCKING_IO */ diff --git a/core/pubnub_callback_subscribe_loop.h b/core/pubnub_callback_subscribe_loop.h index 31b3da76..e9a1f725 100644 --- a/core/pubnub_callback_subscribe_loop.h +++ b/core/pubnub_callback_subscribe_loop.h @@ -5,6 +5,7 @@ #include "pubnub_api_types.h" #include "pubnub_coreapi_ex.h" +#include "lib/pb_extern.h" /** @file pubnub_callback_subscribe_loop.h @@ -42,7 +43,7 @@ typedef void (*pubnub_subloop_callback_t)(pubnub_t *pbp, char const* message, en @retval NULL Failed to create a descriptor @result The subscribe loop descriptor created */ -pubnub_subloop_t* pubnub_subloop_define(pubnub_t *p, char const *channel, struct pubnub_subscribe_options options, pubnub_subloop_callback_t cb); +PUBNUB_EXTERN pubnub_subloop_t* pubnub_subloop_define(pubnub_t *p, char const *channel, struct pubnub_subscribe_options options, pubnub_subloop_callback_t cb); /** Starts a subscribe loop. @@ -67,7 +68,7 @@ pubnub_subloop_t* pubnub_subloop_define(pubnub_t *p, char const *channel, struct @retval PNR_OK Success @retval other Indicates the reason for failure */ -enum pubnub_res pubnub_subloop_start(pubnub_subloop_t* pbsld); +PUBNUB_EXTERN enum pubnub_res pubnub_subloop_start(pubnub_subloop_t* pbsld); /** Stops a subscribe loop. If loop is calling the callback ("delivering message(s)"), stop will be done once that is @@ -80,10 +81,10 @@ enum pubnub_res pubnub_subloop_start(pubnub_subloop_t* pbsld); @param[in] pbsld The subscribe loop descriptor */ -void pubnub_subloop_stop(pubnub_subloop_t* pbsld); +PUBNUB_EXTERN void pubnub_subloop_stop(pubnub_subloop_t* pbsld); /** Undefines - releases the subscribe loop descriptor */ -void pubnub_subloop_undef(pubnub_subloop_t* pbsld); +PUBNUB_EXTERN void pubnub_subloop_undef(pubnub_subloop_t* pbsld); #endif /* !defined INC_PUBNUB_CALLBACK_SUBSCRIBE_LOOP */ diff --git a/core/pubnub_ccore.h b/core/pubnub_ccore.h index a917c85b..b3d6fa8f 100644 --- a/core/pubnub_ccore.h +++ b/core/pubnub_ccore.h @@ -3,6 +3,7 @@ #define INC_PUBNUB_CCORE #include "pubnub_api_types.h" +#include "lib/pb_extern.h" #include @@ -28,7 +29,7 @@ struct pbcc_context; @param p The Pubnub C core context to parse the response "in" @return 0: OK, -1: error (invalid response) */ -enum pubnub_res pbcc_parse_time_response(struct pbcc_context* p); +PUBNUB_EXTERN enum pubnub_res pbcc_parse_time_response(struct pbcc_context* p); /** Parses the string received as a response for a history v2 operation (transaction). This checks if the response is valid, @@ -38,7 +39,7 @@ enum pubnub_res pbcc_parse_time_response(struct pbcc_context* p); @param p The Pubnub C core context to parse the response "in" @return 0: OK, -1: error (invalid response) */ -enum pubnub_res pbcc_parse_history_response(struct pbcc_context* p); +PUBNUB_EXTERN enum pubnub_res pbcc_parse_history_response(struct pbcc_context* p); /** Parses the string received as a response for a presence query operation (transaction). Presence query is done on several @@ -50,7 +51,7 @@ enum pubnub_res pbcc_parse_history_response(struct pbcc_context* p); @param p The Pubnub C core context to parse the response "in" @return 0: OK, -1: error (invalid response) */ -enum pubnub_res pbcc_parse_presence_response(struct pbcc_context* p); +PUBNUB_EXTERN enum pubnub_res pbcc_parse_presence_response(struct pbcc_context* p); /** Parses the string received as a response for a channel-registry operation (transaction). It is done on several user requests @@ -64,24 +65,24 @@ enum pubnub_res pbcc_parse_presence_response(struct pbcc_context* p); @return The result of the parsing, expressed as the "Pubnub result" enum */ -enum pubnub_res pbcc_parse_channel_registry_response(struct pbcc_context* p); +PUBNUB_EXTERN enum pubnub_res pbcc_parse_channel_registry_response(struct pbcc_context* p); /** Prepares the Leave operation (transaction), mostly by formatting the URI of the HTTP request. */ -enum pubnub_res pbcc_leave_prep(struct pbcc_context* p, +PUBNUB_EXTERN enum pubnub_res pbcc_leave_prep(struct pbcc_context* p, const char* channel, const char* channel_group); /** Prepares the Time operation (transaction), mostly by formatting the URI of the HTTP request. */ -enum pubnub_res pbcc_time_prep(struct pbcc_context* p); +PUBNUB_EXTERN enum pubnub_res pbcc_time_prep(struct pbcc_context* p); /** Prepares the History v2 operation (transaction), mostly by formatting the URI of the HTTP request. */ -enum pubnub_res pbcc_history_prep(struct pbcc_context* p, +PUBNUB_EXTERN enum pubnub_res pbcc_history_prep(struct pbcc_context* p, const char* channel, unsigned count, bool include_token, @@ -94,14 +95,14 @@ enum pubnub_res pbcc_history_prep(struct pbcc_context* p, /** Prepares the Heartbeat operation (transaction), mostly by formatting the URI of the HTTP request. */ -enum pubnub_res pbcc_heartbeat_prep(struct pbcc_context* p, +PUBNUB_EXTERN enum pubnub_res pbcc_heartbeat_prep(struct pbcc_context* p, const char* channel, const char* channel_group); /** Prepares the Here-now operation (transaction), mostly by formatting the URI of the HTTP request. */ -enum pubnub_res pbcc_here_now_prep(struct pbcc_context* p, +PUBNUB_EXTERN enum pubnub_res pbcc_here_now_prep(struct pbcc_context* p, const char* channel, const char* channel_group, enum pubnub_tribool disable_uuids, @@ -110,12 +111,12 @@ enum pubnub_res pbcc_here_now_prep(struct pbcc_context* p, /** Prepares the Where-now operation (transaction), mostly by formatting the URI of the HTTP request. */ -enum pubnub_res pbcc_where_now_prep(struct pbcc_context* p, const char* uuid); +PUBNUB_EXTERN enum pubnub_res pbcc_where_now_prep(struct pbcc_context* p, const char* uuid); /** Prepares the Set state operation (transaction), mostly by formatting the URI of the HTTP request. */ -enum pubnub_res pbcc_set_state_prep(struct pbcc_context* p, +PUBNUB_EXTERN enum pubnub_res pbcc_set_state_prep(struct pbcc_context* p, char const* channel, char const* channel_group, const char* uuid, @@ -124,7 +125,7 @@ enum pubnub_res pbcc_set_state_prep(struct pbcc_context* p, /** Prepares the Get state operation (transaction), mostly by formatting the URI of the HTTP request. */ -enum pubnub_res pbcc_state_get_prep(struct pbcc_context* p, +PUBNUB_EXTERN enum pubnub_res pbcc_state_get_prep(struct pbcc_context* p, char const* channel, char const* channel_group, const char* uuid); @@ -132,13 +133,13 @@ enum pubnub_res pbcc_state_get_prep(struct pbcc_context* p, /** Preparse the Remove channel group operation (transaction) , mostly by formatting the URI of the HTTP request. */ -enum pubnub_res pbcc_remove_channel_group_prep(struct pbcc_context* p, +PUBNUB_EXTERN enum pubnub_res pbcc_remove_channel_group_prep(struct pbcc_context* p, char const* channel_group); /** Preparse an operation (transaction) against the channel registry, mostly by formatting the URI of the HTTP request. */ -enum pubnub_res pbcc_channel_registry_prep(struct pbcc_context* p, +PUBNUB_EXTERN enum pubnub_res pbcc_channel_registry_prep(struct pbcc_context* p, char const* channel_group, char const* param, char const* channel); diff --git a/core/pubnub_coreapi.h b/core/pubnub_coreapi.h index 48030237..e803c828 100644 --- a/core/pubnub_coreapi.h +++ b/core/pubnub_coreapi.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" #include @@ -67,7 +68,7 @@ typedef struct pubnub_char_mem_block pubnub_chamebl_t; @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_leave(pubnub_t *p, const char *channel, const char *channel_group); +PUBNUB_EXTERN enum pubnub_res pubnub_leave(pubnub_t *p, const char *channel, const char *channel_group); /** Get the current Pubnub time token . This actually means "initiate a time transaction". Since time token is in the response to most @@ -85,7 +86,7 @@ enum pubnub_res pubnub_leave(pubnub_t *p, const char *channel, const char *chann @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_time(pubnub_t *p); +PUBNUB_EXTERN enum pubnub_res pubnub_time(pubnub_t *p); /** Get the message history for the @p channel. This actually means "initiate a history transaction/operation". @@ -115,7 +116,7 @@ enum pubnub_res pubnub_time(pubnub_t *p); @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_history(pubnub_t *p, const char *channel, unsigned count, bool include_token); +PUBNUB_EXTERN enum pubnub_res pubnub_history(pubnub_t *p, const char *channel, unsigned count, bool include_token); /** Inform Pubnub that we're still working on @p channel and/or @p channel_group. This actually means "initiate a heartbeat @@ -151,7 +152,7 @@ enum pubnub_res pubnub_history(pubnub_t *p, const char *channel, unsigned count, @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_heartbeat(pubnub_t *p, const char* channel, const char* channel_group); +PUBNUB_EXTERN enum pubnub_res pubnub_heartbeat(pubnub_t *p, const char* channel, const char* channel_group); /** Get the currently present users on a @p channel and/or @p channel_group. This actually means "initiate a here_now @@ -196,7 +197,7 @@ enum pubnub_res pubnub_heartbeat(pubnub_t *p, const char* channel, const char* c @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_here_now(pubnub_t *p, const char *channel, const char *channel_group); +PUBNUB_EXTERN enum pubnub_res pubnub_here_now(pubnub_t *p, const char *channel, const char *channel_group); /** Get the currently present users on all channel. This actually @@ -214,7 +215,7 @@ enum pubnub_res pubnub_here_now(pubnub_t *p, const char *channel, const char *ch @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_global_here_now(pubnub_t *p); +PUBNUB_EXTERN enum pubnub_res pubnub_global_here_now(pubnub_t *p); /** Get the currently present users on a @p channel and/or @p channel_group. This actually means "initiate a here_now @@ -239,7 +240,7 @@ enum pubnub_res pubnub_global_here_now(pubnub_t *p); @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_where_now(pubnub_t *p, const char *user_id); +PUBNUB_EXTERN enum pubnub_res pubnub_where_now(pubnub_t *p, const char *user_id); /** Sets some state for the @p channel and/or @channel_group for a user, identified by @p uuid. This actually means "initiate a set @@ -277,7 +278,7 @@ enum pubnub_res pubnub_where_now(pubnub_t *p, const char *user_id); @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_set_state(pubnub_t *p, char const *channel, char const *channel_group, const char *user_id, char const *state); +PUBNUB_EXTERN enum pubnub_res pubnub_set_state(pubnub_t *p, char const *channel, char const *channel_group, const char *user_id, char const *state); /** Gets some state for the @p channel and/or @p channel_group for a @@ -313,7 +314,7 @@ enum pubnub_res pubnub_set_state(pubnub_t *p, char const *channel, char const *c @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_state_get(pubnub_t *p, char const *channel, char const *channel_group, const char *user_id); +PUBNUB_EXTERN enum pubnub_res pubnub_state_get(pubnub_t *p, char const *channel, char const *channel_group, const char *user_id); /** Removes a @p channel_group and all its channels. This actually means "initiate a remove_channel_group transaction". It can be @@ -335,7 +336,7 @@ enum pubnub_res pubnub_state_get(pubnub_t *p, char const *channel, char const *c @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_remove_channel_group(pubnub_t *p, char const *channel_group); +PUBNUB_EXTERN enum pubnub_res pubnub_remove_channel_group(pubnub_t *p, char const *channel_group); /** Removes a @p channel from the @p channel_group . This actually means "initiate a remove_channel_from_channel_group @@ -362,7 +363,7 @@ enum pubnub_res pubnub_remove_channel_group(pubnub_t *p, char const *channel_gro @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_remove_channel_from_group(pubnub_t *p, char const *channel, char const *channel_group); +PUBNUB_EXTERN enum pubnub_res pubnub_remove_channel_from_group(pubnub_t *p, char const *channel, char const *channel_group); /** Adds a @p channel to the @p channel_group . This actually means "initiate a add_channel_to_channel_group transaction". It can be @@ -388,7 +389,7 @@ enum pubnub_res pubnub_remove_channel_from_group(pubnub_t *p, char const *channe @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_add_channel_to_group(pubnub_t *p, char const *channel, char const *channel_group); +PUBNUB_EXTERN enum pubnub_res pubnub_add_channel_to_group(pubnub_t *p, char const *channel, char const *channel_group); /** Lists all channels of a @p channel_group. This actually means "initiate a list_channel_group transaction". It can be @@ -412,7 +413,7 @@ enum pubnub_res pubnub_add_channel_to_group(pubnub_t *p, char const *channel, ch @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_list_channel_group(pubnub_t *p, char const *channel_group); +PUBNUB_EXTERN enum pubnub_res pubnub_list_channel_group(pubnub_t *p, char const *channel_group); /** Checks if a transaction can be started on @p pb context. In other words, checks if previous transaction is finished. @@ -420,7 +421,7 @@ enum pubnub_res pubnub_list_channel_group(pubnub_t *p, char const *channel_group @retval true can start new transaction @retval false otherwise (cannot start a new transaction) */ -bool pubnub_can_start_transaction(pubnub_t* pb); +PUBNUB_EXTERN bool pubnub_can_start_transaction(pubnub_t* pb); /** Extracts 'error_message' attribute value from the transaction response on the context @p pb into @p o_msg. @@ -429,13 +430,13 @@ bool pubnub_can_start_transaction(pubnub_t* pb); @retval 0 error message successfully picked up @retval -1 on error(not found, or transaction still in progress on the context) */ -int pubnub_get_error_message(pubnub_t* pb, pubnub_chamebl_t* o_msg); +PUBNUB_EXTERN int pubnub_get_error_message(pubnub_t* pb, pubnub_chamebl_t* o_msg); /** Returns body from the transaction response on the context @p pb into @p o_msg. Can be called for any response @retval 0 in case of transaction is not in progress @retval -1 if transaction is still in progress on the context */ -int pubnub_last_http_response_body(pubnub_t* pb, pubnub_chamebl_t* o_msg); +PUBNUB_EXTERN int pubnub_last_http_response_body(pubnub_t* pb, pubnub_chamebl_t* o_msg); #endif /* defined INC_PUBNUB_COREAPI */ diff --git a/core/pubnub_coreapi_ex.c b/core/pubnub_coreapi_ex.c index 07ae2850..e746eda0 100644 --- a/core/pubnub_coreapi_ex.c +++ b/core/pubnub_coreapi_ex.c @@ -310,5 +310,5 @@ enum pubnub_res pubnub_set_state_ex(pubnub_t *p, : pubnub_set_state(p, channel, opts.channel_group, opts.user_id, state); } -#endif PUBNUB_QT +#endif /* PUBNUB_QT */ diff --git a/core/pubnub_coreapi_ex.h b/core/pubnub_coreapi_ex.h index bbfacd9c..ceec8bef 100644 --- a/core/pubnub_coreapi_ex.h +++ b/core/pubnub_coreapi_ex.h @@ -4,7 +4,7 @@ #include "pubnub_api_types.h" -#include "pubnub_memory_block.h" +#include "lib/pb_extern.h" #include #include @@ -67,7 +67,7 @@ struct pubnub_publish_options { Will set `store = true`, `cipher_key = NULL`, `replicate = true`, `meta = NULL` and `method = pubnubPublishViaGet` */ -struct pubnub_publish_options pubnub_publish_defopts(void); +PUBNUB_EXTERN struct pubnub_publish_options pubnub_publish_defopts(void); /** The extended publish V1. Basically the same as pubnub_publish(), but with added optional parameters in @p opts. @@ -84,7 +84,7 @@ struct pubnub_publish_options pubnub_publish_defopts(void); @param opt Publish V1 options @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_publish_ex(pubnub_t* p, +PUBNUB_EXTERN enum pubnub_res pubnub_publish_ex(pubnub_t* p, const char* channel, const char* message, struct pubnub_publish_options opts); @@ -107,7 +107,7 @@ struct pubnub_subscribe_options { set `channel_group = NULL`, `heartbeat` to default heartbeat value. */ -struct pubnub_subscribe_options pubnub_subscribe_defopts(void); +PUBNUB_EXTERN struct pubnub_subscribe_options pubnub_subscribe_defopts(void); /** The extended subscribe. Basically the same as pubnub_subscribe() but with options (except @p channel) given in @p opts. @@ -129,7 +129,7 @@ struct pubnub_subscribe_options pubnub_subscribe_defopts(void); @param opt Subscribe options @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_subscribe_ex(pubnub_t* p, +PUBNUB_EXTERN enum pubnub_res pubnub_subscribe_ex(pubnub_t* p, const char* channel, struct pubnub_subscribe_options opts); @@ -151,7 +151,7 @@ struct pubnub_here_now_options { set `channel_group = NULL`, `disable_uuids=true` and `state = false`. */ -struct pubnub_here_now_options pubnub_here_now_defopts(void); +PUBNUB_EXTERN struct pubnub_here_now_options pubnub_here_now_defopts(void); /** The extended "here now". It is basically the same as the pubnub_here_now(), just adding a few options that will be sent. @@ -171,7 +171,7 @@ struct pubnub_here_now_options pubnub_here_now_defopts(void); @param opt Here-now options for this here-now @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_here_now_ex(pubnub_t* p, +PUBNUB_EXTERN enum pubnub_res pubnub_here_now_ex(pubnub_t* p, const char* channel, struct pubnub_here_now_options opt); @@ -184,7 +184,7 @@ enum pubnub_res pubnub_here_now_ex(pubnub_t* p, @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_global_here_now_ex(pubnub_t* p, +PUBNUB_EXTERN enum pubnub_res pubnub_global_here_now_ex(pubnub_t* p, struct pubnub_here_now_options opt); @@ -237,7 +237,7 @@ struct pubnub_history_options { It's best to always call it to initialize the #pubnub_history_options, since it has several parameters. */ -struct pubnub_history_options pubnub_history_defopts(void); +PUBNUB_EXTERN struct pubnub_history_options pubnub_history_defopts(void); /** The extended "history". It is basically the same as the pubnub_history(), just adding a few options that will be sent. @@ -254,7 +254,7 @@ struct pubnub_history_options pubnub_history_defopts(void); @param opt Options for this history transaction @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_history_ex(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_history_ex(pubnub_t* pb, char const* channel, struct pubnub_history_options opt); @@ -280,7 +280,7 @@ struct pubnub_set_state_options { /** This returns the default options for set_state transactions. Will set `channel_group = NULL`, `user_id = NULL` and `heartbeat to false` */ -struct pubnub_set_state_options pubnub_set_state_defopts(void); +PUBNUB_EXTERN struct pubnub_set_state_options pubnub_set_state_defopts(void); /** The extended set_state. Basically the same as pubnub_set_state() but with options (except @p channel) given in @p opts. @@ -302,7 +302,7 @@ struct pubnub_set_state_options pubnub_set_state_defopts(void); @param opt Subscribe options @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_set_state_ex(pubnub_t* p, +PUBNUB_EXTERN enum pubnub_res pubnub_set_state_ex(pubnub_t* p, const char* channel, const char* state, struct pubnub_set_state_options opts); diff --git a/core/pubnub_create.h b/core/pubnub_create.h index b0994e6c..77519878 100644 --- a/core/pubnub_create.h +++ b/core/pubnub_create.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" /** @file pubnub_create.h @@ -16,7 +17,7 @@ * on the returned context. If pubnub_alloc() fails, it just returns NULL. * @pre keysub != NULL */ -pubnub_t *pubnub_create(char const *pubkey, char const *keysub); +PUBNUB_EXTERN pubnub_t *pubnub_create(char const *pubkey, char const *keysub); #endif /* !defined INC_PUBNUB_CREATE */ diff --git a/core/pubnub_crypto.h b/core/pubnub_crypto.h index cd0e7693..7e702c73 100644 --- a/core/pubnub_crypto.h +++ b/core/pubnub_crypto.h @@ -6,6 +6,7 @@ #include "core/pubnub_api_types.h" #include "core/pubnub_memory_block.h" #include "core/pbcc_crypto.h" +#include "lib/pb_extern.h" /** @@ -15,7 +16,7 @@ @return PNR_OK on success, otherwise an error code. */ -enum pubnub_res pubnub_set_cipher_key(pubnub_t *p, char const *cipher_key); +PUBNUB_EXTERN enum pubnub_res pubnub_set_cipher_key(pubnub_t *p, char const *cipher_key); /** Sets @p secret_key to be used with the Pubnub context @p p. @@ -30,7 +31,7 @@ enum pubnub_res pubnub_set_cipher_key(pubnub_t *p, char const *cipher_key); use the secret key (i.e. do no encrpytion/decryption) @param PNR_OK or a value indicating an error */ -enum pubnub_res pubnub_set_secret_key(pubnub_t *p, char const* secret_key); +PUBNUB_EXTERN enum pubnub_res pubnub_set_secret_key(pubnub_t *p, char const* secret_key); /** Encrypts a message @p msg to a Base64 encoded @p base64_str, which @@ -48,13 +49,13 @@ enum pubnub_res pubnub_set_secret_key(pubnub_t *p, char const* secret_key); @param n The size of the string @return 0: OK, -1: error */ -PUBNUB_DEPRECATED int pubnub_encrypt(char const *cipher_key, pubnub_bymebl_t msg, char *base64_str, size_t *n); +PUBNUB_EXTERN PUBNUB_DEPRECATED int pubnub_encrypt(char const *cipher_key, pubnub_bymebl_t msg, char *base64_str, size_t *n); /** Similar to pubnub_encrypt() - but this function doesn't allocate memory, it uses the memory provided by @p buffer for its "working memory". */ -PUBNUB_DEPRECATED int pubnub_encrypt_buffered(char const *cipher_key, pubnub_bymebl_t msg, char *base64_str, size_t *n, pubnub_bymebl_t buffer); +PUBNUB_EXTERN PUBNUB_DEPRECATED int pubnub_encrypt_buffered(char const *cipher_key, pubnub_bymebl_t msg, char *base64_str, size_t *n, pubnub_bymebl_t buffer); /** Decrypts a message from a Base64 encoded string @p base64_str to user-allocated memory @p data. On input @p data->size holds the @@ -73,12 +74,12 @@ PUBNUB_DEPRECATED int pubnub_encrypt_buffered(char const *cipher_key, pubnub_bym @param data User allocated memory block to write the decrypted contents to @return 0: OK, -1: error */ -PUBNUB_DEPRECATED int pubnub_decrypt(char const *cipher_key, char const *base64_str, pubnub_bymebl_t *data); +PUBNUB_EXTERN PUBNUB_DEPRECATED int pubnub_decrypt(char const *cipher_key, char const *base64_str, pubnub_bymebl_t *data); /** Similar to pubnub_decrypt(), but never allocates memory - it uses the memory provided by @p buffer as its "working memory". */ -PUBNUB_DEPRECATED int pubnub_decrypt_buffered(char const *cipher_key, char const *base64_str, pubnub_bymebl_t *data, pubnub_bymebl_t *buffer); +PUBNUB_EXTERN PUBNUB_DEPRECATED int pubnub_decrypt_buffered(char const *cipher_key, char const *base64_str, pubnub_bymebl_t *data, pubnub_bymebl_t *buffer); /** Similar to pubnub_decrpyt(), but this will allocate the memory to write the decrypted contents to and return it as the result. @@ -88,7 +89,7 @@ PUBNUB_DEPRECATED int pubnub_decrypt_buffered(char const *cipher_key, char const @result Memory block (pointer and size) of the decoded and decrypted message. On failure, pointer will be NULL and size is undefined. */ -PUBNUB_DEPRECATED pubnub_bymebl_t pubnub_decrypt_alloc(char const *cipher_key, char const *base64_str); +PUBNUB_EXTERN PUBNUB_DEPRECATED pubnub_bymebl_t pubnub_decrypt_alloc(char const *cipher_key, char const *base64_str); /** Decrypts the next message in the context @p p using the key @@ -115,7 +116,7 @@ PUBNUB_DEPRECATED pubnub_bymebl_t pubnub_decrypt_alloc(char const *cipher_key, c point to be made is that it also does some memory management (allocting and deallocating). */ -PUBNUB_DEPRECATED enum pubnub_res pubnub_get_decrypted(pubnub_t *pb, char const* cipher_key, char *s, size_t *n); +PUBNUB_EXTERN PUBNUB_DEPRECATED enum pubnub_res pubnub_get_decrypted(pubnub_t *pb, char const* cipher_key, char *s, size_t *n); /** This function is very similar to pubnub_get_decrypted(), but it allocates the (memory for the) decrypted string and returns it as @@ -132,7 +133,7 @@ PUBNUB_DEPRECATED enum pubnub_res pubnub_get_decrypted(pubnub_t *pb, char const* On failure, a NULL pointer is returned. */ -PUBNUB_DEPRECATED pubnub_bymebl_t pubnub_get_decrypted_alloc(pubnub_t *pb, char const* cipher_key); +PUBNUB_EXTERN PUBNUB_DEPRECATED pubnub_bymebl_t pubnub_get_decrypted_alloc(pubnub_t *pb, char const* cipher_key); /** Publishes the @p message on @p channel in the context @p p encrypted with the key @p cipher_key @@ -145,26 +146,26 @@ PUBNUB_DEPRECATED pubnub_bymebl_t pubnub_get_decrypted_alloc(pubnub_t *pb, char opts.cipher_key = cipher_key;; return pubnub_publish_ex(p, channel, message, opts); */ -PUBNUB_DEPRECATED enum pubnub_res pubnub_publish_encrypted(pubnub_t *p, char const* channel, char const* message, char const* cipher_key); +PUBNUB_EXTERN PUBNUB_DEPRECATED enum pubnub_res pubnub_publish_encrypted(pubnub_t *p, char const* channel, char const* message, char const* cipher_key); /** Get the buffer size required to encode an array with the given number of bytes. */ -int base64_max_size(int encode_this_many_bytes); +PUBNUB_EXTERN int base64_max_size(int encode_this_many_bytes); /** Base64 encoding. Returns non-zero when the provided buffer is too small to hold the encoded string. */ -int base64encode(char* result, int max_size, const void* b64_encode_this, int encode_this_many_bytes); +PUBNUB_EXTERN int base64encode(char* result, int max_size, const void* b64_encode_this, int encode_this_many_bytes); /** Cryptographic message signing for PAM. The caller is responsible for freeing the returned pointer. */ -char* pn_pam_hmac_sha256_sign(char const* key, char const* message); +PUBNUB_EXTERN char* pn_pam_hmac_sha256_sign(char const* key, char const* message); -enum pubnub_res pn_gen_pam_v2_sign(pubnub_t* p, char const* qs_to_sign, char const* partial_url, char* signature); -enum pubnub_res pn_gen_pam_v3_sign(pubnub_t* p, char const* qs_to_sign, char const* partial_url, char const* msg, char* signature); +PUBNUB_EXTERN enum pubnub_res pn_gen_pam_v2_sign(pubnub_t* p, char const* qs_to_sign, char const* partial_url, char* signature); +PUBNUB_EXTERN enum pubnub_res pn_gen_pam_v3_sign(pubnub_t* p, char const* qs_to_sign, char const* partial_url, char const* msg, char* signature); /** Prepare the aes cbc crypto module for use. @@ -180,7 +181,7 @@ enum pubnub_res pn_gen_pam_v3_sign(pubnub_t* p, char const* qs_to_sign, char con @return Pointer to the aes cbc crypto module structure. */ -struct pubnub_crypto_provider_t *pubnub_crypto_aes_cbc_module_init(const uint8_t* cipher_key); +PUBNUB_EXTERN struct pubnub_crypto_provider_t *pubnub_crypto_aes_cbc_module_init(const uint8_t* cipher_key); /** @@ -194,7 +195,7 @@ struct pubnub_crypto_provider_t *pubnub_crypto_aes_cbc_module_init(const uint8_t @return Pointer to the aes cbc crypto module structure. */ -struct pubnub_crypto_provider_t *pubnub_crypto_legacy_module_init(const uint8_t* cipher_key); +PUBNUB_EXTERN struct pubnub_crypto_provider_t *pubnub_crypto_legacy_module_init(const uint8_t* cipher_key); /** @@ -209,7 +210,7 @@ struct pubnub_crypto_provider_t *pubnub_crypto_legacy_module_init(const uint8_t* @return Pointer to the crypto module structure. */ -struct pubnub_crypto_provider_t *pubnub_crypto_module_init(struct pubnub_cryptor_t *default_algorithm, struct pubnub_cryptor_t *algorithms, size_t n_algorithms); +PUBNUB_EXTERN struct pubnub_crypto_provider_t *pubnub_crypto_module_init(struct pubnub_cryptor_t *default_algorithm, struct pubnub_cryptor_t *algorithms, size_t n_algorithms); /** @@ -221,7 +222,7 @@ struct pubnub_crypto_provider_t *pubnub_crypto_module_init(struct pubnub_cryptor @param pubnub Pointer to the pubnub context. @param crypto_provider Pointer to the crypto provider to use. */ -void pubnub_set_crypto_module(pubnub_t *pubnub, struct pubnub_crypto_provider_t *crypto_provider); +PUBNUB_EXTERN void pubnub_set_crypto_module(pubnub_t *pubnub, struct pubnub_crypto_provider_t *crypto_provider); /** Get the crypto module used by the pubnub context. @@ -233,6 +234,6 @@ void pubnub_set_crypto_module(pubnub_t *pubnub, struct pubnub_crypto_provider_t @return Pointer to the crypto provider used by the pubnub context. */ -pubnub_crypto_provider_t *pubnub_get_crypto_module(pubnub_t *pubnub); +PUBNUB_EXTERN pubnub_crypto_provider_t *pubnub_get_crypto_module(pubnub_t *pubnub); #endif /* defined INC_PUBNUB_CRYPTO */ diff --git a/core/pubnub_dns_servers.h b/core/pubnub_dns_servers.h index 7a9944cf..4a742990 100644 --- a/core/pubnub_dns_servers.h +++ b/core/pubnub_dns_servers.h @@ -1,7 +1,9 @@ /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */ #if !defined INC_PUBNUB_DNS_SERVERS #define INC_PUBNUB_DNS_SERVERS + #include + /** IPv4 Address, in binary format. */ struct pubnub_ipv4_address { @@ -26,6 +28,7 @@ struct pubnub_ipv6_address { #if PUBNUB_SET_DNS_SERVERS #include +#include "lib/pb_extern.h" /** Sets the primary DNS server IPv4 address to use when resolving the Pubnub origin, in binary form(network order). @@ -38,7 +41,7 @@ struct pubnub_ipv6_address { @retval -1 error: Pubnub DNS module not used and can't set the primary Ipv4 DNS server */ -int pubnub_dns_set_primary_server_ipv4(struct pubnub_ipv4_address ipv4); +PUBNUB_EXTERN int pubnub_dns_set_primary_server_ipv4(struct pubnub_ipv4_address ipv4); /** Sets the secondary DNS server IPv4 address to use when resolving the Pubnub origin, in binary form(network order). @@ -54,7 +57,7 @@ int pubnub_dns_set_primary_server_ipv4(struct pubnub_ipv4_address ipv4); @retval -1 error: Pubnub DNS module not used and can't set the secondary Ipv4 DNS server */ -int pubnub_dns_set_secondary_server_ipv4(struct pubnub_ipv4_address ipv4); +PUBNUB_EXTERN int pubnub_dns_set_secondary_server_ipv4(struct pubnub_ipv4_address ipv4); /** Sets the primary DNS server IPv4 address from the corresponding 'numbers-and-dots' notation string to use when resolving the Pubnub origin. @@ -67,7 +70,7 @@ int pubnub_dns_set_secondary_server_ipv4(struct pubnub_ipv4_address ipv4); @retval -1 error: Pubnub DNS module not used, or can't set the primary Ipv4 DNS server */ -int pubnub_dns_set_primary_server_ipv4_str(char const* ipv4_str); +PUBNUB_EXTERN int pubnub_dns_set_primary_server_ipv4_str(char const* ipv4_str); /** Sets the secondary DNS server IPv4 address from the corresponding 'numbers-and-dots' notation string to use when resolving the Pubnub origin. @@ -83,7 +86,7 @@ int pubnub_dns_set_primary_server_ipv4_str(char const* ipv4_str); @retval -1 error: Pubnub DNS module not used, or can't set the secondary Ipv4 DNS server */ -int pubnub_dns_set_secondary_server_ipv4_str(char const* ipv4_str); +PUBNUB_EXTERN int pubnub_dns_set_secondary_server_ipv4_str(char const* ipv4_str); /** Reads the currently set primary DNS server's IPv4 address, in binary form(network order). @@ -93,7 +96,7 @@ int pubnub_dns_set_secondary_server_ipv4_str(char const* ipv4_str); @retval -1 error: Pubnub DNS module not used and can't read the primary Ipv4 DNS server */ -int pubnub_get_dns_primary_server_ipv4(struct pubnub_ipv4_address* o_ipv4); +PUBNUB_EXTERN int pubnub_get_dns_primary_server_ipv4(struct pubnub_ipv4_address* o_ipv4); /** Reads the currently set secondary DNS server's IPv4 address, in binary form(network order). @@ -103,7 +106,7 @@ int pubnub_get_dns_primary_server_ipv4(struct pubnub_ipv4_address* o_ipv4); @retval -1 error: Pubnub DNS module not used and can't read the secondary Ipv4 DNS server */ -int pubnub_get_dns_secondary_server_ipv4(struct pubnub_ipv4_address* o_ipv4); +PUBNUB_EXTERN int pubnub_get_dns_secondary_server_ipv4(struct pubnub_ipv4_address* o_ipv4); /** Reads the DNS servers in the system configuration. Will read at most @p n servers, even if more are configured. Keep in @@ -123,7 +126,7 @@ int pubnub_get_dns_secondary_server_ipv4(struct pubnub_ipv4_address* o_ipv4); @retval -1: error, can't read DNS server configuration @retval otherwise: number of DNS servers read */ -int pubnub_dns_read_system_servers_ipv4(struct pubnub_ipv4_address* o_ipv4, +PUBNUB_EXTERN int pubnub_dns_read_system_servers_ipv4(struct pubnub_ipv4_address* o_ipv4, size_t n); #if PUBNUB_USE_IPV6 /** Sets the primary DNS server IPv6 address to use when @@ -137,7 +140,7 @@ int pubnub_dns_read_system_servers_ipv4(struct pubnub_ipv4_address* o_ipv4, @retval -1 error: Pubnub DNS module not used and can't set the primary Ipv6 DNS server */ -int pubnub_dns_set_primary_server_ipv6(struct pubnub_ipv6_address ipv6); +PUBNUB_EXTERN int pubnub_dns_set_primary_server_ipv6(struct pubnub_ipv6_address ipv6); /** Sets the secondary DNS server IPv6 address to use when resolving the Pubnub origin, in binary form(network order). @@ -153,7 +156,7 @@ int pubnub_dns_set_primary_server_ipv6(struct pubnub_ipv6_address ipv6); @retval -1 error: Pubnub DNS module not used and can't set the secondary Ipv6 DNS server */ -int pubnub_dns_set_secondary_server_ipv6(struct pubnub_ipv6_address ipv6); +PUBNUB_EXTERN int pubnub_dns_set_secondary_server_ipv6(struct pubnub_ipv6_address ipv6); /** Sets the primary DNS server IPv6 address from the corresponding 'numbers-and-colons' notation string to use when resolving the Pubnub origin. @@ -166,7 +169,7 @@ int pubnub_dns_set_secondary_server_ipv6(struct pubnub_ipv6_address ipv6); @retval -1 error: Pubnub DNS module not used, or can't set the primary Ipv6 DNS server */ -int pubnub_dns_set_primary_server_ipv6_str(char const* ipv6_str); +PUBNUB_EXTERN int pubnub_dns_set_primary_server_ipv6_str(char const* ipv6_str); /** Sets the secondary DNS server IPv6 address from the corresponding 'numbers-and-colons' notation string to use when resolving the Pubnub origin. @@ -182,7 +185,7 @@ int pubnub_dns_set_primary_server_ipv6_str(char const* ipv6_str); @retval -1 error: Pubnub DNS module not used and can't set the secondary Ipv6 DNS server */ -int pubnub_dns_set_secondary_server_ipv6_str(char const* ipv6_str); +PUBNUB_EXTERN int pubnub_dns_set_secondary_server_ipv6_str(char const* ipv6_str); /** Reads the currently set primary DNS server's IPv6 address, in binary form(network order). @@ -192,7 +195,7 @@ int pubnub_dns_set_secondary_server_ipv6_str(char const* ipv6_str); @retval -1 error: Pubnub DNS module not used and can't read the primary Ipv6 DNS server */ -int pubnub_get_dns_primary_server_ipv6(struct pubnub_ipv6_address* o_ipv6); +PUBNUB_EXTERN int pubnub_get_dns_primary_server_ipv6(struct pubnub_ipv6_address* o_ipv6); /** Reads the currently set secondary DNS server's IPv6 address, in binary form(network order). @@ -202,7 +205,7 @@ int pubnub_get_dns_primary_server_ipv6(struct pubnub_ipv6_address* o_ipv6); @retval -1 error: Pubnub DNS module not used and can't read the secondary Ipv6 DNS server */ -int pubnub_get_dns_secondary_server_ipv6(struct pubnub_ipv6_address* o_ipv6); +PUBNUB_EXTERN int pubnub_get_dns_secondary_server_ipv6(struct pubnub_ipv6_address* o_ipv6); #endif /* PUBNUB_USE_IPV6 */ #else diff --git a/core/pubnub_fetch_history.h b/core/pubnub_fetch_history.h index 77180d8f..13efa072 100644 --- a/core/pubnub_fetch_history.h +++ b/core/pubnub_fetch_history.h @@ -3,6 +3,7 @@ #define INC_PUBNUB_FETCH_HISTORY #include "pbcc_fetch_history.h" +#include "lib/pb_extern.h" /** Options for fetch history. */ struct pubnub_fetch_history_options { @@ -59,7 +60,7 @@ struct pubnub_fetch_history_options { It's best to always call it to initialize the #pubnub_fetch_history_options, since it has several parameters. */ -struct pubnub_fetch_history_options pubnub_fetch_history_defopts(void); +PUBNUB_EXTERN struct pubnub_fetch_history_options pubnub_fetch_history_defopts(void); /** The fetch history. It is basically the same as the @@ -77,10 +78,10 @@ struct pubnub_fetch_history_options pubnub_fetch_history_defopts(void); @param opt Options for this fetch history transaction @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_fetch_history(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_fetch_history(pubnub_t* pb, char const* channel, struct pubnub_fetch_history_options opt); -pubnub_chamebl_t pubnub_get_fetch_history(pubnub_t* pb); +PUBNUB_EXTERN pubnub_chamebl_t pubnub_get_fetch_history(pubnub_t* pb); #endif /* !defined INC_PUBNUB_FETCH_HISTORY */ diff --git a/core/pubnub_free_with_timeout.h b/core/pubnub_free_with_timeout.h index d8492480..71008f0b 100644 --- a/core/pubnub_free_with_timeout.h +++ b/core/pubnub_free_with_timeout.h @@ -2,6 +2,9 @@ #if !defined INC_PUBNUB_FREE_WITH_TIMEOUT #define INC_PUBNUB_FREE_WITH_TIMEOUT +#include "pubnub_api_types.h" +#include "lib/pb_extern.h" + /** Tries pubnub_free() in a tight loop until either: - it succeeds @@ -24,7 +27,7 @@ @retval 0 pubnub_free() succeeded @retval -1 failed to pubnub_free() in @p millisec */ -int pubnub_free_with_timeout(pubnub_t* pbp, unsigned millisec); +PUBNUB_EXTERN int pubnub_free_with_timeout(pubnub_t* pbp, unsigned millisec); #endif /* !defined INC_PUBNUB_FREE_WITH_TIMEOUT */ diff --git a/core/pubnub_generate_uuid.h b/core/pubnub_generate_uuid.h index a621a63d..e9463d4e 100644 --- a/core/pubnub_generate_uuid.h +++ b/core/pubnub_generate_uuid.h @@ -3,6 +3,7 @@ #define INC_PUBNUB_GENERATE_UUID #include +#include "lib/pb_extern.h" #define UUID_STRING_LENGTH 36 #define UUID_SIZE (UUID_STRING_LENGTH + 1) @@ -107,7 +108,7 @@ struct Pubnub_UUID_String { @return 0: OK (generated), otherwise: error, algorithm not available */ -int pubnub_generate_uuid_v1_time(struct Pubnub_UUID *o_uuid, +PUBNUB_EXTERN int pubnub_generate_uuid_v1_time(struct Pubnub_UUID *o_uuid, uint16_t *io_clock_seq, uint8_t const i_timestamp[8], uint8_t const i_node[6] @@ -127,7 +128,7 @@ int pubnub_generate_uuid_v1_time(struct Pubnub_UUID *o_uuid, @param namelen The length of the @p name data @return 0: OK (generated), otherwise: error, algorithm not available */ -int pubnub_generate_uuid_v3_name_md5(struct Pubnub_UUID *uuid, +PUBNUB_EXTERN int pubnub_generate_uuid_v3_name_md5(struct Pubnub_UUID *uuid, struct Pubnub_UUID *nsid, void *name, unsigned namelen @@ -142,7 +143,7 @@ int pubnub_generate_uuid_v3_name_md5(struct Pubnub_UUID *uuid, @return 0: OK (generated), otherwise: error, random number generator not available */ -int pubnub_generate_uuid_v4_random(struct Pubnub_UUID *uuid); +PUBNUB_EXTERN int pubnub_generate_uuid_v4_random(struct Pubnub_UUID *uuid); /** The name based algorithms (this - v5 and the other - v3) don't need any other state but the arguments they declare. @@ -158,7 +159,7 @@ int pubnub_generate_uuid_v4_random(struct Pubnub_UUID *uuid); @param namelen The length of the @p name data @return 0: OK (generated), otherwise: error, algorithm not available */ -int pubnub_generate_uuid_v5_name_sha1(struct Pubnub_UUID *uuid, +PUBNUB_EXTERN int pubnub_generate_uuid_v5_name_sha1(struct Pubnub_UUID *uuid, struct Pubnub_UUID *nsid, void *name, unsigned namelen @@ -166,14 +167,14 @@ int pubnub_generate_uuid_v5_name_sha1(struct Pubnub_UUID *uuid, /** Returns UUID as a standard HEX-based representation */ -struct Pubnub_UUID_String pubnub_uuid_to_string(struct Pubnub_UUID const *uuid); +PUBNUB_EXTERN struct Pubnub_UUID_String pubnub_uuid_to_string(struct Pubnub_UUID const *uuid); /** Compares two UUIDs (@p left and @p right) and returns: - 0: equal - <0: left < right - >0: left > right */ -int pubnub_uuid_compare(struct Pubnub_UUID const *left, struct Pubnub_UUID const *right); +PUBNUB_EXTERN int pubnub_uuid_compare(struct Pubnub_UUID const *left, struct Pubnub_UUID const *right); #endif /* !defined INC_PUBNUB_GENERATE_UUID */ diff --git a/core/pubnub_grant_token_api.h b/core/pubnub_grant_token_api.h index 60faf301..546ae8fe 100644 --- a/core/pubnub_grant_token_api.h +++ b/core/pubnub_grant_token_api.h @@ -8,6 +8,7 @@ #include #include "lib/cbor/cbor.h" +#include "lib/pb_extern.h" struct pam_permission{ bool read; @@ -20,7 +21,7 @@ struct pam_permission{ bool join; }; -int pubnub_get_grant_bit_mask_value(struct pam_permission pam); +PUBNUB_EXTERN int pubnub_get_grant_bit_mask_value(struct pam_permission pam); /** Returns the token for a set of permissions specified in @p perm_obj. @@ -50,15 +51,15 @@ int pubnub_get_grant_bit_mask_value(struct pam_permission pam); @param perm_obj The JSON string with the permissions for resources and patterns. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_grant_token(pubnub_t* pb, char const* perm_obj); +PUBNUB_EXTERN enum pubnub_res pubnub_grant_token(pubnub_t* pb, char const* perm_obj); -pubnub_chamebl_t pubnub_get_grant_token(pubnub_t* pb); +PUBNUB_EXTERN pubnub_chamebl_t pubnub_get_grant_token(pubnub_t* pb); /** Parses the @p token and returns the json string. @see pubnub_grant_token @return malloc allocated char pointer (must be passed to `free` to avoid a memory leak) */ -char* pubnub_parse_token(pubnub_t* pb, char const* token); +PUBNUB_EXTERN char* pubnub_parse_token(pubnub_t* pb, char const* token); #endif /* !defined INC_PUBNUB_GRANT_TOKEN_API */ diff --git a/core/pubnub_helper.h b/core/pubnub_helper.h index 409e7aee..23a517fc 100644 --- a/core/pubnub_helper.h +++ b/core/pubnub_helper.h @@ -5,6 +5,7 @@ #include "pubnub_api_types.h" #include "pbpal.h" +#include "lib/pb_extern.h" /** @file pubnub_helper.h @@ -44,24 +45,24 @@ enum pubnub_publish_res { /** Parses the given publish @p result. You usually obtain this with pubnub_last_publish_result(). */ -enum pubnub_publish_res pubnub_parse_publish_result(char const *result); +PUBNUB_EXTERN enum pubnub_publish_res pubnub_parse_publish_result(char const *result); /** Returns a string (in English) describing a Pubnub result enum value @p e. */ -char const* pubnub_res_2_string(enum pubnub_res e); +PUBNUB_EXTERN char const* pubnub_res_2_string(enum pubnub_res e); /** Returns a string literal describing enum value @p e Used for debugging. */ -char const* pbpal_resolv_n_connect_res_2_string(enum pbpal_resolv_n_connect_result e); +PUBNUB_EXTERN char const* pbpal_resolv_n_connect_res_2_string(enum pbpal_resolv_n_connect_result e); #if PUBNUB_USE_SUBSCRIBE_V2 #include "pubnub_subscribe_v2_message.h" /** Returns a string literal describing enum value @p type Used when looking at pubnub V2 message received by pubnub_subscribe_v2(). */ -char const* pubnub_msg_type_to_str(enum pubnub_message_type type); +PUBNUB_EXTERN char const* pubnub_msg_type_to_str(enum pubnub_message_type type); #endif /** Returns whether retrying a Pubnub transaction makes sense. This @@ -89,7 +90,7 @@ char const* pubnub_msg_type_to_str(enum pubnub_message_type type); timeout. In that case, retrying would send the same message again, duplicating it. */ -enum pubnub_tribool pubnub_should_retry(enum pubnub_res e); +PUBNUB_EXTERN enum pubnub_tribool pubnub_should_retry(enum pubnub_res e); /** Replace specified char in string. * @@ -98,6 +99,6 @@ enum pubnub_tribool pubnub_should_retry(enum pubnub_res e); * @param replace What should be used instead of searched needle. * @return Updated string. */ -char* replace_char(char* str, char find, char replace); +PUBNUB_EXTERN char* replace_char(char* str, char find, char replace); #endif /* defined INC_PUBNUB_HELPER */ diff --git a/core/pubnub_keep_alive.h b/core/pubnub_keep_alive.h index 01aeb5a7..48a76dd6 100644 --- a/core/pubnub_keep_alive.h +++ b/core/pubnub_keep_alive.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" /** @file pubnub_keep_alive.h @@ -27,7 +28,7 @@ sent on this connection before closing it. If 0, it is ignored. Setting to 1 has the effect of not using keep-alive. */ -void pubnub_set_keep_alive_param(pubnub_t* pb, unsigned timeout, unsigned max); +PUBNUB_EXTERN void pubnub_set_keep_alive_param(pubnub_t* pb, unsigned timeout, unsigned max); #endif /* !defined INC_PUBNUB_KEEP_ALIVE */ diff --git a/core/pubnub_memory_block.h b/core/pubnub_memory_block.h index dca4b51e..7039eba8 100644 --- a/core/pubnub_memory_block.h +++ b/core/pubnub_memory_block.h @@ -4,6 +4,7 @@ #include #include +#include /** @file pubnub_memory_block.h @@ -54,6 +55,6 @@ typedef struct pubnub_char_mem_block pubnub_chamebl_t; Result 'ptr' field is equal to @p str and 'size' to its length. In case @p str is NULL, the 'size' field becomes 0. */ -pubnub_chamebl_t pubnub_str_2_chamebl_t(char* str); +PUBNUB_EXTERN pubnub_chamebl_t pubnub_str_2_chamebl_t(char* str); #endif /* !defined INC_PUBNUB_MEMORY_BLOCK */ diff --git a/core/pubnub_ntf_callback.h b/core/pubnub_ntf_callback.h index ffb6399c..f7e343c6 100644 --- a/core/pubnub_ntf_callback.h +++ b/core/pubnub_ntf_callback.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" /** @file pubnub_ntf_callback.h @@ -55,15 +56,15 @@ typedef void (*pubnub_callback_t)(pubnub_t *pb, enum pubnub_trans trans, enum pu @return PNR_OK on success, a value indicating the error otherwise */ -enum pubnub_res pubnub_register_callback(pubnub_t *pb, pubnub_callback_t cb, void *user_data); +PUBNUB_EXTERN enum pubnub_res pubnub_register_callback(pubnub_t *pb, pubnub_callback_t cb, void *user_data); /** Returns the user data set with pubnub_register_callback(). */ -void *pubnub_get_user_data(pubnub_t *pb); +PUBNUB_EXTERN void *pubnub_get_user_data(pubnub_t *pb); /** Returns the callback set with pubnub_register_callback(). */ -pubnub_callback_t pubnub_get_callback(pubnub_t *pb); +PUBNUB_EXTERN pubnub_callback_t pubnub_get_callback(pubnub_t *pb); /** Enables safe exit from the main() by disabling platform watcher thread. It exists and is used in callback environment only. @@ -76,7 +77,7 @@ pubnub_callback_t pubnub_get_callback(pubnub_t *pb); inside the code(You can register your termination function: pubnub_stop() anywhere you like, but it will be called at the time of the program termination). */ -void pubnub_stop(void); +PUBNUB_EXTERN void pubnub_stop(void); #endif /* !defined INC_PUBNUB_NTF_CALLBACK */ diff --git a/core/pubnub_ntf_sync.h b/core/pubnub_ntf_sync.h index 58b3be30..1711f8c1 100644 --- a/core/pubnub_ntf_sync.h +++ b/core/pubnub_ntf_sync.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" /** @file pubnub_ntf_sync.h @@ -37,7 +38,7 @@ @return The outcome of the transaction */ -enum pubnub_res pubnub_await(pubnub_t *p); +PUBNUB_EXTERN enum pubnub_res pubnub_await(pubnub_t *p); #endif /* defined INC_PUBNUB_NTF_CONTIKI */ diff --git a/core/pubnub_objects_api.h b/core/pubnub_objects_api.h index b6ce98a9..3d81ac61 100644 --- a/core/pubnub_objects_api.h +++ b/core/pubnub_objects_api.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" #include @@ -24,7 +25,7 @@ is omitted. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_getall_uuidmetadata(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_getall_uuidmetadata(pubnub_t* pb, char const* include, size_t limit, char const* start, @@ -43,7 +44,7 @@ enum pubnub_res pubnub_getall_uuidmetadata(pubnub_t* pb, Object to create. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_set_uuidmetadata(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_set_uuidmetadata(pubnub_t* pb, char const* uuid_metadataid, char const* include, char const* uuid_metadata_obj); @@ -58,7 +59,7 @@ enum pubnub_res pubnub_set_uuidmetadata(pubnub_t* pb, Cannot be NULL. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_get_uuidmetadata(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_get_uuidmetadata(pubnub_t* pb, char const* include, char const* uuid_metadataid); @@ -69,7 +70,7 @@ enum pubnub_res pubnub_get_uuidmetadata(pubnub_t* pb, @param uuid_metadataid The UUID Metatdata ID. Cannot be NULL. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_remove_uuidmetadata(pubnub_t* pb, char const* uuid_metadataid); +PUBNUB_EXTERN enum pubnub_res pubnub_remove_uuidmetadata(pubnub_t* pb, char const* uuid_metadataid); /** Returns the spaces associated with the subscriber key of the context @p pbp, optionally @@ -88,7 +89,7 @@ enum pubnub_res pubnub_remove_uuidmetadata(pubnub_t* pb, char const* uuid_metada is omitted. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_getall_channelmetadata(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_getall_channelmetadata(pubnub_t* pb, char const* include, size_t limit, char const* start, @@ -105,7 +106,7 @@ enum pubnub_res pubnub_getall_channelmetadata(pubnub_t* pb, @param channel_metadata_obj The JSON string with the definition of the channel metadata Object to create. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_set_channelmetadata(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_set_channelmetadata(pubnub_t* pb, char const* channel_metadataid, char const* include, char const* channel_metadata_obj); @@ -119,7 +120,7 @@ enum pubnub_res pubnub_set_channelmetadata(pubnub_t* pb, @param channel_metadataid The Channel ID for which to retrieve the channel metadata object. Cannot be NULL. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_get_channelmetadata(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_get_channelmetadata(pubnub_t* pb, char const* include, char const* channel_metadataid); @@ -130,7 +131,7 @@ enum pubnub_res pubnub_get_channelmetadata(pubnub_t* pb, @param channel_metadataid The Channel ID. Cannot be NULL. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_remove_channelmetadata(pubnub_t* pb, char const* channel_metadataid); +PUBNUB_EXTERN enum pubnub_res pubnub_remove_channelmetadata(pubnub_t* pb, char const* channel_metadataid); /** Returns the channel memberships of the user specified by @p uuid_metadataid, optionally including @@ -152,7 +153,7 @@ enum pubnub_res pubnub_remove_channelmetadata(pubnub_t* pb, char const* channel_ is omitted. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_get_memberships(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_get_memberships(pubnub_t* pb, char const* uuid_metadataid, char const* include, size_t limit, @@ -188,7 +189,7 @@ enum pubnub_res pubnub_get_memberships(pubnub_t* pb, Cannot be NULL. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_set_memberships(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_set_memberships(pubnub_t* pb, char const* uuid_metadataid, char const* include, char const* set_obj); @@ -215,7 +216,7 @@ enum pubnub_res pubnub_set_memberships(pubnub_t* pb, Cannot be NULL. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_remove_memberships(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_remove_memberships(pubnub_t* pb, char const* uuid_metadataid, char const* include, char const* remove_obj); @@ -239,7 +240,7 @@ enum pubnub_res pubnub_remove_memberships(pubnub_t* pb, is omitted. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_get_members(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_get_members(pubnub_t* pb, char const* channel_metadataid, char const* include, size_t limit, @@ -267,7 +268,7 @@ enum pubnub_res pubnub_get_members(pubnub_t* pb, @param add_obj The JSON object that defines the add to perform. Cannot be NULL. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_add_members(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_add_members(pubnub_t* pb, char const* channel_metadataid, char const* include, char const* add_obj); @@ -298,7 +299,7 @@ enum pubnub_res pubnub_add_members(pubnub_t* pb, @param set_obj The JSON object that defines the add/update to perform. Cannot be NULL. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_set_members(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_set_members(pubnub_t* pb, char const* channel_metadataid, char const* include, char const* set_obj); @@ -326,7 +327,7 @@ enum pubnub_res pubnub_set_members(pubnub_t* pb, @param remove_obj The JSON object that defines the remove to perform. Cannot be NULL. @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_remove_members(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_remove_members(pubnub_t* pb, char const* channel_metadataid, char const* include, char const* remove_obj); diff --git a/core/pubnub_proxy.h b/core/pubnub_proxy.h index 55b0cf4d..d475dbbb 100644 --- a/core/pubnub_proxy.h +++ b/core/pubnub_proxy.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" #include @@ -104,7 +105,7 @@ enum pubnub_http_authentication_scheme { /** Returns the current proxy type/protocol for the context @p p. */ -enum pubnub_proxy_type pubnub_proxy_protocol_get(pubnub_t* p); +PUBNUB_EXTERN enum pubnub_proxy_type pubnub_proxy_protocol_get(pubnub_t* p); /** Sets the configuration for the Internet proxy, by explicitly specifying the protocol to use and the proxy server. @@ -124,7 +125,7 @@ enum pubnub_proxy_type pubnub_proxy_protocol_get(pubnub_t* p); @return 0: OK, otherwise: error, specified protocol not supported, or @p ip_address_or_url too long(or invalid) */ -int pubnub_set_proxy_manual(pubnub_t* p, +PUBNUB_EXTERN int pubnub_set_proxy_manual(pubnub_t* p, enum pubnub_proxy_type protocol, char const* ip_address_or_url, uint16_t port); @@ -146,12 +147,12 @@ int pubnub_set_proxy_manual(pubnub_t* p, @return 0: OK, otherwise: error, reading system configuration failed */ -int pubnub_set_proxy_from_system(pubnub_t* p, enum pubnub_proxy_type protocol); +PUBNUB_EXTERN int pubnub_set_proxy_from_system(pubnub_t* p, enum pubnub_proxy_type protocol); /** Sets all proxy parameters to 'zero' and proxy protocol to 'pbproxyNONE' @param p The Context to 'clean' off proxy configuration for(Set to "no proxy"). */ -void pubnub_set_proxy_none(pubnub_t* p); +PUBNUB_EXTERN void pubnub_set_proxy_none(pubnub_t* p); /** Sets the authentication password and scheme to be used for Proxy authentication. @@ -170,7 +171,7 @@ void pubnub_set_proxy_none(pubnub_t* p); @return 0: OK, otherwise: error */ -int pubnub_set_proxy_authentication_username_password(pubnub_t* p, +PUBNUB_EXTERN int pubnub_set_proxy_authentication_username_password(pubnub_t* p, char const* username, char const* password); @@ -183,13 +184,13 @@ int pubnub_set_proxy_authentication_username_password(pubnub_t* p, @param p The Context to set proxy authentication for @return 0: OK, otherwise: error, scheme not supported */ -int pubnub_set_proxy_authentication_none(pubnub_t* p); +PUBNUB_EXTERN int pubnub_set_proxy_authentication_none(pubnub_t* p); /** Returns the currently set HTTP proxy authentication scheme for context @p p. */ -enum pubnub_http_authentication_scheme +PUBNUB_EXTERN enum pubnub_http_authentication_scheme pubnub_proxy_authentication_scheme_get(pubnub_t* p); @@ -212,7 +213,7 @@ pubnub_proxy_authentication_scheme_get(pubnub_t* p); @retval 0 OK @retval otherwise Some error */ -int pubnub_proxy_get_config(pubnub_t* pb, +PUBNUB_EXTERN int pubnub_proxy_get_config(pubnub_t* pb, enum pubnub_proxy_type* protocol, uint16_t* port, char* host, diff --git a/core/pubnub_proxy_wpad.h b/core/pubnub_proxy_wpad.h index 4c49c0c3..1935b680 100644 --- a/core/pubnub_proxy_wpad.h +++ b/core/pubnub_proxy_wpad.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" /** @file pubnub_proxy_wpad.h @@ -47,7 +48,7 @@ a Pubnub transaction, for all intents and purposes, you should treat it as one. */ -enum pubnub_res pubnub_proxy_set_configuration_via_wpad(pubnub_t *p); +PUBNUB_EXTERN enum pubnub_res pubnub_proxy_set_configuration_via_wpad(pubnub_t *p); /** This starts a transaction to set the proxy configuration on the @@ -55,7 +56,7 @@ enum pubnub_res pubnub_proxy_set_configuration_via_wpad(pubnub_t *p); not really a Pubnub transaction, for all intents and purposes, you should treat it as one. */ -enum pubnub_res pubnub_proxy_set_configuration_via_pac(pubnub_t *p, char const *url); +PUBNUB_EXTERN enum pubnub_res pubnub_proxy_set_configuration_via_pac(pubnub_t *p, char const *url); #endif /* defined INC_PUBNUB_PROXY_WPAD */ diff --git a/core/pubnub_pubsubapi.h b/core/pubnub_pubsubapi.h index 6d5e2839..c4bea77c 100644 --- a/core/pubnub_pubsubapi.h +++ b/core/pubnub_pubsubapi.h @@ -5,6 +5,7 @@ #include "pubnub_api_types.h" #include "lib/pb_deprecated.h" +#include "lib/pb_extern.h" #include #include @@ -37,7 +38,7 @@ to messages @return Returns the @p p context */ -pubnub_t* pubnub_init(pubnub_t* p, const char* publish_key, const char* subscribe_key); +PUBNUB_EXTERN pubnub_t* pubnub_init(pubnub_t* p, const char* publish_key, const char* subscribe_key); /** Set the user identification of PubNub client context @p p to @p uuid. Pass NULL to unset. @@ -47,7 +48,7 @@ pubnub_t* pubnub_init(pubnub_t* p, const char* publish_key, const char* subscrib @see pubnub_set_user_id */ -PUBNUB_DEPRECATED enum pubnub_res pubnub_set_uuid(pubnub_t* p, const char* uuid); +PUBNUB_EXTERN PUBNUB_DEPRECATED enum pubnub_res pubnub_set_uuid(pubnub_t* p, const char* uuid); /** Get the user identification of PubNub client context @p p. After pubnub_init(), it will return `NULL` until you change it @@ -58,7 +59,7 @@ PUBNUB_DEPRECATED enum pubnub_res pubnub_set_uuid(pubnub_t* p, const char* uuid) @see pubnub_user_id_get */ -PUBNUB_DEPRECATED char const* pubnub_uuid_get(pubnub_t* p); +PUBNUB_EXTERN PUBNUB_DEPRECATED char const* pubnub_uuid_get(pubnub_t* p); /** Set the user identification of PubNub client context @p p to @p uuid. Pass NULL to unset. @@ -69,13 +70,13 @@ PUBNUB_DEPRECATED char const* pubnub_uuid_get(pubnub_t* p); the whole software/ firmware stops working). So, the contents of the @p user_id string is not copied to the Pubnub context @p p. */ -enum pubnub_res pubnub_set_user_id(pubnub_t* p, const char* user_id); +PUBNUB_EXTERN enum pubnub_res pubnub_set_user_id(pubnub_t* p, const char* user_id); /** Get the user identification of PubNub client context @p p. After pubnub_init(), it will return `NULL` until you change it to non-`NULL` via pubnub_set_user_id(). */ -char const* pubnub_user_id_get(pubnub_t* p); +PUBNUB_EXTERN char const* pubnub_user_id_get(pubnub_t* p); /** Set the authentication information of PubNub client context @p p. Pass NULL to unset. @@ -85,14 +86,14 @@ char const* pubnub_user_id_get(pubnub_t* p); pubnub_done() on @p p, or the otherwise stop using it (like when the whole software/ firmware stops working). So, the contents of the auth string is not copied to the Pubnub context @p p. */ -void pubnub_set_auth(pubnub_t* p, const char* auth); +PUBNUB_EXTERN void pubnub_set_auth(pubnub_t* p, const char* auth); /** Returns the current authentication information for the context @p p. After pubnub_init(), it will return `NULL` until you change it to non-`NULL` via pubnub_set_auth(). */ -char const* pubnub_auth_get(pubnub_t* p); +PUBNUB_EXTERN char const* pubnub_auth_get(pubnub_t* p); /** Cancels an ongoing API transaction. This will, once it is done, close the (TCP/IP) connection to Pubnub (if it was open). The @@ -119,16 +120,16 @@ char const* pubnub_auth_get(pubnub_t* p); pubnub_done() on @p pb, or the otherwise stop using it (like when the whole software/ firmware stops working). So, the contents of the auth string is not copied to the Pubnub context @p pb. */ -void pubnub_set_auth_token(pubnub_t* pb, const char* token); +PUBNUB_EXTERN void pubnub_set_auth_token(pubnub_t* pb, const char* token); /** Returns the current auth token information for the context @p pb. After pubnub_init(), it will return `NULL` until you change it to non-`NULL` via pubnub_set_auth_token(). */ -char const* pubnub_auth_token_get(pubnub_t* pb); +PUBNUB_EXTERN char const* pubnub_auth_token_get(pubnub_t* pb); -enum pubnub_cancel_res pubnub_cancel(pubnub_t* p); +PUBNUB_EXTERN enum pubnub_cancel_res pubnub_cancel(pubnub_t* p); /** Publish the @p message (in JSON format) on @p p channel, using the @p p context. This actually means "initiate a publish @@ -156,7 +157,7 @@ enum pubnub_cancel_res pubnub_cancel(pubnub_t* p); @return #PNR_STARTED or #PNR_OK on success, an error otherwise */ -enum pubnub_res pubnub_publish(pubnub_t* p, const char* channel, const char* message); +PUBNUB_EXTERN enum pubnub_res pubnub_publish(pubnub_t* p, const char* channel, const char* message); /** Sends a signal @p message (in JSON format) on @p channel, using @p pb context. This actually means "initiate a signal transaction". @@ -192,7 +193,7 @@ enum pubnub_res pubnub_publish(pubnub_t* p, const char* channel, const char* mes @return #PNR_STARTED or #PNR_OK on success, an error otherwise */ -enum pubnub_res pubnub_signal(pubnub_t* pb, +PUBNUB_EXTERN enum pubnub_res pubnub_signal(pubnub_t* pb, const char* channel, const char* message); @@ -216,7 +217,7 @@ enum pubnub_res pubnub_signal(pubnub_t* pb, @return Pointer to the message, NULL on error @see pubnub_subscribe */ -char const* pubnub_get(pubnub_t* p); +PUBNUB_EXTERN char const* pubnub_get(pubnub_t* p); /** Returns a pointer to an fetched subscribe operation/transaction's next channel. Each transaction may hold a list of channels, and @@ -232,7 +233,7 @@ char const* pubnub_get(pubnub_t* p); @see pubnub_subscribe @see pubnub_get */ -char const* pubnub_get_channel(pubnub_t* pb); +PUBNUB_EXTERN char const* pubnub_get_channel(pubnub_t* pb); /** Subscribe to @p channel and/or @p channel_group. This actually means "initiate a subscribe operation/transaction". The outcome @@ -278,7 +279,7 @@ char const* pubnub_get_channel(pubnub_t* pb); @see pubnub_get */ -enum pubnub_res pubnub_subscribe(pubnub_t* p, +PUBNUB_EXTERN enum pubnub_res pubnub_subscribe(pubnub_t* p, const char* channel, const char* channel_group); @@ -289,11 +290,11 @@ enum pubnub_res pubnub_subscribe(pubnub_t* p, @see pubnub_set_blocking_io @see pubnub_set_non_blocking_io */ -enum pubnub_res pubnub_last_result(pubnub_t* p); +PUBNUB_EXTERN enum pubnub_res pubnub_last_result(pubnub_t* p); /** Returns the HTTP reply code of the last transaction in the @p p * context. */ -int pubnub_last_http_code(pubnub_t* p); +PUBNUB_EXTERN int pubnub_last_http_code(pubnub_t* p); /** Returns the string of the result of the last `publish` transaction, as returned from Pubnub. If the last transaction is not a publish, @@ -301,14 +302,14 @@ int pubnub_last_http_code(pubnub_t* p); was successfull, it will return "Sent", otherwise a description of the error. */ -char const* pubnub_last_publish_result(pubnub_t* p); +PUBNUB_EXTERN char const* pubnub_last_publish_result(pubnub_t* p); /** Returns the string of the last received time token on the @c p context. After pubnub_init() this should be "0". @param p Pubnub context to get the last received time token from @return A read only string of the last received time token */ -char const* pubnub_last_time_token(pubnub_t* p); +PUBNUB_EXTERN char const* pubnub_last_time_token(pubnub_t* p); /** Gets the origin to be used for the context @p p. If setting of the origin is not enabled, this will return @@ -316,7 +317,7 @@ char const* pubnub_last_time_token(pubnub_t* p); @param p Pubnub context to get the origin from @return A read only string of origin used for context @p p */ -char const* pubnub_get_origin(pubnub_t* p); +PUBNUB_EXTERN char const* pubnub_get_origin(pubnub_t* p); /** Sets the origin to be used for the context @p p. If setting of the origin is not enabled, this will fail. It may also fail if it @@ -330,7 +331,7 @@ char const* pubnub_get_origin(pubnub_t* p); @retval +1 origin set will be applied with new connection, @retval -1 setting origin not enabled */ -int pubnub_origin_set(pubnub_t* p, char const* origin); +PUBNUB_EXTERN int pubnub_origin_set(pubnub_t* p, char const* origin); /** Sets the port to be used for the context @p p. If setting of the port is not enabled, this will fail. It may also fail if it @@ -342,7 +343,7 @@ int pubnub_origin_set(pubnub_t* p, char const* origin); @retval +1 port set will be applied with new connection, @retval -1 setting port not enabled */ -int pubnub_port_set(pubnub_t* p, uint16_t port); +PUBNUB_EXTERN int pubnub_port_set(pubnub_t* p, uint16_t port); /** Enables the use of HTTP Keep-Alive ("persistent connections") on the context @p p. @@ -369,7 +370,7 @@ int pubnub_port_set(pubnub_t* p, uint16_t port); sockets, relative to Pubnub contexts, this may be an issue. */ -void pubnub_use_http_keep_alive(pubnub_t* p); +PUBNUB_EXTERN void pubnub_use_http_keep_alive(pubnub_t* p); /** Disables the use of HTTP Keep-Alive ("persistent connections") on the context @p p. @@ -377,7 +378,7 @@ void pubnub_use_http_keep_alive(pubnub_t* p); The default is to _use_ the HTTP Keep-Alive, but, you might want to turn that off - see pubnub_use_http_keep_alive(). */ -void pubnub_dont_use_http_keep_alive(pubnub_t* p); +PUBNUB_EXTERN void pubnub_dont_use_http_keep_alive(pubnub_t* p); #endif /* !defined INC_PUBNUB_PUBSUBAPI */ diff --git a/core/pubnub_revoke_token_api.h b/core/pubnub_revoke_token_api.h index cc27633e..54e751dc 100644 --- a/core/pubnub_revoke_token_api.h +++ b/core/pubnub_revoke_token_api.h @@ -1,5 +1,11 @@ /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */ +#ifndef INC_PUBNUB_REVOKE_TOKEN_API +#define INC_PUBNUB_REVOKE_TOKEN_API + +#include "pubnub_api_types.h" +#include "pubnub_memory_block.h" +#include "lib/pb_extern.h" /** Revokes the token specified in @p token. @@ -8,7 +14,7 @@ @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_revoke_token(pubnub_t* pb, char const* token); +PUBNUB_EXTERN enum pubnub_res pubnub_revoke_token(pubnub_t* pb, char const* token); /** Returns the result of the revoke token operation. @@ -16,4 +22,6 @@ enum pubnub_res pubnub_revoke_token(pubnub_t* pb, char const* token); @param pb The pubnub context. Can't be NULL @return pubnub_chamebl_t with pointer to string with response */ -pubnub_chamebl_t pubnub_get_revoke_token_response(pubnub_t* pb); +PUBNUB_EXTERN pubnub_chamebl_t pubnub_get_revoke_token_response(pubnub_t* pb); + +#endif /* INC_PUBNUB_REVOKE_TOKEN_API */ diff --git a/core/pubnub_ssl.h b/core/pubnub_ssl.h index 54924b7b..46874c35 100644 --- a/core/pubnub_ssl.h +++ b/core/pubnub_ssl.h @@ -4,6 +4,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" #include @@ -31,7 +32,7 @@ experiences issues handshaking across local proxies, firewalls, etc? (default: YES) */ -void pubnub_set_ssl_options(pubnub_t *p, bool useSSL, bool ignoreSecureConnectionRequirement); +PUBNUB_EXTERN void pubnub_set_ssl_options(pubnub_t *p, bool useSSL, bool ignoreSecureConnectionRequirement); /** Sets the option to reuse the SSL session on a new connection to @p reuse on the context @p p. @@ -42,7 +43,7 @@ void pubnub_set_ssl_options(pubnub_t *p, bool useSSL, bool ignoreSecureConnectio @param p The context for which to set the option for SSL session reuse @param reuse The value (true/false == on/off) of the option */ -void pubnub_set_reuse_ssl_session(pubnub_t *p, bool reuse); +PUBNUB_EXTERN void pubnub_set_reuse_ssl_session(pubnub_t *p, bool reuse); /** Sets the location(s) of CA certificates for verification purposes. This is only available on targets that have a file @@ -72,7 +73,7 @@ void pubnub_set_reuse_ssl_session(pubnub_t *p, bool reuse); @return 0: OK, -1: error (not supported, invalid location(s)) */ -int pubnub_set_ssl_verify_locations(pubnub_t *p, char const* sCAfile, char const* sCApath); +PUBNUB_EXTERN int pubnub_set_ssl_verify_locations(pubnub_t *p, char const* sCAfile, char const* sCApath); /** Instructs C-core to use system certificate store with context @p p. This is only available on targets that have a system certificate @@ -91,7 +92,7 @@ int pubnub_set_ssl_verify_locations(pubnub_t *p, char const* sCAfile, char const @param p The context for which to use system certificate store @return 0: OK, -1: error (not supported) */ -int pubnub_ssl_use_system_certificate_store(pubnub_t *p); +PUBNUB_EXTERN int pubnub_ssl_use_system_certificate_store(pubnub_t *p); /** Instructs C-core to _not_ use system certificate store with @@ -105,7 +106,7 @@ int pubnub_ssl_use_system_certificate_store(pubnub_t *p); @param p The context for which to not use system certificate store */ -void pubnub_ssl_dont_use_system_certificate_store(pubnub_t *p); +PUBNUB_EXTERN void pubnub_ssl_dont_use_system_certificate_store(pubnub_t *p); /** Sets the contents of a "user-defined", in-memory, PEM certificate @@ -129,6 +130,6 @@ void pubnub_ssl_dont_use_system_certificate_store(pubnub_t *p); to be valid during the lifetime of @p p. Use `NULL` if you don't want to use your certificate. */ -void pubnub_ssl_set_usrdef_pem_cert(pubnub_t *p, char const *contents); +PUBNUB_EXTERN void pubnub_ssl_set_usrdef_pem_cert(pubnub_t *p, char const *contents); #endif /* defined INC_PUBNUB_SSL */ diff --git a/core/pubnub_subscribe_v2.h b/core/pubnub_subscribe_v2.h index c7805ac2..b22993c9 100644 --- a/core/pubnub_subscribe_v2.h +++ b/core/pubnub_subscribe_v2.h @@ -5,6 +5,7 @@ #include "pubnub_config.h" #include "pubnub_api_types.h" +#include "lib/pb_extern.h" #if !PUBNUB_USE_SUBSCRIBE_V2 #error To use the subscribe V2 API you must define PUBNUB_USE_SUBSCRIBE_V2=1 @@ -55,7 +56,7 @@ struct pubnub_subscribe_v2_options { Will set `channel_group = NULL`, `heartbeat` to default heartbeat value and `filter_expr = NULL`. */ -struct pubnub_subscribe_v2_options pubnub_subscribe_v2_defopts(void); +PUBNUB_EXTERN struct pubnub_subscribe_v2_options pubnub_subscribe_v2_defopts(void); /** The V2 subscribe. To get messages for subscribe V2, use pubnub_get_v2() - keep in mind that it can provide you with @@ -78,7 +79,7 @@ struct pubnub_subscribe_v2_options pubnub_subscribe_v2_defopts(void); @param opt Subscribe V2 options @return #PNR_STARTED on success, an error otherwise */ -enum pubnub_res pubnub_subscribe_v2(pubnub_t* p, +PUBNUB_EXTERN enum pubnub_res pubnub_subscribe_v2(pubnub_t* p, const char* channel, struct pubnub_subscribe_v2_options opts); @@ -97,9 +98,7 @@ enum pubnub_res pubnub_subscribe_v2(pubnub_t* p, puts("No more messages"); } */ -struct pubnub_v2_message pubnub_get_v2(pubnub_t* pbp); - - +PUBNUB_EXTERN struct pubnub_v2_message pubnub_get_v2(pubnub_t* pbp); #endif /* !defined INC_PUBNUB_SUBSCRIBE_V2 */ diff --git a/core/pubnub_subscribe_with_state.h b/core/pubnub_subscribe_with_state.h index 290df4fa..8878a2cd 100644 --- a/core/pubnub_subscribe_with_state.h +++ b/core/pubnub_subscribe_with_state.h @@ -5,6 +5,7 @@ #include "pubnub_api_types.h" #include "lib/pb_deprecated.h" +#include "lib/pb_extern.h" #include @@ -42,7 +43,8 @@ @see pubnub_subscribe */ -PUBNUB_DEPRECATED enum pubnub_res pubnub_subscribe_with_state(pubnub_t *p, const char *channel, const char *channel_group, char const *state); +PUBNUB_EXTERN PUBNUB_DEPRECATED enum pubnub_res pubnub_subscribe_with_state( + pubnub_t *p, const char *channel, const char *channel_group, char const *state); diff --git a/core/pubnub_sync_subscribe_loop.h b/core/pubnub_sync_subscribe_loop.h index 2c9679ec..a8132c59 100644 --- a/core/pubnub_sync_subscribe_loop.h +++ b/core/pubnub_sync_subscribe_loop.h @@ -5,6 +5,7 @@ #include "pubnub_api_types.h" #include "pubnub_coreapi_ex.h" +#include "lib/pb_extern.h" /** @file pubnub_sync_subscribe_loop.h @@ -38,7 +39,7 @@ struct pubnub_subloop_descriptor { @result The subscribe loop descriptor made */ -struct pubnub_subloop_descriptor pubnub_subloop_define(pubnub_t *p, char const *channel); +PUBNUB_EXTERN struct pubnub_subloop_descriptor pubnub_subloop_define(pubnub_t *p, char const *channel); /** Designed to be called once in every iteration of a subscribe loop. Fetches the next message on the given @p channel and/or @p @@ -60,7 +61,7 @@ struct pubnub_subloop_descriptor pubnub_subloop_define(pubnub_t *p, char const * @retval PNR_OK Success @retval other Indicates the reason for failure */ -enum pubnub_res pubnub_subloop_fetch(struct pubnub_subloop_descriptor const* pbsld, char const** message); +PUBNUB_EXTERN enum pubnub_res pubnub_subloop_fetch(struct pubnub_subloop_descriptor const* pbsld, char const** message); #endif /* !defined INC_PUBNUB_SYNC_SUBSCRIBE_LOOP */ diff --git a/core/pubnub_timer_list.h b/core/pubnub_timer_list.h index 149d49af..d6cdf843 100644 --- a/core/pubnub_timer_list.h +++ b/core/pubnub_timer_list.h @@ -4,12 +4,13 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" /** Initialize the element of the list - so that it is not in the list. @pre pbp != NULL */ -void pubnub_timer_list_init(pubnub_t *pbp); +PUBNUB_EXTERN void pubnub_timer_list_init(pubnub_t *pbp); /** Add/enqueue a Pubnub context into a list of contexts/timers. If it gets enqueued to the start of the list, caller needs @@ -22,7 +23,7 @@ void pubnub_timer_list_init(pubnub_t *pbp); @param timeout_ms timer timeout in milliseconds @return The head of the list (may differ from @p list) */ -pubnub_t *pubnub_timer_list_add(pubnub_t *list, pubnub_t *to_add, int timeout_ms); +PUBNUB_EXTERN pubnub_t *pubnub_timer_list_add(pubnub_t *list, pubnub_t *to_add, int timeout_ms); /** Remove/dequeue a Pubnub context from a list of contexts/timers. It is assumed (i.e. it is a precondition) that @p to_remove @@ -34,7 +35,7 @@ pubnub_t *pubnub_timer_list_add(pubnub_t *list, pubnub_t *to_add, int timeout_ms @param to_remove Context to remove from the @p list @return The head of the list (may differ from @p list) */ -pubnub_t *pubnub_timer_list_remove(pubnub_t *list, pubnub_t *to_remove); +PUBNUB_EXTERN pubnub_t *pubnub_timer_list_remove(pubnub_t *list, pubnub_t *to_remove); /** Examines the @p list of timers/contexts, taking into account that @p time_passed_ms has gone by since last check, and dequeues all @@ -47,19 +48,19 @@ pubnub_t *pubnub_timer_list_remove(pubnub_t *list, pubnub_t *to_remove); @param time_passed_ms Number of milliseconds passed since last check @return List of expired timers (NULL if none have expired) */ -pubnub_t *pubnub_timer_list_as_time_goes_by(pubnub_t **pplist, int time_passed_ms); +PUBNUB_EXTERN pubnub_t *pubnub_timer_list_as_time_goes_by(pubnub_t **pplist, int time_passed_ms); /** Returns a pointer to the next element in the list for the given element @p p. @pre p != NULL */ -pubnub_t *pubnub_timer_list_next(pubnub_t *p); +PUBNUB_EXTERN pubnub_t *pubnub_timer_list_next(pubnub_t *p); /** Returns a pointer to the previous element in the list for the given element @p p. @pre p != NULL */ -pubnub_t *pubnub_timer_list_previous(pubnub_t *p); +PUBNUB_EXTERN pubnub_t *pubnub_timer_list_previous(pubnub_t *p); #endif /* !defined INC_PUBNUB_TIMER_LIST */ diff --git a/core/pubnub_timers.h b/core/pubnub_timers.h index 8c23da9d..0c32d15d 100644 --- a/core/pubnub_timers.h +++ b/core/pubnub_timers.h @@ -5,6 +5,7 @@ #include "pubnub_api_types.h" #include "pubnub_ccore_limits.h" +#include "lib/pb_extern.h" /** @file pubnub_timers.h @@ -52,7 +53,7 @@ @retval 0 OK @retval -1 timers not supported */ -int pubnub_set_transaction_timeout(pubnub_t* p, int duration_ms); +PUBNUB_EXTERN int pubnub_set_transaction_timeout(pubnub_t* p, int duration_ms); /** Returns the current transaction timeout for the context. @@ -61,7 +62,7 @@ int pubnub_set_transaction_timeout(pubnub_t* p, int duration_ms); @return Current transaction timeout, in milliseconds (should always be > 0) */ -int pubnub_transaction_timeout_get(pubnub_t* p); +PUBNUB_EXTERN int pubnub_transaction_timeout_get(pubnub_t* p); /** Sets the 'wait_connect_TCP_socket' timeout for the context. @@ -82,7 +83,7 @@ int pubnub_transaction_timeout_get(pubnub_t* p); @retval 0 OK @retval -1 timers not supported */ -int pubnub_set_wait_connect_timeout(pubnub_t* p, int duration_ms); +PUBNUB_EXTERN int pubnub_set_wait_connect_timeout(pubnub_t* p, int duration_ms); /** Returns the current 'wait_connect_TCP_socket' timeout for the context. @@ -91,7 +92,7 @@ int pubnub_set_wait_connect_timeout(pubnub_t* p, int duration_ms); @return Current transaction timeout, in milliseconds (should always be > 0) */ -int pubnub_wait_connect_timeout_get(pubnub_t* p); +PUBNUB_EXTERN int pubnub_wait_connect_timeout_get(pubnub_t* p); #endif /* defined INC_PUBNUB_TIMERS_IO */ diff --git a/core/pubnub_url_encode.h b/core/pubnub_url_encode.h index a4db557d..278b3de2 100644 --- a/core/pubnub_url_encode.h +++ b/core/pubnub_url_encode.h @@ -7,10 +7,12 @@ #define OK_SPAN_CHARACTERS (char*)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~,[]" #define OK_SPAN_CHARS_MINUS_COMMA (char*)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~[]" +#include "lib/pb_extern.h" + /** Url-encodes string @p what to user provided @p buffer which has its @p buffer_size. @retval length of url-encoded string on success, @retval -1 on error(url-encoded string too long for buffer provided) */ -int pubnub_url_encode(char* buffer, char const* what, size_t buffer_size, enum pubnub_trans pt); +PUBNUB_EXTERN int pubnub_url_encode(char* buffer, char const* what, size_t buffer_size, enum pubnub_trans pt); #endif /* !defined INC_PUBNUB_URL_ENCODE */ diff --git a/core/pubnub_version.h b/core/pubnub_version.h index 51b2061d..e28fbc38 100644 --- a/core/pubnub_version.h +++ b/core/pubnub_version.h @@ -2,6 +2,7 @@ #if !defined INC_PUBNUB_VERSION #define INC_PUBNUB_VERSION +#include "lib/pb_extern.h" /** @file pubnub_version.h This is the name / version API of the Pubnub client library. @@ -13,22 +14,22 @@ /** Returns a string with the name of the Pubnub SDK client you are using. */ -char const *pubnub_sdk_name(void); +PUBNUB_EXTERN char const *pubnub_sdk_name(void); /** Returns a string with the version of the Pubnub SDK client you are using. */ -char const *pubnub_version(void); +PUBNUB_EXTERN char const *pubnub_version(void); /** Returns an URL encoded string with the full identification of the SDK - name, version, possible something more. */ -char const *pubnub_uname(void); +PUBNUB_EXTERN char const *pubnub_uname(void); /** Returns the full identification of the SDK - name, version, etc. (without Url encoding). */ -char const *pubnub_uagent(void); +PUBNUB_EXTERN char const *pubnub_uagent(void); diff --git a/core/pubnub_version_internal.h b/core/pubnub_version_internal.h index e86202df..dd6aaf6d 100644 --- a/core/pubnub_version_internal.h +++ b/core/pubnub_version_internal.h @@ -3,7 +3,7 @@ #define INC_PUBNUB_VERSION_INTERNAL -#define PUBNUB_SDK_VERSION "4.6.2" +#define PUBNUB_SDK_VERSION "4.7.0" #endif /* !defined INC_PUBNUB_VERSION_INTERNAL */ diff --git a/core/srand_from_pubnub_time.h b/core/srand_from_pubnub_time.h index 9ada09cc..ba84b700 100644 --- a/core/srand_from_pubnub_time.h +++ b/core/srand_from_pubnub_time.h @@ -3,6 +3,7 @@ #include "pubnub_api_types.h" +#include "lib/pb_extern.h" /** This helper function will call the C standard srand() function with the seed @@ -19,7 +20,7 @@ @param pbp The Pubnub context to use to get time @return 0: OK, -1: error (srand() was not called) */ -int srand_from_pubnub_time(pubnub_t *pbp); +PUBNUB_EXTERN int srand_from_pubnub_time(pubnub_t *pbp); #endif /* !defined INC_SRAND_FROM_PUBNUB_TIME */ diff --git a/lib/pb_extern.h b/lib/pb_extern.h new file mode 100644 index 00000000..ddef37db --- /dev/null +++ b/lib/pb_extern.h @@ -0,0 +1,11 @@ +/* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */ + +/// This defines the `PUBNUB_EXTERN` macro, which is used to declare +/// functions that are part of the Pubnub C client library API. +/// Users still can override this, if they want to, by defining +/// `PUBNUB_EXTERN` before including any Pubnub header. + +#ifndef PUBNUB_EXTERN +#define PUBNUB_EXTERN extern +#endif /* PUBNUB_EXTERN */ +