#ifndef LIB_H
#define LIB_H

#pragma pack(push,1)
#pragma pack(1)

#define MAX_TC 200

typedef struct
{
	int ID[MAX_TC];
	unsigned long IP [MAX_TC];
	int type[MAX_TC];
	char name[MAX_TC][20];
	int NumTerm;
}TabConec;

unsigned long Inet_addr(char *ip);
char *Inet_ntoa(unsigned long ip);

void GetTabConec(TabConec *tabela);
char *GetTypeTerm(int ID,int type);

int StartServer();

typedef struct
{
	char gateway[21];
	char nameserv[21];
	char TCname[21];
	char UpdServ[99];
	char Updser[21];
	char UpdPass[21];
}UPDConfig;

typedef struct
{
	char IPdinamico;
	char BuscaServer;
}PARAMConfig;

typedef struct
{
	char host[21];
	char address[21];
	char netMask[21];
	char line1[21];
	char line2[21];
	char line3[21];
	char line4[21];
	int time;
}Config;

int SendImageFromFile(int ID, char *filename, int width, int height, int div, int index, int loop, int pause);
int SendText(int ID, char *line1, char *Line2, int time);
int SendRestart(int ID);

int SendGetParamConfig(int ID);
int GetParamConfig(int ID,PARAMConfig *param);
int SendParamConfig(int ID, PARAMConfig param);

int SendGetConfig(int ID);
int GetConfig(int ID, Config *conf);
int SendConfig(int ID,Config conf);

int SendGetUpdConfig(int ID);
int GetUpdConfig(int ID, UPDConfig *upd);
int SendUpdConfig(int ID,UPDConfig upd);

int SendProductNotFound(int ID);
int SendProductPrice(int ID,char *name, char *price);

int CheckCMD(char *buffer);

#define BARCODE 89
#define MCR 69
#define CHAR 53
#define SEND_FILE_OK 100
#define RELOAD_OK 118
#define DELETE_OK 102
#define RELOAD_PRE_OK 120
#define SENDSETUP_OK 24
#define SET_LEC 66
#define SET_KEY 50
#define SET_TIME_OK 40
#define TEXT_OK 36
#define DISP_CLEAR_OK 34
#define IMAGE_OK 38
#define LOOP_START 44
#define LOOP_STOP 46
#define RESTART_OK 122

#define black 0x100
#define brown 0x101
#define green 0x102
#define olive 0x103
#define navy 0x104
#define purple 0x105
#define teal 0x106
#define gray 0x107
#define silver 0x108
#define red 0x109
#define lime 0x10A
#define yellow 0x10B
#define blue 0x10C
#define fuchsia 0x10D
#define aqua 0x10E
#define white 0x10F

typedef struct {
	unsigned long dwMY_IP_ADD;
	unsigned long dwServer_IP;
	unsigned long dwNetMask;
	unsigned long dwGateway;
	unsigned long dwNameServer;
	char TCName[32];
	unsigned short wPortsv;
	char FTPs[100];
	char FTPu[30];
	char FTPp[30];
	unsigned long dwDHCP;
	unsigned long dwSearchServer;
} ARG_SETUP_TCP;

typedef struct {
	unsigned short wPosX;
	unsigned short wPosY;
	char sText[128];
	char sFont[32];
	unsigned short wSize;
	unsigned short wColor;
	unsigned short wBGColor;
} ARG_DISPLAY_TEXT;

int SendSetLec(int ID, int arg);
int ReceiveMCR(int ID, char *Track1, char *Track2);

int SetEnableKey(int ID, int arg);
int ReceiveCHAR(int ID, char *caractere);

int ClearDisp(int ID, unsigned short color);
int SetTime(int ID, unsigned short time);
int StartLoop(int ID);
int StopLoop(int ID);
int SendText_504(int ID, ARG_DISPLAY_TEXT text);
int SendImage_504(int ID,char *Paleta,char *Imagem);

int SendSetup_504(int ID, ARG_SETUP_TCP setup);
int GetSetup_504(int ID, ARG_SETUP_TCP *setup);
int SendGetSetup_504(int ID);

int ReceiveBAR(int ID, char *Buffer);

int SendFile(int ID, char *origem, char *dest);
int ReloadADV(int ID);
int DeleteADV(int ID);
int DeletePreImage(int ID);
int ReloadPreImage(int ID);
int LoadImage(int ID,int Frame);

int Restart_504(int ID);
int CheckCMD_504(int *ID, int *cmd);
int chave_ativa();

#pragma pack(pop)

#endif
