summaryrefslogtreecommitdiff
path: root/src/audit.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2014-10-08 15:29:27 +0300
committerTimo Teräs <timo.teras@iki.fi>2014-10-08 15:29:27 +0300
commit38e3f5463878a29e675be8430135e36b552c0ac1 (patch)
tree6487e72ccb5a65d804b3f768cd22cf353df039b8 /src/audit.c
parent275dd16c42b7208723cfa84ac9c6eb0dcb8071b6 (diff)
downloadapk-tools-38e3f5463878a29e675be8430135e36b552c0ac1.tar.gz
apk-tools-38e3f5463878a29e675be8430135e36b552c0ac1.tar.bz2
apk-tools-38e3f5463878a29e675be8430135e36b552c0ac1.tar.xz
apk-tools-38e3f5463878a29e675be8430135e36b552c0ac1.zip
rework option parsing to have a group structure
Add also a new 'commit' group that is the common options for all applets that can commit package changes.
Diffstat (limited to 'src/audit.c')
-rw-r--r--src/audit.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/audit.c b/src/audit.c
index 4710e82..0d1ca5c 100644
--- a/src/audit.c
+++ b/src/audit.c
@@ -37,8 +37,7 @@ struct audit_ctx {
unsigned packages_only : 1;
};
-static int audit_parse(void *ctx, struct apk_db_options *dbopts,
- int optch, int optindex, const char *optarg)
+static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int optch, const char *optarg)
{
struct audit_ctx *actx = (struct audit_ctx *) ctx;
@@ -59,11 +58,27 @@ static int audit_parse(void *ctx, struct apk_db_options *dbopts,
actx->recursive = 1;
break;
default:
- return -1;
+ return -ENOTSUP;
}
return 0;
}
+static const struct apk_option options_applet[] = {
+ { 0x10000, "backup", "List all modified configuration files (in "
+ "protected_paths.d) that need to be backed up" },
+ { 0x10001, "system", "Verify checksums of all installed non-configuration files " },
+ { 0x10002, "check-permissions", "Check file and directory uid/gid/mode too" },
+ { 'r', "recursive", "List individually all entries in new directories" },
+ { 0x10003, "packages", "List only the changed packages (or names only with -q)" },
+};
+
+static const struct apk_option_group optgroup_applet = {
+ .name = "Audit",
+ .options = options_applet,
+ .num_options = ARRAY_SIZE(options_applet),
+ .parse = option_parse_applet,
+};
+
struct audit_tree_ctx {
struct audit_ctx *actx;
struct apk_database *db;
@@ -326,24 +341,13 @@ static int audit_main(void *ctx, struct apk_database *db, struct apk_string_arra
return r;
}
-static struct apk_option audit_options[] = {
- { 0x10000, "backup", "List all modified configuration files (in "
- "protected_paths.d) that need to be backed up" },
- { 0x10001, "system", "Verify checksums of all installed non-configuration files " },
- { 0x10002, "check-permissions", "Check file and directory uid/gid/mode too" },
- { 'r', "recursive", "List individually all entries in new directories" },
- { 0x10003, "packages", "List only the changed packages (or names only with -q)" },
-};
-
static struct apk_applet apk_audit = {
.name = "audit",
.help = "Audit the directories for changes",
.arguments = "[directory to audit]...",
.open_flags = APK_OPENF_READ|APK_OPENF_NO_SCRIPTS|APK_OPENF_NO_REPOS,
.context_size = sizeof(struct audit_ctx),
- .num_options = ARRAY_SIZE(audit_options),
- .options = audit_options,
- .parse = audit_parse,
+ .optgroups = { &optgroup_global, &optgroup_applet },
.main = audit_main,
};