diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-05-04 21:45:11 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-05-06 13:05:25 +0300 |
commit | 1d7123d83796182f851ccccaf056063955343718 (patch) | |
tree | ca675fd3363af3584694d0db5a3b65e618ae894b /src/apk_applet.h | |
parent | 791f93fcbe7a543e0bb844887ba395be8ed8ea44 (diff) | |
download | apk-tools-1d7123d83796182f851ccccaf056063955343718.tar.gz apk-tools-1d7123d83796182f851ccccaf056063955343718.tar.bz2 apk-tools-1d7123d83796182f851ccccaf056063955343718.tar.xz apk-tools-1d7123d83796182f851ccccaf056063955343718.zip |
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.
Diffstat (limited to 'src/apk_applet.h')
-rw-r--r-- | src/apk_applet.h | 18 |
1 files changed, 8 insertions, 10 deletions
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 { |