summaryrefslogtreecommitdiff
path: root/src/tty-ask-password-agent.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-08-01 00:43:05 +0200
committerLennart Poettering <lennart@poettering.net>2011-08-01 00:43:05 +0200
commitf975e971accc4d50c73ae53167db3df7a7099cf2 (patch)
treeba7442194a0e6a13cb12645db19e90073f2cb80b /src/tty-ask-password-agent.c
parentf786e80d7a76fd7446d142f610d62ea8c28ed902 (diff)
load-fragment: speed up parsing by using a perfect hash table with configuration settings built by gperf
Diffstat (limited to 'src/tty-ask-password-agent.c')
-rw-r--r--src/tty-ask-password-agent.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/tty-ask-password-agent.c b/src/tty-ask-password-agent.c
index 02b959ea59..ca183c350b 100644
--- a/src/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent.c
@@ -250,13 +250,13 @@ static int parse_password(const char *filename, char **wall) {
int socket_fd = -1;
bool accept_cached = false;
- const ConfigItem items[] = {
- { "Socket", config_parse_string, 0, &socket_name, "Ask" },
- { "NotAfter", config_parse_uint64, 0, &not_after, "Ask" },
- { "Message", config_parse_string, 0, &message, "Ask" },
- { "PID", config_parse_unsigned, 0, &pid, "Ask" },
- { "AcceptCached", config_parse_bool, 0, &accept_cached, "Ask" },
- { NULL, NULL, 0, NULL, NULL }
+ const ConfigTableItem items[] = {
+ { "Ask", "Socket", config_parse_string, 0, &socket_name },
+ { "Ask", "NotAfter", config_parse_uint64, 0, &not_after },
+ { "Ask", "Message", config_parse_string, 0, &message },
+ { "Ask", "PID", config_parse_unsigned, 0, &pid },
+ { "Ask", "AcceptCached", config_parse_bool, 0, &accept_cached },
+ { NULL, NULL, NULL, 0, NULL }
};
FILE *f;
@@ -264,8 +264,8 @@ static int parse_password(const char *filename, char **wall) {
assert(filename);
- if (!(f = fopen(filename, "re"))) {
-
+ f = fopen(filename, "re");
+ if (!f) {
if (errno == ENOENT)
return 0;
@@ -273,7 +273,8 @@ static int parse_password(const char *filename, char **wall) {
return -errno;
}
- if ((r = config_parse(filename, f, NULL, items, true, NULL)) < 0) {
+ r = config_parse(filename, f, NULL, config_item_table_lookup, (void*) items, true, NULL);
+ if (r < 0) {
log_error("Failed to parse password file %s: %s", filename, strerror(-r));
goto finish;
}