From a850c7981769a2b39e65b051fe266afc13c763b1 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 19 Jun 2015 22:18:24 +0000 Subject: [PATCH] Hide cosmo struct definition from the public API. --- clients/c/cosmopolite-int.h | 39 +++++++++++++++++++++++++++++++++++++ clients/c/cosmopolite.c | 1 + clients/c/cosmopolite.h | 33 +------------------------------ clients/c/test.c | 1 + 4 files changed, 42 insertions(+), 32 deletions(-) create mode 100644 clients/c/cosmopolite-int.h diff --git a/clients/c/cosmopolite-int.h b/clients/c/cosmopolite-int.h new file mode 100644 index 0000000..c6dbb87 --- /dev/null +++ b/clients/c/cosmopolite-int.h @@ -0,0 +1,39 @@ +#ifndef _COSMOPOLITE_INT_H +#define _COSMOPOLITE_INT_H + +// Declarations that aren't in the public API but are available to the test suite. + +struct cosmo { + char client_id[COSMO_UUID_SIZE]; + char instance_id[COSMO_UUID_SIZE]; + cosmo_callbacks callbacks; + void *passthrough; + + pthread_mutex_t lock; + pthread_cond_t cond; + bool shutdown; + char *profile; + json_t *command_queue; + json_t *ack; + json_t *subscriptions; + uint64_t next_delay_ms; + unsigned int seedp; + + enum { + INITIAL_CONNECT, + CONNECTED, + DISCONNECTED, + } connect_state; + struct timespec last_success; + + enum { + LOGIN_UNKNOWN, + LOGGED_OUT, + LOGGED_IN, + } login_state; + + pthread_t thread; + CURL *curl; +}; + +#endif diff --git a/clients/c/cosmopolite.c b/clients/c/cosmopolite.c index 103464e..bef5bcf 100644 --- a/clients/c/cosmopolite.c +++ b/clients/c/cosmopolite.c @@ -8,6 +8,7 @@ #include #include "cosmopolite.h" +#include "cosmopolite-int.h" #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) diff --git a/clients/c/cosmopolite.h b/clients/c/cosmopolite.h index 53b34ee..1551d5a 100644 --- a/clients/c/cosmopolite.h +++ b/clients/c/cosmopolite.h @@ -17,38 +17,7 @@ typedef struct { void (*message)(const json_t *, void *); } cosmo_callbacks; -typedef struct { - char client_id[COSMO_UUID_SIZE]; - char instance_id[COSMO_UUID_SIZE]; - cosmo_callbacks callbacks; - void *passthrough; - - pthread_mutex_t lock; - pthread_cond_t cond; - bool shutdown; - char *profile; - json_t *command_queue; - json_t *ack; - json_t *subscriptions; - uint64_t next_delay_ms; - unsigned int seedp; - - enum { - INITIAL_CONNECT, - CONNECTED, - DISCONNECTED, - } connect_state; - struct timespec last_success; - - enum { - LOGIN_UNKNOWN, - LOGGED_OUT, - LOGGED_IN, - } login_state; - - pthread_t thread; - CURL *curl; -} cosmo; +typedef struct cosmo cosmo; void cosmo_uuid(char *uuid); diff --git a/clients/c/test.c b/clients/c/test.c index 5beb386..18c9ec1 100644 --- a/clients/c/test.c +++ b/clients/c/test.c @@ -2,6 +2,7 @@ #include #include "cosmopolite.h" +#include "cosmopolite-int.h" #define RUN_TEST(func) run_test(#func, func)