util.h 715 Bytes
Newer Older
Julian Rother's avatar
Julian Rother committed
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
#include <unistd.h>
#include <stdarg.h>

/* Generic */
#define SL(s) (s), (sizeof(s)-1)
#define BL(b) (b), (sizeof(b))
size_t xvsnprintf(char *p, size_t len, const char *fmt, va_list ap);
size_t xsnprintf(char *p, size_t len, const char *fmt, ...);

void avlogbuf_callback(void *classp, int level, const char *fmt, va_list ap);
char *get_avlogbuf(void);

/* API */
int ping_job(int id, char *state, char *status, ...);

/* JSON parser */
#define JSTR_SIZE 100

ssize_t jbin(char *s, char *buf, size_t len);
char *jstrb(char *s, char *err, char *buf);
char *jstr(char *s, char *err);
int jint(char *s, int err);
char *jenter(char *s);
char *jnext(char *s);
char *jvalue(char *s);
char *jlookup(char *s, char *key);