Elaborato_SO/inc/structures.h

53 lines
771 B
C
Raw Normal View History

2023-05-14 18:51:32 +02:00
#ifndef STRUCTURES_H
#define STRUCTURES_H
2023-05-14 21:43:25 +02:00
2023-05-14 18:51:32 +02:00
// semaphore
union semun {
int val;
struct semid_ds * buf;
unsigned short * array;
};
// shared memory
2023-05-14 22:13:55 +02:00
#define KEYFILE "../LICENSE"
#define SHMERR (void *)-1
2023-05-14 18:51:32 +02:00
typedef struct {
int collums;
int rows;
char player1Token;
char player2Token;
} input_server_t;
typedef enum {
EMPTY,
PLAYER1,
PLAYER2
} tile_t;
2023-05-14 21:43:25 +02:00
// signal
#define DEFAULT_SIGINT 2
#define TIME_TO_RESET 10
2023-05-14 18:51:32 +02:00
2023-05-14 22:13:55 +02:00
//message queue
typedef struct {
2023-05-16 16:53:23 +02:00
long mtype; // type 1
2023-05-16 17:07:35 +02:00
int player_id;
2023-05-14 22:13:55 +02:00
input_server_t server_in;
2023-05-16 15:55:05 +02:00
} msg_t;
2023-05-14 22:13:55 +02:00
2023-05-16 16:53:23 +02:00
typedef struct {
long mtype; // type 2
int move;
} move_t;
2023-05-16 23:42:42 +02:00
#define MAX_NAME 16
2023-05-16 23:27:27 +02:00
typedef struct {
long mtype; // type 3
int id;
2023-05-17 14:24:46 +02:00
char name_player[MAX_NAME];
2023-05-16 23:27:27 +02:00
} player_names_t;
2023-05-14 18:51:32 +02:00
#endif