diff --git a/mio/Makefile.in b/mio/Makefile.in index e8308fe..2fe5d77 100644 --- a/mio/Makefile.in +++ b/mio/Makefile.in @@ -347,6 +347,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -577,7 +578,7 @@ distdir: $(DISTFILES) ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir @@ -603,7 +604,7 @@ dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir @@ -621,7 +622,7 @@ dist dist-all: distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ @@ -631,7 +632,7 @@ distcheck: dist *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac diff --git a/mio/configure b/mio/configure index 37efc64..e802f73 100755 --- a/mio/configure +++ b/mio/configure @@ -771,6 +771,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -861,6 +862,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1113,6 +1115,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1250,7 +1261,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1403,6 +1414,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -18546,7 +18558,19 @@ fi done - if test "x$ac_cv_func_SSL_library_init" = "xyes" + for ac_func in OPENSSL_init_ssl +do : + ac_fn_c_check_func "$LINENO" "OPENSSL_init_ssl" "ac_cv_func_OPENSSL_init_ssl" +if test "x$ac_cv_func_OPENSSL_init_ssl" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_OPENSSL_INIT_SSL 1 +_ACEOF + +fi +done + + + if test "x$ac_cv_func_SSL_library_init" = "xyes" -o "x$ac_cv_func_OPENSSL_init_ssl" = "xyes" then $as_echo "#define HAVE_SSL 1" >>confdefs.h @@ -18641,6 +18665,98 @@ fi $as_echo "#define HAVE_SSL_LIBRARY_INIT 1" >>confdefs.h +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL_init_ssl in -lssl" >&5 +$as_echo_n "checking for OPENSSL_init_ssl in -lssl... " >&6; } +if ${ac_cv_lib_ssl_OPENSSL_init_ssl+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lssl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char OPENSSL_init_ssl (); +int +main () +{ +return OPENSSL_init_ssl (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_ssl_OPENSSL_init_ssl=yes +else + ac_cv_lib_ssl_OPENSSL_init_ssl=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_OPENSSL_init_ssl" >&5 +$as_echo "$ac_cv_lib_ssl_OPENSSL_init_ssl" >&6; } +if test "x$ac_cv_lib_ssl_OPENSSL_init_ssl" = xyes; then : + + SSL_LIBS="-lssl" + +$as_echo "#define HAVE_SSL 1" >>confdefs.h + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ERR_get_error in -lcrypto" >&5 +$as_echo_n "checking for ERR_get_error in -lcrypto... " >&6; } +if ${ac_cv_lib_crypto_ERR_get_error+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcrypto $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ERR_get_error (); +int +main () +{ +return ERR_get_error (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_crypto_ERR_get_error=yes +else + ac_cv_lib_crypto_ERR_get_error=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_ERR_get_error" >&5 +$as_echo "$ac_cv_lib_crypto_ERR_get_error" >&6; } +if test "x$ac_cv_lib_crypto_ERR_get_error" = xyes; then : + + SSL_LIBS="${SSL_LIBS} -lcrypto" + +fi + + + $as_echo "#define HAVE_OPENSSL_INIT_SSL 1" >>confdefs.h + + fi fi diff --git a/mio/configure.ac b/mio/configure.ac index 084e323..2a5aa2b 100644 --- a/mio/configure.ac +++ b/mio/configure.ac @@ -279,7 +279,11 @@ then dnl check for an SSL library AC_CHECK_FUNCS([SSL_library_init]) - if test "x$ac_cv_func_SSL_library_init" = "xyes" + dnl SSL_library_init is a macro aliasing OPENSSL_init_ssl in openssl 1.1.0 or later + dnl #define SSL_library_init() OPENSSL_init_ssl(0, NULL) + AC_CHECK_FUNCS([OPENSSL_init_ssl]) + + if test "x$ac_cv_func_SSL_library_init" = "xyes" -o "x$ac_cv_func_OPENSSL_init_ssl" = "xyes" then AC_DEFINE(HAVE_SSL, 1, [ssl support]) else @@ -295,6 +299,19 @@ then dnl only for consistency with AC_CHECK_FUNCS AC_DEFINE(HAVE_SSL_LIBRARY_INIT, 1) ]) + + AC_CHECK_LIB([ssl], [OPENSSL_init_ssl], [ + SSL_LIBS="-lssl" + AC_DEFINE(HAVE_SSL, 1, [ssl support]) + + dnl additional check + AC_CHECK_LIB([crypto], [ERR_get_error], [ + SSL_LIBS="${SSL_LIBS} -lcrypto" + ]) + + dnl only for consistency with AC_CHECK_FUNCS + AC_DEFINE(HAVE_OPENSSL_INIT_SSL, 1) + ]) fi OLDLIBS="$LIBS" diff --git a/mio/lib/Makefile.in b/mio/lib/Makefile.in index d76fa83..b17aa12 100644 --- a/mio/lib/Makefile.in +++ b/mio/lib/Makefile.in @@ -365,6 +365,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/mio/lib/main.c b/mio/lib/main.c index fa92f76..126c37d 100644 --- a/mio/lib/main.c +++ b/mio/lib/main.c @@ -657,7 +657,7 @@ int main (int argc, char* argv[]) tcp_conn.options = MIO_DEV_SCK_CONNECT_SSL; if (mio_dev_sck_connect(tcp[0], &tcp_conn) <= -1) { - printf ("mio_dev_sck_connect() failed....\n"); + MIO_INFO0 (mio, "tcp[0] mio_dev_sck_connect() failed....\n"); /* carry on regardless of failure */ } @@ -672,7 +672,7 @@ int main (int argc, char* argv[]) tcp[1] = mio_dev_sck_make(mio, MIO_SIZEOF(tcp_server_t), &tcp_make); if (!tcp[1]) { - printf ("Cannot make tcp\n"); + MIO_INFO0 (mio, "cannot make tcp[1]....\n"); goto oops; } ts = (tcp_server_t*)(tcp[1] + 1); @@ -684,7 +684,7 @@ int main (int argc, char* argv[]) if (mio_dev_sck_bind(tcp[1],&tcp_bind) <= -1) { - printf ("tcp[1] mio_dev_sck_bind() failed....\n"); + MIO_INFO0 (mio, "tcp[1] mio_dev_sck_bind() failed....\n"); goto oops; } @@ -692,7 +692,7 @@ int main (int argc, char* argv[]) tcp_lstn.backlogs = 100; if (mio_dev_sck_listen(tcp[1], &tcp_lstn) <= -1) { - printf ("tcp[1] mio_dev_sck_listen() failed....\n"); + MIO_INFO0 (mio, "tcp[1] mio_dev_sck_listen() failed....\n"); goto oops; } @@ -722,14 +722,14 @@ int main (int argc, char* argv[]) if (mio_dev_sck_bind(tcp[2], &tcp_bind) <= -1) { - printf ("tcp[2] mio_dev_sck_bind() failed....\n"); + MIO_INFO0 (mio, "tcp[2] mio_dev_sck_bind() failed....\n"); goto oops; } tcp_lstn.backlogs = 100; if (mio_dev_sck_listen(tcp[2], &tcp_lstn) <= -1) { - printf ("tcp[2] mio_dev_sck_listen() failed....\n"); + MIO_INFO0 (mio, "tcp[2] mio_dev_sck_listen() failed....\n"); goto oops; } diff --git a/mio/lib/mio-cfg.h.in b/mio/lib/mio-cfg.h.in index fd27130..eb2ae56 100644 --- a/mio/lib/mio-cfg.h.in +++ b/mio/lib/mio-cfg.h.in @@ -370,6 +370,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_ERR_H +/* Define to 1 if you have the `OPENSSL_init_ssl' function. */ +#undef HAVE_OPENSSL_INIT_SSL + /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_SSL_H diff --git a/mio/lib/mio-pro.c b/mio/lib/mio-pro.c index 123c5f6..9280f38 100644 --- a/mio/lib/mio-pro.c +++ b/mio/lib/mio-pro.c @@ -152,7 +152,7 @@ static pid_t standard_fork_and_exec (mio_t* mio, int pfds[], int flags, param_t* pfds[1] = MIO_SYSHND_INVALID; /* let the pipe be standard input */ - if (dup2 (pfds[0], 0) <= -1) goto slave_oops; + if (dup2(pfds[0], 0) <= -1) goto slave_oops; close (pfds[0]); pfds[0] = MIO_SYSHND_INVALID; diff --git a/mio/lib/mio.c b/mio/lib/mio.c index 6ec945e..0794ec0 100644 --- a/mio/lib/mio.c +++ b/mio/lib/mio.c @@ -1268,25 +1268,6 @@ int mio_dev_timedwrite (mio_dev_t* dev, const void* data, mio_iolen_t len, const return __dev_write(dev, data, len, tmout, wrctx, dstaddr); } -int mio_makesyshndasync (mio_t* mio, mio_syshnd_t hnd) -{ -#if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK) - int flags; - - if ((flags = fcntl(hnd, F_GETFL)) <= -1 || - (flags = fcntl(hnd, F_SETFL, flags | O_NONBLOCK)) <= -1) - { - mio_seterrwithsyserr (mio, 0, errno); - return -1; - } - - return 0; -#else - mio_seterrnum (mio, MIO_ENOIMPL); - return -1; -#endif -} - /* -------------------------------------------------------------------------- */ void mio_gettime (mio_t* mio, mio_ntime_t* now) diff --git a/mio/lib/sys.c b/mio/lib/sys.c index 029c5b7..d33445e 100644 --- a/mio/lib/sys.c +++ b/mio/lib/sys.c @@ -67,3 +67,26 @@ void mio_sys_fini (mio_t* mio) mio_freemem (mio, mio->sysdep); mio->sysdep = MIO_NULL; } + + +/* TODO: migrate this function */ +#include +#include +int mio_makesyshndasync (mio_t* mio, mio_syshnd_t hnd) +{ +#if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK) + int flags; + + if ((flags = fcntl(hnd, F_GETFL)) <= -1 || + (flags = fcntl(hnd, F_SETFL, flags | O_NONBLOCK)) <= -1) + { + mio_seterrwithsyserr (mio, 0, errno); + return -1; + } + + return 0; +#else + mio_seterrnum (mio, MIO_ENOIMPL); + return -1; +#endif +}