fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
lcmd.h
Go to the documentation of this file.
1
3#ifndef FSAUTOPROC_LCMD_H
4#define FSAUTOPROC_LCMD_H
5
6#include <regex.h>
7#include <stdbool.h>
8#include <stdint.h>
9
10#include "sl.h"
11
12struct inode_s;
13struct fdset_s;
14
17#define LCTRIG_NEW (1 << 0)
18
21#define LCTRIG_MOD (1 << 1)
22
25#define LCTRIG_DEL (1 << 2)
26
29#define LCTRIG_NOP (1 << 3)
30
33#define LCTRIG_ALL (LCTRIG_NEW | LCTRIG_MOD | LCTRIG_DEL | LCTRIG_NOP)
34
37#define LCTOPT_TRACE (1 << 7)
38
41#define LCTOPT_VERBOSE (1 << 8)
42
46struct lcmdset_s {
47 int onflags;
48 regex_t** fpatterns;
49 slist_t* syscmds;
50 char* name;
51 uint64_t msspent;
52};
53
56void lcmdfree_r(struct lcmdset_s** cs);
57
74struct lcmdset_s** lcmdparse(const char* fp);
75
81bool lcmdmatchany(struct lcmdset_s** cs, const char* fp);
82
95int lcmdexec(struct lcmdset_s** cs, const struct inode_s* node,
96 const struct fdset_s* fds, int flags);
97
98#endif//FSAUTOPROC_LCMD_H
struct lcmdset_s ** lcmdparse(const char *fp)
Prses the provided file path and populates an array of command sets. The file must be a valid JSON fi...
Definition lcmd.c:179
void lcmdfree_r(struct lcmdset_s **cs)
Iterates and frees all memory allocated by the command set array.
Definition lcmd.c:39
bool lcmdmatchany(struct lcmdset_s **cs, const char *fp)
Checks if the provided file path matches any of the file patterns in the command set.
Definition lcmd.c:231
int lcmdexec(struct lcmdset_s **cs, const struct inode_s *node, const struct fdset_s *fds, int flags)
Sequentially iterates the command set and executes the configured system commands on the provided fil...
Definition lcmd.c:294
A set of file descriptors for redirecting writes to stdout and stderr from child processes to log fil...
Definition fd.h:9
Individual file node in the index map.
Definition index.h:12
A set of system commands to execute when a file event of a specific type and file path is triggered.
Definition lcmd.h:46
uint64_t msspent
Sum milliseconds spent executing commands.
Definition lcmd.h:51
slist_t * syscmds
Commands to pass to system(3)
Definition lcmd.h:49
char * name
Command set name or description for logging.
Definition lcmd.h:50
int onflags
Command set trigger bit flags.
Definition lcmd.h:47
regex_t ** fpatterns
Compiled regex patterns used for file path matching.
Definition lcmd.h:48