1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#ifndef BOKF_CMD_UTIL_H
#define BOKF_CMD_UTIL_H
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "commands.h"
#include "protocol.h"
#include "yyjson.h"
const char *sq(const unsigned char *p);
const char *arg_str(yyjson_val *args, const char *key);
int arg_int(yyjson_val *args, const char *key, int64_t *out);
int arg_bool(yyjson_val *args, const char *key, int *out);
const char *arg_type_name(enum arg_type type);
int enum_allowed(const char *values, const char *v);
void arg_error(char *err, size_t errlen, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
int command_validate_args(const struct command *cmd, yyjson_val *args,
char *err, size_t errlen);
yyjson_mut_val *fail(struct req *r, const char *code, const char *msg);
yyjson_mut_val *failf(struct req *r, const char *code, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
yyjson_mut_val *db_error(struct req *r);
yyjson_mut_val *db_sqlite_error(struct req *r);
void bind_text_or_null(sqlite3_stmt *st, int idx, const char *s);
int mkdir_p(const char *path, mode_t mode);
yyjson_mut_val *json_to_mut(yyjson_mut_doc *doc, const char *json);
int is_digits(const char *s);
int64_t default_fy_id(sqlite3 *db, int64_t org_id);
int req_fy(struct req *r, int64_t *out);
unsigned char *read_file(const char *path, size_t *out_len);
struct tpl_head {
int64_t id;
char name[128];
char series[16];
char description[256];
};
struct tpl_loaded {
char account[16];
char formula[256];
char desc[128];
};
double parse_kr_double(const char *s, int *ok);
char *replace_x(const char *text, double x);
int load_template(sqlite3 *db, int64_t org_id, int64_t id, const char *name,
struct tpl_head *head, char **err);
int load_template_rows(sqlite3 *db, int64_t org_id, int64_t tpl,
struct tpl_loaded **out, size_t *out_n, char **err);
#endif
|