From b535af4fc468f1d9e9be7be33b219d583a40d22c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 7 May 2003 00:06:37 +0000 Subject: [PATCH] - make it work without SSL - switch from -Ds in Makefile to config.h - small header cleaup --- .cvsignore | 4 ++++ Makefile.am | 2 +- autogen.sh | 1 + configure.in | 53 ++++++++++++++++++++++++++++++++++-------------- debian/changelog | 8 +++++++- src/config.c | 10 ++++++--- src/cram.c | 6 ++++-- src/dotlock.c | 4 +++- src/imap.c | 8 ++++++-- src/isync.h | 8 +++++--- src/list.c | 3 ++- src/maildir.c | 5 +++-- src/main.c | 3 ++- src/sync.c | 3 ++- 14 files changed, 85 insertions(+), 33 deletions(-) diff --git a/.cvsignore b/.cvsignore index b6c9bfd..6ca8ac7 100644 --- a/.cvsignore +++ b/.cvsignore @@ -3,9 +3,13 @@ Makefile.in autom4te.cache aclocal.m4 build-stamp +config.h +config.h.in config.cache config.log config.status configure +configure.lineno configure-stamp isync.spec +stamp-h1 diff --git a/Makefile.am b/Makefile.am index 87129f1..6204e22 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ SUBDIRS = debian src man_MANS = isync.1 -EXTRA_DIST = isyncrc.sample isync.spec.in $(man_MANS) +EXTRA_DIST = isyncrc.sample isync.spec $(man_MANS) DISTCLEANFILES = *~ build-stamp configure-stamp log: diff --git a/autogen.sh b/autogen.sh index 2a77cc7..b7da409 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,6 +2,7 @@ # $Id$ set -e -v aclocal +autoheader automake --add-missing autoconf ./configure "$@" diff --git a/configure.in b/configure.in index c5252bb..626f01e 100644 --- a/configure.in +++ b/configure.in @@ -1,24 +1,37 @@ AC_INIT(src/isync.h) -AM_INIT_AUTOMAKE(isync,0.9) +AM_CONFIG_HEADER(config.h) +AM_INIT_AUTOMAKE(isync, 0.9.1) AM_PROG_CC_STDC if test "$GCC" = yes; then - CFLAGS="$CFLAGS -pipe -W -Wall -Wshadow -Wmissing-prototypes" + CFLAGS="$CFLAGS -pipe -W -Wall -Wshadow -Wmissing-prototypes" fi -AC_ARG_WITH(ssl-dir, [ --with-ssl-dir=DIR location where OpenSSL is installed], - [if test -d $withval/lib; then - LIBS="$LIBS -L$withval/lib" - CFLAGS="$CFLAGS -I$withval/include" - else - AC_MSG_ERROR(can't find OpenSSL in $withval) - fi]) - AC_CHECK_FUNCS(getopt_long) -AC_CHECK_LIB(socket,socket) -AC_CHECK_LIB(nsl,inet_ntoa) -AC_CHECK_LIB(crypto,ERR_error_string) -AC_CHECK_LIB(ssl,SSL_library_init) + +AC_CHECK_LIB(socket, socket) +AC_CHECK_LIB(nsl, inet_ntoa) + +ssl=false +AC_ARG_WITH(ssl, + [ --with-ssl=DIR yes/no/OpenSSL installation root [detect]], + [ob_cv_with_ssl=$withval]) +if test "x$ob_cv_with_ssl" != xno; then + if test -d "$ob_cv_with_ssl/lib"; then + CPFLAGS="$CPPFLAGS -I$ob_cv_with_ssl/include" + LDFLAGS="$LDFLAGS -L$ob_cv_with_ssl/lib" + fi + AC_CHECK_LIB(crypto, ERR_error_string, [cryptolib=" -lcrypto"]) + AC_CHECK_LIB(ssl, SSL_library_init, [ + LIBS="-lssl$cryptolib $LIBS" + AC_DEFINE(HAVE_LIBSSL, 1, [Define if you want SSL support]) + ssl=true + ],[ + if test -n "$ob_cv_with_ssl"; then + AC_MSG_ERROR([can't find OpenSSL]) + fi + ]) +fi AC_CACHE_CHECK(for dbm_open, ac_cv_dbmopen, [ac_cv_dbmopen=no @@ -37,10 +50,20 @@ if test $ac_cv_dbmopen = no; then if test $ac_cv_libdb = yes; then LIBS="$LIBS -ldb" - AC_DEFINE(HAVE_LIBDB) + AC_DEFINE(HAVE_LIBDB, 1, [Define if you have libdb]) else AC_MSG_ERROR([Could not find dbm_open(), you must install libdb]) fi fi AC_OUTPUT(Makefile src/Makefile debian/Makefile isync.spec) + +if $ssl; then + AC_MSG_RESULT([ +Using SSL +]) +else + AC_MSG_RESULT([ +Not using SSL +]) +fi diff --git a/debian/changelog b/debian/changelog index 6aa6fd2..29de5e0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,14 @@ +isync (0.9.1-1) unstable; urgency=medium + + * New upstream release + + -- Oswald Buddenhagen Wed, 07 May 2003 01:22:00 +0200 + isync (0.9-1) unstable; urgency=low * New upstream release - -- Oswald Buddenhagen Wed, 26 Mar 2003 04:12:00 +0100 + -- Oswald Buddenhagen Mon, 05 May 2003 20:15:00 +0200 isync (0.8-1) unstable; urgency=low diff --git a/src/config.c b/src/config.c index 8ae9366..f391d5d 100644 --- a/src/config.c +++ b/src/config.c @@ -22,6 +22,8 @@ * despite that library's more restrictive license. */ +#include "isync.h" + #include #include #include @@ -30,7 +32,6 @@ #include #include #include -#include "isync.h" config_t *boxes = 0; @@ -45,8 +46,11 @@ static char * my_strndup (const char *s, size_t nchars) { char *r = malloc (sizeof (char) * (nchars + 1)); - strncpy (r, s, nchars); - r[nchars] = 0; + if (r) + { + memcpy (r, s, nchars); + r[nchars] = 0; + } return r; } diff --git a/src/cram.c b/src/cram.c index 4b21a21..663899a 100644 --- a/src/cram.c +++ b/src/cram.c @@ -21,11 +21,13 @@ * despite that library's more restrictive license. */ -#include -#include "isync.h" +#include #if HAVE_LIBSSL +#include "isync.h" + +#include #include #include diff --git a/src/dotlock.c b/src/dotlock.c index d7da7f5..ea82b96 100644 --- a/src/dotlock.c +++ b/src/dotlock.c @@ -24,13 +24,15 @@ /* * this file contains routines to establish a mutex using a `dotlock' file */ + +#include "dotlock.h" + #include #include #include #if TESTING #include #endif -#include "dotlock.h" static struct flock lck = { 0, SEEK_SET, 0, 0, 0 }; diff --git a/src/imap.c b/src/imap.c index 44004d1..b4552f6 100644 --- a/src/imap.c +++ b/src/imap.c @@ -22,12 +22,15 @@ * despite that library's more restrictive license. */ +#include "isync.h" + #include #include #include #include #include #include +#include #include #include #include @@ -36,9 +39,8 @@ #include #include #if HAVE_LIBSSL -#include +# include #endif -#include "isync.h" const char *Flags[] = { "\\Seen", @@ -594,6 +596,7 @@ imap_exec (imap_t * imap, const char *fmt, ...) /* not reached */ } +#ifdef HAVE_LIBSSL static int start_tls (imap_t *imap, config_t * cfg) { @@ -619,6 +622,7 @@ start_tls (imap_t *imap, config_t * cfg) puts ("SSL support enabled"); return 0; } +#endif imap_t * imap_connect (config_t * cfg) diff --git a/src/isync.h b/src/isync.h index bc40ae8..9955c53 100644 --- a/src/isync.h +++ b/src/isync.h @@ -22,6 +22,10 @@ * despite that library's more restrictive license. */ +#include + +#include + #if HAVE_LIBDB # define DB_DBM_HSEARCH 1 # include @@ -29,8 +33,6 @@ # include #endif -#include -#include #if HAVE_LIBSSL # include #endif @@ -47,9 +49,9 @@ typedef struct typedef struct { Socket_t *sock; - char buf[1024]; int bytes; int offset; + char buf[1024]; } buffer_t; diff --git a/src/list.c b/src/list.c index ac7ad40..8886710 100644 --- a/src/list.c +++ b/src/list.c @@ -21,10 +21,11 @@ * despite that library's more restrictive license. */ +#include "isync.h" + #include #include #include -#include "isync.h" static char * skip_string (char *s) diff --git a/src/maildir.c b/src/maildir.c index 13a0b4b..8394af8 100644 --- a/src/maildir.c +++ b/src/maildir.c @@ -22,6 +22,9 @@ * despite that library's more restrictive license. */ +#include "isync.h" +#include "dotlock.h" + #include #include #include @@ -32,8 +35,6 @@ #include #include #include -#include "isync.h" -#include "dotlock.h" /* 2, */ static void diff --git a/src/main.c b/src/main.c index 3cfbd59..f6cea7e 100644 --- a/src/main.c +++ b/src/main.c @@ -22,6 +22,8 @@ * despite that library's more restrictive license. */ +#include "isync.h" + #include #include #include @@ -33,7 +35,6 @@ #include #include #include -#include "isync.h" int Quiet; diff --git a/src/sync.c b/src/sync.c index 331889e..a417827 100644 --- a/src/sync.c +++ b/src/sync.c @@ -22,6 +22,8 @@ * despite that library's more restrictive license. */ +#include "isync.h" + #include #include #include @@ -31,7 +33,6 @@ #include #include #include -#include "isync.h" static unsigned int MaildirCount = 0;