From 83fdeaf59d8b442238981c5d6dd6854469848025 Mon Sep 17 00:00:00 2001 From: victor Date: Sun, 5 Sep 2004 13:41:11 +0000 Subject: fix bbsrf, warning free, defined HAVE_DES_CRYPT git-svn-id: http://opensvn.csie.org/pttbbs/branches/victor.solaris@2183 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs.mk | 2 +- util/bbsrf.c | 75 ++++++++++++++++++++++++++++++----------------------------- util/xchatd.c | 2 +- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/pttbbs.mk b/pttbbs.mk index 505806f4..1550a789 100644 --- a/pttbbs.mk +++ b/pttbbs.mk @@ -28,7 +28,7 @@ LDFLAGS_Linux= -pipe -Wall LIBS_Linux= # SunOS特有的環境 -CFLAGS_Solaris= -DSolaris -I/usr/local/include +CFLAGS_Solaris= -DSolaris -DHAVE_DES_CRYPT -I/usr/local/include LDFLAGS_Solaris= -L/usr/local/lib -L/usr/lib/ LIBS_Solaris= -lnsl -lsocket -liconv -lkstat diff --git a/util/bbsrf.c b/util/bbsrf.c index c527d761..c3bf44a9 100644 --- a/util/bbsrf.c +++ b/util/bbsrf.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -14,34 +13,56 @@ #include #include "config.h" +#ifdef Solaris + #include + #define U_FILE UTMPX_FILE +#else + #include + #define U_FILE UTMP_FILE +#endif + +#ifdef FreeBSD + #define UTMP_FILE _PATH_UTMP +#endif + +#ifndef Solaris + #if MAXHOSTNAMELEN < UT_HOSTSIZE + #define MAX_HOMENAME_LEN MAXHOSTNAMELEN + #else + #define MAX_HOMENAME_LEN UT_HOSTSIZE + #endif +#else + /* according to /usr/include/utmpx.h ... */ + #define MAX_HOMENAME_LEN 256 +#endif + /* fill the hid with from hostname */ void gethid(char *hid, char *tty) { int fd; char *tp; +#ifdef Solaris + struct utmpx data; +#else struct utmp data; +#endif - gethostname(hid, MAXHOSTNAMELEN); - hid[MAXHOSTNAMELEN] = '\0'; + gethostname(hid, MAX_HOMENAME_LEN); + hid[MAX_HOMENAME_LEN] = '\0'; tp = strrchr(tty, '/') + 1; if (tp && strlen(tp) == 5) { - fd = open(_PATH_UTMP, O_RDONLY); + fd = open(U_FILE, O_RDONLY); if (fd < 0) - syslog(LOG_ERR, "%s: %m", _PATH_UTMP); + syslog(LOG_ERR, "%s: %m", U_FILE); else { while (read(fd, &data, sizeof(data)) == sizeof(data)) if (strcmp(data.ut_line, tp) == 0) { if (data.ut_host[0]) { -#if MAXHOSTNAMELEN < UT_HOSTSIZE - strncpy(hid, data.ut_host, MAXHOSTNAMELEN); - hid[MAXHOSTNAMELEN] = '\0'; -#else - strncpy(hid, data.ut_host, UT_HOSTSIZE); - hid[UT_HOSTSIZE] = '\0'; -#endif + strncpy(hid, data.ut_host, MAX_HOMENAME_LEN); + hid[MAX_HOMENAME_LEN] = '\0'; } break; } @@ -50,30 +71,6 @@ void gethid(char *hid, char *tty) } } -/* - get system load averages - return 0 if success; otherwise, return -1. - */ -int getload(double load[3]) -{ - int rtv = -1; -#if defined(linux) - FILE *fp; - - fp = fopen(LOAD_FILE, "r"); - if (fp) - { - if (fscanf(fp, "%lf %lf %lf", &load[0], &load[1], &load[2]) == 3) - rtv = 0; - fclose(fp); - } -#elif defined(__FreeBSD__) - if (getloadavg(load, 3) == 3) - rtv = 0; -#endif - return rtv; -} - /* show ban file if filename exist, print it out, sleep 1 second, and return 0; @@ -100,9 +97,13 @@ int showbanfile(char *filename) int main(void) { int uid, rtv = 0; - char *tty, ttybuf[32], hid[MAXHOSTNAMELEN + 1]; + char *tty, ttybuf[32], hid[MAX_HOMENAME_LEN + 1]; +#ifndef Solaris openlog("bbsrf", LOG_PID | LOG_PERROR, LOG_USER); +#else + openlog("bbsrf", LOG_PID, LOG_USER); +#endif chdir(BBSHOME); uid = getuid(); diff --git a/util/xchatd.c b/util/xchatd.c index 862ecf2c..bcc3d6ea 100644 --- a/util/xchatd.c +++ b/util/xchatd.c @@ -3135,7 +3135,7 @@ start_daemon() if (fd >= 0) { /* sprintf(buf, "%5d\n", value); */ - sprintf(buf, "%5d\n", getpid()); + sprintf(buf, "%5d\n", (int)getpid()); write(fd, buf, 6); close(fd); } -- cgit v1.2.3