/* commmon.h - Common definitions, functions, etc
 *
 * (c) Tiago Alves Macambira - 2003
 *
 * $Id: common.h,v 1.6 2003/08/04 03:20:13 tmacam Exp $
 *
 */

#ifndef _COMMON_H
#define _COMMON_H
#include <netinet/in.h>

#define SERV_TCP_PORT 1112
#define REQ_SIZE      100
#define RES_SIZE      100

#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif

#define MAX_FILENAME_LEN 400
#define MAX_PATTERN_LEN	256	/* tamanho máximo para o padrão de busca */
/*#define MAX_ADDRESS_SIZE 20*/

int sendall(int s, char *buf, int *len);
unsigned long get_long_time();



typedef struct {
	int socketfd;				/* socket descriptor*/
	char filename[MAX_FILENAME_LEN];	/* obvious*/
	struct sockaddr_in address;		/* slaves inet adress */
	unsigned long matches;			/* # matches found by D slave*/
} slave_ctl;

typedef struct{
	unsigned int approx_k;			/* numero de erros permitido*/
	unsigned char pattern[MAX_PATTERN_LEN];	/* padrão de busca */
	unsigned char filename[MAX_FILENAME_LEN];
} slave_request;

typedef struct {
	unsigned long int matches_found; /* Numero de ocorrências */
	unsigned long process_time;	/* tempo em us usado no escravo */
} slave_response;

#endif
