Select Git revision
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
util.h 1.47 KiB
#include <unistd.h>
#include <stdarg.h>
#include <libavutil/opt.h>
#include <libavformat/avformat.h>
/* Generic */
#define SL(s) (s), (sizeof(s)-1)
#define BL(b) (b), (sizeof(b))
extern int jobid;
char *vmprintf(const char *fmt, va_list ap);
char *mprintf(const char *fmt, ...);
void *xmalloc(size_t size);
char *hashfile(char *path);
double fileduration(char *path);
size_t filesize(char *path);
char *json_fileinfo(char *path);
void overwrite_check(char *path, char *srcpath, char *srchash);
int checktime(time_t min);
#define WORKER_APIKEY "WORKER_APIKEY"
#define WORKER_APIBASE "WORKER_APIBASE"
#define WORKER_RELEASED "WORKER_RELEASED"
#define WORKER_TMP "WORKER_TMP"
#define WORKER_RAW "WORKER_RAW"
void init_env(void);
/* JSON av parsing */
void parse_dict(AVDictionary **d, char *s);
void parse_chapters(AVFormatContext *ctx, char *s, int64_t duration);
/* Logging */
void init_avlogbuf(void);
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, ...);
void job_failed(char *msg, ...);
/* JSON parser */
#define JSON_KEY_SIZE 100
ssize_t jbin(char *s, char *buf, size_t len);
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)
int jint(char *s, int err);
char *jenter(char *s);
char *jnext(char *s);
char *jvalue(char *s);
char *jlookup(char *s, char *key);
/* JSON util */
char *jescape(char *s);