20#ifndef __CLSYNC_INDEXES_H
21#define __CLSYNC_INDEXES_H
45 GHashTable *nodenames_ht;
48typedef struct indexes indexes_t;
53static inline int indexes_remove_bywd ( indexes_t *indexes_p,
int wd )
56 char *fpath = g_hash_table_lookup ( indexes_p->wd2fpath_ht, GINT_TO_POINTER ( wd ) );
57 ret |= g_hash_table_remove ( indexes_p->wd2fpath_ht, GINT_TO_POINTER ( wd ) );
59 if ( fpath == NULL ) {
60 error (
"Cannot remove from index \"fpath2wd\" by wd %i.", wd );
64 ret |= g_hash_table_remove ( indexes_p->fpath2wd_ht, fpath );
71static inline char *indexes_wd2fpath ( indexes_t *indexes_p,
int wd )
73 return g_hash_table_lookup ( indexes_p->wd2fpath_ht, GINT_TO_POINTER ( wd ) );
79static inline int indexes_fpath2wd ( indexes_t *indexes_p,
const char *fpath )
81 gpointer gint_p = g_hash_table_lookup ( indexes_p->fpath2wd_ht, fpath );
86 return GPOINTER_TO_INT ( gint_p );
92static inline int indexes_add_wd ( indexes_t *indexes_p,
int wd,
const char *fpath_const,
size_t fpathlen )
94 debug ( 4,
"indexes_add_wd(indexes_p, %i, \"%s\", %i)", wd, fpath_const, fpathlen );
95 char *fpath = xmalloc ( fpathlen + 1 );
96 memcpy ( fpath, fpath_const, fpathlen + 1 );
97 g_hash_table_insert ( indexes_p->wd2fpath_ht, GINT_TO_POINTER ( wd ), fpath );
98 g_hash_table_insert ( indexes_p->fpath2wd_ht, fpath, GINT_TO_POINTER ( wd ) );
102static inline eventinfo_t *indexes_fpath2ei ( indexes_t *indexes_p,
const char *fpath )
104 return (
eventinfo_t * ) g_hash_table_lookup ( indexes_p->fpath2ei_ht, fpath );
107static inline int indexes_fpath2ei_add ( indexes_t *indexes_p,
char *fpath,
eventinfo_t *evinfo )
109 debug ( 5,
"\"%s\"", fpath );
110 g_hash_table_replace ( indexes_p->fpath2ei_ht, fpath, evinfo );
116 g_hash_table_replace ( indexes_p->fpath2ei_coll_ht[
queue_id], fpath, evinfo );
117 debug ( 3,
"indexes_queueevent(indexes_p, \"%s\", evinfo, %i). It's now %i events collected in queue %i.", fpath,
queue_id, g_hash_table_size ( indexes_p->fpath2ei_coll_ht[
queue_id] ),
queue_id );
123 return (
eventinfo_t * ) g_hash_table_lookup ( indexes_p->fpath2ei_coll_ht[
queue_id], fpath );
128 return g_hash_table_size ( indexes_p->fpath2ei_coll_ht[
queue_id] );
131static inline int indexes_removefromqueue ( indexes_t *indexes_p,
char *fpath,
queue_id_t queue_id )
134 g_hash_table_remove ( indexes_p->fpath2ei_coll_ht[
queue_id], fpath );
135 debug ( 3,
"indexes_removefromqueue(indexes_p, \"%s\", %i). It's now %i events collected in queue %i.", fpath,
queue_id, g_hash_table_size ( indexes_p->fpath2ei_coll_ht[
queue_id] ),
queue_id );
141 g_hash_table_replace ( indexes_p->exc_fpath_coll_ht[
queue_id], fpath, GINT_TO_POINTER ( flags ) );
142 debug ( 3,
"indexes_addexclude(indexes_p, \"%s\", %i). It's now %i events collected in queue %i.", fpath,
queue_id, g_hash_table_size ( indexes_p->exc_fpath_coll_ht[
queue_id] ),
queue_id );
146static inline int indexes_addexclude_aggr ( indexes_t *indexes_p,
char *fpath,
eventinfo_flags_t flags )
148 debug ( 3,
"indexes_addexclude_aggr(indexes_p, \"%s\", %u).", fpath, flags );
149 gpointer flags_gp = g_hash_table_lookup ( indexes_p->exc_fpath_ht, fpath );
151 if ( flags_gp != NULL )
152 flags |= GPOINTER_TO_INT ( flags_gp );
158 g_hash_table_replace ( indexes_p->exc_fpath_ht, fpath, GINT_TO_POINTER ( flags ) );
159 debug ( 3,
"indexes_addexclude_aggr(indexes_p, \"%s\", flags): %u.", fpath, flags );
163static inline int indexes_outaggr_add ( indexes_t *indexes_p,
char *outline,
eventinfo_flags_t flags )
165 gpointer flags_gp = g_hash_table_lookup ( indexes_p->out_lines_aggr_ht, outline );
167 if ( flags_gp != NULL )
168 flags |= GPOINTER_TO_INT ( flags_gp );
174 g_hash_table_replace ( indexes_p->out_lines_aggr_ht, outline, GINT_TO_POINTER ( flags ) );
175 debug ( 3,
"indexes_outaggr_aggr(indexes_p, \"%s\").", outline );
179static inline fileinfo_t *indexes_fileinfo ( indexes_t *indexes_p,
const char *fpath )
181 return (
fileinfo_t * ) g_hash_table_lookup ( indexes_p->fileinfo_ht, fpath );
184static inline int indexes_fileinfo_add ( indexes_t *indexes_p,
const char *fpath_const,
fileinfo_t *fi )
186 size_t fpathlen = strlen ( fpath_const );
187 debug ( 4,
"indexes_add_wd(indexes_p, \"%s\", %p)", fpath_const, fpathlen );
188 char *fpath = xmalloc ( fpathlen + 1 );
189 memcpy ( fpath, fpath_const, fpathlen + 1 );
190 g_hash_table_insert ( indexes_p->fileinfo_ht, fpath, fi );
@ EVIF_CONTENTRECURSIVELY
enum eventinfo_flags eventinfo_flags_t
struct eventinfo eventinfo_t
#define debug(debug_level,...)
struct fileinfo fileinfo_t
GHashTable * fpath2ei_coll_ht[QUEUE_MAX]
GHashTable * exc_fpath_ht
GHashTable * out_lines_aggr_ht
GHashTable * nonthreaded_syncing_fpath2ei_ht
GHashTable * exc_fpath_coll_ht[QUEUE_MAX]