diff --git a/include/ChangeLog b/include/ChangeLog index eaee0ddd3..0d72a879a 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,9 @@ +2006-09-28 David Shaw + + * compat.h: New, used for libcompat.a functions. + + * util.h: Includes compat.h. + 2006-04-20 David Shaw * cipher.h: Add dsa2_generate(); diff --git a/include/compat.h b/include/compat.h new file mode 100644 index 000000000..c1f900a9e --- /dev/null +++ b/include/compat.h @@ -0,0 +1,6 @@ +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +int hextobyte( const char *s ); + +#endif /* !_COMPAT_H_ */ diff --git a/include/util.h b/include/util.h index ee25be12e..559d0b9a0 100644 --- a/include/util.h +++ b/include/util.h @@ -30,7 +30,7 @@ #include "errors.h" #include "types.h" #include "mpi.h" - +#include "compat.h" typedef struct { int *argc; /* pointer to argc (value subject to change) */ @@ -164,7 +164,6 @@ int answer_is_yes( const char *s ); int answer_is_yes_no_quit( const char *s ); int answer_is_okay_cancel (const char *s, int def_answer); int match_multistr(const char *multistr,const char *match); -int hextobyte( const char *s ); /*-- strgutil.c --*/ void free_strlist( STRLIST sl ); diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog index a64f28962..4f9229c6f 100644 --- a/keyserver/ChangeLog +++ b/keyserver/ChangeLog @@ -1,5 +1,10 @@ 2006-09-28 David Shaw + * Makefile.am: Link gpgkeys_ldap to libcompat.a. + + * gpgkeys_ldap.c, ksutil.h, ksutil.c: Remove hextobyte instead of + ks_hextobyte as it is provided by libcompat now. + * gpgkeys_ldap.c (build_attrs), ksutil.c (ks_toupper, ks_strcasecmp), ksutil.h: Remove the need for strcasecmp as the field tags are always lowercase. diff --git a/keyserver/Makefile.am b/keyserver/Makefile.am index 9233fbe8c..337991031 100644 --- a/keyserver/Makefile.am +++ b/keyserver/Makefile.am @@ -36,7 +36,7 @@ gpgkeys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS) gpgkeys_ldap_CPPFLAGS = @LDAP_CPPFLAGS@ -gpgkeys_ldap_LDADD = @LDAPLIBS@ @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ +gpgkeys_ldap_LDADD = ../util/libcompat.a @LDAPLIBS@ @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ gpgkeys_finger_LDADD = ../util/libutil.a @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ diff --git a/keyserver/gpgkeys_ldap.c b/keyserver/gpgkeys_ldap.c index 1212f97bf..cdafe7fa7 100644 --- a/keyserver/gpgkeys_ldap.c +++ b/keyserver/gpgkeys_ldap.c @@ -532,7 +532,7 @@ build_attrs(LDAPMod ***modlist,char *line) while(*tok) if(tok[0]=='%' && tok[1] && tok[2]) { - if((userid[i]=ks_hextobyte(&tok[1]))==-1) + if((userid[i]=hextobyte(&tok[1]))==-1) userid[i]='?'; i++; diff --git a/keyserver/ksutil.c b/keyserver/ksutil.c index 6d24cb87e..44224bc64 100644 --- a/keyserver/ksutil.c +++ b/keyserver/ksutil.c @@ -549,28 +549,3 @@ curl_writer_finalize(struct curl_writer_ctx *ctx) ctx->flags.done=1; } } - -int -ks_hextobyte (const char *s) -{ - int c; - - if ( *s >= '0' && *s <= '9' ) - c = 16 * (*s - '0'); - else if ( *s >= 'A' && *s <= 'F' ) - c = 16 * (10 + *s - 'A'); - else if ( *s >= 'a' && *s <= 'f' ) - c = 16 * (10 + *s - 'a'); - else - return -1; - s++; - if ( *s >= '0' && *s <= '9' ) - c += *s - '0'; - else if ( *s >= 'A' && *s <= 'F' ) - c += 10 + *s - 'A'; - else if ( *s >= 'a' && *s <= 'f' ) - c += 10 + *s - 'a'; - else - return -1; - return c; -} diff --git a/keyserver/ksutil.h b/keyserver/ksutil.h index 069901087..3affc06b6 100644 --- a/keyserver/ksutil.h +++ b/keyserver/ksutil.h @@ -138,6 +138,4 @@ struct curl_writer_ctx size_t curl_writer(const void *ptr,size_t size,size_t nmemb,void *cw_ctx); void curl_writer_finalize(struct curl_writer_ctx *ctx); -int ks_hextobyte (const char *s); - #endif /* !_KSUTIL_H_ */ diff --git a/util/ChangeLog b/util/ChangeLog index 426d4d3c9..671b51bb0 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,11 @@ +2006-09-28 David Shaw + + * Makefile.am: Build libcompat.a for keyserver helpers. libutil.a + always contains everything in libcompat.a, so we only need to link + to one or the other. + + * miscutil.c: Move hextobyte to new file compat.c. + 2006-07-31 Werner Koch * iobuf.c (iobuf_ioctl, fd_cache_invalidate): Allow closing all diff --git a/util/Makefile.am b/util/Makefile.am index 48457c29f..1da5a1075 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -20,11 +20,12 @@ INCLUDES = -I.. -I$(top_srcdir)/include -I$(top_srcdir)/intl -noinst_LIBRARIES = libutil.a +noinst_LIBRARIES = libutil.a libcompat.a libutil_a_SOURCES = logger.c fileutil.c miscutil.c strgutil.c \ ttyio.c argparse.c memory.c secmem.c errors.c iobuf.c \ - dotlock.c http.c pka.c membuf.c cert.c + dotlock.c http.c pka.c membuf.c cert.c \ + $(libcompat_a_SOURCES) if USE_SIMPLE_GETTEXT libutil_a_SOURCES+=simple-gettext.c @@ -52,10 +53,18 @@ endif EXTRA_libutil_a_SOURCES = regcomp.c regexec.c regex_internal.c \ regex_internal.h -# LIBOBJS is for the replacement functions +# LIBOBJS and libcompat.a are for the replacement functions and +# similar simple stuff. They're segregated in libcompat so we can +# link it to the keyserver helpers which have different licensing. +# libutil.a, by definition, includes everything that libcompat.a does. + libutil_a_DEPENDENCIES = @LIBOBJS@ libutil_a_LIBADD = @LIBOBJS@ +libcompat_a_SOURCES=compat.c +libcompat_a_DEPENDENCIES = @LIBOBJS@ +libcompat_a_LIBADD = @LIBOBJS@ + http-test: http.c cc -DHAVE_CONFIG_H -I. -I. -I.. $(INCLUDES) $(LDFLAGS) -g -Wall \ -DTEST -o http-test http.c libutil.a @LIBINTL@ @DNSLIBS@ @CAPLIBS@ diff --git a/util/compat.c b/util/compat.c new file mode 100644 index 000000000..aca558aee --- /dev/null +++ b/util/compat.c @@ -0,0 +1,24 @@ +int +hextobyte (const char *s) +{ + int c; + + if ( *s >= '0' && *s <= '9' ) + c = 16 * (*s - '0'); + else if ( *s >= 'A' && *s <= 'F' ) + c = 16 * (10 + *s - 'A'); + else if ( *s >= 'a' && *s <= 'f' ) + c = 16 * (10 + *s - 'a'); + else + return -1; + s++; + if ( *s >= '0' && *s <= '9' ) + c += *s - '0'; + else if ( *s >= 'A' && *s <= 'F' ) + c += 10 + *s - 'A'; + else if ( *s >= 'a' && *s <= 'f' ) + c += 10 + *s - 'a'; + else + return -1; + return c; +} diff --git a/util/miscutil.c b/util/miscutil.c index 698e80691..01241bc23 100644 --- a/util/miscutil.c +++ b/util/miscutil.c @@ -453,28 +453,3 @@ match_multistr(const char *multistr,const char *match) return 0; } - -int -hextobyte( const char *s ) -{ - int c; - - if( *s >= '0' && *s <= '9' ) - c = 16 * (*s - '0'); - else if( *s >= 'A' && *s <= 'F' ) - c = 16 * (10 + *s - 'A'); - else if( *s >= 'a' && *s <= 'f' ) - c = 16 * (10 + *s - 'a'); - else - return -1; - s++; - if( *s >= '0' && *s <= '9' ) - c += *s - '0'; - else if( *s >= 'A' && *s <= 'F' ) - c += 10 + *s - 'A'; - else if( *s >= 'a' && *s <= 'f' ) - c += 10 + *s - 'a'; - else - return -1; - return c; -}