From 05c8e0a31a0d4192c590e833b24393208e1c751f Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Tue, 30 Jun 2026 19:03:25 +0900 Subject: fix: MCPCをvendored fork化しMCP準拠と接続安定性を改善 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Git submoduleを廃止してMCPCを直接管理 - Windowsで254リクエスト付近に発生する切断を修正 - JSON-RPC 2.0エラー応答を標準化 - tool schemaとruntimeの必須・任意引数を一致 - 1000回連続呼び出しの回帰テストを追加 --- third_party/mcpc/tst/commtst.h | 147 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 third_party/mcpc/tst/commtst.h (limited to 'third_party/mcpc/tst/commtst.h') diff --git a/third_party/mcpc/tst/commtst.h b/third_party/mcpc/tst/commtst.h new file mode 100644 index 0000000..49dcc93 --- /dev/null +++ b/third_party/mcpc/tst/commtst.h @@ -0,0 +1,147 @@ +#ifndef h_commtst +#define h_commtst + + +// clang-format off +#ifdef is_unix +#define _POSIX_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#ifdef is_win + +/* # define _WINSOCKAPI_ */ +#include +#include +#include +/* # include */ +#include +#include +#include "commtst.h" + +#endif +// clang-format on + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define ass0(f) \ + do { \ + int ec = (f); \ + if (0 != ec) { \ + fprintf(stderr, \ + "%s:%d,ec:%d syserr:%s\n", \ + __FILE__, \ + __LINE__, \ + ec, \ + strerror(errno)); \ + abort(); \ + } \ + } while (0) + +#define assT(f) \ + do { \ + if (!(f)) { \ + fprintf(stderr, \ + "abort@%s:%d,syserr:%s\n", \ + __FILE__, \ + __LINE__, \ + strerror(errno)); \ + abort(); \ + } \ + } while (0) + +#define assF(f) \ + do { \ + if ((f)) { \ + fprintf(stderr, \ + "abort@%s:%d,syserr:%s\n", \ + __FILE__, \ + __LINE__, \ + strerror(errno)); \ + abort(); \ + } \ + } while (0) + +#define assTcb(f, cb) \ + do { \ + if (!(f)) { \ + { cb }; \ + fprintf(stderr, "abort@%s:%d\n", __FILE__, __LINE__); \ + abort(); \ + } \ + } while (0) + +#define BUFCAP 1024 +#define PORT 8080 + +typedef int8_t i8_t; +typedef uint8_t u8_t; +typedef int16_t i16_t; +typedef uint16_t u16_t; +typedef int32_t i32_t; +typedef uint32_t u32_t; +typedef int64_t i64_t; +typedef uint64_t u64_t; + +typedef char8_t ch8_t; + +typedef size_t sz_t; + +#ifdef is_win +typedef SSIZE_T ssize_t; +#endif + +void read_atmost (void *src, char *rbuf, const size_t nexact, size_t *nread); + +void recv_atmost ( +#ifdef is_unix + int csock, +#elif defined(is_win) + SOCKET cosck, +#endif + char *rbuf, const size_t nmost, size_t *nread); + +int32_t read_u8str (const char8_t * const filename, char8_t * const destbuf); + +int32_t read_u8str_sz (const char8_t * const filename, char8_t * const destbuf, size_t *nread); + +void zero_trailing_white_char (char8_t * buf, const size_t len); + +void zero_trailing_white_char2 (char8_t * buf, size_t *len); + + +#ifdef is_unix +FILE *unix_fd2strm_r (int fd); +#endif + +#ifdef is_win +FILE *win_handle2strm (HANDLE h); +#endif + +#ifdef is_win +int win_handle2fd (HANDLE h); +#endif + + +#endif -- cgit v1.2.3