Add strtonum to compat library and export it

crypto library requires strtonum now, and add it to compat library.
remove it from applications compat/ directories.
This commit is contained in:
kinichiro 2021-12-26 15:42:47 +09:00
parent 1b95c5d584
commit adde656bb7
10 changed files with 13 additions and 40 deletions

View File

@ -29,14 +29,6 @@ else()
set(NC_SRC ${NC_SRC} compat/readpassphrase.c) set(NC_SRC ${NC_SRC} compat/readpassphrase.c)
endif() endif()
check_function_exists(strtonum HAVE_STRTONUM)
if(HAVE_STRTONUM AND CMAKE_SYSTEM_NAME MATCHES "Darwin" AND
CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 20)
add_definitions(-DHAVE_STRTONUM)
else()
set(NC_SRC ${NC_SRC} compat/strtonum.c)
endif()
if(NOT "${OPENSSLDIR}" STREQUAL "") if(NOT "${OPENSSLDIR}" STREQUAL "")
add_definitions(-DDEFAULT_CA_FILE=\"${OPENSSLDIR}/cert.pem\") add_definitions(-DDEFAULT_CA_FILE=\"${OPENSSLDIR}/cert.pem\")
else() else()

View File

@ -43,8 +43,4 @@ if !HAVE_READPASSPHRASE
nc_SOURCES += compat/readpassphrase.c nc_SOURCES += compat/readpassphrase.c
endif endif
if !HAVE_STRTONUM
nc_SOURCES += compat/strtonum.c
endif
endif endif

View File

@ -13,14 +13,6 @@ else()
set(OCSPCHECK_SRC ${OCSPCHECK_SRC} compat/memmem.c) set(OCSPCHECK_SRC ${OCSPCHECK_SRC} compat/memmem.c)
endif() endif()
check_function_exists(strtonum HAVE_STRTONUM)
if(HAVE_STRTONUM AND CMAKE_SYSTEM_NAME MATCHES "Darwin" AND
CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 20)
add_definitions(-DHAVE_STRTONUM)
else()
set(OCSPCHECK_SRC ${OCSPCHECK_SRC} compat/strtonum.c)
endif()
if(NOT "${OPENSSLDIR}" STREQUAL "") if(NOT "${OPENSSLDIR}" STREQUAL "")
add_definitions(-DDEFAULT_CA_FILE=\"${OPENSSLDIR}/cert.pem\") add_definitions(-DDEFAULT_CA_FILE=\"${OPENSSLDIR}/cert.pem\")
else() else()

View File

@ -22,7 +22,3 @@ noinst_HEADERS = http.h
if !HAVE_MEMMEM if !HAVE_MEMMEM
ocspcheck_SOURCES += compat/memmem.c ocspcheck_SOURCES += compat/memmem.c
endif endif
if !HAVE_STRTONUM
ocspcheck_SOURCES += compat/strtonum.c
endif

View File

@ -61,14 +61,6 @@ if(WIN32)
set(OPENSSL_SRC ${OPENSSL_SRC} compat/poll_win.c) set(OPENSSL_SRC ${OPENSSL_SRC} compat/poll_win.c)
endif() endif()
check_function_exists(strtonum HAVE_STRTONUM)
if(HAVE_STRTONUM AND CMAKE_SYSTEM_NAME MATCHES "Darwin" AND
CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 20)
add_definitions(-DHAVE_STRTONUM)
else()
set(OPENSSL_SRC ${OPENSSL_SRC} compat/strtonum.c)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin") if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
if(NOT HAVE_CLOCK_GETTIME) if(NOT HAVE_CLOCK_GETTIME)

View File

@ -84,10 +84,6 @@ openssl_SOURCES += compat/clock_gettime_osx.c
endif endif
endif endif
if !HAVE_STRTONUM
openssl_SOURCES += compat/strtonum.c
endif
noinst_HEADERS = apps.h noinst_HEADERS = apps.h
noinst_HEADERS += progs.h noinst_HEADERS += progs.h
noinst_HEADERS += s_apps.h noinst_HEADERS += s_apps.h

View File

@ -888,6 +888,11 @@ if(NOT HAVE_STRSEP)
set(EXTRA_EXPORT ${EXTRA_EXPORT} strsep) set(EXTRA_EXPORT ${EXTRA_EXPORT} strsep)
endif() endif()
if(NOT HAVE_STRTONUM)
set(CRYPTO_SRC ${CRYPTO_SRC} compat/strtonum.c)
set(EXTRA_EXPORT ${EXTRA_EXPORT} strtonum)
endif()
if(NOT HAVE_SYSLOG_R) if(NOT HAVE_SYSLOG_R)
set(CRYPTO_SRC ${CRYPTO_SRC} compat/syslog_r.c) set(CRYPTO_SRC ${CRYPTO_SRC} compat/syslog_r.c)
endif() endif()

View File

@ -76,6 +76,9 @@ endif
if !HAVE_STRSEP if !HAVE_STRSEP
-echo strsep >> crypto_portable.sym -echo strsep >> crypto_portable.sym
endif endif
if !HAVE_STRTONUM
-echo strtonum >> crypto_portable.sym
endif
if !HAVE_TIMEGM if !HAVE_TIMEGM
-echo timegm >> crypto_portable.sym -echo timegm >> crypto_portable.sym
endif endif
@ -175,6 +178,10 @@ if !HAVE_STRSEP
libcompat_la_SOURCES += compat/strsep.c libcompat_la_SOURCES += compat/strsep.c
endif endif
if !HAVE_STRTONUM
libcompat_la_SOURCES += compat/strtonum.c
endif
if !HAVE_ASPRINTF if !HAVE_ASPRINTF
libcompat_la_SOURCES += compat/bsd-asprintf.c libcompat_la_SOURCES += compat/bsd-asprintf.c
endif endif

View File

@ -24,7 +24,6 @@
#include <apps.h> #include <apps.h>
#include <apps.c> #include <apps.c>
#include <strtonum.c>
/* Needed to keep apps.c happy... */ /* Needed to keep apps.c happy... */
BIO *bio_err; BIO *bio_err;

View File

@ -82,6 +82,7 @@ for i in crypto/compat; do
$libc_src/crypt/chacha_private.h \ $libc_src/crypt/chacha_private.h \
$libc_src/stdlib/reallocarray.c \ $libc_src/stdlib/reallocarray.c \
$libc_src/stdlib/recallocarray.c \ $libc_src/stdlib/recallocarray.c \
$libc_src/stdlib/strtonum.c \
$libc_src/string/explicit_bzero.c \ $libc_src/string/explicit_bzero.c \
$libc_src/string/strcasecmp.c \ $libc_src/string/strcasecmp.c \
$libc_src/string/strlcpy.c \ $libc_src/string/strlcpy.c \
@ -243,7 +244,6 @@ echo "copying nc(1) source"
$CP $bin_src/nc/nc.1 apps/nc $CP $bin_src/nc/nc.1 apps/nc
rm -f apps/nc/*.c apps/nc/*.h rm -f apps/nc/*.c apps/nc/*.h
$CP_LIBC $libc_src/net/base64.c apps/nc/compat $CP_LIBC $libc_src/net/base64.c apps/nc/compat
$CP_LIBC $libc_src/stdlib/strtonum.c apps/nc/compat
for i in `awk '/SOURCES|HEADERS|MANS/ { print $3 }' apps/nc/Makefile.am` ; do for i in `awk '/SOURCES|HEADERS|MANS/ { print $3 }' apps/nc/Makefile.am` ; do
if [ -e $bin_src/nc/$i ]; then if [ -e $bin_src/nc/$i ]; then
$CP $bin_src/nc/$i apps/nc $CP $bin_src/nc/$i apps/nc
@ -255,7 +255,6 @@ echo "copying ocspcheck(1) source"
$CP $sbin_src/ocspcheck/ocspcheck.8 apps/ocspcheck $CP $sbin_src/ocspcheck/ocspcheck.8 apps/ocspcheck
rm -f apps/ocspcheck/*.c apps/ocspcheck/*.h rm -f apps/ocspcheck/*.c apps/ocspcheck/*.h
$CP_LIBC $libc_src/string/memmem.c apps/ocspcheck/compat $CP_LIBC $libc_src/string/memmem.c apps/ocspcheck/compat
$CP_LIBC $libc_src/stdlib/strtonum.c apps/ocspcheck/compat
for i in `awk '/SOURCES|HEADERS|MANS/ { print $3 }' apps/ocspcheck/Makefile.am` ; do for i in `awk '/SOURCES|HEADERS|MANS/ { print $3 }' apps/ocspcheck/Makefile.am` ; do
if [ -e $sbin_src/ocspcheck/$i ]; then if [ -e $sbin_src/ocspcheck/$i ]; then
$CP $sbin_src/ocspcheck/$i apps/ocspcheck $CP $sbin_src/ocspcheck/$i apps/ocspcheck
@ -265,7 +264,6 @@ done
# copy openssl(1) source # copy openssl(1) source
echo "copying openssl(1) source" echo "copying openssl(1) source"
$CP $bin_src/openssl/openssl.1 apps/openssl $CP $bin_src/openssl/openssl.1 apps/openssl
$CP_LIBC $libc_src/stdlib/strtonum.c apps/openssl/compat
$CP $libcrypto_src/cert.pem . $CP $libcrypto_src/cert.pem .
$CP $libcrypto_src/openssl.cnf . $CP $libcrypto_src/openssl.cnf .
$CP $libcrypto_src/x509v3.cnf . $CP $libcrypto_src/x509v3.cnf .