util.h 1.06 KB
Newer Older
Julian Rother's avatar
Julian Rother committed
1 2
#include <unistd.h>
#include <stdarg.h>
3 4
#include <libavutil/opt.h>
#include <libavformat/avformat.h>
Julian Rother's avatar
Julian Rother committed
5 6 7 8

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

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

14 15 16 17 18 19
void *xmalloc(size_t size);

/* JSON av parsing */
void parse_dict(AVDictionary **d, char *s);
void parse_chapters(AVFormatContext *ctx, char *s, int64_t duration);

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

/* JSON parser */
Julian Rother's avatar
Julian Rother committed
30
#define JSON_KEY_SIZE 100
Julian Rother's avatar
Julian Rother committed
31 32

ssize_t jbin(char *s, char *buf, size_t len);
Julian Rother's avatar
Julian Rother committed
33 34
char *jstrb(char *s, char *err, char *buf, size_t len);
#define jstr(s, e) jstrb(s, e, (char[JSON_KEY_SIZE]){0}, JSON_KEY_SIZE)
Julian Rother's avatar
Julian Rother committed
35 36 37 38 39
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
40 41

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