$Log$
+ Revision 590.163 2002/03/26 04:38:31 nbryant
+ * support autoconf 2.53
+ * make a note that people should be using libtool 1.4d
+ * cut some of the more pointless bells and whistles out of the configure
+ script in an effort to make it more maintainable
+ * modularized ipc_c_tcp.c and client_crypto.o so that they're not tied
+ to the curses stuff.
+ * timezone/daylight and other FreeBSD fixes
+ * more effort in the configure script to detect the common
+ bastardizations (ahem, ports) of Berkeley DB without falling down
+
Revision 590.162 2002/03/25 03:09:39 nbryant
fix warning on platforms where pthread_t may be a pointer
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
all: $(TARGETS)
-.SUFFIXES: .lo .ro .d .c
+.SUFFIXES: .lo .d .c
EXEEXT=@EXEEXT@
-CX=@CX@
SMTP=@SMTP@
CPPFLAGS=@CPPFLAGS@ -I.
CFLAGS=@CFLAGS@
CC=@CC@
-GDBM=@GDBM@
RESOLV=@RESOLV@
LIBS=@LIBS@
LDFLAGS=@LDFLAGS@
-CURSES=@CURSES@
-NETLIBS=@NETLIBS@
chkpwd_LIBS=@chkpwd_LIBS@
LIBOBJS=@LIBOBJS@
-CL_LIBOBJS=@CL_LIBOBJS@
-PTHREAD_DEFS=@PTHREAD_DEFS@
-PTHREAD_LIBS=@PTHREAD_LIBS@
-SSL_LIBS=@SSL_LIBS@
-CLIENT_PTLIBS=@CLIENT_PTLIBS@
INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@
SHELL=/bin/sh
#
#
-citadel$(EXEEXT): ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \
- routines2$(CX) messages$(CX) screen$(CX) \
- client_passwords$(CX) md5$(CX) client_crypto$(CX) \
- commands$(CX) client_chat$(CX) serv_info$(CX) tools$(CX) $(LIBOBJS)
- $(CC) ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \
- routines2$(CX) messages$(CX) screen$(CX) \
- commands$(CX) client_chat$(CX) serv_info$(CX) tools$(CX) \
- client_passwords$(CX) md5$(CX) client_crypto$(CX) \
- $(LIBOBJS) $(LDFLAGS) -o citadel $(CURSES) $(NETLIBS) $(SSL_LIBS) $(CLIENT_PTLIBS)
-
-.c.o:
- $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $<
+citadel$(EXEEXT): ipc_c_tcp.o citadel.o rooms.o routines.o \
+ routines2.o messages.o screen.o \
+ client_passwords.o md5.o client_crypto.o \
+ commands.o client_chat.o serv_info.o tools.o $(LIBOBJS)
+ $(CC) ipc_c_tcp.o citadel.o rooms.o routines.o \
+ routines2.o messages.o screen.o \
+ commands.o client_chat.o serv_info.o tools.o \
+ client_passwords.o md5.o client_crypto.o \
+ $(LIBOBJS) $(LDFLAGS) -o citadel $(LIBS)
.y.c:
$(YACC) $(YFLAGS) $<
#
#
-SERV_OBJS = server_main.ro
+SERV_OBJS = server_main.o
-parsedate.ro: parsedate.c
+parsedate.o: parsedate.c
LIBSERV_OBJS = user_ops.lo citserver.lo sysdep.lo dynloader.lo tools.lo $(DATABASE:.c=.lo) \
control.lo policy.lo config.lo support.lo room_ops.lo file_ops.lo msgbase.lo \
libcitserver.la: $(LIBSERV_OBJS)
$(LIBTOOL) $(CC) $(LDFLAGS) -rpath $(prefix) -no-undefined -avoid-version \
- -o libcitserver.la $(LIBSERV_OBJS) $(GDBM) $(LIBS) $(PTHREAD_LIBS) $(NETLIBS) $(SSL_LIBS) $(RESOLV)
+ -o libcitserver.la $(LIBSERV_OBJS) $(LIBS) $(RESOLV)
citserver: $(SERV_OBJS) $(LIBTOOL) libcitserver.la
$(LIBTOOL) --mode=link $(CC) $(SERV_OBJS) $(LDFLAGS) libcitserver.la -o \
- citserver $(PTHREAD_LIBS)
+ citserver $(LIBS)
-.c.ro:
- $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -DCIT_CLIENT $(PTHREAD_DEFS) -c $< -o $@
+.c.o:
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -DCIT_CLIENT -c $< -o $@
.c.lo: $(LIBTOOL)
@test -d modules || mkdir -p modules
- $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(PTHREAD_DEFS) -c $< -o $@
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
modules/libchat.la: serv_chat.lo libcitserver.la $(LIBTOOL)
$(LTSHARE) -o libchat.la ../serv_chat.lo ../libcitserver.la
../imap_fetch.lo ../imap_search.lo ../imap_store.lo ../imap_misc.lo ../libcitserver.la
aidepost: aidepost.o libcitserver.la $(LIBOBJS)
- $(LIBTOOL) $(CC) aidepost.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o aidepost $(PTHREAD_LIBS)
+ $(LIBTOOL) $(CC) aidepost.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o aidepost $(LIBS)
modules/libpas2.la: serv_pas2.lo md5.lo $(LIBTOOL) libcitserver.la
$(LTSHARE) -o libpas2.la ../serv_pas2.lo ../md5.lo ../libcitserver.la
$(LTSHARE) -o libical.la ../serv_ical.lo ../libcitserver.la
citmail: citmail.o config.o
- $(CC) citmail.o config.o $(LDFLAGS) -o citmail $(NETLIBS)
+ $(CC) citmail.o config.o $(LDFLAGS) -o citmail $(LIBS)
setup: setup.o tools.o
- $(CC) setup.o tools.o $(CURSES) $(NETLIBS) $(LDFLAGS) -o setup
+ $(CC) setup.o tools.o $(LIBS) $(LDFLAGS) -o setup
chkpwd: chkpwd.o auth.o config.o
$(CC) chkpwd.o auth.o config.o $(LDFLAGS) -o chkpwd $(chkpwd_LIBS)
netsetup: netsetup.o config.o
$(CC) netsetup.o config.o $(LDFLAGS) -o netsetup
-whobbs$(EXEEXT): whobbs.o ipc_c_tcp.o tools.o $(LIBOBJS)
- $(CC) whobbs.o ipc_c_tcp.o tools.o $(LIBOBJS) $(LDFLAGS) -o whobbs $(NETLIBS)
+whobbs$(EXEEXT): whobbs.o ipc_c_tcp.o tools.o client_crypto.o $(LIBOBJS)
+ $(CC) whobbs.o ipc_c_tcp.o tools.o client_crypto.o $(LIBOBJS) $(LDFLAGS) -o whobbs $(LIBS)
-migratenet$(EXEEXT): migratenet.o config.o ipc_c_tcp.o tools.o libcitserver.la $(LIBOBJS)
- $(LIBTOOL) $(CC) migratenet.o config.o ipc_c_tcp.o tools.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o migratenet $(NETLIBS)
+migratenet$(EXEEXT): migratenet.o config.o ipc_c_tcp.o client_crypto.o tools.o libcitserver.la $(LIBOBJS)
+ $(LIBTOOL) $(CC) migratenet.o config.o ipc_c_tcp.o client_crypto.o tools.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o migratenet $(LIBS)
-sendcommand: sendcommand.o ipc_c_tcp.o libcitserver.la $(LIBOBJS)
- $(LIBTOOL) $(CC) sendcommand.o ipc_c_tcp.o libcitserver.la \
- $(LIBOBJS) $(LDFLAGS) -o sendcommand $(NETLIBS) $(PTHREAD_LIBS)
+sendcommand: sendcommand.o ipc_c_tcp.o client_crypto.o libcitserver.la $(LIBOBJS)
+ $(LIBTOOL) $(CC) sendcommand.o ipc_c_tcp.o client_crypto.o libcitserver.la \
+ $(LIBOBJS) $(LDFLAGS) -o sendcommand $(LIBS)
base64: base64.o
$(CC) base64.o $(LDFLAGS) -o base64
-userlist: userlist.o ipc_c_tcp.o tools.o $(LIBOBJS)
- $(CC) userlist.o ipc_c_tcp.o tools.o \
- $(LIBOBJS) $(LDFLAGS) -o userlist $(NETLIBS)
+userlist: userlist.o ipc_c_tcp.o client_crypto.o tools.o $(LIBOBJS)
+ $(CC) userlist.o ipc_c_tcp.o client_crypto.o tools.o \
+ $(LIBOBJS) $(LDFLAGS) -o userlist $(LIBS)
msgform: msgform.o
$(CC) msgform.o $(LDFLAGS) -o msgform
readlog: readlog.o config.o
$(CC) readlog.o config.o $(LDFLAGS) -o readlog
-stats: stats.o ipc_c_tcp.o libcitserver.la $(LIBOBJS)
- $(LIBTOOL) $(CC) stats.o ipc_c_tcp.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o stats $(NETLIBS) $(PTHREAD_LIBS)
+stats: stats.o ipc_c_tcp.o client_crypto.o libcitserver.la $(LIBOBJS)
+ $(LIBTOOL) $(CC) stats.o ipc_c_tcp.o client_crypto.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o stats $(LIBS)
.PHONY: install-data install-doc install-exec clean cleaner distclean
fi
clean:
- rm -f *.o *.ro *.lo parsedate.c
+ rm -f *.o *.lo parsedate.c
cleaner: clean
rm -rf $(CLIENT_TARGETS) $(SERVER_TARGETS) $(UTIL_TARGETS) \
.c.d:
@echo Checking dependencies for $<
- @$(CC) -M $(CPPFLAGS) $(PTHREAD_DEFS) $< | sed -e 's!$*.o!$*.o $*.ro $*.lo $@!' > $@
+ @$(CC) -M $(CPPFLAGS) $< | sed -e 's!$*.o!$*.o $*.lo $@!' > $@
@test -s $@ || rm -f $@
Makefile: $(srcdir)/Makefile.in config.status
echo ... running aclocal ...
aclocal
echo ... running libtoolize ...
-libtoolize --force
+libtoolize -c --force
echo ... running autoconf ...
autoconf
echo ... running autoheader ...
autoheader
echo
-echo This script has been tested with autoconf 2.52, libtool 1.4.2, and
+echo This script has been tested with autoconf 2.53, libtool 1.4d, and
echo automake 1.5. Other versions may work, but I recommend the latest
echo compatible versions of these.
echo
-echo Some versions of libtool may have outputted, above, a spurious warning
-echo that you have to regenerate your aclocal.m4. This is a mostly harmless bug
-echo and can be ignored.
+echo libtool 1.4.2 is not sufficient to build portable configure scripts;
+echo at least version 1.4d from alpha.gnu.org is needed.
echo
echo Also note that autoconf, automake, and libtool should all be configured
echo with the same prefix.
return argc;
}
+static void statusHook(char *s) {
+ sln_printf(s);
+ sln_flush();
+}
+
/*
* main
*/
char hexstring[MD5_HEXSTRING_SIZE];
int stored_password = 0;
char password[SIZ];
+
+ setIPCDeathHook(screen_delete);
+ setIPCErrorPrintf(err_printf);
+ setCryptoStatusHook(statusHook);
/* Permissions sanity check - don't run citadel setuid/setgid */
if (getuid() != geteuid()) {
int ScheduledShutdown = 0;
int do_defrag = 0;
-/* These are commented out. Why do we need them? They're defined in time.h
- * anyway, and declaring them again here makes FreeBSD barf on it.
-extern long int timezone;
-extern int daylight;
- */
-
/*
* Various things that need to be initialized at startup
*/
void cmd_time(void)
{
time_t tv;
+ struct tm *tmp;
tv = time(NULL);
- localtime(&tv);
+ tmp = localtime(&tv);
- cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, daylight);
+ /* timezone and daylight global variables are not portable. */
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
+ cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp->tm_gmtoff, tmp->tm_isdst);
+#else
+ cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp->tm_isdst);
+#endif
}
/*
#include <sys/types.h>
#include "citadel.h"
#include "client_crypto.h"
-#include "screen.h"
+#include "ipc.h"
#ifdef HAVE_OPENSSL
SSL *ssl;
#endif /* HAVE_OPENSSL */
+static void (*status_hook)(char *s) = NULL;
+
+void setCryptoStatusHook(void (*hook)(char *s)) {
+ status_hook = hook;
+}
+
+
#ifdef HAVE_OPENSSL
/*
* input binary data from encrypted connection
while (len < bytes) {
if (SSL_want_read(ssl)) {
if ((SSL_write(ssl, junk, 0)) < 1) {
- err_printf("SSL_write in serv_read:\n");
+ error_printf("SSL_write in serv_read:\n");
ERR_print_errors_fp(stderr);
}
}
serv_read(&buf[len], bytes - len);
return;
}
- err_printf("SSL_read in serv_read:\n");
+ error_printf("SSL_read in serv_read:\n");
ERR_print_errors_fp(stderr);
connection_died();
return;
while (bytes_written < nbytes) {
if (SSL_want_write(ssl)) {
if ((SSL_read(ssl, junk, 0)) < 1) {
- err_printf("SSL_read in serv_write:\n");
+ error_printf("SSL_read in serv_write:\n");
ERR_print_errors_fp(stderr);
}
}
nbytes - bytes_written);
return;
}
- err_printf("SSL_write in serv_write:\n");
+ error_printf("SSL_write in serv_write:\n");
ERR_print_errors_fp(stderr);
connection_died();
return;
ssl_method = SSLv23_client_method();
ssl_ctx = SSL_CTX_new(ssl_method);
if (!ssl_ctx) {
- err_printf("SSL_CTX_new failed: %s\n",
+ error_printf("SSL_CTX_new failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
return 0;
}
/* Any reasonable cipher we can get */
if (!(SSL_CTX_set_cipher_list(ssl_ctx, CIT_CIPHERS))) {
- err_printf("No ciphers available for encryption\n");
+ error_printf("No ciphers available for encryption\n");
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
return 0;
/* Load DH parameters into the context */
dh = DH_new();
if (!dh) {
- err_printf("Can't allocate a DH object: %s\n",
+ error_printf("Can't allocate a DH object: %s\n",
ERR_reason_error_string(ERR_get_error()));
return 0;
}
if (!(BN_hex2bn(&(dh->p), DH_P))) {
- err_printf("Can't assign DH_P: %s\n",
+ error_printf("Can't assign DH_P: %s\n",
ERR_reason_error_string(ERR_get_error()));
return 0;
}
if (!(BN_hex2bn(&(dh->g), DH_G))) {
- err_printf("Can't assign DH_G: %s\n",
+ error_printf("Can't assign DH_G: %s\n",
ERR_reason_error_string(ERR_get_error()));
return 0;
}
/* New SSL object */
ssl = SSL_new(ssl_ctx);
if (!ssl) {
- err_printf("SSL_new failed: %s\n",
+ error_printf("SSL_new failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
RAND_egd("/var/run/egd-pool");
if (!RAND_status()) {
- err_printf("PRNG not properly seeded\n");
+ error_printf("PRNG not properly seeded\n");
return 0;
}
/* Associate network connection with SSL object */
if (SSL_set_fd(ssl, serv_sock) < 1) {
- err_printf("SSL_set_fd failed: %s\n",
+ error_printf("SSL_set_fd failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
return 0;
}
- sln_printf("Requesting encryption...\r");
- sln_flush();
+ if (status_hook != NULL)
+ status_hook("Requesting encryption...\r");
/* Ready to start SSL/TLS */
serv_puts("STLS");
serv_gets(buf);
if (buf[0] != '2') {
- err_printf("Server can't start TLS: %s\n", &buf[4]);
+ error_printf("Server can't start TLS: %s\n", &buf[4]);
return 0;
}
/* Do SSL/TLS handshake */
if ((a = SSL_connect(ssl)) < 1) {
- err_printf("SSL_connect failed: %s\n",
+ error_printf("SSL_connect failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
int bits, alg_bits;
bits = SSL_CIPHER_get_bits(SSL_get_current_cipher(ssl), &alg_bits);
- err_printf("Encrypting with %s cipher %s (%d of %d bits)\n",
+ error_printf("Encrypting with %s cipher %s (%d of %d bits)\n",
SSL_CIPHER_get_version(SSL_get_current_cipher(ssl)),
SSL_CIPHER_get_name(SSL_get_current_cipher(ssl)),
bits, alg_bits);
void serv_write_ssl(char *buf, int nbytes);
void ssl_lock(int mode, int n, const char *file, int line);
#endif /* HAVE_OPENSSL */
+
+extern int ssl_is_connected;
+
+void setCryptoStatusHook(void (*hook)(char *s));
db_dir="$with_db"
with_db=yes
else
+ test -f /usr/local/lib/libdb.a -o -f /usr/local/lib/libdb.so \
+ -o -f /usr/local/lib/libdb4.a -o -f /usr/local/lib/libdb4.so \
+ -o -f /usr/local/lib/libdb3.a -o -f /usr/local/lib/libdb3.so && db_dir=/usr/local
+
test -d /usr/local/BerkeleyDB.3.1 && db_dir=/usr/local/BerkeleyDB.3.1
test -d /usr/local/BerkeleyDB.3.2 && db_dir=/usr/local/BerkeleyDB.3.2
test -d /usr/local/BerkeleyDB.3.3 && db_dir=/usr/local/BerkeleyDB.3.3
dnl build pthreads programs with gcc due to header problems.
alpha*-dec-osf*)
test -z "$CC" && CC=cc
- PTHREAD_LIBS="-lpthread -lexc"
+ LIBS="-lpthread -lexc $LIBS"
check_pthread=no
;;
dnl FreeBSD is similar to Digital UNIX with DEC C, which has a -pthread flag:
*-*-freebsd*)
if test "$with_kthread" = yes; then
- PTHREAD_LIBS=-kthread
+ LIBS="-kthread $LIBS"
else
- PTHREAD_LIBS=-pthread
+ LIBS="-pthread $LIBS"
fi
check_pthread=no
PTHREAD_DEFS=-D_THREAD_SAFE
;;
*-*-openbsd*)
- PTHREAD_LIBS=-pthread
+ LIBS="-pthread $LIBS"
check_pthread=no
PTHREAD_DEFS=-pthread
;;
PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
;;
esac
+DEFS="$DEFS $PTHREAD_DEFS"
dnl Checks for programs.
AC_PROG_CC
dnl Checks for libraries.
-dnl libdl, libgdbm, and libcrypt are only used in the server, so the
-dnl Makefile only passes $(LIBS) to that target. If other programs start
-dnl requiring additional libraries, we'll have to use other variables, as is
-dnl done with curses.
-
dnl We want to test for the following in libc before checking for their
dnl respective libraries, because some systems (like Irix) have both, and the
dnl non-libc versions may be broken.
AC_CHECK_FUNCS(crypt dlopen gethostbyname connect)
if test "$ac_cv_func_gethostbyname" = no; then
- AC_CHECK_LIB(nsl, gethostbyname, NETLIBS="-lnsl $NETLIBS")
+ AC_CHECK_LIB(nsl, gethostbyname)
fi
if test "$ac_cv_func_connect" = no; then
- AC_CHECK_LIB(socket, connect, NETLIBS="-lsocket $NETLIBS",, $NETLIBS)
+ AC_CHECK_LIB(socket, connect)
fi
if test "$ac_cv_func_dlopen" = no; then
if test "x$with_db" != xno -a "x$with_gdbm" != xyes; then
test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
- test "$db_dir" && CPPFLAGS="$CPPFLAGS -I$db_dir/include" || \
- ( test -d /usr/include/db4 && CPPFLAGS="$CPPFLAGS -I/usr/include/db4" ) || \
- ( test -d /usr/local/include/db4 && CPPFLAGS="$CPPFLAGS -I/usr/local/include/db4" ) || \
- ( test -d /usr/include/db3 && CPPFLAGS="$CPPFLAGS -I/usr/include/db3" ) || \
- ( test -d /usr/local/include/db3 && CPPFLAGS="$CPPFLAGS -I/usr/local/include/db3" )
+ dblib=""
+ test -d "$db_dir/include/db4" && CPPFLAGS="$CPPFLAGS -I$db_dir/include/db4" && dblib="db4" || \
+ ( test -d "$db_dir/include/db3" && CPPFLAGS="$CPPFLAGS -I$db_dir/include/db3" && dblib="db3" ) || \
+ ( test "$db_dir" -a -d "$db_dir/include" && CPPFLAGS="$CPPFLAGS -I$db_dir/include" ) || \
+ ( test -d /usr/include/db4 && CPPFLAGS="$CPPFLAGS -I/usr/include/db4" && dblib="db4" ) || \
+ ( test -d /usr/include/db3 && CPPFLAGS="$CPPFLAGS -I/usr/include/db3" && dblib="db3" )
- AC_CHECK_LIB(db3, db_env_create,
- [GDBM="$GDBM -ldb3"
+ AC_SEARCH_LIBS(db_env_create, [$dblib db db4 db3], [
DATABASE=database_sleepycat.c
- with_gdbm=no], [AC_CHECK_LIB(db, db_env_create,
- [GDBM="$GDBM -ldb"
- DATABASE=database_sleepycat.c
- with_gdbm=no], [], [$NETLIBS])], [$NETLIBS])
+ with_gdbm=no
+ ])
+
fi
if test "x$with_gdbm" != xno -a "x$with_db" != xyes; then
test "$db_dir" && CPPFLAGS="$CPPFLAGS -I$db_dir/include"
AC_CHECK_LIB(gdbm, gdbm_open,
- [GDBM="$GDBM -lgdbm"
+ [LIBS="-lgdbm $LIBS"
DATABASE=database.c
with_db=no])
fi
test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
-save_LIBS=$LIBS
-LIBS=$CURSES
AC_SEARCH_LIBS(tgetent, [ncurses curses termcap])
AC_SEARCH_LIBS(initscr, [ncurses curses])
AC_CHECK_FUNCS(vw_printw wcolor_set)
-CURSES=$LIBS
-LIBS=$save_LIBS
dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
dnl which the -pthread flag takes care of this.)
if test "$check_pthread" != no; then
- AC_CHECK_LIB(pthread, pthread_create,
- PTHREAD_LIBS="-lpthread $PTHREAD_LIBS")
- AC_CHECK_LIB(pthreads, pthread_create,
- PTHREAD_LIBS="-lpthreads $PTHREAD_LIBS")
+ AC_CHECK_LIB(pthread, pthread_create)
+ AC_CHECK_LIB(pthreads, pthread_create)
fi
# The big search for OpenSSL
if test "x$ac_cv_openssldir" != "xno" ; then
AC_DEFINE(HAVE_OPENSSL)
- LIBS="$saved_LIBS"
- SSL_LIBS="-lssl -lcrypto"
+ LIBS="-lssl -lcrypto $LIBS"
dnl Need to recover ssldir - test above runs in subshell
ssldir=$ac_cv_openssldir
if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
dnl TODO: for the DB header checks, we should check whether the headers
dnl define db_env_create, somehow
dnl
-AC_CHECK_HEADERS(curses.h ncurses.h dl.h fcntl.h limits.h termios.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h utmp.h utmpx.h paths.h db.h db3/db.h db4/db.h)
+AC_CHECK_HEADERS(curses.h ncurses.h dl.h fcntl.h limits.h termios.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h utmp.h utmpx.h paths.h db.h db3/db.h db4/db.h pthread.h netinet/in.h)
+
+AC_CHECK_HEADER(resolv.h, [SMTP=modules/libsmtp.la; DOMAIN=domain.c],,
+[#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif])
-AC_CHECK_HEADER(resolv.h, [SMTP=modules/libsmtp.la; DOMAIN=domain.c])
AC_SUBST(SMTP)
AC_SUBST(DOMAIN)
-dnl some systems require -pthread, -D_REENTRANT, etc to be passed to cc if we
-dnl include pthread.h:
-save_CPPFLAGS=$CPPFLAGS
-CPPFLAGS="$CPPFLAGS $PTHREAD_DEFS"
-AC_CHECK_HEADERS(pthread.h)
-CPPFLAGS=$save_CPPFLAGS
-
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
-dnl Now check for pthreads -- set up variables so that the compiler will be run
-dnl with proper flags for pthread programs
-save_LIBS=$LIBS
-LIBS="$PTHREAD_LIBS $LIBS"
+dnl Now check for pthreads
dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
dnl we need to include pthread.h
test "$DATABASE" && TARGETS="client server utils serv_modules"
if test "x$enable_threaded_client" != xno; then
AC_DEFINE(THREADED_CLIENT)
- CLIENT_PTLIBS=$PTHREAD_LIBS
- CL_LIBOBJS='$(LIBOBJS:.o=.ro)'
- CX=.ro
fi
fi
-if test "x$CX" != x.ro; then
- CL_LIBOBJS='$(LIBOBJS)'
- CX=.o
-fi
-
-dnl Now restore the old libs so we don't pass the wrong stuff to makefile
-LIBS=$save_LIBS
-
AC_REPLACE_FUNCS(snprintf getutline)
dnl Done! Now write the Makefile and sysdep.h
AC_SUBST(AUTH)
AC_SUBST(CHKPWD)
-AC_SUBST(CURSES)
-AC_SUBST(GDBM)
AC_SUBST(RESOLV)
-AC_SUBST(NETLIBS)
AC_SUBST(chkpwd_LIBS)
AC_SUBST(TARGETS)
-AC_SUBST(PTHREAD_DEFS)
-AC_SUBST(PTHREAD_LIBS)
-AC_SUBST(CLIENT_PTLIBS)
-AC_SUBST(CL_LIBOBJS)
-AC_SUBST(CX)
AC_SUBST(DATABASE)
-AC_SUBST(SSL_LIBS)
AC_CONFIG_HEADER(sysdep.h)
AC_CONFIG_FILES([Makefile weekly])
AC_OUTPUT
#define IN_LIBCIT
#endif
-#define timezonevar 1
-
+#include "sysdep.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int getsockfd(void);
char serv_getc(void);
int is_connected(void);
+extern int (*error_printf)(char *s, ...);
+void setIPCDeathHook(void (*hook)(void));
+void setIPCErrorPrintf(int (*func)(char *s, ...));
#include "citadel_decls.h"
#include "ipc.h"
#include "tools.h"
-#if defined(HAVE_OPENSSL) && defined(CIT_CLIENT)
+#if defined(HAVE_OPENSSL)
#include "client_crypto.h"
#endif
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#endif
-#ifdef CIT_CLIENT
-#include "screen.h"
-#else
-extern int err_printf(char *fmt, ...);
-#endif
/*
* If server_is_local is set to nonzero, the client assumes that it is running
int serv_sock;
-#if defined(HAVE_OPENSSL) && defined(CIT_CLIENT)
-extern int ssl_is_connected;
-#endif
+static void (*deathHook)(void) = NULL;
+int (*error_printf)(char *s, ...) = (int (*)(char *, ...))printf;
+void setIPCDeathHook(void (*hook)(void)) {
+ deathHook = hook;
+}
+
+void setIPCErrorPrintf(int (*func)(char *s, ...)) {
+ error_printf = func;
+}
void connection_died(void) {
-#ifdef CIT_CLIENT
- screen_delete();
-#endif
- err_printf("\rYour connection to this Citadel server is broken.\n"
+ if (deathHook != NULL)
+ deathHook();
+
+ error_printf("\rYour connection to this Citadel server is broken.\n"
"Last error: %s\n"
"Please re-connect and log in again.\n",
strerror(errno));
static void ipc_timeout(int signum)
{
- err_printf("\rConnection timed out.\n");
+ error_printf("\rConnection timed out.\n");
logoff(3);
}
if (phe) {
memcpy(&sin.sin_addr, phe->h_addr, phe->h_length);
} else if ((sin.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) {
- err_printf("Can't get %s host entry: %s\n",
+ error_printf("Can't get %s host entry: %s\n",
host, strerror(errno));
logoff(3);
}
if ((ppe = getprotobyname(protocol)) == 0) {
- err_printf("Can't get %s protocol entry: %s\n",
+ error_printf("Can't get %s protocol entry: %s\n",
protocol, strerror(errno));
logoff(3);
}
s = socket(PF_INET, type, ppe->p_proto);
if (s < 0) {
- err_printf("Can't create socket: %s\n", strerror(errno));
+ error_printf("Can't create socket: %s\n", strerror(errno));
logoff(3);
}
signal(SIGALRM, ipc_timeout);
alarm(30);
if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
- err_printf("can't connect to %s:%s: %s\n",
+ error_printf("can't connect to %s:%s: %s\n",
host, service, strerror(errno));
logoff(3);
}
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
- err_printf("Can't create socket: %s\n", strerror(errno));
+ error_printf("Can't create socket: %s\n", strerror(errno));
logoff(3);
}
if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- err_printf("can't connect: %s\n", strerror(errno));
+ error_printf("can't connect: %s\n", strerror(errno));
logoff(3);
}
*/
void serv_puts(char *buf)
{
- /* err_printf("< %s\n", buf); */
+ /* error_printf("< %s\n", buf); */
serv_write(buf, strlen(buf));
serv_write("\n", 1);
}
strcpy(citport, argv[a]);
}
else {
- err_printf("%s: usage: ",argv[0]);
- err_printf("%s [host] [port] ",argv[0]);
+ error_printf("%s: usage: ",argv[0]);
+ error_printf("%s [host] [port] ",argv[0]);
logoff(2);
}
}
pthread_mutex_t **SSLCritters; /* Things needing locking */
static unsigned long id_callback(void) {
- return pthread_self();
+ return (unsigned long)pthread_self();
}
void init_ssl(void)
#include "tools.h"
#include "citadel.h"
-#ifdef CIT_CLIENT
-#include "screen.h"
-#else
-int err_printf(char *fmt, ...);
-int err_printf(char *fmt, ...)
-{
- va_list ap;
- int retval;
- va_start(ap, fmt);
- retval = fprintf(stderr, fmt, ap);
- va_end(ap);
- return retval;
-}
-#endif
-
#define TRUE 1
#define FALSE 0
char *safestrncpy(char *dest, const char *src, size_t n)
{
if (dest == NULL || src == NULL) {
- err_printf("safestrncpy: NULL argument\n");
+ fprintf(stderr, "safestrncpy: NULL argument\n");
abort();
}
strncpy(dest, src, n);