fsautoproc
Basic file transformation automation management utility
|
Main program entry point. More...
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "deng.h"
#include "fd.h"
#include "fl.h"
#include "fs.h"
#include "index.h"
#include "lcmd.h"
#include "log.h"
#include "prog.h"
#include "tp.h"
Macros | |
#define | strdupoptarg(into) |
Duplicates the current optarg value into the specified variable. If the duplication fails, an error message is printed and the function returns 1. | |
Functions | |
static void | freeinitargs (void) |
Frees all duplicated initialization arguments. | |
static void | freeall (void) |
Frees all allocated resources. | |
static int | parseinitargs (const int argc, char **const argv) |
Parses the program initialization arguments into initargs . | |
static int | loadindex (struct index_s *idx, const char *fp) |
Loads the index from the specified file path into the provided index. | |
static int | writeindex (struct index_s *idx, const char *fp) |
Writes the index to the specified file path. | |
static bool | filterjunk (const char *fp) |
Filters out junk files from the index based on loaded command sets cmdsets and the initargs.includejunk flag/program option. | |
static void | onnotify (const enum deng_notif_t notif) |
Callback function passed to the diff engine to handle progress notifications. This function will print a progress bar to the console when a directory is completed, and block between stage completions to ensure all thread work requests are complete before the next stage. | |
static void | trigfileevent (struct inode_s *in, const int trig) |
Queues command execution for a file event of the specified type, using the provided inode for the file information. If the skipproc flag is set, the command execution is skipped. If the verbose flag is set, the command execution is done with verbose output. | |
static void | onnew (struct inode_s *in) |
Callback function for the diff engine to handle new file events. This will log a work request in the thread pool for any command sets which match the new file event. | |
static void | ondel (struct inode_s *in) |
Callback function for the diff engine to handle deleted file events. This will log a work request in the thread pool for any command sets which match the deleted file event. | |
static void | onmod (struct inode_s *in) |
Callback function for the diff engine to handle modified file events. This will log a work request in the thread pool for any command sets which match the modified file event. | |
static void | onnop (struct inode_s *in) |
Callback function for the diff engine to handle no-op file events. This will log a work request in the thread pool for any command sets which match the unmodified file event. | |
static int | cmpchanges (void) |
Compares the current file system state with a previously saved index. | |
static int | tracefile (const char *fp) |
Traces which command sets match the specified file by manually invoking the command execution logic with a trace flag. lcmdexec will print the command set names that match the file. | |
static void | printmsspent (void) |
Prints the time spent for each command set to the console. | |
int | main (int argc, char **argv) |
Main program entry point. | |
Variables | ||
struct { | ||
char * configfile | ||
Configuration file path (-c) More... | ||
char * indexfile | ||
Index file path (-i) More... | ||
char * lockfile | ||
Exclusive lock file path (-x) More... | ||
char * searchdir | ||
Search directory root (-s) More... | ||
char * tracefile | ||
Trace file path (-r) More... | ||
_Bool pipefiles | ||
Pipe subprocess stdout/stderr to files (-p) More... | ||
_Bool includejunk | ||
Include ignored files in index (-j) More... | ||
_Bool listspent | ||
List time spent for each command set (-l) More... | ||
_Bool skipproc | ||
Skip processing files, only update file index (-u) More... | ||
int threads | ||
Number of worker threads (-t) More... | ||
_Bool verbose | ||
Enable verbose output (-v) More... | ||
} | initargs | |
Managed initialization arguments for the program. | ||
static struct lcmdset_s ** | cmdsets | |
Command sets loaded from configuration. | ||
static struct index_s | lastmap | |
Stored index from previous run (if any) | ||
static struct index_s | thismap | |
Live checked index from this run. | ||
static struct flock_s | worklock | |
Exclusive work lock for local directory. | ||
Main program entry point.
#define strdupoptarg | ( | into | ) |
Duplicates the current optarg
value into the specified variable. If the duplication fails, an error message is printed and the function returns 1.
into | The variable to duplicate into |
|
static |
Compares the current file system state with a previously saved index.
|
static |
Filters out junk files from the index based on loaded command sets cmdsets
and the initargs.includejunk
flag/program option.
fp | The file path to filter |
|
static |
Frees all allocated resources.
|
static |
Frees all duplicated initialization arguments.
|
static |
Loads the index from the specified file path into the provided index.
idx | The index to load into |
fp | The file path to load the index from |
int main | ( | int | argc, |
char ** | argv ) |
Main program entry point.
argc | The number of arguments |
argv | The argument array |
|
static |
Callback function for the diff engine to handle deleted file events. This will log a work request in the thread pool for any command sets which match the deleted file event.
in | The inode for the deleted file |
|
static |
Callback function for the diff engine to handle modified file events. This will log a work request in the thread pool for any command sets which match the modified file event.
in | The inode for the modified file |
|
static |
Callback function for the diff engine to handle new file events. This will log a work request in the thread pool for any command sets which match the new file event.
in | The inode for the new file |
|
static |
Callback function for the diff engine to handle no-op file events. This will log a work request in the thread pool for any command sets which match the unmodified file event.
|
static |
Callback function passed to the diff engine to handle progress notifications. This function will print a progress bar to the console when a directory is completed, and block between stage completions to ensure all thread work requests are complete before the next stage.
notif | The notification type |
|
static |
Parses the program initialization arguments into initargs
.
argc | The number of arguments |
argv | The argument array |
-h
option is provided.
|
static |
Prints the time spent for each command set to the console.
|
static |
Traces which command sets match the specified file by manually invoking the command execution logic with a trace flag. lcmdexec
will print the command set names that match the file.
fp | The file path to trace |
|
static |
Queues command execution for a file event of the specified type, using the provided inode for the file information. If the skipproc
flag is set, the command execution is skipped. If the verbose
flag is set, the command execution is done with verbose output.
in | The inode for the file event |
trig | The file event type |
|
static |
Writes the index to the specified file path.
idx | The index to write |
fp | The file path to save the index to |
|
static |
Command sets loaded from configuration.
char* configfile |
Configuration file path (-c)
_Bool includejunk |
Include ignored files in index (-j)
char* indexfile |
Index file path (-i)
struct { ... } initargs |
Managed initialization arguments for the program.
|
static |
Stored index from previous run (if any)
_Bool listspent |
List time spent for each command set (-l)
char* lockfile |
Exclusive lock file path (-x)
_Bool pipefiles |
Pipe subprocess stdout/stderr to files (-p)
char* searchdir |
Search directory root (-s)
_Bool skipproc |
Skip processing files, only update file index (-u)
|
static |
Live checked index from this run.
int threads |
Number of worker threads (-t)
char* tracefile |
Trace file path (-r)
_Bool verbose |
Enable verbose output (-v)
|
static |
Exclusive work lock for local directory.