File: gam_node.h

package info (click to toggle)
gamin 0.1.10-4.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 7,416 kB
  • ctags: 2,022
  • sloc: ansic: 10,675; sh: 10,333; python: 3,706; xml: 1,303; makefile: 319; awk: 48
file content (107 lines) | stat: -rw-r--r-- 3,788 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

#ifndef __GAM_NODE_H__
#define __GAM_NODE_H__

#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "gam_event.h"
#include "gam_subscription.h"
#include "gam_fs.h"

G_BEGIN_DECLS

#define FLAG_NEW_NODE 1 << 5

/*
 * Special monitoring modes (pflags)
 */
#define MON_MISSING 1 << 0  /* The resource is missing */
#define MON_NOKERNEL    1 << 1  /* file(system) not monitored by the kernel */
#define MON_BUSY    1 << 2  /* Too busy to be monitored by the kernel */
#define MON_WRONG_TYPE  1 << 3  /* Expecting a directory and got a file */
#define MON_ALL_PFLAGS (MON_MISSING|MON_NOKERNEL|MON_BUSY|MON_WRONG_TYPE)

typedef struct _GamNode GamNode;

typedef gboolean (*GamSubFilterFunc) (GamSubscription *sub);

struct _GamNode {
        /* the node informations proper */
	char *path;		/* The file path */
	GList *subs;		/* the list of subscriptions */
	GNode *node;		/* pointer in the tree */
	gboolean is_dir;	/* is that a directory or expected to be one */
	int flags;		/* generic flags */
	int poll_time;		/* How often this node should be polled */
	gam_fs_mon_type mon_type; /* the type of notification that should be done */

        /* what used to be stored in a separate data structure */
	int checks;
	int pflags;		/* A combination of MON_xxx flags */
	time_t lasttime;	/* Epoch of last time checking was done */
	int flow_on_ticks;	/* Number of ticks while flow control is on */
	struct stat sbuf;	/* The stat() informations in last check */
};


GamNode               *gam_node_new                 (const char     *path,
						   GamSubscription *initial_sub,
						   gboolean        is_dir);

void                  gam_node_free                (GamNode         *node);

GamNode               *gam_node_parent              (GamNode         *node);

gboolean              gam_node_is_dir              (GamNode         *node);

void                  gam_node_set_is_dir          (GamNode         *node,
						   gboolean        is_dir);
	
const char  *gam_node_get_path            (GamNode         *node);

GList                *gam_node_get_subscriptions   (GamNode         *node);

gboolean              gam_node_add_subscription    (GamNode         *node,
						   GamSubscription *sub);

gboolean              gam_node_remove_subscription (GamNode         *node,
						   GamSubscription *sub);

gboolean              gam_node_has_dir_subscriptions(GamNode * node);

void                  gam_node_set_node            (GamNode         *node,
						   GNode          *gnode);
GNode                *gam_node_get_node            (GamNode         *node);

void                  gam_node_set_data            (GamNode         *node,
						   gpointer        data,
						   GDestroyNotify  destroy);

gpointer              gam_node_get_data            (GamNode         *node);

void                  gam_node_set_flag            (GamNode         *node,
						   int             flag);
void                  gam_node_unset_flag          (GamNode         *node,
						   int             flag);
gboolean              gam_node_has_flag            (GamNode         *node,
						   int             flag);

void                  gam_node_set_pflag            (GamNode         *node,
						     int             flag);
void                  gam_node_unset_pflag          (GamNode         *node,
						     int             flag);
gboolean              gam_node_has_pflag            (GamNode         *node,
						     int             flag);
void                  gam_node_set_pflags           (GamNode         *node,
						     int             flags);
gboolean              gam_node_has_pflags           (GamNode         *node,
						     int             flags);


void	gam_node_emit_event (GamNode *node, GaminEventType event);


G_END_DECLS

#endif /* __GAM_NODE_H__ */