util.h 1.14 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
void *xmalloc(size_t size);
Julian Rother's avatar
Julian Rother committed
15
char *hashfile(char *path);
16 17
double fileduration(char *path);
size_t filesize(char *path);
18 19 20 21 22

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

/* JSON parser */
Julian Rother's avatar
Julian Rother committed
33
#define JSON_KEY_SIZE 100
Julian Rother's avatar
Julian Rother committed
34 35

ssize_t jbin(char *s, char *buf, size_t len);
Julian Rother's avatar
Julian Rother committed
36 37
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
38 39 40 41 42
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
43 44

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