From 4bc721c3bf7589b519c5730d093f704ce56e3f09 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Mon, 29 Jun 2026 21:43:54 +0900 Subject: refactor: MCP層をmcpc APIベースに刷新 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 独自JSON-RPC処理をmcpcへ置き換え - 各MCPツールを個別ソースへ分離 - 共通コンテキストと登録処理を整理 - mcpc互換修正と統合テストを更新 --- src/sys/system.h | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/sys/system.h (limited to 'src/sys/system.h') diff --git a/src/sys/system.h b/src/sys/system.h new file mode 100644 index 0000000..b526ec5 --- /dev/null +++ b/src/sys/system.h @@ -0,0 +1,90 @@ +#ifndef TINY_CONVMEM_SYS_SYSTEM_H +#define TINY_CONVMEM_SYS_SYSTEM_H + +#include +#include +#include + +typedef enum tiny_sys_status +{ + TINY_SYS_OK = 0, + TINY_SYS_NOT_FOUND, + TINY_SYS_BUSY, + TINY_SYS_ERROR +} tiny_sys_status_t; + +typedef enum tiny_sys_file_mode +{ + TINY_SYS_FILE_READ = 0, + TINY_SYS_FILE_WRITE_NEW, + TINY_SYS_FILE_READ_WRITE, + TINY_SYS_FILE_READ_WRITE_CREATE, + TINY_SYS_FILE_LOCK +} tiny_sys_file_mode_t; + +typedef enum tiny_sys_seek_origin +{ + TINY_SYS_SEEK_BEGIN = 0, + TINY_SYS_SEEK_CURRENT, + TINY_SYS_SEEK_END +} tiny_sys_seek_origin_t; + +typedef struct tiny_sys_file +{ + intptr_t native; +} tiny_sys_file_t; + +typedef struct tiny_sys_arguments +{ + int count; + char **values; +} tiny_sys_arguments_t; + +/* Internal test seam. A call index of 1 fails the next matching operation. */ +typedef enum tiny_sys_test_operation +{ + TINY_SYS_TEST_OPEN = 0, + TINY_SYS_TEST_READ, + TINY_SYS_TEST_WRITE, + TINY_SYS_TEST_SEEK, + TINY_SYS_TEST_SIZE, + TINY_SYS_TEST_TRUNCATE, + TINY_SYS_TEST_FLUSH, + TINY_SYS_TEST_REPLACE, + TINY_SYS_TEST_RANDOM, + TINY_SYS_TEST_OPERATION_COUNT +} tiny_sys_test_operation_t; + +void tiny_sys_test_reset(void); +bool tiny_sys_test_fail_after(tiny_sys_test_operation_t operation, size_t call_index); +void tiny_sys_test_max_transfer(uint32_t length); + +bool tiny_sys_arguments_init(tiny_sys_arguments_t *arguments, int argc, char **argv); +void tiny_sys_arguments_free(tiny_sys_arguments_t *arguments); + +char *tiny_sys_path_absolute(const char *path); +char *tiny_sys_path_join(const char *directory, const char *name); +char *tiny_sys_temp_directory_create(const char *prefix); +tiny_sys_status_t tiny_sys_directory_create(const char *path); +bool tiny_sys_file_remove(const char *path); +bool tiny_sys_directory_remove(const char *path); +bool tiny_sys_path_replace(const char *source, const char *destination); + +void tiny_sys_file_init(tiny_sys_file_t *file); +bool tiny_sys_file_valid(const tiny_sys_file_t *file); +tiny_sys_status_t +tiny_sys_file_open(tiny_sys_file_t *file, const char *path, tiny_sys_file_mode_t mode); +void tiny_sys_file_close(tiny_sys_file_t *file); +bool tiny_sys_file_read(tiny_sys_file_t *file, void *data, uint32_t length, uint32_t *actual); +bool +tiny_sys_file_write(tiny_sys_file_t *file, const void *data, uint32_t length, uint32_t *actual); +bool tiny_sys_file_seek(tiny_sys_file_t *file, int64_t offset, tiny_sys_seek_origin_t origin); +bool tiny_sys_file_size(const tiny_sys_file_t *file, uint64_t *size); +bool tiny_sys_file_truncate(tiny_sys_file_t *file); +bool tiny_sys_file_flush(tiny_sys_file_t *file); + +uint64_t tiny_sys_now_milliseconds(void); +uint64_t tiny_sys_monotonic_milliseconds(void); +bool tiny_sys_random_bytes(void *data, size_t length); + +#endif -- cgit v1.2.3