1/*
2 * File:   fce_api_internal.h
3 * Author: mw
4 *
5 * Created on 1. Oktober 2010, 23:48
6 */
7
8#ifndef _FCE_API_INTERNAL_H
9#define	_FCE_API_INTERNAL_H
10
11#include <stdbool.h>
12
13#define FCE_MAX_UDP_SOCKS 5     /* Allow a maximum of udp listeners for file change events */
14#define FCE_SOCKET_RETRY_DELAY_S 600 /* Pause this time in s after socket was broken */
15#define FCE_PACKET_VERSION  1
16#define FCE_HISTORY_LEN 10  /* This is used to coalesce events */
17#define MAX_COALESCE_TIME_MS 1000  /* Events oldeer than this are not coalesced */
18
19#define FCE_COALESCE_CREATE (1 << 0)
20#define FCE_COALESCE_DELETE (1 << 1)
21#define FCE_COALESCE_ALL    (FCE_COALESCE_CREATE | FCE_COALESCE_DELETE)
22
23struct udp_entry
24{
25    int sock;
26    char *addr;
27    char *port;
28    struct addrinfo addrinfo;
29    struct sockaddr_storage sockaddr;
30    time_t next_try_on_error;      /* In case of error set next timestamp to retry */
31};
32
33struct fce_history
34{
35    unsigned char mode;
36	int is_dir;
37	char path[MAXPATHLEN + 1];
38	struct timeval tv;
39};
40
41struct fce_close_event {
42    time_t time;
43	char path[MAXPATHLEN + 1];
44};
45
46#define PACKET_HDR_LEN (sizeof(struct fce_packet) - FCE_MAX_PATH_LEN)
47
48bool fce_handle_coalescation( char *path, int is_dir, int mode );
49void fce_initialize_history();
50
51
52#endif	/* _FCE_API_INTERNAL_H */
53
54