#ifndef CST_TOOLS_INTERNAL_H #define CST_TOOLS_INTERNAL_H #include "cst_tools.h" #include "cst_util.h" #define READ_FILE_MAX (2 * 1024 * 1024) /* Value of key, or NULL when absent. */ const char *tool_arg(const ctl_tool_call_t *call, const char *key); const char *tool_arg_n(const ctl_tool_call_t *call, const char *key, size_t *len); /* Integer arg, def when absent or empty. */ long tool_arg_long(const ctl_tool_call_t *call, const char *key, long def); int tool_arg_bool(const ctl_tool_call_t *call, const char *key, int def); int tool_set_result(cst_tool_result_t *r, const char *s, int code); int tool_set_resultf(cst_tool_result_t *r, int code, const char *fmt, ...); int tool_take_buf(cst_tool_result_t *r, cst_buf_t *b, int code); /* Whole file (NULL when missing, unreadable or larger than max>0). */ char *tool_slurp(const char *full, size_t *out_len, size_t max); int tool_write_whole(const char *full, const char *data, size_t n); void tool_ensure_parent_dirs(const char *workspace_root, const char *rel); void tool_append_diff(cst_buf_t *b, const char *relpath, const char *oldc, size_t olen, const char *newc, size_t nlen); int tool_is_binary(const char *s, size_t n); /* Workspace-relative display form of an absolute resolved path. */ const char *tool_rel(const char *workspace_real, const char *full); int cst_tool_read_file2(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_list_dir(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_glob(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_grep(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_edit_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_delete_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_move_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_todo_write(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_ask_user(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); /* Clipboard text (system clipboard, not the workspace). */ int cst_tool_clipboard_read(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_clipboard_write(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_preview_clipboard_write(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, char **out); int cst_tool_web_fetch(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_web_search(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_download(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_md_to_html(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_preview_md_to_html(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, char **out); int cst_tool_read_pdf(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_session_search(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_device_info(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_view_image(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_tool_deliver_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, cst_tool_result_t *r); int cst_preview_write_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, char **out); int cst_preview_apply_patch(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, char **out); int cst_preview_edit_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, char **out); int cst_preview_delete_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, char **out); int cst_preview_move_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c, char **out); #endif