diff options
author | Werner Koch <[email protected]> | 2009-12-14 12:16:30 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2009-12-14 12:16:30 +0000 |
commit | 3fd1733f47d977d5f1bcf406022e15532d6bfda6 (patch) | |
tree | 891074f53b329e84e03ac2b0176671476425ae05 | |
parent | Another one. (diff) | |
download | libassuan-3fd1733f47d977d5f1bcf406022e15532d6bfda6.tar.gz libassuan-3fd1733f47d977d5f1bcf406022e15532d6bfda6.zip |
Return and parse comment lines with the assuan_client_ functions.
-rw-r--r-- | src/ChangeLog | 7 | ||||
-rw-r--r-- | src/assuan.h | 1 | ||||
-rw-r--r-- | src/client.c | 22 |
3 files changed, 24 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 92c9d0b..c5469c7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2009-12-14 Werner Koch <[email protected]> + + * assuan.h (ASSUAN_RESPONSE_COMMENT): New. + * client.c (assuan_client_read_response): Return comment lines. + (assuan_client_parse_response): Return ASSUAN_RESPONSE_COMMENT. + (_assuan_read_from_server): Skip comment lines. + 2009-12-08 Marcus Brinkmann <[email protected]> * assuan.h (struct assuan_system_hooks): Don't use "namespace" as diff --git a/src/assuan.h b/src/assuan.h index 604ecc6..0cd943b 100644 --- a/src/assuan.h +++ b/src/assuan.h @@ -431,6 +431,7 @@ gpg_error_t assuan_get_peercred (assuan_context_t ctx, #define ASSUAN_RESPONSE_INQUIRE 3 #define ASSUAN_RESPONSE_STATUS 4 #define ASSUAN_RESPONSE_END 5 +#define ASSUAN_RESPONSE_COMMENT 6 typedef int assuan_response_t; /* This already de-escapes data lines. */ diff --git a/src/client.c b/src/client.c index 5420e44..05cb579 100644 --- a/src/client.c +++ b/src/client.c @@ -91,7 +91,7 @@ assuan_client_read_response (assuan_context_t ctx, line = ctx->inbound.line; linelen = ctx->inbound.linelen; } - while (*line == '#' || !linelen); + while (!linelen); /* For data lines, we deescape immediately. The user will never have to worry about it. */ @@ -181,6 +181,11 @@ assuan_client_parse_response (assuan_context_t ctx, char *line, int linelen, *response = ASSUAN_RESPONSE_END; *off = 3; } + else if (linelen >= 1 && line[0] == '#') + { + *response = ASSUAN_RESPONSE_COMMENT; + *off = 1; + } else return _assuan_error (ctx, GPG_ERR_ASS_INV_RESPONSE); @@ -196,11 +201,16 @@ _assuan_read_from_server (assuan_context_t ctx, assuan_response_t *response, char *line; int linelen; - *response = ASSUAN_RESPONSE_ERROR; - *off = 0; - rc = assuan_client_read_response (ctx, &line, &linelen); - if (!rc) - rc = assuan_client_parse_response (ctx, line, linelen, response, off); + do + { + *response = ASSUAN_RESPONSE_ERROR; + *off = 0; + rc = assuan_client_read_response (ctx, &line, &linelen); + if (!rc) + rc = assuan_client_parse_response (ctx, line, linelen, response, off); + } + while (!rc && *response == ASSUAN_RESPONSE_COMMENT); + return rc; } |