Enhanced -find testing by operators -not, -or, -and, (, ), -if, -else, -endif
This commit is contained in:
@ -736,6 +736,229 @@ int Dirseq_next_adr(struct DirseQ *o, char reply[SfileadrL], int flag);
|
||||
int Linkitem_reset_stack(struct LinkiteM **o, struct LinkiteM *to, int flag);
|
||||
|
||||
|
||||
|
||||
|
||||
#define Xorriso_findjob_on_expR yes
|
||||
|
||||
#ifdef Xorriso_findjob_on_expR
|
||||
|
||||
/*
|
||||
A single Testnode.
|
||||
*/
|
||||
struct ExprtesT {
|
||||
|
||||
struct FindjoB *boss;
|
||||
|
||||
int invert; /* 0=normal 1=invert result */
|
||||
|
||||
/*
|
||||
0= -false (with invert : -true)
|
||||
1= -name char *arg1 (regex_t in *arg2)
|
||||
2= -type char *arg1
|
||||
3= -damaged
|
||||
4= -lba_range int *arg1 int *arg2
|
||||
5= -has_acl
|
||||
6= -has_xattr
|
||||
7= -has_aaip
|
||||
8= -has_filter
|
||||
9= -wanted_node IsoNode *arg1 (for internal use, arg1 not allocated)
|
||||
10= -pending_data
|
||||
11= -decision *arg1 ("y", "1", "n", "0")
|
||||
*/
|
||||
int test_type;
|
||||
|
||||
void *arg1;
|
||||
void *arg2;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
A computational node.
|
||||
A tree of these nodes forms the expression.
|
||||
Sequences of AND/OR operations form branches, brackets spawn new branches,
|
||||
NOT inverts node's test resp. subtree result.
|
||||
*/
|
||||
struct ExprnodE {
|
||||
|
||||
struct ExprnodE *up;
|
||||
|
||||
char origin[8];
|
||||
|
||||
/* Operators */
|
||||
int invert; /* 0=normal 1=invert own result (subtree or test, but not op) */
|
||||
|
||||
int assoc; /*
|
||||
0= left : compute own value, combine with left value,
|
||||
compute right value, combine with current value
|
||||
1= right: compute own value, compute right value,
|
||||
combine own and right, combine with left value
|
||||
*/
|
||||
|
||||
int use_shortcuts; /* 0= evaluate all tests of -and and -or,
|
||||
1= evaluate only until the combined result is known
|
||||
*/
|
||||
|
||||
struct ExprnodE *left;
|
||||
int left_op; /* 0=OR , 1=AND */
|
||||
|
||||
struct ExprnodE *right;
|
||||
int right_op; /* see left_op */
|
||||
|
||||
/* Brackets : a pointer to the first node in a subchain */
|
||||
struct ExprnodE *sub;
|
||||
|
||||
int is_if_then_else;
|
||||
struct ExprnodE *true_branch;
|
||||
struct ExprnodE *false_branch;
|
||||
|
||||
/* elementary test : if sub!=NULL , test is ignored */
|
||||
struct ExprtesT *test;
|
||||
|
||||
/* Result */
|
||||
int own_value;
|
||||
int composed_value;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct FindjoB {
|
||||
|
||||
char *start_path;
|
||||
|
||||
struct ExprnodE *test_tree;
|
||||
|
||||
struct ExprnodE *cursor;
|
||||
int invert; /* 0=normal 1=set invert-property for next new test node */
|
||||
int use_shortcuts;
|
||||
|
||||
/* 0= echo
|
||||
1= rm (also rmdir)
|
||||
2= rm_r
|
||||
>>> 3= mv target
|
||||
4= chown user
|
||||
5= chgrp group
|
||||
6= chmod mode_and mode_or
|
||||
7= alter_date type date
|
||||
8= lsdl
|
||||
9= chown_r user
|
||||
10= chgrp_r group
|
||||
11= chmod_r mode_and mode_or
|
||||
12= alter_date_r type date
|
||||
13= find
|
||||
14= compare disk_equivalent_of_start_path
|
||||
15= in_iso iso_rr_equivalent_of_start_path
|
||||
16= not_in_iso iso_rr_equiv
|
||||
17= update disk_equiv
|
||||
18= add_missing iso_rr_equiv
|
||||
19= empty_iso_dir iso_rr_equiv
|
||||
20= is_full_in_iso iso_rr_equiv
|
||||
21= report_damage
|
||||
22= report_lba
|
||||
23= internal:memorize path of last matching node in found_path
|
||||
24= getfacl
|
||||
25= setfacl access_acl default_acl
|
||||
26= getfattr
|
||||
27= setfattr
|
||||
28= set_filter name
|
||||
29= show_stream
|
||||
*/
|
||||
int action;
|
||||
|
||||
/* action specific parameters */
|
||||
char *target;
|
||||
char *text_2;
|
||||
uid_t user;
|
||||
gid_t group;
|
||||
mode_t mode_and, mode_or;
|
||||
int type; /* see Xorriso_set_time flag */
|
||||
time_t date;
|
||||
char *found_path;
|
||||
struct FindjoB *subjob;
|
||||
|
||||
/* Errors */
|
||||
char errmsg[4096];
|
||||
int errn; /*
|
||||
>0 = UNIX errno
|
||||
-1 = close_bracket: no bracket open
|
||||
-2 = binary operator or closing bracket expected
|
||||
-3 = unexpected binary operator or closing bracket
|
||||
-4 = unsupported command
|
||||
-5 = -then -elseif -else -endif without -if or at wrong place
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
int Exprtest_match(struct XorrisO *xorriso, struct ExprtesT *ftest,
|
||||
void *node_pt, char *name,
|
||||
struct stat *boss_stbuf, struct stat *stbuf, int flag);
|
||||
|
||||
|
||||
int Exprnode_destroy(struct ExprnodE **fnode, int flag);
|
||||
|
||||
int Exprnode_tree_value(struct XorrisO *xorriso, struct ExprnodE *fnode,
|
||||
int left_value, void *node, char *name,
|
||||
struct stat *boss_stbuf, struct stat *stbuf, int flag);
|
||||
|
||||
|
||||
int Findjob_new(struct FindjoB **o, char *start_path, int flag);
|
||||
|
||||
int Findjob_destroy(struct FindjoB **o, int flag);
|
||||
|
||||
int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag);
|
||||
|
||||
int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag);
|
||||
|
||||
int Findjob_set_commit_filter_2(struct FindjoB *o, int flag);
|
||||
|
||||
int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count,
|
||||
int flag);
|
||||
|
||||
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag);
|
||||
|
||||
int Findjob_set_decision(struct FindjoB *o, char *decision, int flag);
|
||||
|
||||
int Findjob_open_bracket(struct FindjoB *job, int flag);
|
||||
|
||||
int Findjob_close_bracket(struct FindjoB *job, int flag);
|
||||
|
||||
int Findjob_not(struct FindjoB *job, int flag);
|
||||
|
||||
int Findjob_and(struct FindjoB *job, int flag);
|
||||
|
||||
int Findjob_or(struct FindjoB *job, int flag);
|
||||
|
||||
int Findjob_if(struct FindjoB *job, int flag);
|
||||
|
||||
int Findjob_then(struct FindjoB *job, int flag);
|
||||
|
||||
int Findjob_else(struct FindjoB *job, int flag);
|
||||
|
||||
int Findjob_elseif(struct FindjoB *job, int flag);
|
||||
|
||||
int Findjob_endif(struct FindjoB *job, int flag);
|
||||
|
||||
int Findjob_test_2(struct XorrisO *xorriso, struct FindjoB *o,
|
||||
void *node, char *name,
|
||||
struct stat *boss_stbuf, struct stat *stbuf, int flag);
|
||||
|
||||
int Findjob_set_action_found_path(struct FindjoB *o, int flag);
|
||||
|
||||
int Findjob_get_action(struct FindjoB *o, int flag);
|
||||
|
||||
int Findjob_get_action_parms(struct FindjoB *o, char **target, char **text_2,
|
||||
uid_t *user, gid_t *group,
|
||||
mode_t *mode_and, mode_t *mode_or,
|
||||
int *type, time_t *date, struct FindjoB **subjob,
|
||||
int flag);
|
||||
|
||||
int Findjob_set_found_path(struct FindjoB *o, char *path, int flag);
|
||||
|
||||
int Findjob_get_found_path(struct FindjoB *o, char **path, int flag);
|
||||
|
||||
#else /* Xorriso_findjob_on_expR */
|
||||
|
||||
|
||||
struct FindjoB;
|
||||
|
||||
|
||||
@ -810,6 +1033,8 @@ int Findjob_set_found_path(struct FindjoB *o, char *path, int flag);
|
||||
|
||||
int Findjob_get_found_path(struct FindjoB *o, char **path, int flag);
|
||||
|
||||
#endif /* ! Xorriso_findjob_on_expR */
|
||||
|
||||
|
||||
struct SplitparT;
|
||||
|
||||
|
Reference in New Issue
Block a user