diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-20 20:11:19 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-20 20:11:19 +0200 |
| commit | 8351fa7752bb8341ef405a37ff7c73142715e981 (patch) | |
| tree | dde603d313f4f26934f2ce20a22dfd9b69324cf0 /src/cmd_util.h | |
| parent | beafdbe0d64340387d619c38554976410129f05b (diff) | |
| download | bokf-8351fa7752bb8341ef405a37ff7c73142715e981.tar.gz bokf-8351fa7752bb8341ef405a37ff7c73142715e981.zip | |
commands: split the command table by domain
Diffstat (limited to 'src/cmd_util.h')
| -rw-r--r-- | src/cmd_util.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/cmd_util.h b/src/cmd_util.h new file mode 100644 index 0000000..4113eb2 --- /dev/null +++ b/src/cmd_util.h @@ -0,0 +1,52 @@ +#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))); +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 |
