2017-02-02 10:18:34 +00:00
|
|
|
#ifndef _LIB_H_
|
|
|
|
|
|
|
|
#define _LIB_H_
|
|
|
|
|
|
|
|
|
|
|
|
#define BUFSIZE 20
|
|
|
|
|
|
|
|
|
|
|
|
// debug flags
|
2017-02-05 11:08:02 +00:00
|
|
|
#define DEBUG 0x1
|
|
|
|
#define DEBUG_LEN 40
|
2017-02-02 10:18:34 +00:00
|
|
|
|
2017-02-14 08:33:48 +00:00
|
|
|
// constants
|
|
|
|
#define maxClients 0x4
|
|
|
|
|
2017-02-02 10:18:34 +00:00
|
|
|
|
2017-02-05 11:08:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2017-02-02 10:18:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************
|
|
|
|
**** Signatures ****
|
|
|
|
************************************************/
|
|
|
|
|
2017-02-05 11:08:02 +00:00
|
|
|
int debug(const char* tag, const char* msg);
|
2017-02-02 10:18:34 +00:00
|
|
|
|
2017-02-05 11:08:02 +00:00
|
|
|
int xbind(const int port);
|
2017-02-08 10:44:10 +00:00
|
|
|
int xlisten(const int xsocket, struct sockaddr_in* client);
|
|
|
|
|
2017-02-05 14:31:44 +00:00
|
|
|
int xconnect(const char* hostname, const int port, struct sockaddr_in* serv);
|
2017-02-08 10:44:10 +00:00
|
|
|
|
|
|
|
int xread(const int xsocket, char* buffer, int bufsize);
|
|
|
|
int xwrite(const int xsocket, char* buffer);
|
2017-02-14 08:31:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************
|
|
|
|
**** Structs ****
|
|
|
|
************************************************/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
FIN=0,
|
|
|
|
FACTO=1,
|
|
|
|
POW=2,
|
|
|
|
ANALYSE=3
|
|
|
|
}requete_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
requete_t type;
|
|
|
|
int taille;
|
|
|
|
}requete;
|
|
|
|
|
2017-02-02 10:18:34 +00:00
|
|
|
#endif
|