summaryrefslogtreecommitdiff
path: root/src/apk_applet.h
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-05-04 21:45:11 +0300
committerTimo Teräs <timo.teras@iki.fi>2020-05-06 13:05:25 +0300
commit1d7123d83796182f851ccccaf056063955343718 (patch)
treeca675fd3363af3584694d0db5a3b65e618ae894b /src/apk_applet.h
parent791f93fcbe7a543e0bb844887ba395be8ed8ea44 (diff)
downloadapk-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.h18
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 {