From 1d7123d83796182f851ccccaf056063955343718 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Mon, 4 May 2020 21:45:11 +0300 Subject: rewrite option descriptors to be single string This reduces the number of relocations on PIE binaries, and also reduces the executable size. Parsing of the options is slightly sped up as only the exact matching option group parser is called. --- src/apk_applet.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/apk_applet.h') diff --git a/src/apk_applet.h b/src/apk_applet.h index 390ec59..f1bf9b2 100644 --- a/src/apk_applet.h +++ b/src/apk_applet.h @@ -17,19 +17,17 @@ #include "apk_defines.h" #include "apk_database.h" -struct apk_option { - int val; - const char *name; - int has_arg; -}; +#define APK_OPTAPPLET "\x00" +#define APK_OPTGROUP(_name) _name "\x00" +#define APK_OPT1n(_opt) "\xf0" _opt "\x00" +#define APK_OPT1R(_opt) "\xaf" "\xf0" _opt "\x00" +#define APK_OPT2n(_opt, _short) _short _opt "\x00" +#define APK_OPT2R(_opt, _short) "\xaf" _short _opt "\x00" struct apk_option_group { - const char *name; - int num_options; - const struct apk_option *options; - + const char *desc; int (*parse)(void *ctx, struct apk_db_options *dbopts, - int optch, const char *optarg); + int opt, const char *optarg); }; struct apk_applet { -- cgit v1.2.3-70-g09d2