-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.h
More file actions
59 lines (50 loc) · 918 Bytes
/
server.h
File metadata and controls
59 lines (50 loc) · 918 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef SERVER_H
#define SERVER_H
#include "manager.h"
#include <stdio.h>
#define TOKEN "life.token"
#define FIFO "life.fifo"
enum
{
MAX_MANAGERS = 100,
TIMEOUT = 300
};
typedef struct
{
int managers_count;
int client_queue;
int size_x;
int size_y;
Manager managers[MAX_MANAGERS];
int manager_queues[MAX_MANAGERS];
int rstripes[MAX_MANAGERS + 1];
int wstripes[MAX_MANAGERS + 1];
FILE *fifo;
} Server;
enum
{
SERVER_ADD = 1,
SERVER_CLEAR,
SERVER_START,
SERVER_STOP,
SERVER_SNAPSHOT,
SERVER_END,
SERVER_MAX,
SERVER_ANSWER
};
enum
{
ALREADY_STARTED = 1,
ALREADY_STOPPED,
INVALID_COORDINATES
};
typedef struct
{
long type;
int parameter1;
int parameter2;
} ServerCommand;
Server server_create(int size_x, int size_y, int managers_count);
void server_destroy(Server server);
void server_run(Server server);
#endif