util.h 799 Bytes
Newer Older
Julian Rother's avatar
Julian Rother committed
1 2 3 4 5 6
#include <unistd.h>
#include <stdarg.h>

/* Generic */
#define SL(s) (s), (sizeof(s)-1)
#define BL(b) (b), (sizeof(b))
Julian Rother's avatar
Julian Rother committed
7
extern int jobid;
Julian Rother's avatar
Julian Rother committed
8

Julian Rother's avatar
Julian Rother committed
9 10 11 12 13
char *vmprintf(const char *fmt, va_list ap);
char *mprintf(const char *fmt, ...);

/* Logging */
void init_avlogbuf(void);
Julian Rother's avatar
Julian Rother committed
14 15 16 17 18
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, ...);
Julian Rother's avatar
Julian Rother committed
19
void job_failed(char *msg, ...);
Julian Rother's avatar
Julian Rother committed
20 21 22 23 24 25 26 27 28 29 30 31

/* 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);
Julian Rother's avatar
Julian Rother committed
32 33

/* JSON util */
34
char *jescape(char *s);