diff options
author | Justus Winter <[email protected]> | 2016-03-02 13:14:33 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2016-03-02 13:14:33 +0000 |
commit | e77c85577d1bdd77ad3b81907145fd68f2653c01 (patch) | |
tree | 4c6fc3f74de8d0f052bdbd3ec0de407958be2821 /agent | |
parent | dirmngr: Add missing CFLAGS. (diff) | |
download | gnupg-e77c85577d1bdd77ad3b81907145fd68f2653c01.tar.gz gnupg-e77c85577d1bdd77ad3b81907145fd68f2653c01.zip |
common: Consolidate Assuan server argument handling.
* common/Makefile.am (common_sources): Add new files.
* common/server-help.c: New file.
* common/server-help.h: Likewise.
* agent/command.c: Drop argument handling primitives in favor of using
the consolidated ones.
* dirmngr/server.c: Likewise.
* g10/server.c: Likewise.
* g13/server.c: Likewise.
* scd/command.c: Likewise.
* sm/server.c: Likewise.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'agent')
-rw-r--r-- | agent/command.c | 81 |
1 files changed, 1 insertions, 80 deletions
diff --git a/agent/command.c b/agent/command.c index 421df0044..dfe292db6 100644 --- a/agent/command.c +++ b/agent/command.c @@ -41,6 +41,7 @@ #include "cvt-openpgp.h" #include "../common/ssh-utils.h" #include "../common/asshelp.h" +#include "../common/server-help.h" /* Maximum allowed size of the inquired ciphertext. */ @@ -229,86 +230,6 @@ reset_notify (assuan_context_t ctx, char *line) } -/* Skip over options in LINE. - - Blanks after the options are also removed. Options are indicated - by two leading dashes followed by a string consisting of non-space - characters. The special option "--" indicates an explicit end of - options; all what follows will not be considered an option. The - first no-option string also indicates the end of option parsing. */ -static char * -skip_options (const char *line) -{ - while (spacep (line)) - line++; - while ( *line == '-' && line[1] == '-' ) - { - while (*line && !spacep (line)) - line++; - while (spacep (line)) - line++; - } - return (char*)line; -} - - -/* Check whether the option NAME appears in LINE. An example for a - line with options is: - --algo=42 --data foo bar - This function would then only return true if NAME is "data". */ -static int -has_option (const char *line, const char *name) -{ - const char *s; - int n = strlen (name); - - s = strstr (line, name); - if (s && s >= skip_options (line)) - return 0; - return (s && (s == line || spacep (s-1)) && (!s[n] || spacep (s+n))); -} - - -/* Same as has_option but does only test for the name of the option - and ignores an argument, i.e. with NAME being "--hash" it would - return true for "--hash" as well as for "--hash=foo". */ -static int -has_option_name (const char *line, const char *name) -{ - const char *s; - int n = strlen (name); - - s = strstr (line, name); - if (s && s >= skip_options (line)) - return 0; - return (s && (s == line || spacep (s-1)) - && (!s[n] || spacep (s+n) || s[n] == '=')); -} - - -/* Return a pointer to the argument of the option with NAME. If such - an option is not given, NULL is retruned. */ -static char * -option_value (const char *line, const char *name) -{ - char *s; - int n = strlen (name); - - s = strstr (line, name); - if (s && s >= skip_options (line)) - return NULL; - if (s && (s == line || spacep (s-1)) - && s[n] && (spacep (s+n) || s[n] == '=')) - { - s += n + 1; - s += strspn (s, " "); - if (*s && !spacep(s)) - return s; - } - return NULL; -} - - /* Replace all '+' by a blank in the string S. */ static void plus_to_blank (char *s) |