blob: bc92467b288ee994c3a69fb27ea7ba755b375307 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#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();
void send_message(char* content, match_t match);
/* blocks */
char* read_message(match_t match, char* cancelToken);
char* make_uuid();
#endif
|