diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-09-05 21:41:11 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-09-05 21:41:11 +0800 |
commit | 83fdeaf59d8b442238981c5d6dd6854469848025 (patch) | |
tree | f97249063be06510b68f50a4cccf776cd0b9bc99 /util | |
parent | 3c99d25d8934e858b84c079a299904457790667d (diff) | |
download | pttbbs-83fdeaf59d8b442238981c5d6dd6854469848025.tar pttbbs-83fdeaf59d8b442238981c5d6dd6854469848025.tar.gz pttbbs-83fdeaf59d8b442238981c5d6dd6854469848025.tar.bz2 pttbbs-83fdeaf59d8b442238981c5d6dd6854469848025.tar.lz pttbbs-83fdeaf59d8b442238981c5d6dd6854469848025.tar.xz pttbbs-83fdeaf59d8b442238981c5d6dd6854469848025.tar.zst pttbbs-83fdeaf59d8b442238981c5d6dd6854469848025.zip |
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
Diffstat (limited to 'util')
-rw-r--r-- | util/bbsrf.c | 75 | ||||
-rw-r--r-- | util/xchatd.c | 2 |
2 files changed, 39 insertions, 38 deletions
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 <stdlib.h> #include <sys/param.h> #include <sys/types.h> -#include <utmp.h> #include <pwd.h> #include <syslog.h> #include <fcntl.h> @@ -14,34 +13,56 @@ #include <sys/uio.h> #include "config.h" +#ifdef Solaris + #include <utmpx.h> + #define U_FILE UTMPX_FILE +#else + #include <utmp.h> + #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; } @@ -51,30 +72,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; otherwise, return -1. @@ -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); } |