summaryrefslogtreecommitdiff
path: root/src/fscomch.h
blob: b7900e3e9557d5d9e9d5fcf7c8f44dd781af90cf (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
#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