Elaborato_SO/inc/structures.h

55 lines
804 B
C

#ifndef STRUCTURES_H
#define STRUCTURES_H
#include <sys/types.h>
// semaphore
union semun {
int val;
struct semid_ds * buf;
unsigned short * array;
};
// shared memory
#define KEYFILE "../LICENSE"
#define SHMERR (void *)-1
typedef struct {
int collums;
int rows;
char player1Token;
char player2Token;
} input_server_t;
typedef enum {
EMPTY,
PLAYER1,
PLAYER2
} tile_t;
// signal
#define DEFAULT_SIGINT 2
#define TIME_TO_RESET 10
//message queue
typedef struct {
long mtype; // type 1
int player_id;
input_server_t server_in;
} msg_t;
typedef struct {
long mtype; // type 2
int move;
} move_t;
#define MAX_NAME 16
typedef struct {
long mtype; // type 3
int id;
char name_player[MAX_NAME];
pid_t pid;
} player_ds;
#endif