aboutsummaryrefslogtreecommitdiffstats
path: root/common/t-dns-cert.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2011-11-30 16:14:08 +0000
committerWerner Koch <[email protected]>2011-11-30 16:34:49 +0000
commit31f548a18aed729c05ea367f2d8a8104480430d5 (patch)
treed3033d8ffbdc23f6115243cdb65b4438d19ac846 /common/t-dns-cert.c
parent* common/estream.c (es_fopenmem_init): New. (diff)
downloadgnupg-31f548a18aed729c05ea367f2d8a8104480430d5.tar.gz
gnupg-31f548a18aed729c05ea367f2d8a8104480430d5.zip
Rewrite dns-cert.c to not use the gpg-only iobuf stuff.
* common/dns-cert.c: Remove iobuf.h. (get_dns_cert): Rename to _get_dns_cert. Remove MAX_SIZE arg. Change iobuf arg to a estream-t. Rewrite function to make use of estream instead of iobuf. Require all parameters. Return an gpg_error_t error instead of the type. Add arg ERRSOURCE. * common/dns-cert.h (get_dns_cert): New macro to pass the error source to _gpg_dns_cert. * common/t-dns-cert.c (main): Adjust for changes in get_dns_cert. * g10/keyserver.c (keyserver_import_cert): Ditto. * doc/gpg.texi (GPG Configuration Options): Remove max-cert-size.
Diffstat (limited to '')
-rw-r--r--common/t-dns-cert.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/common/t-dns-cert.c b/common/t-dns-cert.c
index f3e8892a7..1dcae6f29 100644
--- a/common/t-dns-cert.c
+++ b/common/t-dns-cert.c
@@ -23,18 +23,17 @@
#include <assert.h>
#include "util.h"
-#include "iobuf.h"
#include "dns-cert.h"
int
main (int argc, char **argv)
{
+ gpg_error_t err;
unsigned char *fpr;
size_t fpr_len;
char *url;
- int rc;
- iobuf_t iobuf;
+ estream_t key;
char const *name;
if (argc)
@@ -55,18 +54,19 @@ main (int argc, char **argv)
printf ("CERT lookup on `%s'\n", name);
- rc = get_dns_cert (name, 65536, &iobuf, &fpr, &fpr_len, &url);
- if (rc == -1)
- fputs ("lookup result: error\n", stdout);
- else if (!rc)
- fputs ("lookup result: no answer\n", stdout);
- else if (rc == 1)
+ err = get_dns_cert (name, &key, &fpr, &fpr_len, &url);
+ if (err)
+ printf ("get_dns_cert failed: %s <%s>\n",
+ gpg_strerror (err), gpg_strsource (err));
+ else if (key)
{
- printf ("lookup result: %d bytes\n",
- (int)iobuf_get_temp_length(iobuf));
- iobuf_close (iobuf);
+ int count = 0;
+
+ while (es_getc (key) != EOF)
+ count++;
+ printf ("Key found (%d bytes)\n", count);
}
- else if (rc == 2)
+ else
{
if (fpr)
{
@@ -85,9 +85,11 @@ main (int argc, char **argv)
else
printf ("No URL found\n");
- xfree (fpr);
- xfree (url);
}
+ es_fclose (key);
+ xfree (fpr);
+ xfree (url);
+
return 0;
}