summaryrefslogtreecommitdiff
path: root/src/sys/system.h
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-06-29 21:43:54 +0900
committertanaka takashi <isazaka@gmail.com>2026-06-30 01:23:51 +0900
commit4bc721c3bf7589b519c5730d093f704ce56e3f09 (patch)
tree38da055ab15fd70f5c92584560ea73486e5ddce0 /src/sys/system.h
parent4c6a831aa2a57e2bcc20aa3fc2f1b7172f5be285 (diff)
refactor: MCP層をmcpc APIベースに刷新
- 独自JSON-RPC処理をmcpcへ置き換え - 各MCPツールを個別ソースへ分離 - 共通コンテキストと登録処理を整理 - mcpc互換修正と統合テストを更新
Diffstat (limited to 'src/sys/system.h')
-rw-r--r--src/sys/system.h90
1 files changed, 90 insertions, 0 deletions
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 <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+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