summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2012-02-07 10:15:57 +0100
committerWerner Koch <wk@gnupg.org>2012-02-07 10:15:57 +0100
commit13ec74481ce0137f7a60b3256cc4840073c77efa (patch)
treee64592195ace4c61af85095fdbab613246d16f46 /common
parentAdd replacement hack for Android's broken ttyname. (diff)
downloadgnupg2-13ec74481ce0137f7a60b3256cc4840073c77efa.tar.xz
gnupg2-13ec74481ce0137f7a60b3256cc4840073c77efa.zip
common: Replace macro based function calls by using DEFAULT_ERRSOURCE.
* common/dns-cert.h (get_dns_cert): Remove macro. * common/dns-cert.c (_get_dns_cert): Rename to get_dns_cert. Replace arg ERRSOURCE by global DEFAULT_ERRSOURCE. * common/http.h (http_parse_uri, http_raw_connect, http_open) (http_open_document, http_wait_response): Remove macros. * common/http.c (_http_parse_uri, _http_raw_connect, _http_open) (_http_open_document, _http_wait_response): Remove underscore from symbols. Replace args ERRSOURCE by global DEFAULT_ERRSOURCE. * common/ssh-utils.h (ssh_get_fingerprint) (ssh_get_fingerprint_string): Remove macros. * common/ssh-utils.h (_ssh_get_fingerprint) (_ssh_get_fingerprint_string): Remove underscore from symbols. Replace args ERRSOURCE by global DEFAULT_ERRSOURCE. * common/tlv.h (parse_ber_header, parse_sexp): Remove macros. * common/tlv.c: Include util.h. (_parse_ber_header, _parse_sexp): Remove underscore from symbols. Replace args ERRSOURCE by global DEFAULT_ERRSOURCE.
Diffstat (limited to 'common')
-rw-r--r--common/dns-cert.c39
-rw-r--r--common/dns-cert.h9
-rw-r--r--common/http.c104
-rw-r--r--common/http.h59
-rw-r--r--common/ssh-utils.c36
-rw-r--r--common/ssh-utils.h11
-rw-r--r--common/tlv.c35
-rw-r--r--common/tlv.h15
8 files changed, 136 insertions, 172 deletions
diff --git a/common/dns-cert.c b/common/dns-cert.c
index 56af13a1d..501abadd5 100644
--- a/common/dns-cert.c
+++ b/common/dns-cert.c
@@ -71,9 +71,8 @@
first CERT found with a supported type; it is expected that only
one CERT record is used. */
gpg_error_t
-_get_dns_cert (const char *name, estream_t *r_key,
- unsigned char **r_fpr, size_t *r_fprlen, char **r_url,
- gpg_err_source_t errsource)
+get_dns_cert (const char *name, estream_t *r_key,
+ unsigned char **r_fpr, size_t *r_fprlen, char **r_url)
{
#ifdef USE_DNS_CERT
#ifdef USE_ADNS
@@ -90,7 +89,7 @@ _get_dns_cert (const char *name, estream_t *r_key,
if (adns_init (&state, adns_if_noerrprint, NULL))
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
log_error ("error initializing adns: %s\n", strerror (errno));
return err;
}
@@ -98,7 +97,7 @@ _get_dns_cert (const char *name, estream_t *r_key,
if (adns_synchronous (state, name, (adns_r_unknown | my_adns_r_cert),
adns_qf_quoteok_query, &answer))
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
/* log_error ("DNS query failed: %s\n", strerror (errno)); */
adns_finish (state);
return err;
@@ -108,11 +107,11 @@ _get_dns_cert (const char *name, estream_t *r_key,
/* log_error ("DNS query returned an error: %s (%s)\n", */
/* adns_strerror (answer->status), */
/* adns_errabbrev (answer->status)); */
- err = gpg_err_make (errsource, GPG_ERR_NOT_FOUND);
+ err = gpg_err_make (default_errsource, GPG_ERR_NOT_FOUND);
goto leave;
}
- err = gpg_err_make (errsource, GPG_ERR_NOT_FOUND);
+ err = gpg_err_make (default_errsource, GPG_ERR_NOT_FOUND);
for (count = 0; count < answer->nrrs; count++)
{
int datalen = answer->rrs.byteblock[count].len;
@@ -132,7 +131,8 @@ _get_dns_cert (const char *name, estream_t *r_key,
thus we do the same. */
*r_key = es_fopenmem_init (0, "rwb", data, datalen);
if (!*r_key)
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource,
+ gpg_err_code_from_syserror ());
else
err = 0;
goto leave;
@@ -149,7 +149,8 @@ _get_dns_cert (const char *name, estream_t *r_key,
*r_fpr = xtrymalloc (*r_fprlen);
if (!*r_fpr)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource,
+ gpg_err_code_from_syserror ());
goto leave;
}
memcpy (*r_fpr, data + 1, *r_fprlen);
@@ -162,7 +163,8 @@ _get_dns_cert (const char *name, estream_t *r_key,
*url = xtrymalloc (datalen - (*r_fprlen + 1) + 1);
if (!*r_url)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource,
+ gpg_err_code_from_syserror ());
xfree (*r_fpr);
*r_fpr = NULL;
goto leave;
@@ -198,9 +200,9 @@ _get_dns_cert (const char *name, estream_t *r_key,
/* Allocate a 64k buffer which is the limit for an DNS response. */
answer = xtrymalloc (65536);
if (!answer)
- return gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
- err = gpg_err_make (errsource, GPG_ERR_NOT_FOUND);
+ err = gpg_err_make (default_errsource, GPG_ERR_NOT_FOUND);
r = res_query (name, C_IN, T_CERT, answer, 65536);
/* Not too big, not too small, no errors and at least 1 answer. */
@@ -220,7 +222,7 @@ _get_dns_cert (const char *name, estream_t *r_key,
rc = dn_skipname (pt, emsg);
if (rc == -1)
{
- err = gpg_err_make (errsource, GPG_ERR_INV_OBJ);
+ err = gpg_err_make (default_errsource, GPG_ERR_INV_OBJ);
goto leave;
}
pt += rc + QFIXEDSZ;
@@ -238,7 +240,7 @@ _get_dns_cert (const char *name, estream_t *r_key,
rc = dn_skipname (pt, emsg); /* the name we just queried for */
if (rc == -1)
{
- err = gpg_err_make (errsource, GPG_ERR_INV_OBJ);
+ err = gpg_err_make (default_errsource, GPG_ERR_INV_OBJ);
goto leave;
}
@@ -289,7 +291,8 @@ _get_dns_cert (const char *name, estream_t *r_key,
/* PGP type */
*r_key = es_fopenmem_init (0, "rwb", pt, dlen);
if (!*r_key)
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource,
+ gpg_err_code_from_syserror ());
else
err = 0;
goto leave;
@@ -304,7 +307,7 @@ _get_dns_cert (const char *name, estream_t *r_key,
*r_fpr = xtrymalloc (*r_fprlen);
if (!*r_fpr)
{
- err = gpg_err_make (errsource,
+ err = gpg_err_make (default_errsource,
gpg_err_code_from_syserror ());
goto leave;
}
@@ -318,7 +321,7 @@ _get_dns_cert (const char *name, estream_t *r_key,
*r_url = xtrymalloc (dlen - (*r_fprlen + 1) + 1);
if (!*r_fpr)
{
- err = gpg_err_make (errsource,
+ err = gpg_err_make (default_errsource,
gpg_err_code_from_syserror ());
xfree (*r_fpr);
*r_fpr = NULL;
@@ -351,6 +354,6 @@ _get_dns_cert (const char *name, estream_t *r_key,
(void)r_fprlen;
(void)r_url;
- return gpg_err_make (errsource, GPG_ERR_NOT_SUPPORTED);
+ return gpg_err_make (default_errsource, GPG_ERR_NOT_SUPPORTED);
#endif
}
diff --git a/common/dns-cert.h b/common/dns-cert.h
index a1d3d86da..351c357ea 100644
--- a/common/dns-cert.h
+++ b/common/dns-cert.h
@@ -19,12 +19,9 @@
#ifndef GNUPG_COMMON_DNS_CERT_H
#define GNUPG_COMMON_DNS_CERT_H
-gpg_error_t _get_dns_cert (const char *name, estream_t *r_key,
- unsigned char **r_fpr, size_t *r_fprlen,
- char **r_url,
- gpg_err_source_t errsource);
-#define get_dns_cert(a,b,c,d,e) \
- _get_dns_cert ((a),(b),(c),(d),(e), GPG_ERR_SOURCE_DEFAULT);
+gpg_error_t get_dns_cert (const char *name, estream_t *r_key,
+ unsigned char **r_fpr, size_t *r_fprlen,
+ char **r_url);
diff --git a/common/http.c b/common/http.c
index ac5928bc1..be93bb502 100644
--- a/common/http.c
+++ b/common/http.c
@@ -155,8 +155,7 @@ static int insert_escapes (char *buffer, const char *string,
const char *special);
static uri_tuple_t parse_tuple (char *string);
static gpg_error_t send_request (http_t hd, const char *auth,const char *proxy,
- const char *srvtag,strlist_t headers,
- gpg_err_source_t errsource);
+ const char *srvtag,strlist_t headers);
static char *build_rel_path (parsed_uri_t uri);
static gpg_error_t parse_response (http_t hd);
@@ -428,10 +427,9 @@ http_register_tls_callback ( gpg_error_t (*cb) (http_t, void *, int) )
pointer for completing the the request and to wait for the
response. */
gpg_error_t
-_http_open (http_t *r_hd, http_req_t reqtype, const char *url,
- const char *auth, unsigned int flags, const char *proxy,
- void *tls_context, const char *srvtag, strlist_t headers,
- gpg_err_source_t errsource)
+http_open (http_t *r_hd, http_req_t reqtype, const char *url,
+ const char *auth, unsigned int flags, const char *proxy,
+ void *tls_context, const char *srvtag, strlist_t headers)
{
gpg_error_t err;
http_t hd;
@@ -439,7 +437,7 @@ _http_open (http_t *r_hd, http_req_t reqtype, const char *url,
*r_hd = NULL;
if (!(reqtype == HTTP_REQ_GET || reqtype == HTTP_REQ_POST))
- return gpg_err_make (errsource, GPG_ERR_INV_ARG);
+ return gpg_err_make (default_errsource, GPG_ERR_INV_ARG);
/* Create the handle. */
hd = xtrycalloc (1, sizeof *hd);
@@ -449,9 +447,9 @@ _http_open (http_t *r_hd, http_req_t reqtype, const char *url,
hd->flags = flags;
hd->tls_context = tls_context;
- err = _http_parse_uri (&hd->uri, url, 0, errsource);
+ err = http_parse_uri (&hd->uri, url, 0);
if (!err)
- err = send_request (hd, auth, proxy, srvtag, headers, errsource);
+ err = send_request (hd, auth, proxy, srvtag, headers);
if (err)
{
@@ -472,9 +470,8 @@ _http_open (http_t *r_hd, http_req_t reqtype, const char *url,
this http abstraction layer. This has the advantage of providing
service tags and an estream interface. */
gpg_error_t
-_http_raw_connect (http_t *r_hd, const char *server, unsigned short port,
- unsigned int flags, const char *srvtag,
- gpg_err_source_t errsource)
+http_raw_connect (http_t *r_hd, const char *server, unsigned short port,
+ unsigned int flags, const char *srvtag)
{
gpg_error_t err = 0;
int sock;
@@ -495,15 +492,16 @@ _http_raw_connect (http_t *r_hd, const char *server, unsigned short port,
sock = connect_server (server, port, hd->flags, srvtag, &hnf);
if (sock == -1)
{
- err = gpg_err_make (errsource, (hnf? GPG_ERR_UNKNOWN_HOST
- :gpg_err_code_from_syserror ()));
+ err = gpg_err_make (default_errsource,
+ (hnf? GPG_ERR_UNKNOWN_HOST
+ : gpg_err_code_from_syserror ()));
xfree (hd);
return err;
}
hd->sock = my_socket_new (sock);
if (!hd->sock)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
xfree (hd);
return err;
}
@@ -512,14 +510,14 @@ _http_raw_connect (http_t *r_hd, const char *server, unsigned short port,
cookie = xtrycalloc (1, sizeof *cookie);
if (!cookie)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
goto leave;
}
cookie->sock = my_socket_ref (hd->sock);
hd->fp_write = es_fopencookie (cookie, "w", cookie_functions);
if (!hd->fp_write)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
my_socket_unref (cookie->sock);
xfree (cookie);
goto leave;
@@ -529,14 +527,14 @@ _http_raw_connect (http_t *r_hd, const char *server, unsigned short port,
cookie = xtrycalloc (1, sizeof *cookie);
if (!cookie)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
goto leave;
}
cookie->sock = my_socket_ref (hd->sock);
hd->fp_read = es_fopencookie (cookie, "r", cookie_functions);
if (!hd->fp_read)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
my_socket_unref (cookie->sock);
xfree (cookie);
goto leave;
@@ -582,7 +580,7 @@ http_start_data (http_t hd)
gpg_error_t
-_http_wait_response (http_t hd, gpg_err_source_t errsource)
+http_wait_response (http_t hd)
{
gpg_error_t err;
cookie_t cookie;
@@ -594,7 +592,7 @@ _http_wait_response (http_t hd, gpg_err_source_t errsource)
object keeps the actual system socket open. */
cookie = hd->write_cookie;
if (!cookie)
- return gpg_err_make (errsource, GPG_ERR_INTERNAL);
+ return gpg_err_make (default_errsource, GPG_ERR_INTERNAL);
es_fclose (hd->fp_write);
hd->fp_write = NULL;
@@ -611,7 +609,7 @@ _http_wait_response (http_t hd, gpg_err_source_t errsource)
/* Create a new cookie and a stream for reading. */
cookie = xtrycalloc (1, sizeof *cookie);
if (!cookie)
- return gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
cookie->sock = my_socket_ref (hd->sock);
if (hd->uri->use_tls)
cookie->tls_session = hd->tls_context;
@@ -620,7 +618,7 @@ _http_wait_response (http_t hd, gpg_err_source_t errsource)
hd->fp_read = es_fopencookie (cookie, "r", cookie_functions);
if (!hd->fp_read)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
my_socket_unref (cookie->sock);
xfree (cookie);
hd->read_cookie = NULL;
@@ -641,19 +639,18 @@ _http_wait_response (http_t hd, gpg_err_source_t errsource)
be used as an HTTP proxy and any enabled $http_proxy gets
ignored. */
gpg_error_t
-_http_open_document (http_t *r_hd, const char *document,
- const char *auth, unsigned int flags, const char *proxy,
- void *tls_context, const char *srvtag, strlist_t headers,
- gpg_err_source_t errsource)
+http_open_document (http_t *r_hd, const char *document,
+ const char *auth, unsigned int flags, const char *proxy,
+ void *tls_context, const char *srvtag, strlist_t headers)
{
gpg_error_t err;
- err = _http_open (r_hd, HTTP_REQ_GET, document, auth, flags,
- proxy, tls_context, srvtag, headers, errsource);
+ err = http_open (r_hd, HTTP_REQ_GET, document, auth, flags,
+ proxy, tls_context, srvtag, headers);
if (err)
return err;
- err = _http_wait_response (*r_hd, errsource);
+ err = http_wait_response (*r_hd);
if (err)
http_close (*r_hd, 0);
@@ -719,14 +716,14 @@ http_get_status_code (http_t hd)
* the URL in the same way it would do for an HTTP style URI.
*/
gpg_error_t
-_http_parse_uri (parsed_uri_t *ret_uri, const char *uri,
- int no_scheme_check, gpg_err_source_t errsource)
+http_parse_uri (parsed_uri_t *ret_uri, const char *uri,
+ int no_scheme_check)
{
gpg_err_code_t ec;
*ret_uri = xtrycalloc (1, sizeof **ret_uri + strlen (uri));
if (!*ret_uri)
- return gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
strcpy ((*ret_uri)->buffer, uri);
ec = do_parse_uri (*ret_uri, 0, no_scheme_check);
if (ec)
@@ -734,7 +731,7 @@ _http_parse_uri (parsed_uri_t *ret_uri, const char *uri,
xfree (*ret_uri);
*ret_uri = NULL;
}
- return gpg_err_make (errsource, ec);
+ return gpg_err_make (default_errsource, ec);
}
void
@@ -1075,8 +1072,7 @@ parse_tuple (char *string)
*/
static gpg_error_t
send_request (http_t hd, const char *auth,
- const char *proxy, const char *srvtag, strlist_t headers,
- gpg_err_source_t errsource)
+ const char *proxy, const char *srvtag, strlist_t headers)
{
gnutls_session_t tls_session;
gpg_error_t err;
@@ -1093,7 +1089,7 @@ send_request (http_t hd, const char *auth,
if (hd->uri->use_tls && !tls_session)
{
log_error ("TLS requested but no GNUTLS context provided\n");
- return gpg_err_make (errsource, GPG_ERR_INTERNAL);
+ return gpg_err_make (default_errsource, GPG_ERR_INTERNAL);
}
server = *hd->uri->host ? hd->uri->host : "localhost";
@@ -1110,12 +1106,12 @@ send_request (http_t hd, const char *auth,
if (proxy)
http_proxy = proxy;
- err = _http_parse_uri (&uri, http_proxy, 0, errsource);
+ err = http_parse_uri (&uri, http_proxy, 0);
if (err)
{
log_error ("invalid HTTP proxy (%s): %s\n",
http_proxy, gpg_strerror (err));
- return gpg_err_make (errsource, GPG_ERR_CONFIGURATION);
+ return gpg_err_make (default_errsource, GPG_ERR_CONFIGURATION);
}
if (uri->auth)
@@ -1126,7 +1122,8 @@ send_request (http_t hd, const char *auth,
uri->auth, strlen(uri->auth));
if (!proxy_authstr)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource,
+ gpg_err_code_from_syserror ());
http_release_parsed_uri (uri);
return err;
}
@@ -1148,14 +1145,15 @@ send_request (http_t hd, const char *auth,
if (sock == -1)
{
xfree (proxy_authstr);
- return gpg_err_make (errsource, (hnf? GPG_ERR_UNKNOWN_HOST
- : gpg_err_code_from_syserror ()));
+ return gpg_err_make (default_errsource,
+ (hnf? GPG_ERR_UNKNOWN_HOST
+ : gpg_err_code_from_syserror ()));
}
hd->sock = my_socket_new (sock);
if (!hd->sock)
{
xfree (proxy_authstr);
- return gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
}
@@ -1177,7 +1175,7 @@ send_request (http_t hd, const char *auth,
{
log_info ("TLS handshake failed: %s\n", gnutls_strerror (rc));
xfree (proxy_authstr);
- return gpg_err_make (errsource, GPG_ERR_NETWORK);
+ return gpg_err_make (default_errsource, GPG_ERR_NETWORK);
}
if (tls_callback)
@@ -1204,7 +1202,7 @@ send_request (http_t hd, const char *auth,
if (!myauth)
{
xfree (proxy_authstr);
- return gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
}
remove_escapes (myauth);
}
@@ -1222,13 +1220,14 @@ send_request (http_t hd, const char *auth,
if (!authstr)
{
xfree (proxy_authstr);
- return gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ return gpg_err_make (default_errsource,
+ gpg_err_code_from_syserror ());
}
}
p = build_rel_path (hd->uri);
if (!p)
- return gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
if (http_proxy && *http_proxy)
{
@@ -1261,7 +1260,7 @@ send_request (http_t hd, const char *auth,
xfree (p);
if (!request)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
xfree (authstr);
xfree (proxy_authstr);
return err;
@@ -1276,7 +1275,7 @@ send_request (http_t hd, const char *auth,
cookie = xtrycalloc (1, sizeof *cookie);
if (!cookie)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
goto leave;
}
cookie->sock = my_socket_ref (hd->sock);
@@ -1287,13 +1286,13 @@ send_request (http_t hd, const char *auth,
hd->fp_write = es_fopencookie (cookie, "w", cookie_functions);
if (!hd->fp_write)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
my_socket_unref (cookie->sock);
xfree (cookie);
hd->write_cookie = NULL;
}
else if (es_fputs (request, hd->fp_write) || es_fflush (hd->fp_write))
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
else
err = 0;
@@ -1304,7 +1303,8 @@ send_request (http_t hd, const char *auth,
if ((es_fputs (headers->d, hd->fp_write) || es_fflush (hd->fp_write))
|| (es_fputs("\r\n",hd->fp_write) || es_fflush(hd->fp_write)))
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource,
+ gpg_err_code_from_syserror ());
break;
}
}
diff --git a/common/http.h b/common/http.h
index 7a11b84f3..74c29105a 100644
--- a/common/http.h
+++ b/common/http.h
@@ -74,51 +74,38 @@ typedef struct http_context_s *http_t;
void http_register_tls_callback (gpg_error_t (*cb) (http_t, void *, int));
-gpg_error_t _http_parse_uri (parsed_uri_t *ret_uri, const char *uri,
- int no_scheme_check, gpg_err_source_t errsource);
-#define http_parse_uri(a,b,c) \
- _http_parse_uri ((a), (b), (c), GPG_ERR_SOURCE_DEFAULT)
+gpg_error_t http_parse_uri (parsed_uri_t *ret_uri, const char *uri,
+ int no_scheme_check);
void http_release_parsed_uri (parsed_uri_t uri);
-gpg_error_t _http_raw_connect (http_t *r_hd,
- const char *server, unsigned short port,
- unsigned int flags, const char *srvtag,
- gpg_err_source_t errsource);
-#define http_raw_connect(a,b,c,d,e) \
- _http_raw_connect ((a),(b),(c),(d),(e), GPG_ERR_SOURCE_DEFAULT)
-
-gpg_error_t _http_open (http_t *r_hd, http_req_t reqtype,
- const char *url,
- const char *auth,
- unsigned int flags,
- const char *proxy,
- void *tls_context,
- const char *srvtag,
- strlist_t headers,
- gpg_err_source_t errsource);
-#define http_open(a,b,c,d,e,f,g,h,i) \
- _http_open ((a),(b),(c),(d),(e),(f),(g),(h),(i), GPG_ERR_SOURCE_DEFAULT)
+gpg_error_t http_raw_connect (http_t *r_hd,
+ const char *server, unsigned short port,
+ unsigned int flags, const char *srvtag);
+
+gpg_error_t http_open (http_t *r_hd, http_req_t reqtype,
+ const char *url,
+ const char *auth,
+ unsigned int flags,
+ const char *proxy,
+ void *tls_context,
+ const char *srvtag,
+ strlist_t headers);
void http_start_data (http_t hd);
-gpg_error_t _http_wait_response (http_t hd, gpg_err_source_t errsource);
-#define http_wait_response(a) \
- _http_wait_response ((a), GPG_ERR_SOURCE_DEFAULT)
+gpg_error_t http_wait_response (http_t hd);
void http_close (http_t hd, int keep_read_stream);
-gpg_error_t _http_open_document (http_t *r_hd,
- const char *document,
- const char *auth,
- unsigned int flags,
- const char *proxy,
- void *tls_context,
- const char *srvtag,
- strlist_t headers,
- gpg_err_source_t errsource);
-#define http_open_document(a,b,c,d,e,f,g,h) \
- _http_open_document ((a),(b),(c),(d),(e),(f),(g),(h), GPG_ERR_SOURCE_DEFAULT)
+gpg_error_t http_open_document (http_t *r_hd,
+ const char *document,
+ const char *auth,
+ unsigned int flags,
+ const char *proxy,
+ void *tls_context,
+ const char *srvtag,
+ strlist_t headers);
estream_t http_get_read_ptr (http_t hd);
estream_t http_get_write_ptr (http_t hd);
diff --git a/common/ssh-utils.c b/common/ssh-utils.c
index e2de80258..663d61590 100644
--- a/common/ssh-utils.c
+++ b/common/ssh-utils.c
@@ -31,11 +31,9 @@
/* Return the Secure Shell type fingerprint for KEY. The length of
the fingerprint is returned at R_LEN and the fingerprint itself at
R_FPR. In case of a error code is returned and NULL stored at
- R_FPR. This function is usually called via the ssh_get_fingerprint
- macro which makes sure to use the correct value for ERRSOURCE. */
+ R_FPR. */
static gpg_error_t
-get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len,
- gpg_err_source_t errsource, int as_string)
+get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len, int as_string)
{
gpg_error_t err;
gcry_sexp_t list = NULL;
@@ -59,7 +57,7 @@ get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len,
list = gcry_sexp_find_token (key, "shadowed-private-key", 0);
if (!list)
{
- err = gpg_err_make (errsource, GPG_ERR_UNKNOWN_SEXP);
+ err = gpg_err_make (default_errsource, GPG_ERR_UNKNOWN_SEXP);
goto leave;
}
@@ -71,7 +69,7 @@ get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len,
name = gcry_sexp_nth_string (list, 0);
if (!name)
{
- err = gpg_err_make (errsource, GPG_ERR_INV_SEXP);
+ err = gpg_err_make (default_errsource, GPG_ERR_INV_SEXP);
goto leave;
}
@@ -91,7 +89,7 @@ get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len,
break;
default:
elems = "";
- err = gpg_err_make (errsource, GPG_ERR_PUBKEY_ALGO);
+ err = gpg_err_make (default_errsource, GPG_ERR_PUBKEY_ALGO);
break;
}
if (err)
@@ -106,7 +104,7 @@ get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len,
l2 = gcry_sexp_find_token (list, s, 1);
if (!l2)
{
- err = gpg_err_make (errsource, GPG_ERR_INV_SEXP);
+ err = gpg_err_make (default_errsource, GPG_ERR_INV_SEXP);
goto leave;
}
a = gcry_sexp_nth_mpi (l2, 1, GCRYMPI_FMT_USG);
@@ -114,7 +112,7 @@ get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len,
l2 = NULL;
if (!a)
{
- err = gpg_err_make (errsource, GPG_ERR_INV_SEXP);
+ err = gpg_err_make (default_errsource, GPG_ERR_INV_SEXP);
goto leave;
}
@@ -129,7 +127,7 @@ get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len,
*r_fpr = gcry_malloc (as_string? 61:20);
if (!*r_fpr)
{
- err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
goto leave;
}
@@ -157,31 +155,25 @@ get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len,
/* Return the Secure Shell type fingerprint for KEY. The length of
the fingerprint is returned at R_LEN and the fingerprint itself at
R_FPR. In case of an error an error code is returned and NULL
- stored at R_FPR. This function is usually called via the
- ssh_get_fingerprint macro which makes sure to use the correct value
- for ERRSOURCE. */
+ stored at R_FPR. */
gpg_error_t
-_ssh_get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len,
- gpg_err_source_t errsource)
+ssh_get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len)
{
- return get_fingerprint (key, r_fpr, r_len, errsource, 0);
+ return get_fingerprint (key, r_fpr, r_len, 0);
}
/* Return the Secure Shell type fingerprint for KEY as a string. The
fingerprint is mallcoed and stored at R_FPRSTR. In case of an
- error an error code is returned and NULL stored at R_FPRSTR. This
- function is usually called via the ssh_get_fingerprint_string macro
- which makes sure to use the correct value for ERRSOURCE. */
+ error an error code is returned and NULL stored at R_FPRSTR. */
gpg_error_t
-_ssh_get_fingerprint_string (gcry_sexp_t key, char **r_fprstr,
- gpg_err_source_t errsource)
+ssh_get_fingerprint_string (gcry_sexp_t key, char **r_fprstr)
{
gpg_error_t err;
size_t dummy;
void *string;
- err = get_fingerprint (key, &string, &dummy, errsource, 1);
+ err = get_fingerprint (key, &string, &dummy, 1);
*r_fprstr = string;
return err;
}
diff --git a/common/ssh-utils.h b/common/ssh-utils.h
index 1813c8b51..10e2ac2ad 100644
--- a/common/ssh-utils.h
+++ b/common/ssh-utils.h
@@ -21,16 +21,9 @@
#define GNUPG_COMMON_SSH_UTILS_H
-gpg_error_t _ssh_get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len,
- gpg_err_source_t errsource);
-#define ssh_get_fingerprint(a,b,c) \
- _ssh_get_fingerprint ((a), (b), (c), GPG_ERR_SOURCE_DEFAULT)
-
-gpg_error_t _ssh_get_fingerprint_string (gcry_sexp_t key, char **r_fprstr,
- gpg_err_source_t errsource);
-#define ssh_get_fingerprint_string(a,b) \
- _ssh_get_fingerprint_string ((a), (b), GPG_ERR_SOURCE_DEFAULT)
+gpg_error_t ssh_get_fingerprint (gcry_sexp_t key, void **r_fpr, size_t *r_len);
+gpg_error_t ssh_get_fingerprint_string (gcry_sexp_t key, char **r_fprstr);
#endif /*GNUPG_COMMON_SSH_UTILS_H*/
diff --git a/common/tlv.c b/common/tlv.c
index 61f770e93..39eae89ba 100644
--- a/common/tlv.c
+++ b/common/tlv.c
@@ -34,6 +34,7 @@ typedef int gpg_error_t;
#include <gpg-error.h>
#endif
+#include "util.h"
#include "tlv.h"
static const unsigned char *
@@ -151,11 +152,10 @@ find_tlv_unchecked (const unsigned char *buffer, size_t length,
and the length part from the TLV triplet. Update BUFFER and SIZE
on success. */
gpg_error_t
-_parse_ber_header (unsigned char const **buffer, size_t *size,
- int *r_class, int *r_tag,
- int *r_constructed, int *r_ndef,
- size_t *r_length, size_t *r_nhdr,
- gpg_err_source_t errsource)
+parse_ber_header (unsigned char const **buffer, size_t *size,
+ int *r_class, int *r_tag,
+ int *r_constructed, int *r_ndef,
+ size_t *r_length, size_t *r_nhdr)
{
int c;
unsigned long tag;
@@ -168,7 +168,7 @@ _parse_ber_header (unsigned char const **buffer, size_t *size,
/* Get the tag. */
if (!length)
- return gpg_err_make (errsource, GPG_ERR_EOF);
+ return gpg_err_make (default_errsource, GPG_ERR_EOF);
c = *buf++; length--; ++*r_nhdr;
*r_class = (c & 0xc0) >> 6;
@@ -182,7 +182,7 @@ _parse_ber_header (unsigned char const **buffer, size_t *size,
{
tag <<= 7;
if (!length)
- return gpg_err_make (errsource, GPG_ERR_EOF);
+ return gpg_err_make (default_errsource, GPG_ERR_EOF);
c = *buf++; length--; ++*r_nhdr;
tag |= c & 0x7f;
@@ -193,7 +193,7 @@ _parse_ber_header (unsigned char const **buffer, size_t *size,
/* Get the length. */
if (!length)
- return gpg_err_make (errsource, GPG_ERR_EOF);
+ return gpg_err_make (default_errsource, GPG_ERR_EOF);
c = *buf++; length--; ++*r_nhdr;
if ( !(c & 0x80) )
@@ -201,20 +201,20 @@ _parse_ber_header (unsigned char const **buffer, size_t *size,
else if (c == 0x80)
*r_ndef = 1;
else if (c == 0xff)
- return gpg_err_make (errsource, GPG_ERR_BAD_BER);
+ return gpg_err_make (default_errsource, GPG_ERR_BAD_BER);
else
{
unsigned long len = 0;
int count = c & 0x7f;
if (count > sizeof (len) || count > sizeof (size_t))
- return gpg_err_make (errsource, GPG_ERR_BAD_BER);
+ return gpg_err_make (default_errsource, GPG_ERR_BAD_BER);
for (; count; count--)
{
len <<= 8;
if (!length)
- return gpg_err_make (errsource, GPG_ERR_EOF);
+ return gpg_err_make (default_errsource, GPG_ERR_EOF);
c = *buf++; length--; ++*r_nhdr;
len |= c & 0xff;
}
@@ -255,9 +255,8 @@ _parse_ber_header (unsigned char const **buffer, size_t *size,
handle_error ();
*/
gpg_error_t
-_parse_sexp (unsigned char const **buf, size_t *buflen,
- int *depth, unsigned char const **tok, size_t *toklen,
- gpg_err_source_t errsource)
+parse_sexp (unsigned char const **buf, size_t *buflen,
+ int *depth, unsigned char const **tok, size_t *toklen)
{
const unsigned char *s;
size_t n, vlen;
@@ -267,7 +266,7 @@ _parse_sexp (unsigned char const **buf, size_t *buflen,
*tok = NULL;
*toklen = 0;
if (!n)
- return *depth ? gpg_err_make (errsource, GPG_ERR_INV_SEXP) : 0;
+ return *depth ? gpg_err_make (default_errsource, GPG_ERR_INV_SEXP) : 0;
if (*s == '(')
{
s++; n--;
@@ -279,7 +278,7 @@ _parse_sexp (unsigned char const **buf, size_t *buflen,
if (*s == ')')
{
if (!*depth)
- return gpg_err_make (errsource, GPG_ERR_INV_SEXP);
+ return gpg_err_make (default_errsource, GPG_ERR_INV_SEXP);
*toklen = 1;
s++; n--;
(*depth)--;
@@ -290,10 +289,10 @@ _parse_sexp (unsigned char const **buf, size_t *buflen,
for (vlen=0; n && *s && *s != ':' && (*s >= '0' && *s <= '9'); s++, n--)
vlen = vlen*10 + (*s - '0');
if (!n || *s != ':')
- return gpg_err_make (errsource, GPG_ERR_INV_SEXP);
+ return gpg_err_make (default_errsource, GPG_ERR_INV_SEXP);
s++; n--;
if (vlen > n)
- return gpg_err_make (errsource, GPG_ERR_INV_SEXP);
+ return gpg_err_make (default_errsource, GPG_ERR_INV_SEXP);
*tok = s;
*toklen = vlen;
s += vlen;
diff --git a/common/tlv.h b/common/tlv.h
index fd57e1e90..f346394ac 100644
--- a/common/tlv.h
+++ b/common/tlv.h
@@ -80,14 +80,10 @@ const unsigned char *find_tlv_unchecked (const unsigned char *buffer,
/* ASN.1 BER parser: Parse BUFFER of length SIZE and return the tag
and the length part from the TLV triplet. Update BUFFER and SIZE
on success. */
-gpg_error_t _parse_ber_header (unsigned char const **buffer, size_t *size,
+gpg_error_t parse_ber_header (unsigned char const **buffer, size_t *size,
int *r_class, int *r_tag,
int *r_constructed,
- int *r_ndef, size_t *r_length, size_t *r_nhdr,
- gpg_err_source_t errsource);
-#define parse_ber_header(a,b,c,d,e,f,g,h) \
- _parse_ber_header ((a),(b),(c),(d),(e),(f),(g),(h),\
- GPG_ERR_SOURCE_DEFAULT)
+ int *r_ndef, size_t *r_length, size_t *r_nhdr);
/* Return the next token of an canonical encoded S-expression. BUF
@@ -102,11 +98,8 @@ gpg_error_t _parse_ber_header (unsigned char const **buffer, size_t *size,
reflect on return the actual depth of the tree. To detect the end
of the S-expression it is advisable to check DEPTH after a
successful return. */
-gpg_error_t _parse_sexp (unsigned char const **buf, size_t *buflen,
- int *depth, unsigned char const **tok, size_t *toklen,
- gpg_err_source_t errsource);
-#define parse_sexp(a,b,c,d,e) \
- _parse_sexp ((a),(b),(c),(d),(e), GPG_ERR_SOURCE_DEFAULT)
+gpg_error_t parse_sexp (unsigned char const **buf, size_t *buflen,
+ int *depth, unsigned char const **tok, size_t *toklen);