summaryrefslogblamecommitdiffstats
path: root/types.h
blob: 692042a51673e663f8ca4db8e352d0f64bbefedc (plain) (tree)
1
2
3
4
5
6
7






                   




                   
                    
 
                   
                        




                    

                                   
































                                                                                     
                     

                                                                            
                             

                 








                             
                                    


                           
      
#ifndef _TYPES_H_
#define _TYPES_H_

#include <stddef.h>
#include <stdint.h>
#include <time.h>

#define ADDRLEN 40
#define BINDLEN 250
#define PWLEN 40
#define BASELEN 250
#define SIDLEN 28
#define MOUNTLEN 100

#define REQLEN 4000
#define MAXMSGLEN 100000

#define BOOL uint8_t
#define TRUE 1
#define FALSE 0

typedef struct _server_t_ server_t;

typedef struct {
	void (*callback)(void *data, int haveIn, int haveOut, int doCleanup);
	int fd;
} epoll_item_t;

typedef struct {
	void (*callback)(void *data, int haveIn, int haveOut, int doCleanup);
	int fd;
} epoll_listen_t;

typedef struct {
	void (*callback)(void *data, int haveIn, int haveOut, int doCleanup);
	int fd;
	int padding;
	// Send buffer (me to client)
	size_t sbPos, sbFill, sbLen;
	char *sendBuffer; // Dynamically allocated, might or might not get huge
	// Recv buffer (client's request)
	size_t rbPos;
	char readBuffer[REQLEN]; // Static, queries > 4000 bytes simply not supported
	BOOL bound;
} epoll_client_t;

typedef struct {
	void (*callback)(void *data, int haveIn, int haveOut, int doCleanup);
	int fd;
	// Send buffer (me to server)
	size_t sbPos, sbFill, sbLen;
	char *sendBuffer; // Dynamically allocated, might or might not get huge
	// Recv buffer (server's response)
	size_t rbPos;
	char readBuffer[MAXMSGLEN];
	BOOL bound;
	BOOL dynamic;
	//unsigned long messageId; // ID of message currently being received
	time_t lastActive;
	server_t *serverData;
} epoll_server_t;

struct _server_t_ {
	size_t baseLen;
	char ip[4];
	time_t lastLookup;
	char addr[ADDRLEN];
	char bind[BINDLEN];
	char password[PWLEN];
	char base[BASELEN];
	char sid[SIDLEN];
	char homeTemplate[MOUNTLEN];
	epoll_server_t con;
};

#endif