libpushover.h 1.57 KB
Newer Older
Shawn Webb's avatar
Shawn Webb committed
1
2
3
4
5
6
7
#ifndef _LIBPUSHOVER_H
#define _LIBPUSHOVER_H

#include <stdbool.h>

#include <curl/curl.h>

Shawn Webb's avatar
Shawn Webb committed
8
9
#define	LIBPUSHOVER_VERSION	 20200428001UL

Shawn Webb's avatar
Shawn Webb committed
10
11
12
#define EXPORTED_SYM	 __attribute__((visibility("default")))
#define PUSHOVER_URI	 "https://api.pushover.net/1/messages.json"

13
14
15
#define	PUSHOVER_FLAGS_NONE	0
#define	PUSHOVER_FLAGS_ALLOC	1

Shawn Webb's avatar
Shawn Webb committed
16
17
18
19
20
21
22
23
24
typedef enum _pushover_priority {
	PSH_PRIO_NONE = -2,
	PSH_PRIO_QUIET = -1,
	PSH_PRIO_DEF = 0,
	PSH_PRIO_HIGH = 1,
	PSH_PRIO_CONFIRM = 2
} pushover_priority_t;

typedef struct _pushover_ctx {
Shawn Webb's avatar
Shawn Webb committed
25
	uint64_t	 psh_version;
Shawn Webb's avatar
Shawn Webb committed
26
27
28
29
30
	char		*psh_token;
	char		*psh_uri;
} pushover_ctx_t;

typedef struct _pushover_message {
31
	char			*psh_dest;
Shawn Webb's avatar
Shawn Webb committed
32
33
34
35
	char			*psh_msg;
	char			*psh_title;
	char			*psh_device;
	pushover_priority_t	 psh_priority;
36
	uint64_t		 psh_flags;
Shawn Webb's avatar
Shawn Webb committed
37
38
39
} pushover_message_t;

pushover_ctx_t *pushover_init_ctx(const char *);
Shawn Webb's avatar
Shawn Webb committed
40
void pushover_free_ctx(pushover_ctx_t **);
Shawn Webb's avatar
Shawn Webb committed
41
bool pushover_set_uri(pushover_ctx_t *, const char *);
42
bool pushover_set_token(pushover_ctx_t *, const char *);
Shawn Webb's avatar
Shawn Webb committed
43
pushover_message_t *pushover_init_message(pushover_message_t *);
44
void pushover_free_message(pushover_message_t **);
Shawn Webb's avatar
Shawn Webb committed
45
bool pushover_message_set_msg(pushover_message_t *, char *);
46
bool pushover_message_set_dest(pushover_message_t *, char *);
Shawn Webb's avatar
Shawn Webb committed
47
48
49
50
51
52
bool pushover_message_set_title(pushover_message_t *, char *);
bool pushover_message_set_device(pushover_message_t *, char *);
bool pushover_message_set_priority(pushover_message_t *,
    pushover_priority_t);
bool pushover_submit_message(pushover_ctx_t *, pushover_message_t *);

53
54
bool pushover_message_priority_sane(pushover_priority_t);

Shawn Webb's avatar
Shawn Webb committed
55
#endif /* !_LIBPUSHOVER_H */