1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

dirmngr: Rearrange files to fix de6d831.

* dirmngr/http-common.c: New.
* dirmngr/http-common.h: New.
* dirmngr/Makefile.am (dirmngr_SOURCES): Add them.
(t_http_SOURCES): Add them.
(t_ldap_parse_uri_SOURCES): Add them.
* dirmngr/misc.c (get_default_keyserver): Move to ...
* dirmngr/http-common.c: here.
* dirmngr/http.c: Include http-common.h instead of misc.h.
* dirmngr/http-ntbtls.c: Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2017-03-02 18:17:58 +01:00
parent de6d8313f6
commit 1890896fe6
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
8 changed files with 81 additions and 31 deletions

View File

@ -61,8 +61,7 @@ dirmngr_SOURCES = dirmngr.c dirmngr.h server.c crlcache.c crlfetch.c \
cdb.h cdblib.c misc.c dirmngr-err.h \
ocsp.c ocsp.h validate.c validate.h \
dns-stuff.c dns-stuff.h \
http.c http.h \
http-ntbtls.c \
http.c http.h http-common.c http-common.h http-ntbtls.c \
ks-action.c ks-action.h ks-engine.h \
ks-engine-hkp.c ks-engine-http.c ks-engine-finger.c ks-engine-kdns.c
@ -141,7 +140,7 @@ endif
# http tests
# We need to add the KSBA flags in case we are building against GNUTLS.
# In that case NTBTLS flags are empty, but we need ksba anyway.
t_http_SOURCES = $(t_common_src) t-http.c http.c dns-stuff.c
t_http_SOURCES = $(t_common_src) t-http.c http.c dns-stuff.c http-common.c
t_http_CFLAGS = -DWITHOUT_NPTH=1 $(USE_C99_CFLAGS) \
$(LIBGCRYPT_CFLAGS) $(NTBTLS_CFLAGS) $(LIBGNUTLS_CFLAGS) \
$(GPG_ERROR_CFLAGS) $(KSBA_CFLAGS)
@ -150,7 +149,7 @@ t_http_LDADD = $(t_common_ldadd) \
t_ldap_parse_uri_SOURCES = \
t-ldap-parse-uri.c ldap-parse-uri.c ldap-parse-uri.h \
http.c dns-stuff.c \
http.c http-common.c dns-stuff.c \
$(ldap_url) $(t_common_src)
t_ldap_parse_uri_CFLAGS = -DWITHOUT_NPTH=1 $(USE_C99_CFLAGS) \
$(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS)

View File

@ -72,6 +72,7 @@
#include "../common/init.h"
#include "gc-opt-flags.h"
#include "dns-stuff.h"
#include "http-common.h"
#ifndef ENAMETOOLONG
# define ENAMETOOLONG EINVAL

50
dirmngr/http-common.c Normal file
View File

@ -0,0 +1,50 @@
/* http-common.c - Common support for TLS implementations.
* Copyright (C) 2017 Werner Koch
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dirmngr.h"
#include "http-common.h"
/* Return a static string with the default keyserver. If NAME_ONLY is
* given only the name part is returned. */
const char *
get_default_keyserver (int name_only)
{
static const char *result;
if (!name_only)
return DIRMNGR_DEFAULT_KEYSERVER;
if (!result)
{
/* Strip the scheme from the constant. */
result = strstr (DIRMNGR_DEFAULT_KEYSERVER, "://");
log_assert (result && strlen (result) > 3);
result += 3;
/* Assert that there is no port given. */
log_assert (strchr (result, ':'));
}
return result;
}

25
dirmngr/http-common.h Normal file
View File

@ -0,0 +1,25 @@
/* http-common.h - Defs for common support for TLS implementations.
* Copyright (C) 2017 Werner Koch
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef HTTP_COMMON_H
#define HTTP_COMMON_H
const char *get_default_keyserver (int name_only);
#endif /* HTTP_COMMON_H */

View File

@ -26,7 +26,7 @@
#include "dirmngr.h"
#include "certcache.h"
#include "validate.h"
#include "misc.h"
#include "http-common.h"
#ifdef HTTP_USE_NTBTLS
# include <ntbtls.h>

View File

@ -100,7 +100,7 @@
#include "i18n.h"
#include "dns-stuff.h"
#include "http.h"
#include "misc.h"
#include "http-common.h"
#ifdef USE_NPTH

View File

@ -30,29 +30,6 @@
#include "util.h"
#include "misc.h"
/* Return a static string with the default keyserver. If NAME_ONLY is
* given only the name part is returned. */
const char *
get_default_keyserver (int name_only)
{
static const char *result;
if (!name_only)
return DIRMNGR_DEFAULT_KEYSERVER;
if (!result)
{
/* Strip the scheme from the constant. */
result = strstr (DIRMNGR_DEFAULT_KEYSERVER, "://");
log_assert (result && strlen (result) > 3);
result += 3;
/* Assert that there is no port given. */
log_assert (strchr (result, ':'));
}
return result;
}
/* Convert the hex encoded STRING back into binary and store the
result into the provided buffer RESULT. The actual size of that

View File

@ -21,8 +21,6 @@
#ifndef MISC_H
#define MISC_H
const char *get_default_keyserver (int name_only);
/* Convert hex encoded string back to binary. */
size_t unhexify (unsigned char *result, const char *string);