#ifndef BOKF_CMD_UTIL_H #define BOKF_CMD_UTIL_H #include #include #include #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))); 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