diff options
| author | Werner Koch <[email protected]> | 2018-03-27 06:48:00 +0000 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2018-03-27 06:48:00 +0000 |
| commit | d4dc4245bf0221d2db4118718fc2528ecf43b97b (patch) | |
| tree | 5912abc9b9ba056a882bcd933105ba4dde73c560 /common/agent-opt.c | |
| parent | Change license of argparse.c back to LGPLv2.1 (diff) | |
| parent | agent: Make the request origin a part of the cache items. (diff) | |
| download | gnupg-d4dc4245bf0221d2db4118718fc2528ecf43b97b.tar.gz gnupg-d4dc4245bf0221d2db4118718fc2528ecf43b97b.zip | |
Merge branch 'STABLE-BRANCH-2-2' into master
Diffstat (limited to 'common/agent-opt.c')
| -rw-r--r-- | common/agent-opt.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/common/agent-opt.c b/common/agent-opt.c index b32448242..6d9f9e77e 100644 --- a/common/agent-opt.c +++ b/common/agent-opt.c @@ -69,3 +69,38 @@ str_pinentry_mode (pinentry_mode_t mode) } return "?"; } + + +/* Parse VALUE and return an integer representing a request_origin_t. + * (-1) is returned for an invalid VALUE. */ +int +parse_request_origin (const char *value) +{ + int result; + + if (!strcmp (value, "none") || !strcmp (value, "local")) + result = REQUEST_ORIGIN_LOCAL; + else if (!strcmp (value, "remote")) + result = REQUEST_ORIGIN_REMOTE; + else if (!strcmp (value, "browser")) + result = REQUEST_ORIGIN_BROWSER; + else + result = -1; + + return result; +} + + +/* Return the string representation for the request origin. Returns + * "?" for an invalid mode. */ +const char * +str_request_origin (request_origin_t mode) +{ + switch (mode) + { + case REQUEST_ORIGIN_LOCAL: return "local"; + case REQUEST_ORIGIN_REMOTE: return "remote"; + case REQUEST_ORIGIN_BROWSER: return "browser"; + } + return "?"; +} |
