regify utility  2.0.0-0
File Access Monitoring

This section contains file access monitoring routines. More...

Data Structures

struct  ruFamEvent_
 

Macros

#define RU_FAM_CREATED   0x001
 
#define RU_FAM_DELETED   0x002
 
#define RU_FAM_MODIFIED   0x004
 
#define RU_FAM_MOVED   0x008
 
#define RU_FAM_ATTRIB   0x010
 
#define RU_FAM_KILL_TIMEOUT   5
 
#define RU_FAM_POLL_TIMEOUT   250
 
#define RU_FAM_QUEUE_TIMEOUT   50
 
#define ruFamEventLog(lvl, fe, prefix)
 

Typedefs

typedef struct ruFamEvent_ ruFamEvent
 
typedef void(* ruFamHandler) (ruFamEvent *fe, perm_ptr ctx)
 
typedef void * ruFamCtx
 

Functions

RUAPI ruFamCtx ruFamMonitorFilePath (trans_chars filePath, trans_chars threadName, ruFamHandler eventCallBack, perm_ptr ctx)
 
RUAPI ruFamCtx ruFamKillMonitor (ruFamCtx o)
 
RUAPI bool ruFamQuit (ruFamCtx o)
 
RUAPI const char * ruFamEventTypeString (int32_t action)
 
RUAPI void ruFamLogEventFunc (uint32_t loglevel, trans_chars file, trans_chars func, int32_t line, ruFamEvent *fe, trans_chars prefix)
 
RUAPI char * ruFamEventString (ruFamEvent *fe)
 
RUAPI ruFamEventruFamEventNew (int eventType, trans_chars filePath, trans_chars destPath)
 
RUAPI ptr ruFamEventFree (ptr o)
 

Detailed Description

This section contains file access monitoring routines.

Example:

void myfamHandler(ruFamEvent* fe, perm_ptr ctx) {
// important to free this
}
"/some/dir","test",
myfamHandler, NULL);
// run your program...
void * ruFamCtx
Definition: fam.h:88
#define ruFamEventLog(lvl, fe, prefix)
Definition: fam.h:145
RUAPI ptr ruFamEventFree(ptr o)
RUAPI ruFamCtx ruFamKillMonitor(ruFamCtx o)
RUAPI ruFamCtx ruFamMonitorFilePath(trans_chars filePath, trans_chars threadName, ruFamHandler eventCallBack, perm_ptr ctx)
#define RU_LOG_VERB
This level includes RU_LOG_INFO and verbose logging used for debugging and is usually high quantity.
Definition: logging.h:106
const void * perm_ptr
A permanent pointer.
Definition: regify-util.h:277
Definition: fam.h:72

Macro Definition Documentation

◆ RU_FAM_ATTRIB

#define RU_FAM_ATTRIB   0x010

File meta data changed

◆ RU_FAM_CREATED

#define RU_FAM_CREATED   0x001

File was created

◆ RU_FAM_DELETED

#define RU_FAM_DELETED   0x002

File was deleted

◆ RU_FAM_KILL_TIMEOUT

#define RU_FAM_KILL_TIMEOUT   5

seconds to wait before hard kill

◆ RU_FAM_MODIFIED

#define RU_FAM_MODIFIED   0x004

File was modified

◆ RU_FAM_MOVED

#define RU_FAM_MOVED   0x008

File was moved or renamed

◆ RU_FAM_POLL_TIMEOUT

#define RU_FAM_POLL_TIMEOUT   250

to wait when no events are pending

◆ RU_FAM_QUEUE_TIMEOUT

#define RU_FAM_QUEUE_TIMEOUT   50

to wait when events (like moves) are pending

◆ ruFamEventLog

#define ruFamEventLog (   lvl,
  fe,
  prefix 
)
Value:
ruMacStart { \
if(ruDoesLog(lvl)) { \
ruFamLogEventFunc(lvl, __FILE__, __func__, __LINE__, fe, prefix); \
} \
} ruMacEnd
RUAPI bool ruDoesLog(uint32_t log_level)
Returns whether the given log level should log.

Log string representation of famEvent

Parameters
lvlLog level of this message.
fefamEvent tp log
prefixoptional prefix message

Typedef Documentation

◆ ruFamCtx

typedef void* ruFamCtx

Opaque internal fam context pointer

◆ ruFamEvent

typedef struct ruFamEvent_ ruFamEvent

◆ ruFamHandler

typedef void(* ruFamHandler) (ruFamEvent *fe, perm_ptr ctx)

Signature of call back event handler

Parameters
feruFamEvent to process. Caller must free with ruFamEventFree
ctxUser defined context passed in with ruFamMonitorFilePath

Function Documentation

◆ ruFamEventFree()

RUAPI ptr ruFamEventFree ( ptr  o)

famEvent destructor

Parameters
ofamEvent to free
Returns
NULL

◆ ruFamEventNew()

RUAPI ruFamEvent* ruFamEventNew ( int  eventType,
trans_chars  filePath,
trans_chars  destPath 
)

famEvent Constructor

Parameters
eventTypeevent type
filePathfile path
destPathoptional destination path
Returns
famEvent free with ruFamEventFree after use

◆ ruFamEventString()

RUAPI char* ruFamEventString ( ruFamEvent fe)

String representation of famEvent

Parameters
feevent tp print out
Returns
string to be freed after use

◆ ruFamEventTypeString()

RUAPI const char* ruFamEventTypeString ( int32_t  action)

Return string representation of the event type code

Parameters
actioneventType
Returns
string representating the given eventType. User must not free this.

◆ ruFamKillMonitor()

RUAPI ruFamCtx ruFamKillMonitor ( ruFamCtx  o)

This function stop the thread started by ruFamMonitorFilePath and closes the associated monitor handles.

Parameters
ofamObj to kill
Returns
NULL

◆ ruFamLogEventFunc()

RUAPI void ruFamLogEventFunc ( uint32_t  loglevel,
trans_chars  file,
trans_chars  func,
int32_t  line,
ruFamEvent fe,
trans_chars  prefix 
)

Internal logging function used by ruFamEventLog

Parameters
loglevelLog level of this message.
fileFILE
funcfunc
lineLINE
fefamE vent tp log
prefixoptional prefix message

◆ ruFamMonitorFilePath()

RUAPI ruFamCtx ruFamMonitorFilePath ( trans_chars  filePath,
trans_chars  threadName,
ruFamHandler  eventCallBack,
perm_ptr  ctx 
)

This function creates a new thread that recursively watches filePath and below and calls eventCallBack with events.

Parameters
filePathFilepath to monitor.
threadNameThe name that the new thread should go by in the logs
eventCallBackcallback that will process given event
ctxuser defined data that is then passed to the given eventCallBack along with the event.
Returns

◆ ruFamQuit()

RUAPI bool ruFamQuit ( ruFamCtx  o)

Reports whether fam is in a running state or not

Parameters
ofamObj to check
Returns
false if fam is running