regify utility  2.0.0-0
fam.h
1 /*
2  * Copyright regify
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
44 #ifndef REGIFY_UTIL_FAM_H
45 #define REGIFY_UTIL_FAM_H
46 
47 /* Only need to export C interface if used by C++ source code */
48 #ifdef __cplusplus
49 extern "C" {
50 #endif /* __cplusplus */
51 
52 
54 #define RU_FAM_CREATED 0x001
56 #define RU_FAM_DELETED 0x002
58 #define RU_FAM_MODIFIED 0x004
60 #define RU_FAM_MOVED 0x008
62 #define RU_FAM_ATTRIB 0x010
63 
65 #define RU_FAM_KILL_TIMEOUT 5
67 #define RU_FAM_POLL_TIMEOUT 250
69 #define RU_FAM_QUEUE_TIMEOUT 50
70 
71 typedef struct ruFamEvent_ ruFamEvent;
72 struct ruFamEvent_ {
73  int eventType; // type of event #fam_*
74  perm_chars srcPath; // object file path
75  perm_chars dstPath; // destination path for #RU_FAM_MOVED
76 };
77 
83 typedef void (*ruFamHandler) (ruFamEvent* fe, perm_ptr ctx);
84 
88 typedef void* ruFamCtx;
89 
90 
103  ruFamHandler eventCallBack, perm_ptr ctx);
104 
112 
118 RUAPI bool ruFamQuit(ruFamCtx o);
119 
125 RUAPI const char* ruFamEventTypeString(int32_t action);
126 
136 RUAPI void ruFamLogEventFunc(uint32_t loglevel, trans_chars file, trans_chars func,
137  int32_t line, ruFamEvent *fe, trans_chars prefix);
138 
145 #define ruFamEventLog(lvl, fe, prefix) ruMacStart { \
146  if(ruDoesLog(lvl)) { \
147  ruFamLogEventFunc(lvl, __FILE__, __func__, __LINE__, fe, prefix); \
148  } \
149 } ruMacEnd
150 
156 RUAPI char* ruFamEventString(ruFamEvent* fe);
157 
165 RUAPI ruFamEvent* ruFamEventNew(int eventType, trans_chars filePath, trans_chars destPath);
166 
173 
174 #ifdef __cplusplus
175 }
176 #endif /* __cplusplus */
177 #endif //REGIFY_UTIL_FAM_H
178 
RUAPI bool ruFamQuit(ruFamCtx o)
RUAPI char * ruFamEventString(ruFamEvent *fe)
void * ruFamCtx
Definition: fam.h:88
RUAPI ruFamEvent * ruFamEventNew(int eventType, trans_chars filePath, trans_chars destPath)
RUAPI ptr ruFamEventFree(ptr o)
RUAPI void ruFamLogEventFunc(uint32_t loglevel, trans_chars file, trans_chars func, int32_t line, ruFamEvent *fe, trans_chars prefix)
void(* ruFamHandler)(ruFamEvent *fe, perm_ptr ctx)
Definition: fam.h:83
RUAPI ruFamCtx ruFamKillMonitor(ruFamCtx o)
RUAPI const char * ruFamEventTypeString(int32_t action)
RUAPI ruFamCtx ruFamMonitorFilePath(trans_chars filePath, trans_chars threadName, ruFamHandler eventCallBack, perm_ptr ctx)
const void * perm_ptr
A permanent pointer.
Definition: regify-util.h:277
const char * trans_chars
A transient NULL terminated string pointer.
Definition: regify-util.h:186
const char * perm_chars
A permanent NULL terminated string pointer.
Definition: regify-util.h:176
void * ptr
A generic pointer.
Definition: regify-util.h:304
Definition: fam.h:72
perm_chars dstPath
Definition: fam.h:75
int eventType
Definition: fam.h:73
perm_chars srcPath
Definition: fam.h:74