1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

Merge branch 'STABLE-BRANCH-2-2' into master

This commit is contained in:
Werner Koch 2018-03-27 08:48:00 +02:00
commit d4dc4245bf
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
36 changed files with 516 additions and 135 deletions

View file

@ -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 "?";
}

View file

@ -39,10 +39,23 @@ typedef enum
pinentry_mode_t;
/* Values for the request origin. */
typedef enum
{
REQUEST_ORIGIN_LOCAL = 0,
REQUEST_ORIGIN_REMOTE,
REQUEST_ORIGIN_BROWSER
}
request_origin_t;
/*-- agent-opt.c --*/
int parse_pinentry_mode (const char *value);
const char *str_pinentry_mode (pinentry_mode_t mode);
int parse_request_origin (const char *value);
const char *str_request_origin (request_origin_t mode);
#endif /*GNUPG_COMMON_SHAREDDEFS_H*/