1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim:set expandtab ts=4 shiftwidth=4: */
4 * Copyright (c) 2008, 2010 Oracle and/or its affiliates, Inc. All rights
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 * Authors: Lin Ma <lin.ma@sun.com>
29 #ifdef GIO_COMPILATION
30 #define FN_EVENT_CREATED G_FILE_MONITOR_EVENT_CREATED
32 #define FN_EVENT_CREATED GAMIN_EVENT_CREATED
35 #define NODE_STATE_NONE 0x00000000
36 #define NODE_STATE_ASSOCIATED 0x00000001 /* This is a confilct to NODE_FLAG_STAT_DONE */
37 #define NODE_STATE_HAS_EVENTS 0x00000002
39 #define NODE_FLAG_NONE 0x00000000
40 #define NODE_FLAG_SNAPSHOT_UPDATED 0x00000001
41 #define NODE_FLAG_DIR 0x00000002
42 #define NODE_FLAG_STAT_UPDATED 0x00000004
44 #define NODE_CLE_STATE(f, st) (f->state &= ~(st))
45 #define NODE_SET_STATE(f, st) (f->state = ((f->state & ~(st)) | (st)))
46 #define NODE_HAS_STATE(f, st) (f->state & (st))
48 #define NODE_CLE_FLAG(f, fl) (f->flag &= ~(fl))
49 #define NODE_SET_FLAG(f, fl) (f->flag = ((f->flag & ~(fl)) | (fl)))
50 #define NODE_HAS_FLAG(f, fl) (f->flag & (fl))
52 typedef struct node node_t;
55 file_obj_t fobj; /* Inherit from file_obj_t, must be the first. */
60 GTimeVal atv; /* Timestamp for the first added sub. */
62 /* the parent and children of node */
64 GHashTable *children; /* children in basename */
66 /* List of subscriptions monitoring this fdata/path */
70 #ifdef GIO_COMPILATION
75 #define FILE_OBJECT(f) ((file_obj_t *)(f))
76 #define NODE_NAME(f) (FILE_OBJECT(f)->fo_name)
77 #define NODE_PARENT(f) (((node_t *)f)->parent)
78 #define NODE_IS_ACTIVE(f) (f->dir_subs || f->subs)
79 #define NODE_IS_REQUIRED_BY_PARENT(f) (NODE_PARENT(f) && NODE_PARENT(f)->dir_subs)
81 gboolean node_timeval_lt(const GTimeVal *val1, const GTimeVal *val2);
82 gboolean node_try_delete(node_t* node);
83 void node_traverse(node_t* node, void(*traverse_cb)(node_t*, gpointer), gpointer user_data);
84 node_t* node_find(node_t* node, const gchar* filename, gboolean create_on_missing);
85 gint node_lstat(node_t *f);
86 void node_create_children_snapshot(node_t *f, gint created_event, gboolean emit);
87 void node_adjust_deleted(node_t *f);
88 gboolean node_class_init();
90 typedef struct node_event
95 GTimeVal ctv; /* Created timestamp */
96 GTimeVal rename_tv; /* Possible rename timestamp */
99 node_event_t* node_event_new (int event, gpointer user_data);
100 void node_event_delete (node_event_t* ev);
102 #endif /* _FEN_NODE_H_ */