diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2023-03-19 23:20:53 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2023-03-19 23:20:53 -0700 |
| commit | e33dc4755fb08ed08f30b5e1af65457556d5bcb7 (patch) | |
| tree | c075e9c4f076a7772eb5c0665fbd137e2fd6c3ab /src/fscomch.h | |
| parent | 26321477ae47bbf5d89b651842d8295e9ea9ea5d (diff) | |
fscomch--communication between multiple chess processes
Diffstat (limited to 'src/fscomch.h')
| -rw-r--r-- | src/fscomch.h | 24 |
1 files changed, 24 insertions, 0 deletions
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 <stdio.h> +#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 |
