From 4aed8bcc44474e27485a72334805022d6aa604b1 Mon Sep 17 00:00:00 2001 From: Nathan Bryant Date: Thu, 6 Sep 2001 01:26:40 +0000 Subject: [PATCH] - port to Cygwin (DLL support, etc.) - don't build SMTP module if there's no resolver library (eg on Windows) --- citadel/ChangeLog | 5 + citadel/Makefile.in | 154 +++++++++++++------------ citadel/auth.c | 4 + citadel/citadel.h | 6 + citadel/citserver.c | 6 +- citadel/citserver.h | 5 +- citadel/clientsocket.c | 6 + citadel/config.c | 8 ++ citadel/config.h | 8 +- citadel/configure.ac | 7 +- citadel/control.c | 5 + citadel/database.c | 4 + citadel/database_sleepycat.c | 6 +- citadel/domain.c | 1 + citadel/dynloader.c | 8 ++ citadel/dynloader.h | 6 + citadel/file_ops.c | 5 + citadel/genstamp.c | 4 + citadel/getutline.c | 4 + citadel/housekeeping.c | 6 +- citadel/html.c | 5 + citadel/internet_addressing.c | 5 + citadel/internet_addressing.h | 4 +- citadel/locate_host.c | 5 + citadel/logging.c | 4 + citadel/mime_parser.c | 6 + citadel/msgbase.c | 6 +- citadel/parsedate.y | 4 + citadel/policy.c | 5 + citadel/room_ops.c | 6 + citadel/sendcommand.c | 6 +- citadel/serv_chat.c | 3 +- citadel/server.h | 43 +++++-- citadel/snprintf.c | 4 + citadel/support.c | 4 + citadel/sysdep.c | 204 ++-------------------------------- citadel/sysdep_decls.h | 18 ++- citadel/tools.c | 4 + citadel/user_ops.c | 6 +- 39 files changed, 303 insertions(+), 297 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index b2405f4c6..548fd583a 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 580.31 2001/09/06 01:26:39 nbryant + - port to Cygwin (DLL support, etc.) + - don't build SMTP module if there's no resolver library (eg on Windows) + Revision 580.30 2001/09/06 00:54:01 nbryant updated to libtool 1.4.1 and automake 1.5 @@ -2704,3 +2708,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/Makefile.in b/citadel/Makefile.in index 44de4329a..8393acd40 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -22,22 +22,24 @@ all: $(TARGETS) EXEEXT=@EXEEXT@ CX=@CX@ +SMTP=@SMTP@ + CLIENT_TARGETS=citadel$(EXEEXT) whobbs$(EXEEXT) -SERVER_TARGETS=citserver setup $(CHKPWD) -SERV_MODULES=modules/serv_chat.la modules/serv_vcard.la \ - modules/serv_upgrade.la \ - modules/serv_smtp.la \ - modules/serv_pop3.la \ - modules/serv_imap.la \ - modules/serv_network.la \ - modules/serv_pas2.la \ - modules/serv_inetcfg.la \ - modules/serv_rwho.la \ - modules/serv_moderate.la \ - modules/serv_bio.la \ - modules/serv_expire.la \ - modules/serv_vandelay.la \ - modules/serv_ical.la +SERVER_TARGETS=libcitserver.la citserver setup $(CHKPWD) +SERV_MODULES=modules/libchat.la modules/libvcard.la \ + modules/libupgrade.la \ + $(SMTP) \ + modules/libpop3.la \ + modules/libimap.la \ + modules/libnetwork.la \ + modules/libpas2.la \ + modules/libinetcfg.la \ + modules/librwho.la \ + modules/libmoderate.la \ + modules/libbio.la \ + modules/libexpire.la \ + modules/libvandelay.la \ + modules/libical.la UTIL_TARGETS=aidepost netmailer netproc netsetup msgform readlog rcit \ stats citmail netpoll mailinglist userlist sendcommand \ base64 qpdecode @@ -70,12 +72,14 @@ YACC=@YACC@ DATABASE=@DATABASE@ LIBTOOL=./libtool -LTSHARE=$(LIBTOOL) $(CC) -rpath $(prefix)/modules -module -avoid-version +LTSHARE=cd modules && ../$(LIBTOOL) $(CC) -rpath $(prefix)/modules -no-undefined -avoid-version -module # End configuration section VPATH=$(srcdir) +DOMAIN=@DOMAIN@ + SOURCES=aidepost.c citadel.c citmail.c citserver.c client_chat.c commands.c \ config.c control.c $(DATABASE) dynloader.c file_ops.c \ housekeeping.c internetmail.c ipc_c_tcp.c locate_host.c \ @@ -87,10 +91,10 @@ SOURCES=aidepost.c citadel.c citmail.c citserver.c client_chat.c commands.c \ whobbs.c sendcommand.c mime_parser.c base64.c qpdecode.c getutline.c \ auth.c chkpwd.c html.c vcard.c serv_upgrade.c serv_vandelay.c \ serv_smtp.c serv_pop3.c internet_addressing.c parsedate.c genstamp.c \ - domain.c clientsocket.c serv_inetcfg.c serv_rwho.c serv_bio.c \ + $(DOMAIN) clientsocket.c serv_inetcfg.c serv_rwho.c serv_bio.c \ serv_moderate.c client_passwords.c imap_misc.c \ serv_imap.c imap_tools.c imap_fetch.c imap_search.c imap_store.c \ - serv_network.c serv_pas2.c serv_ical.c md5.c + serv_network.c serv_pas2.c serv_ical.c md5.c server_main.c DEP_FILES=$(SOURCES:.c=.d) @@ -102,6 +106,7 @@ utils: $(UTIL_TARGETS) serv_modules: $(SERV_MODULES) @cd modules && mods=`echo .libs/*.s[ol]` && test "$$mods" != '.libs/*.s[ol]' && ln -sf $$mods . || true + @cd modules && mods=`echo .libs/*.dll` && test "$$mods" != '.libs/*.dll' && ln -sf $$mods . || true # # @@ -130,18 +135,22 @@ netpoll: netpoll.o config.o ipc_c_tcp.o tools.o $(LIBOBJS) # # -SERV_OBJS = citserver.ro user_ops.ro support.ro room_ops.ro file_ops.ro \ - msgbase.ro config.ro sysdep.ro locate_host.ro housekeeping.ro \ - $(DATABASE:.c=.ro) control.ro logging.ro policy.ro dynloader.ro tools.ro \ - mime_parser.ro html.ro internet_addressing.ro \ - parsedate.ro genstamp.ro clientsocket.ro \ - $(AUTH) $(LIBOBJS:.o=.ro) +SERV_OBJS = server_main.ro parsedate.ro: parsedate.c -citserver: $(SERV_OBJS) $(LIBTOOL) - $(LIBTOOL) --mode=link $(CC) -export-dynamic $(SERV_OBJS) $(LDFLAGS) $(PTHREAD_LIBS) \ - $(LIBS) $(NETLIBS) $(GDBM) $(RESOLV) -o citserver +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 \ + locate_host.lo housekeeping.lo logging.lo mime_parser.lo html.lo internet_addressing.lo \ + parsedate.lo genstamp.lo clientsocket.lo $(AUTH) $(LIBOBJS:.o=.lo) + +libcitserver.la: $(LIBSERV_OBJS) + $(LIBTOOL) $(CC) -rpath $(prefix) -no-undefined -avoid-version \ + -o libcitserver.la $(LIBSERV_OBJS) $(GDBM) + +citserver: $(SERV_OBJS) $(LIBTOOL) libcitserver.la + $(LIBTOOL) --mode=link $(CC) $(SERV_OBJS) $(LDFLAGS) $(PTHREAD_LIBS) \ + $(LIBS) $(NETLIBS) $(RESOLV) libcitserver.la -o citserver .c.ro: $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(PTHREAD_DEFS) -c $< -o $@ @@ -150,58 +159,59 @@ citserver: $(SERV_OBJS) $(LIBTOOL) @test -d modules || mkdir -p modules $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(PTHREAD_DEFS) -c $< -o $@ -modules/serv_chat.la: serv_chat.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_chat.la serv_chat.lo +modules/libchat.la: serv_chat.lo libcitserver.la $(LIBTOOL) + $(LTSHARE) -o libchat.la ../serv_chat.lo ../libcitserver.la -modules/serv_test.la: serv_test.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_test.la serv_test.lo +modules/libtest.la: serv_test.lo libcitserver.la $(LIBTOOL) + $(LTSHARE) -o libtest.la ../serv_test.lo ../libcitserver.la -modules/serv_pop3.la: serv_pop3.lo md5.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_pop3.la serv_pop3.lo md5.lo +modules/libpop3.la: serv_pop3.lo md5.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libpop3.la ../serv_pop3.lo ../md5.lo ../libcitserver.la -modules/serv_inetcfg.la: serv_inetcfg.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_inetcfg.la serv_inetcfg.lo +modules/libinetcfg.la: serv_inetcfg.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libinetcfg.la ../serv_inetcfg.lo ../libcitserver.la -modules/serv_rwho.la: serv_rwho.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_rwho.la serv_rwho.lo +modules/librwho.la: serv_rwho.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o librwho.la ../serv_rwho.lo ../libcitserver.la -modules/serv_moderate.la: serv_moderate.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_moderate.la serv_moderate.lo +modules/libmoderate.la: serv_moderate.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libmoderate.la ../serv_moderate.lo ../libcitserver.la -modules/serv_bio.la: serv_bio.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_bio.la serv_bio.lo +modules/libbio.la: serv_bio.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libbio.la ../serv_bio.lo ../libcitserver.la -modules/serv_expire.la: serv_expire.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_expire.la serv_expire.lo +modules/libexpire.la: serv_expire.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libexpire.la ../serv_expire.lo ../libcitserver.la -modules/serv_vandelay.la: serv_vandelay.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_vandelay.la serv_vandelay.lo +modules/libvandelay.la: serv_vandelay.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libvandelay.la ../serv_vandelay.lo ../libcitserver.la -modules/serv_network.la: serv_network.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_network.la serv_network.lo +modules/libnetwork.la: serv_network.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libnetwork.la ../serv_network.lo ../libcitserver.la -modules/serv_upgrade.la: serv_upgrade.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_upgrade.la serv_upgrade.lo +modules/libupgrade.la: serv_upgrade.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libupgrade.la ../serv_upgrade.lo ../libcitserver.la -modules/serv_vcard.la: serv_vcard.lo vcard.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_vcard.la serv_vcard.lo vcard.lo +modules/libvcard.la: serv_vcard.lo vcard.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libvcard.la ../serv_vcard.lo ../vcard.lo ../libcitserver.la -modules/serv_smtp.la: serv_smtp.lo domain.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_smtp.la serv_smtp.lo domain.lo +modules/libsmtp.la: serv_smtp.lo domain.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libsmtp.la ../serv_smtp.lo ../domain.lo ../libcitserver.la -modules/serv_imap.la: serv_imap.lo imap_tools.lo imap_fetch.lo \ - imap_search.lo imap_store.lo imap_misc.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_imap.la imap_tools.lo serv_imap.lo \ - imap_fetch.lo imap_search.lo imap_store.lo imap_misc.lo -aidepost: aidepost.o config.o $(LIBOBJS) - $(CC) aidepost.o config.o $(LIBOBJS) $(LDFLAGS) -o aidepost +modules/libimap.la: serv_imap.lo imap_tools.lo imap_fetch.lo \ + imap_search.lo imap_store.lo imap_misc.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libimap.la ../imap_tools.lo ../serv_imap.lo \ + ../imap_fetch.lo ../imap_search.lo ../imap_store.lo ../imap_misc.lo ../libcitserver.la -modules/serv_pas2.la: serv_pas2.lo md5.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_pas2.la serv_pas2.lo md5.lo +aidepost: aidepost.o libcitserver.la $(LIBOBJS) + $(LIBTOOL) $(CC) aidepost.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o aidepost -modules/serv_ical.la: serv_ical.lo $(LIBTOOL) - $(LTSHARE) -o modules/serv_ical.la serv_ical.lo +modules/libpas2.la: serv_pas2.lo md5.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libpas2.la ../serv_pas2.lo ../md5.lo ../libcitserver.la + +modules/libical.la: serv_ical.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libical.la ../serv_ical.lo ../libcitserver.la @@ -236,8 +246,8 @@ netsetup: netsetup.o config.o 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) -sendcommand: sendcommand.o ipc_c_tcp.o tools.o config.o $(LIBOBJS) - $(CC) sendcommand.o ipc_c_tcp.o tools.o config.o \ +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) qpdecode: qpdecode.o @@ -259,8 +269,8 @@ readlog: readlog.o config.o rcit: rcit.o config.o $(CC) rcit.o config.o $(LDFLAGS) -o rcit -stats: stats.o ipc_c_tcp.o tools.o config.o $(LIBOBJS) - $(CC) stats.o ipc_c_tcp.o tools.o config.o $(LIBOBJS) $(LDFLAGS) -o stats $(NETLIBS) +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) .PHONY: install-data install-doc install-exec clean cleaner distclean @@ -292,13 +302,17 @@ install-exec: all weekly @for i in bio bitbucket files images info modules userpics; do \ $(srcdir)/mkinstalldirs $(root)$(prefix)/$$i; \ done - @for i in $(CLIENT_TARGETS) $(SERVER_TARGETS) $(UTIL_TARGETS) \ - $(SERV_MODULES) ; do \ + @for i in $(CLIENT_TARGETS) $(SERVER_TARGETS) $(UTIL_TARGETS); do \ if test -f $$i; then \ echo $(LIBTOOL) --mode=install $(INSTALL) $$i $(root)$(prefix)/$$i; \ $(LIBTOOL) --mode=install $(INSTALL) $$i $(root)$(prefix)/$$i; \ fi \ done + @for i in $(SERV_MODULES) ; do \ + if test -f $$i; then \ + (cd modules && ../$(LIBTOOL) --mode=install $(INSTALL) `basename $$i` $(root)$(prefix)/$$i) ; \ + fi \ + done @for i in utilsmenu weekly dnetsetup; do \ if test -f $(srcdir)/$$i; then \ echo $(INSTALL) $(srcdir)/$$i $(root)$(prefix)/$$i; \ @@ -323,7 +337,7 @@ distclean: cleaner .c.d: @echo Checking dependencies for $< - @$(CC) -M $(CPPFLAGS) $(PTHREAD_DEFS) $< | sed -e 's!$*.o!$*.o $*.ro $*.mo $@!' > $@ + @$(CC) -M $(CPPFLAGS) $(PTHREAD_DEFS) $< | sed -e 's!$*.o!$*.o $*.ro $*.lo $@!' > $@ @test -s $@ || rm -f $@ Makefile: $(srcdir)/Makefile.in config.status diff --git a/citadel/auth.c b/citadel/auth.c index 66dc67c7a..a62d6003c 100644 --- a/citadel/auth.c +++ b/citadel/auth.c @@ -6,6 +6,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #if defined(__linux) || defined(__sun) /* needed for crypt(): */ #define _XOPEN_SOURCE #define _XOPEN_SOURCE_EXTENDED 1 diff --git a/citadel/citadel.h b/citadel/citadel.h index 41f331c87..a613b43ba 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -6,6 +6,10 @@ */ /* system customizations are in sysconfig.h */ + +#ifndef CITADEL_H +#define CITADEL_H + #include "sysdep.h" #include "sysconfig.h" #include "ipcdef.h" @@ -266,3 +270,5 @@ struct floor { #ifndef LONG_MAX #define LONG_MAX 2147483647L #endif + +#endif /* CITADEL_H */ diff --git a/citadel/citserver.c b/citadel/citserver.c index 919156a6a..8bbd76d24 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -36,6 +40,7 @@ #include #include "citadel.h" #include "server.h" +#include "dynloader.h" #include "sysdep_decls.h" #include "citserver.h" #include "config.h" @@ -48,7 +53,6 @@ #include "locate_host.h" #include "room_ops.h" #include "file_ops.h" -#include "dynloader.h" #include "policy.h" #include "control.h" #include "tools.h" diff --git a/citadel/citserver.h b/citadel/citserver.h index 391e9d4f4..5b4f7bc1e 100644 --- a/citadel/citserver.h +++ b/citadel/citserver.h @@ -1,4 +1,7 @@ /* $Id$ */ + +#include "dynloader.h" + void master_startup (void); void master_cleanup (void); void RemoveContext (struct CitContext *); @@ -28,7 +31,7 @@ void citproto_begin_session(void); void GenerateRoomDisplay(char *real_room, struct CitContext *viewed, struct CitContext *viewer); -extern int do_defrag; +extern DLEXP int do_defrag; char CtdlCheckExpress(void); int CtdlAccessCheck(int); diff --git a/citadel/clientsocket.c b/citadel/clientsocket.c index 00039e5de..286659aef 100644 --- a/citadel/clientsocket.c +++ b/citadel/clientsocket.c @@ -8,6 +8,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -23,6 +27,8 @@ #include #include #include "citadel.h" +#include "server.h" +#include "dynloader.h" #ifndef HAVE_SNPRINTF #include "snprintf.h" #endif diff --git a/citadel/config.c b/citadel/config.c index 4f7de769e..534eb58d9 100644 --- a/citadel/config.c +++ b/citadel/config.c @@ -6,6 +6,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -15,6 +19,8 @@ #include #include #include "citadel.h" +#include "server.h" +#include "dynloader.h" #include "config.h" struct config config; @@ -53,10 +59,12 @@ void get_config(void) { perror("citadel.config"); exit(1); } +#ifndef __CYGWIN__ if (st.st_uid != BBSUID || st.st_mode != (S_IFREG | S_IRUSR | S_IWUSR)) { fprintf(stderr, "check the permissions on citadel.config\n"); exit(1); } +#endif fclose(cfp); if (config.c_setup_level < REV_MIN) { diff --git a/citadel/config.h b/citadel/config.h index 5804b9ae9..e33d5427e 100644 --- a/citadel/config.h +++ b/citadel/config.h @@ -3,8 +3,10 @@ * */ +#include "dynloader.h" + void get_config(void); void put_config(void); -extern struct config config; -extern char bbs_home_directory[PATH_MAX]; -extern int home_specified; +extern DLEXP struct config config; +extern DLEXP char bbs_home_directory[PATH_MAX]; +extern DLEXP int home_specified; diff --git a/citadel/configure.ac b/citadel/configure.ac index 62f57cb63..453423531 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -101,6 +101,7 @@ if test "$GCC" = yes; then esac fi AC_LIBTOOL_DLOPEN +AC_LIBTOOL_WIN32_DLL AC_DISABLE_STATIC AC_PROG_LIBTOOL AC_SUBST(LIBTOOL_DEPS) @@ -173,7 +174,7 @@ if test "$enable_autologin" != no; then AC_DEFINE(ENABLE_CHKPWD) CHKPWD=chkpwd else - AUTH=auth.ro + AUTH=auth.lo fi fi fi @@ -219,6 +220,10 @@ AC_HEADER_SYS_WAIT test "$db_dir" && CPPFLAGS="$CPPFLAGS -I$db_dir/include" AC_CHECK_HEADERS(curses.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) +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 diff --git a/citadel/control.c b/citadel/control.c index 94c3ec8c4..fd44e0905 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -32,6 +36,7 @@ #include "citadel.h" #include "server.h" #include "control.h" +#include "dynloader.h" #include "sysdep_decls.h" #include "support.h" #include "config.h" diff --git a/citadel/database.c b/citadel/database.c index 7bb650384..c9e4264bc 100644 --- a/citadel/database.c +++ b/citadel/database.c @@ -15,6 +15,10 @@ * conditions to occur. (Deadlock is bad. Eliminate.) */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include diff --git a/citadel/database_sleepycat.c b/citadel/database_sleepycat.c index 9bbc86b92..ef648647c 100644 --- a/citadel/database_sleepycat.c +++ b/citadel/database_sleepycat.c @@ -18,6 +18,10 @@ /*****************************************************************************/ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -32,10 +36,10 @@ #include #include "citadel.h" #include "server.h" +#include "dynloader.h" #include "citserver.h" #include "database.h" #include "sysdep_decls.h" -#include "dynloader.h" static DB *dbp[MAXCDB]; /* One DB handle for each Citadel database */ static DB_ENV *dbenv; /* The DB environment (global) */ diff --git a/citadel/domain.c b/citadel/domain.c index 89108f653..ccf62f7c7 100644 --- a/citadel/domain.c +++ b/citadel/domain.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include "sysdep_decls.h" diff --git a/citadel/dynloader.c b/citadel/dynloader.c index 790f1348a..251ca2dee 100644 --- a/citadel/dynloader.c +++ b/citadel/dynloader.c @@ -6,6 +6,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -98,7 +102,11 @@ void DLoader_Init(char *pathname) while ((dptr = readdir(dir)) != NULL) { if (strlen(dptr->d_name) < 4) continue; +#ifndef __CYGWIN__ if (strcasecmp(&dptr->d_name[strlen(dptr->d_name)-3], ".so")) +#else + if (strcasecmp(&dptr->d_name[strlen(dptr->d_name)-4], ".dll")) +#endif continue; snprintf(pathbuf, PATH_MAX, "%s/%s", pathname, dptr->d_name); diff --git a/citadel/dynloader.h b/citadel/dynloader.h index 4fec72fe4..d685fcbfb 100644 --- a/citadel/dynloader.h +++ b/citadel/dynloader.h @@ -1,5 +1,10 @@ /* $Id$ */ +#ifndef DYNLOADER_H +#define DYNLOADER_H + +#include "server.h" + void DLoader_Init(char *pathname); int DLoader_Exec_Cmd(char *cmdbuf); char *Dynamic_Module_Init(void); @@ -27,3 +32,4 @@ void CtdlRegisterServiceHook(int tcp_port, void (*h_greeting_function) (void), void (*h_command_function) (void) ) ; +#endif /* DYNLOADER_H */ diff --git a/citadel/file_ops.c b/citadel/file_ops.c index 38fa138b6..9a6989301 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -29,6 +33,7 @@ #include #include "citadel.h" #include "server.h" +#include "dynloader.h" #include "config.h" #include "file_ops.h" #include "sysdep_decls.h" diff --git a/citadel/genstamp.c b/citadel/genstamp.c index 627ffc19c..ce9575559 100644 --- a/citadel/genstamp.c +++ b/citadel/genstamp.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include #include #include diff --git a/citadel/getutline.c b/citadel/getutline.c index 5eae2a760..f64559abc 100644 --- a/citadel/getutline.c +++ b/citadel/getutline.c @@ -6,6 +6,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #ifdef HAVE_UTMP_H #include diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index c5b33081d..451f6491d 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -33,13 +37,13 @@ #include "tools.h" #include "citadel.h" #include "server.h" +#include "dynloader.h" #include "citserver.h" #include "config.h" #include "housekeeping.h" #include "sysdep_decls.h" #include "room_ops.h" #include "database.h" -#include "dynloader.h" diff --git a/citadel/html.c b/citadel/html.c index 29ee1a8ed..ea06fb3fe 100644 --- a/citadel/html.c +++ b/citadel/html.c @@ -4,6 +4,10 @@ * Functions which handle translation between HTML and plain text */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -29,6 +33,7 @@ #include #include "citadel.h" #include "server.h" +#include "dynloader.h" #include "control.h" #include "sysdep_decls.h" #include "support.h" diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index f60f7a185..ca0530d96 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -5,6 +5,10 @@ * to users on the Citadel system. */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -32,6 +36,7 @@ #include #include "citadel.h" #include "server.h" +#include "dynloader.h" #include "sysdep_decls.h" #include "citserver.h" #include "support.h" diff --git a/citadel/internet_addressing.h b/citadel/internet_addressing.h index dcdafeaec..a097dd70d 100644 --- a/citadel/internet_addressing.h +++ b/citadel/internet_addressing.h @@ -3,6 +3,8 @@ * */ +#include "server.h" + struct internet_address_list { struct internet_address_list *next; char ial_user[SIZ]; @@ -39,4 +41,4 @@ enum { hostalias_gatewaydomain }; -extern char *inetcfg; +extern DLEXP char *inetcfg; diff --git a/citadel/locate_host.c b/citadel/locate_host.c index 5bd0b93a5..e71b0cd14 100644 --- a/citadel/locate_host.c +++ b/citadel/locate_host.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -18,6 +22,7 @@ #include #include "citadel.h" #include "server.h" +#include "dynloader.h" #include "locate_host.h" #include "sysdep_decls.h" #include "config.h" diff --git a/citadel/logging.c b/citadel/logging.c index 5ec154cb3..1e0f7bf30 100644 --- a/citadel/logging.c +++ b/citadel/logging.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include diff --git a/citadel/mime_parser.c b/citadel/mime_parser.c index 2a870d75f..1d35ce7a7 100644 --- a/citadel/mime_parser.c +++ b/citadel/mime_parser.c @@ -8,6 +8,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include #include #include @@ -18,6 +22,8 @@ #include #include #include "citadel.h" +#include "server.h" +#include "dynloader.h" #include "sysdep_decls.h" #include "mime_parser.h" #include "tools.h" diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 12afea81e..15a3d614d 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -31,6 +35,7 @@ #include #include "citadel.h" #include "server.h" +#include "dynloader.h" #include "database.h" #include "msgbase.h" #include "support.h" @@ -40,7 +45,6 @@ #include "user_ops.h" #include "file_ops.h" #include "control.h" -#include "dynloader.h" #include "tools.h" #include "mime_parser.h" #include "html.h" diff --git a/citadel/parsedate.y b/citadel/parsedate.y index b68ca4c24..776781bbb 100644 --- a/citadel/parsedate.y +++ b/citadel/parsedate.y @@ -19,6 +19,10 @@ /* SUPPRESS 593 on yynewstate *//* Label was not used */ /* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include diff --git a/citadel/policy.c b/citadel/policy.c index 076fe8bcd..41b833b90 100644 --- a/citadel/policy.c +++ b/citadel/policy.c @@ -4,6 +4,10 @@ * Functions which manage policy for rooms (such as message expiry) */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -26,6 +30,7 @@ #include "citadel.h" #include "server.h" #include "database.h" +#include "dynloader.h" #include "config.h" #include "room_ops.h" #include "sysdep_decls.h" diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 51b8cf4c0..d94fad48d 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -4,6 +4,11 @@ * Server functions which perform operations on room objects. * */ + +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -26,6 +31,7 @@ #include #include "citadel.h" #include "server.h" +#include "dynloader.h" #include "database.h" #include "config.h" #include "room_ops.h" diff --git a/citadel/sendcommand.c b/citadel/sendcommand.c index 8c7f63e53..0ea558c06 100644 --- a/citadel/sendcommand.c +++ b/citadel/sendcommand.c @@ -32,14 +32,12 @@ #include "citadel.h" #include "tools.h" #include "ipc.h" +#include "server.h" +#include "dynloader.h" #include "config.h" #define LOCKFILE "/tmp/LCK.sendcommand" -struct config config; -extern int home_specified; - - /* * make sure only one copy of sendcommand runs at a time, using lock files */ diff --git a/citadel/serv_chat.c b/citadel/serv_chat.c index c59c62d94..afe54a979 100644 --- a/citadel/serv_chat.c +++ b/citadel/serv_chat.c @@ -31,13 +31,13 @@ #include #include "citadel.h" #include "server.h" +#include "dynloader.h" #include #include "serv_chat.h" #include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "dynloader.h" #include "tools.h" #include "msgbase.h" #include "user_ops.h" @@ -46,7 +46,6 @@ struct ChatLine *ChatQueue = NULL; int ChatLastMsg = 0; -extern struct CitContext *ContextList; diff --git a/citadel/server.h b/citadel/server.h index 103d5a543..1163899cf 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -8,6 +8,25 @@ /* * New format for a message in memory */ + +#ifndef SERVER_H +#define SERVER_H + +#ifdef __CYGWIN__ + +#ifdef IN_LIBCIT +#define DLEXP __declspec(dllexport) +#else +#define DLEXP __declspec(dllimport) +#endif + +#else +#define DLEXP + +#endif /* __CYGWIN__ */ + +#include "citadel.h" + #define CTDLMESSAGE_MAGIC 0x159d struct CtdlMessage { int cm_magic; /* Self-check */ @@ -129,9 +148,9 @@ enum { struct CitContext *MyContext(void); #define CC ((struct CitContext *)MyContext()) -extern struct CitContext *ContextList; -extern int ScheduledShutdown; -extern struct CitControl CitControl; +extern DLEXP struct CitContext *ContextList; +extern DLEXP int ScheduledShutdown; +extern DLEXP struct CitControl CitControl; struct ExpressMessage { @@ -229,13 +248,13 @@ struct LogFunctionHook { int loglevel; void (*h_function_pointer) (char *); }; -extern struct LogFunctionHook *LogHookTable; +extern DLEXP struct LogFunctionHook *LogHookTable; struct CleanupFunctionHook { struct CleanupFunctionHook *next; void (*h_function_pointer) (void); }; -extern struct CleanupFunctionHook *CleanupHookTable; +extern DLEXP struct CleanupFunctionHook *CleanupHookTable; @@ -251,7 +270,7 @@ struct SessionFunctionHook { void (*h_function_pointer) (void); int eventtype; }; -extern struct SessionFunctionHook *SessionHookTable; +extern DLEXP struct SessionFunctionHook *SessionHookTable; /* * Event types can't be enum'ed, because they must remain consistent between @@ -279,7 +298,7 @@ struct UserFunctionHook { void (*h_function_pointer) (char *username, long usernum); int eventtype; }; -extern struct UserFunctionHook *UserHookTable; +extern DLEXP struct UserFunctionHook *UserHookTable; #define EVT_PURGEUSER 100 /* Deleting a user */ #define EVT_OUTPUTMSG 101 /* Outputting a message */ @@ -293,7 +312,7 @@ struct MessageFunctionHook { int (*h_function_pointer) (struct CtdlMessage *msg); int eventtype; }; -extern struct MessageFunctionHook *MessageHookTable; +extern DLEXP struct MessageFunctionHook *MessageHookTable; #define EVT_BEFOREREAD 200 #define EVT_BEFORESAVE 201 @@ -311,7 +330,7 @@ struct XmsgFunctionHook { int (*h_function_pointer) (char *, char *, char *); int order; }; -extern struct XmsgFunctionHook *XmsgHookTable; +extern DLEXP struct XmsgFunctionHook *XmsgHookTable; /* Priority levels for paging functions (lower is better) */ enum { @@ -335,7 +354,7 @@ struct ServiceFunctionHook { void (*h_command_function) (void) ; int msock; }; -extern struct ServiceFunctionHook *ServiceHookTable; +extern DLEXP struct ServiceFunctionHook *ServiceHookTable; @@ -394,7 +413,7 @@ struct TheHeap { void *h_ptr; }; -extern struct TheHeap *heap; +extern DLEXP struct TheHeap *heap; #else @@ -421,3 +440,5 @@ struct ser_ret { /* *************** Semi-important fields */ /* * Message text (MUST be last) */ #define FORDER "IPTAFONHRDBCEGJKLQSUVWXYZM" + +#endif /* SERVER_H */ diff --git a/citadel/snprintf.c b/citadel/snprintf.c index dcc9cd81c..ab014de69 100644 --- a/citadel/snprintf.c +++ b/citadel/snprintf.c @@ -20,6 +20,10 @@ * Written July 1997 by Sten Gunterberg (gunterberg@ergon.ch) */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include #include #include diff --git a/citadel/support.c b/citadel/support.c index e0a098fd4..3262890b2 100644 --- a/citadel/support.c +++ b/citadel/support.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 5e0e64933..6a7722291 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -12,6 +12,9 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif #include "sysdep.h" #include @@ -54,13 +57,13 @@ #endif #include "citadel.h" #include "server.h" +#include "dynloader.h" #include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "database.h" #include "housekeeping.h" -#include "dynloader.h" #include "tools.h" #ifdef HAVE_SYS_SELECT_H @@ -89,7 +92,7 @@ int num_sessions = 0; /* Current number of sessions */ fd_set masterfds; /* Master sockets etc. */ int masterhighest; -static pthread_t initial_thread; /* tid for main() thread */ +pthread_t initial_thread; /* tid for main() thread */ /* @@ -759,17 +762,14 @@ int convert_login(char NameToConvert[]) { } } -static struct worker_node { - pthread_t tid; - struct worker_node *next; -} *worker_list = NULL; +struct worker_node *worker_list = NULL; /* * create a worker thread. this function must always be called from within * an S_WORKER_LIST critical section! */ -static void create_worker(void) { +void create_worker(void) { int ret; struct worker_node *n = mallok(sizeof *n); @@ -936,196 +936,6 @@ void init_master_fdset(void) { } - -/* - * Here's where it all begins. - */ -int main(int argc, char **argv) -{ - char tracefile[128]; /* Name of file to log traces to */ - int a, i; /* General-purpose variables */ - struct passwd *pw; - int drop_root_perms = 1; - char *moddir; - struct worker_node *wnp; - - /* specify default port name and trace file */ - strcpy(tracefile, ""); - - /* initialize the master context */ - InitializeMasterCC(); - - /* parse command-line arguments */ - for (a=1; a 0) ? 0 : 1 ) ; - } - - /* -x specifies the desired logging level */ - else if (!strncmp(argv[a], "-x", 2)) { - verbosity = atoi(&argv[a][2]); - } - - else if (!strncmp(argv[a], "-h", 2)) { - safestrncpy(bbs_home_directory, &argv[a][2], - sizeof bbs_home_directory); - home_specified = 1; - } - - else if (!strncmp(argv[a], "-f", 2)) { - do_defrag = 1; - } - - /* -r tells the server not to drop root permissions. don't use - * this unless you know what you're doing. this should be - * removed in the next release if it proves unnecessary. */ - else if (!strcmp(argv[a], "-r")) - drop_root_perms = 0; - - /* any other parameter makes it crash and burn */ - else { - lprintf(1, "citserver: usage: " - "citserver [-tTraceFile] [-d] [-f]" - " [-xLogLevel] [-hHomeDir]\n"); - exit(1); - } - - } - - /* Tell 'em who's in da house */ - lprintf(1, -"\nMultithreaded message server for Citadel/UX\n" -"Copyright (C) 1987-2001 by the Citadel/UX development team.\n" -"Citadel/UX is free software, covered by the GNU General Public License, and\n" -"you are welcome to change it and/or distribute copies of it under certain\n" -"conditions. There is absolutely no warranty for this software. Please\n" -"read the 'COPYING.txt' file for details.\n\n"); - - /* Initialize... */ - init_sysdep(); - openlog("citserver", LOG_PID, LOG_USER); - - /* Load site-specific parameters */ - lprintf(7, "Loading citadel.config\n"); - get_config(); - - - /* - * Do non system dependent startup functions. - */ - master_startup(); - - /* - * Bind the server to a Unix-domain socket. - */ - CtdlRegisterServiceHook(0, - "citadel.socket", - citproto_begin_session, - do_command_loop); - - /* - * Bind the server to our favorite TCP port (usually 504). - */ - CtdlRegisterServiceHook(config.c_port_number, - NULL, - citproto_begin_session, - do_command_loop); - - /* - * Load any server-side modules (plugins) available here. - */ - lprintf(7, "Initializing loadable modules\n"); - if ((moddir = malloc(strlen(bbs_home_directory) + 9)) != NULL) { - sprintf(moddir, "%s/modules", bbs_home_directory); - DLoader_Init(moddir); - free(moddir); - } - - /* - * The rescan pipe exists so that worker threads can be woken up and - * told to re-scan the context list for fd's to listen on. This is - * necessary, for example, when a context is about to go idle and needs - * to get back on that list. - */ - if (pipe(rescan)) { - lprintf(1, "Can't create rescan pipe!\n"); - exit(errno); - } - - init_master_fdset(); - - /* - * Now that we've bound the sockets, change to the BBS user id and its - * corresponding group ids - */ - if (drop_root_perms) { - if ((pw = getpwuid(BBSUID)) == NULL) - lprintf(1, "WARNING: getpwuid(%d): %s\n" - "Group IDs will be incorrect.\n", BBSUID, - strerror(errno)); - else { - initgroups(pw->pw_name, pw->pw_gid); - if (setgid(pw->pw_gid)) - lprintf(3, "setgid(%d): %s\n", pw->pw_gid, - strerror(errno)); - } - lprintf(7, "Changing uid to %d\n", BBSUID); - if (setuid(BBSUID) != 0) { - lprintf(3, "setuid() failed: %s\n", strerror(errno)); - } - } - - /* We want to check for idle sessions once per minute */ - CtdlRegisterSessionHook(terminate_idle_sessions, EVT_TIMER); - - /* - * Now create a bunch of worker threads. - */ - lprintf(9, "Starting %d worker threads\n", config.c_min_workers-1); - begin_critical_section(S_WORKER_LIST); - for (i=0; i<(config.c_min_workers-1); ++i) { - create_worker(); - } - end_critical_section(S_WORKER_LIST); - - /* Now this thread can become a worker as well. */ - initial_thread = pthread_self(); - worker_thread(NULL); - - /* Server is exiting. Wait for workers to shutdown. */ - lprintf(7, "Waiting for worker threads to shut down\n"); - - begin_critical_section(S_WORKER_LIST); - while (worker_list != NULL) { - wnp = worker_list; - worker_list = wnp->next; - - /* avoid deadlock with an exiting thread */ - end_critical_section(S_WORKER_LIST); - if ((i = pthread_join(wnp->tid, NULL))) - lprintf(1, "pthread_join: %s\n", strerror(i)); - phree(wnp); - begin_critical_section(S_WORKER_LIST); - } - end_critical_section(S_WORKER_LIST); - - master_cleanup(); - - return(0); -} - - /* * Bind a thread to a context. (It's inline merely to speed things up.) */ diff --git a/citadel/sysdep_decls.h b/citadel/sysdep_decls.h index a38ce98c3..5113ff355 100644 --- a/citadel/sysdep_decls.h +++ b/citadel/sysdep_decls.h @@ -1,4 +1,7 @@ /* $Id$ */ + +#include "dynloader.h" + void lprintf (int loglevel, const char *format, ...); void init_sysdep (void); void begin_critical_section (int which_one); @@ -22,6 +25,17 @@ int convert_login (char *NameToConvert); void *worker_thread (void *arg); inline void become_session(struct CitContext *which_con); void CtdlRedirectOutput(FILE *fp, int sock); +void InitializeMasterCC(void); +void init_master_fdset(void); +void create_worker(void); + +extern DLEXP int num_sessions; +extern DLEXP volatile int time_to_die; +extern DLEXP int verbosity; +extern DLEXP int rescan[]; +extern DLEXP pthread_t initial_thread; -extern int num_sessions; -extern volatile int time_to_die; +extern DLEXP struct worker_node { + pthread_t tid; + struct worker_node *next; +} *worker_list; diff --git a/citadel/tools.c b/citadel/tools.c index 38a4e0597..28e5c4789 100644 --- a/citadel/tools.c +++ b/citadel/tools.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 86e0166fc..a246e00e4 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -5,6 +5,10 @@ * */ +#ifdef DLL_EXPORT +#define IN_LIBCIT +#endif + #include "sysdep.h" #include #include @@ -37,6 +41,7 @@ #include "server.h" #include "database.h" #include "user_ops.h" +#include "dynloader.h" #include "sysdep_decls.h" #include "support.h" #include "room_ops.h" @@ -45,7 +50,6 @@ #include "control.h" #include "msgbase.h" #include "config.h" -#include "dynloader.h" #include "tools.h" #include "citserver.h" -- 2.30.2