From 535e458a1b28ecdf69dddcace060807e462980fd Mon Sep 17 00:00:00 2001 From: victor Date: Sun, 12 Sep 2004 03:31:16 +0000 Subject: Solaris compatible git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2193 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/bbs.h | 4 +++- include/osdep.h | 13 ++++++++++--- innbbsd/Makefile | 7 ++++--- innbbsd/bbsnnrp.c | 2 +- innbbsd/connectsock.c | 2 +- innbbsd/innbbsconf.h | 12 ++++++------ innbbsd/port.c | 2 ++ mbbsd/osdep.c | 30 ++++++++++++++++++++++++++++++ mbbsd/register.c | 3 --- mbbsd/user.c | 3 --- util/Makefile | 4 ++-- util/reaper.c | 4 ++++ util/tunepasswd.c | 10 +--------- 13 files changed, 64 insertions(+), 32 deletions(-) diff --git a/include/bbs.h b/include/bbs.h index 5b4dca21..3a2f0cb9 100644 --- a/include/bbs.h +++ b/include/bbs.h @@ -1,7 +1,10 @@ /* $id$ */ + #ifndef INCLUDE_BBS_H #define INCLUDE_BBS_H +#include "osdep.h" + #include #include #include @@ -34,7 +37,6 @@ #include #include -#include "osdep.h" /* our header */ #include "config.h" diff --git a/include/osdep.h b/include/osdep.h index a7c719d1..8e790595 100644 --- a/include/osdep.h +++ b/include/osdep.h @@ -9,13 +9,17 @@ #else #include #endif + #include + #define _XOPEN_SOURCE + #define _ISOC99_SOURCE + #elif defined(__linux__) - #include + #define _GNU_SOURCE + #include - #include #include /* for flock() */ #include /* for strcasecmp() */ @@ -32,10 +36,13 @@ #include #include /* for strcasecmp() */ + #define _ISOC99_SOURCE + #define NEED_FLOCK #define NEED_UNSETENV #define NEED_SCANDIR #define NEED_STRCASESTR + #define NEED_TIMEGM #if __OS_MAJOR_VERSION__ == 5 && __OS_MINOR_VERSION__ < 8 #define NEED_STRLCPY @@ -49,7 +56,7 @@ #else - #warning "Unknown OSTYPE" + #error "Unknown OSTYPE" #endif diff --git a/innbbsd/Makefile b/innbbsd/Makefile index 9399d32d..585bce6f 100644 --- a/innbbsd/Makefile +++ b/innbbsd/Makefile @@ -57,13 +57,14 @@ SRCS = inndchannel.c innbbsd.c connectsock.c rfc931.c \ port.c str_decode.c MOBJS = makedbz.o bbslib.o file.o dbz.o closeonexec.o -HOBJS = mkhistory.o bbslib.o file.o his.o dbz.o port.o closeonexec.o +HOBJS = mkhistory.o bbslib.o file.o his.o dbz.o port.o closeonexec.o \ + $(BBS_REC_EXTRA_$(OSTYPE)) DBZOBJS = dbzserver.o dbzinnbbsd.o pmain.o connectsock.o bbslib.o his.o \ daemon.o file.o dbz.o dbztool.o rfc931.o port.o closeonexec.o \ morelog.o NNRPOBJS = bbsnnrp.o pmain.o bbslib.o connectsock.o file.o LINKOBJS = bbslink.o pmain.o inntobbs.o echobbslib.o connectsock.o file.o port.o\ - str_decode.o + str_decode.o $(BBS_REC_EXTRA_$(OSTYPE)) LINKOBJS2 = bbslink2.o pmain.o inntobbs.o echobbslib.o connectsock.o file.o port.o CTLOBJS = ctlinnbbsd.o pmain.o bbslib.o connectsock.o file.o INNBBSD = innbbsd mkhistory bbsnnrp ctlinnbbsd $(BBSLINK) @@ -97,7 +98,7 @@ irix: Solaris: solaris solaris: - @$(MAKE) EXTRAFLAGS="-DMMAP -DSOLARIS -DSYSV -I/usr/local/include/ -I../include/" LDFLAGS="-L/usr/local/lib -liconv -lsocket -lnsl -lkstat ../mbbsd/osdep.o" YACC="bison -y" target + @$(MAKE) EXTRAFLAGS="-DMMAP -DSolaris -DSYSV -I/usr/local/include/ -I../include/" LDFLAGS="-L/usr/local/lib -liconv -lsocket -lnsl -lkstat" YACC="bison -y" target FreeBSD: @$(MAKE) CC=cc EXTRAFLAGS="-DBSD44 -DMMAP -DGETRUSAGE" LDFLAGS="-lcrypt -liconv" target diff --git a/innbbsd/bbsnnrp.c b/innbbsd/bbsnnrp.c index 544e3336..6aeeeb86 100644 --- a/innbbsd/bbsnnrp.c +++ b/innbbsd/bbsnnrp.c @@ -11,6 +11,7 @@ */ #include "innbbsconf.h" +#include "osdep.h" #include #ifndef AIX #include @@ -18,7 +19,6 @@ #include "bbslib.h" #include "daemon.h" #include "nntp.h" -#include "osdep.h" #ifndef MAX_ARTS #define MAX_ARTS 100 diff --git a/innbbsd/connectsock.c b/innbbsd/connectsock.c index f61ff160..45796d0c 100644 --- a/innbbsd/connectsock.c +++ b/innbbsd/connectsock.c @@ -1,8 +1,8 @@ +#include "osdep.h" #include "innbbsconf.h" #include "daemon.h" #include #include -#include "osdep.h" static jmp_buf timebuf; diff --git a/innbbsd/innbbsconf.h b/innbbsd/innbbsconf.h index 4e068443..dcdc5f21 100644 --- a/innbbsd/innbbsconf.h +++ b/innbbsd/innbbsconf.h @@ -134,14 +134,14 @@ #if !defined(__svr4__) || defined(sun) #define WITH_TM_GMTOFF #endif -#if (defined(__svr4__) && defined(sun)) || defined(SOLARIS) -#ifndef SOLARIS -#define SOLARIS +#if (defined(__svr4__) && defined(sun)) || defined(Solaris) +#ifndef Solaris +#define Solaris #endif #define NO_getdtablesize -#define NO_bcopy -#define NO_bzero -#define NO_flock +//#define NO_bcopy +//#define NO_bzero +//#define NO_flock #define WITH_lockf #endif diff --git a/innbbsd/port.c b/innbbsd/port.c index 8962ea14..fab82771 100644 --- a/innbbsd/port.c +++ b/innbbsd/port.c @@ -13,6 +13,7 @@ getdtablesize() } #endif +#if 0 #if defined(SYSV) && !defined(WITH_RECORD_O) #include flock(fd, op) @@ -31,3 +32,4 @@ flock(fd, op) return lockf(fd, op, 0L); } #endif +#endif diff --git a/mbbsd/osdep.c b/mbbsd/osdep.c index 1bca7208..598cc5fd 100644 --- a/mbbsd/osdep.c +++ b/mbbsd/osdep.c @@ -76,6 +76,36 @@ strlcat(dst, src, siz) #endif +#ifdef NEED_TIMEGM + +#include +#include + +time_t timegm (struct tm *tm) +{ + time_t ret; + char *tz; + + tz = getenv("TZ"); + putenv("TZ="); + tzset(); + ret = mktime(tm); + + if (tz){ + char *buff = malloc( strlen(tz) + 10); + sprintf( buff, "TZ=%s", tz); + putenv(buff); + free(buff); + } + else + unsetenv("TZ"); + tzset(); + + return ret; +} + +#endif + #ifdef NEED_STRLCPY /* ------------------------------------------------------------------------ */ diff --git a/mbbsd/register.c b/mbbsd/register.c index a578f16a..e33a5098 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -1,7 +1,4 @@ /* $Id$ */ -#define _XOPEN_SOURCE -#define _ISOC99_SOURCE - #include "bbs.h" char * diff --git a/mbbsd/user.c b/mbbsd/user.c index eb93217e..819595a8 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -1,7 +1,4 @@ /* $Id$ */ -#define _XOPEN_SOURCE -#define _ISOC99_SOURCE - #include "bbs.h" static char * const sex[8] = { diff --git a/util/Makefile b/util/Makefile index 54e26131..e4e88871 100644 --- a/util/Makefile +++ b/util/Makefile @@ -24,13 +24,13 @@ CPROG_WITH_UTIL= \ reaper buildAnnounce inndBM shmctl \ outmail chkhbf checkmoney merge_dir \ transman angel gamblegive checkdir \ - chesscountry + chesscountry tunepasswd buildir # 下面這些程式, 會直接被 compile CPROG_WITHOUT_UTIL= \ shmsweep uhash_loader showboard \ countalldice webgrep bbsrf initbbs \ - userlist tunepasswd buildir merge_passwd \ + userlist merge_passwd \ merge_board xchatd bbsmail # 下面這些程式會被 install diff --git a/util/reaper.c b/util/reaper.c index 2fc587e0..7904566d 100644 --- a/util/reaper.c +++ b/util/reaper.c @@ -49,7 +49,11 @@ int check(int n, userec_t *u) { int main(int argc, char **argv) { now = time(NULL); +#ifdef Solaris + openlog("reaper", LOG_PID, SYSLOG_FACILITY); +#else openlog("reaper", LOG_PID | LOG_PERROR, SYSLOG_FACILITY); +#endif chdir(BBSHOME); attach_SHM(); diff --git a/util/tunepasswd.c b/util/tunepasswd.c index 1d575dcc..b617fb77 100644 --- a/util/tunepasswd.c +++ b/util/tunepasswd.c @@ -1,13 +1,5 @@ /* $Id$ */ -#include -#include -#include -#include -#include -#include -#include "config.h" -#include "pttstruct.h" -#include "common.h" +#include "bbs.h" int tune(int num) { int i, j, fin, fout; -- cgit v1.2.3