-
Notifications
You must be signed in to change notification settings - Fork 0
/
vink.h
135 lines (102 loc) · 2.31 KB
/
vink.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#ifndef VINK_H_
#define VINK_H_ 1
#include <stdlib.h>
#include <time.h>
#define VINK_API_VERSION 0x000000
#define VINK_CLIENT 0x00001
#ifdef __GNUC__
#define USE_RESULT __attribute__((warn_unused_result))
#else
#define USE_RESULT
#endif
enum vink_protocol
{
VINK_XMPP = 0x0001,
VINK_EPP = 0x0002,
VINK_EMAIL = 0x0004 /* SMTP, POP-3, IMAP, ... */
};
enum vink_part_type
{
VINK_PART_MESSAGE = 0,
VINK_PART_ALTERNATIVE = 0,
VINK_PART_ATTACHMENT = 1,
VINK_PART_MIXED = 2,
VINK_PART_DIGEST = 3,
VINK_PART_RELATED = 4,
VINK_PART_REPORT = 5,
VINK_PART_SIGNED = 6,
VINK_PART_ENCRYPTED = 7,
VINK_PART_FORM_DATA = 8
};
enum vink_presence
{
VINK_PRESENT = 0,
VINK_AWAY,
VINK_CHAT,
VINK_DND,
VINK_XA,
VINK_UNAVAILABLE
};
struct vink_header
{
const char *key;
const char *value;
};
struct vink_message
{
const char *id;
enum vink_protocol protocol;
enum vink_part_type part_type;
time_t sent, received;
const char *content_type;
const char *from;
const char *to;
const char *subject;
const char *body;
size_t body_size;
const struct vink_header *headers;
size_t header_count;
const struct vink_message *parts;
size_t part_count;
void *_private;
};
#include "vink-epp.h"
#include "vink-email.h"
#include "vink-xmpp.h"
struct vink_backend_callbacks
{
struct vink_xmpp_callbacks xmpp;
struct vink_email_callbacks email;
void (*backend_free)(void *data);
void (*list_messages)(const char *jid,
int (*callback)(struct vink_message *msg),
size_t offset, size_t limit);
};
/**
* Initializes the vink library.
*
* Pass the value of VINK_API_VERSION in the `version' parameter.
*/
int
vink_init(const char *config_path, unsigned int flags, unsigned int version) USE_RESULT;
const char *
vink_last_error();
const char *
vink_config(const char *key);
void
vink_message_free(struct vink_message *message);
/* Client functions */
struct vink_client;
struct vink_client *
vink_client_alloc();
void *
vink_client_state(struct vink_client *cl);
int
vink_client_connect(struct vink_client *cl, const char *domain,
enum vink_protocol protocol) USE_RESULT;
int
vink_client_run(struct vink_client *cl) USE_RESULT;
/* Utility functions */
char *
vink_xml_escape(const char* data, size_t size);
#endif /* !VINK_H_ */