Unverified Commit 7369b78d authored by Shawn Webb's avatar Shawn Webb
Browse files

Make the pushover structures opaque.



In order to enforce using the API to set fields, make the structures
opaque. This will help prevent struct field abuse from consumers of this
library.
Signed-off-by: Shawn Webb's avatarShawn Webb <shawn.webb@hardenedbsd.org>
parent 917d3c92
......@@ -34,6 +34,21 @@
#include "libpushover.h"
struct _pushover_ctx {
uint64_t psh_version;
char *psh_token;
char *psh_uri;
};
struct _pushover_message {
char *psh_dest;
char *psh_msg;
char *psh_title;
char *psh_device;
pushover_priority_t psh_priority;
uint64_t psh_flags;
};
static char *msg_to_str(pushover_ctx_t *, pushover_message_t *, CURL *);
static size_t pushover_curl_write_data(void *, size_t, size_t, void *);
......@@ -54,8 +69,10 @@ pushover_init_ctx(const char *token)
goto out;
}
if (token != NULL)
if (token != NULL) {
res->psh_token = strdup(token);
assert(res->psh_token != NULL);
}
res->psh_version = LIBPUSHOVER_VERSION;
......
......@@ -13,6 +13,12 @@
#define PUSHOVER_FLAGS_NONE 0
#define PUSHOVER_FLAGS_ALLOC 1
struct _pushover_ctx;
struct _pushover_message;
typedef struct _pushover_ctx pushover_ctx_t;
typedef struct _pushover_message pushover_message_t;
typedef enum _pushover_priority {
PSH_PRIO_NONE = -2,
PSH_PRIO_QUIET = -1,
......@@ -21,21 +27,6 @@ typedef enum _pushover_priority {
PSH_PRIO_CONFIRM = 2
} pushover_priority_t;
typedef struct _pushover_ctx {
uint64_t psh_version;
char *psh_token;
char *psh_uri;
} pushover_ctx_t;
typedef struct _pushover_message {
char *psh_dest;
char *psh_msg;
char *psh_title;
char *psh_device;
pushover_priority_t psh_priority;
uint64_t psh_flags;
} pushover_message_t;
pushover_ctx_t *pushover_init_ctx(const char *);
void pushover_free_ctx(pushover_ctx_t **);
bool pushover_set_uri(pushover_ctx_t *, const char *);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment