From e33dc4755fb08ed08f30b5e1af65457556d5bcb7 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Sun, 19 Mar 2023 23:20:53 -0700 Subject: fscomch--communication between multiple chess processes --- src/fscomch.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/fscomch.h (limited to 'src/fscomch.h') diff --git a/src/fscomch.h b/src/fscomch.h new file mode 100644 index 0000000..b7900e3 --- /dev/null +++ b/src/fscomch.h @@ -0,0 +1,24 @@ +#include +#ifndef FSCOMCH +#define FSCOMCH + +/* 1/2 second */ +static const unsigned long int awaitMatchNs = 500000000L; +/* 1/4 second */ +static const unsigned long int awaitMoveNs = 250000000L; + +typedef struct Match { + char* uuid; + FILE* streamIn; + FILE* streamOut; +} match_t; +match_t init_match(char* uuid, FILE* streamIn, FILE* streamOut); +void destroy_match(match_t match); +/* returns null if the matchfile is already extant */ +FILE* try_lock_match(); +/* creates a new match, waits for it to be joined by another player */ +match_t await_match(FILE* matchFile, char* cancelToken); +/* joins an existing match */ +match_t join_match(); +char* make_uuid(); +#endif -- cgit v1.3.1