1#ifndef JSON_H
2#define JSON_H
3
4#include <stddef.h>
5#include <stdint.h>
6
7#include "scan.h"
8
9struct json {
10 char* buf;
11 size_t len;
12 size_t cap;
13};
14
15/* Free memory owned by JSON buffer
16 Safe to call on NULL or already freed buffers */
17void json_free(struct json* j);
18
19/* Encode library to JSON
20 On failure, j is freed/emptied
21 Returns 0=Success, -1=Failure */
22int json_library(struct json* j, const struct library* l);
23
24/* Encode item metadata to JSON
25 On failure, j is freed/emptied
26 Returns 0=Success, -1=Failure */
27int json_meta(struct json* j, const struct item* it, size_t size, long mtime, const char* type);
28
29#endif /* JSON_H */
30