@@ -118,6 +118,12 @@ struct NonDirArgs {
118
118
119
119
/* list of xattr dbs */
120
120
sll_t xattr_db_list ;
121
+
122
+ /*
123
+ * an optional opaque pointer to user data for a plugin. if the plugin's db_init() function
124
+ * creates and returns a pointer, then the later plugin functions can use it to store state.
125
+ */
126
+ void * plugin_user_data ;
121
127
};
122
128
123
129
static int process_external (struct input * in , void * args ,
@@ -156,19 +162,16 @@ static int process_nondir(struct work *entry, struct entry_data *ed, void *args)
156
162
external_read_file (in , entry , process_external , nda -> db );
157
163
}
158
164
159
- /* get entry relative path (use extra buffer to prevent memcpy overlap) */
160
- char relpath [MAXPATH ];
161
- const size_t relpath_len = SNFORMAT_S (relpath , MAXPATH , 1 ,
162
- entry -> name + entry -> root_parent .len , entry -> name_len - entry -> root_parent .len );
163
- /* overwrite full path with relative path */
164
- entry -> name_len = SNFORMAT_S (entry -> name , MAXPATH , 1 , relpath , relpath_len );
165
-
166
165
/* update summary table */
167
166
sumit (& nda -> summary , ed );
168
167
169
168
/* add entry + xattr names into bulk insert */
170
169
insertdbgo (entry , ed , nda -> entries_res );
171
170
171
+ if (in -> plugin_ops -> process_file ) {
172
+ in -> plugin_ops -> process_file (entry -> name , nda -> db , nda -> plugin_user_data );
173
+ }
174
+
172
175
out :
173
176
return rc ;
174
177
}
@@ -188,6 +191,7 @@ static int processdir(QPTPool_t *ctx, const size_t id, void *data, void *args) {
188
191
memset (& nda .ed , 0 , sizeof (nda .ed ));
189
192
nda .topath = NULL ;
190
193
nda .ed .type = 'd' ;
194
+ nda .plugin_user_data = NULL ;
191
195
192
196
DIR * dir = NULL ;
193
197
@@ -269,6 +273,14 @@ static int processdir(QPTPool_t *ctx, const size_t id, void *data, void *args) {
269
273
}
270
274
271
275
startdb (nda .db );
276
+
277
+ if (pa -> in .plugin_ops -> db_init ) {
278
+ nda .plugin_user_data = pa -> in .plugin_ops -> db_init (nda .db );
279
+ }
280
+ }
281
+
282
+ if (pa -> in .plugin_ops -> process_dir ) {
283
+ pa -> in .plugin_ops -> process_dir (nda .work -> name , nda .db , nda .plugin_user_data );
272
284
}
273
285
274
286
struct descend_counters ctrs ;
@@ -277,6 +289,10 @@ static int processdir(QPTPool_t *ctx, const size_t id, void *data, void *args) {
277
289
& ctrs );
278
290
279
291
if (process_dbdb ) {
292
+ if (pa -> in .plugin_ops -> db_exit ) {
293
+ pa -> in .plugin_ops -> db_exit (nda .db , nda .plugin_user_data );
294
+ }
295
+
280
296
stopdb (nda .db );
281
297
282
298
/* entries and xattrs have been inserted */
@@ -407,7 +423,7 @@ static void sub_help(void) {
407
423
408
424
int main (int argc , char * argv []) {
409
425
struct PoolArgs pa ;
410
- process_args_and_maybe_exit ("hHvn:xy:z:k:M:s:C:" COMPRESS_OPT "q" , 2 , "input_dir... output_dir" , & pa .in );
426
+ process_args_and_maybe_exit ("hHvn:xy:z:k:M:s:C:U: " COMPRESS_OPT "q" , 2 , "input_dir... output_dir" , & pa .in );
411
427
412
428
/* parse positional args, following the options */
413
429
/* does not have to be canonicalized */
0 commit comments