Skip to content

Commit

Permalink
Provide PUBNUB_EXTERN macro to extern C functions (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavrax committed Nov 20, 2023
1 parent 43856ef commit 5575298
Show file tree
Hide file tree
Showing 41 changed files with 294 additions and 225 deletions.
21 changes: 13 additions & 8 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
17 changes: 9 additions & 8 deletions core/pubnub_actions_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdbool.h>
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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);
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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 */
9 changes: 5 additions & 4 deletions core/pubnub_advanced_history.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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 */
5 changes: 3 additions & 2 deletions core/pubnub_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


#include "pubnub_api_types.h"
#include "lib/pb_extern.h"


/** Returns an allocated context. After successful allocation, please
Expand All @@ -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
Expand All @@ -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 */
11 changes: 6 additions & 5 deletions core/pubnub_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define INC_PUBNUB_ASSERT

#include <stdbool.h>
#include "lib/pb_extern.h"


/** The Pubnub ASSERT macros. There are several layers:
Expand Down Expand Up @@ -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.
Expand All @@ -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);

Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions core/pubnub_auto_heartbeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -20,27 +23,27 @@
@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.
@param pb The pubnub context. Can't be NULL
@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
Expand Down
6 changes: 3 additions & 3 deletions core/pubnub_blocking_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


#include "pubnub_api_types.h"
#include "lib/pb_extern.h"

#include <stdbool.h>

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
9 changes: 5 additions & 4 deletions core/pubnub_callback_subscribe_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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 */
Loading

0 comments on commit 5575298

Please sign in to comment.