fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
deng.c File Reference

Differential file search implementation. More...

#include "deng.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fs.h"
#include "index.h"
#include "log.h"
#include "sl.h"
Include dependency graph for deng.c:

Data Structures

struct  deng_state_s
 Search state context provided to the diff engine as user data which is passed to the file event hook functions. More...
 

Macros

#define SL_IMPL
 
#define invokehook(mach, name, arg)
 Invokes a file event hook function if it is not NULL.
 
#define notifyhook(mach, type)
 Invokes the notify hook function if it is not NULL.
 

Functions

static int stagepre (const char *fp, void *udata)
 Processes a file before the command execution stage to ensure all files are indexed. This function may trigger new (NEW), modified (MOD), and unmodified (NOP) events for each file in the directory tree.
 
static int stagepost (const char *fp, void *udata)
 Processes a file after the command execution stage to ensure all files are indexed. This function may trigger new (NEW) and modified (MOD) events for each file in the directory tree.
 
static int dqpush (const char *fp, void *udata)
 Pushes a directory path onto the directory queue for processing.
 
static int execstage (struct deng_state_s *mach, const char *sd, fswalkfn_t filefn)
 Resets the directory queue to the initial search path, and invokes the filefn function for each file in the directory tree, recursively.
 
static int checkremoved (struct deng_state_s *mach)
 Compares the current file system state with a previous index to determine which files were removed. This function may trigger deleted (DEL) events for each file in the previous index that is not present in the current index.
 
int dengsearch (const char *sd, deng_filter_t filter, const struct deng_hooks_s *hooks, const struct index_s *old, struct index_s *new)
 Recursively scans directory sd and compares the file system state with a previously saved index. Any new, modified, deleted, or unmodified files are reported to the caller via the provided hooks structure, hooks. The index state new is then updated with the current file system state.
 

Detailed Description

Differential file search implementation.

Macro Definition Documentation

◆ invokehook

#define invokehook ( mach,
name,
arg )
Value:
do { \
if ((mach)->hooks->name != NULL) (mach)->hooks->name(arg); \
} while (0)

Invokes a file event hook function if it is not NULL.

Parameters
machThe diff engine state context
nameThe member of the hook function to invoke
argThe argument to pass to the hook function

◆ notifyhook

#define notifyhook ( mach,
type )
Value:
do { \
if ((mach)->hooks->notify != NULL) (mach)->hooks->notify(type); \
} while (0)

Invokes the notify hook function if it is not NULL.

Parameters
machThe diff engine state context
typeThe notification type to pass to the hook

◆ SL_IMPL

#define SL_IMPL

Function Documentation

◆ checkremoved()

static int checkremoved ( struct deng_state_s * mach)
static

Compares the current file system state with a previous index to determine which files were removed. This function may trigger deleted (DEL) events for each file in the previous index that is not present in the current index.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dengsearch()

int dengsearch ( const char * sd,
deng_filter_t filter,
const struct deng_hooks_s * hooks,
const struct index_s * old,
struct index_s * new )

Recursively scans directory sd and compares the file system state with a previously saved index. Any new, modified, deleted, or unmodified files are reported to the caller via the provided hooks structure, hooks. The index state new is then updated with the current file system state.

Parameters
sdThe directory to scan for conditionally ignoring files
filterThe file filter function
hooksThe file event hook functions
oldThe previous index state
newThe current index state
Returns
0 if successful, otherwise a non-zero error code.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dqpush()

static int dqpush ( const char * fp,
void * udata )
static

Pushes a directory path onto the directory queue for processing.

Parameters
fpThe directory path to push
udataThe diff engine state context
Returns
0 if successful, otherwise a non-zero error code.
Here is the caller graph for this function:

◆ execstage()

static int execstage ( struct deng_state_s * mach,
const char * sd,
fswalkfn_t filefn )
static

Resets the directory queue to the initial search path, and invokes the filefn function for each file in the directory tree, recursively.

Parameters
machThe diff engine state context
sdThe initial search directory path
filefnThe function to invoke for each file in the directory tree
Returns
0 if successful, otherwise a non-zero error code.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stagepost()

static int stagepost ( const char * fp,
void * udata )
static

Processes a file after the command execution stage to ensure all files are indexed. This function may trigger new (NEW) and modified (MOD) events for each file in the directory tree.

Parameters
fpThe file path to process
udataThe diff engine state context
Returns
0 if successful, otherwise a non-zero error code.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stagepre()

static int stagepre ( const char * fp,
void * udata )
static

Processes a file before the command execution stage to ensure all files are indexed. This function may trigger new (NEW), modified (MOD), and unmodified (NOP) events for each file in the directory tree.

Parameters
fpThe file path to process
udataThe diff engine state context
Returns
0 if successful, otherwise a non-zero error code.
Here is the call graph for this function:
Here is the caller graph for this function: