summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-09-10 08:49:47 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-09-10 08:49:47 +0800
commit540cfa70e8e8b4db3cc2addccfcbeeb69fffa033 (patch)
tree6a4dec7d69249e48a6f79c4436eb634cb28744b2 /util
parenta8a0ef3c4d10bf576054dc26348d9b4e6efeecc2 (diff)
downloadpttbbs-540cfa70e8e8b4db3cc2addccfcbeeb69fffa033.tar
pttbbs-540cfa70e8e8b4db3cc2addccfcbeeb69fffa033.tar.gz
pttbbs-540cfa70e8e8b4db3cc2addccfcbeeb69fffa033.tar.bz2
pttbbs-540cfa70e8e8b4db3cc2addccfcbeeb69fffa033.tar.lz
pttbbs-540cfa70e8e8b4db3cc2addccfcbeeb69fffa033.tar.xz
pttbbs-540cfa70e8e8b4db3cc2addccfcbeeb69fffa033.tar.zst
pttbbs-540cfa70e8e8b4db3cc2addccfcbeeb69fffa033.zip
merge back from branch victor.solaris
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2189 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r--util/bbsrf.c75
-rw-r--r--util/diskstat.c4
-rw-r--r--util/outmail.c2
-rw-r--r--util/xchatd.c18
4 files changed, 50 insertions, 49 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/diskstat.c b/util/diskstat.c
index 370c1a7b..1b785120 100644
--- a/util/diskstat.c
+++ b/util/diskstat.c
@@ -305,7 +305,7 @@ main(int argc, char **argv)
}
#endif
- signal(SIGINT, printresult);
+ Signal(SIGINT, printresult);
/* find out how many devices we have */
if ((num_devices = getnumdevs()) < 0)
err(1, "can't get number of devices");
@@ -424,7 +424,7 @@ main(int argc, char **argv)
* If the user stops the program (control-Z) and then resumes it,
* print out the header again.
*/
- (void)signal(SIGCONT, phdr);
+ (void)Signal(SIGCONT, phdr);
for (headercount = 1;;) {
struct devinfo *tmp_dinfo;
diff --git a/util/outmail.c b/util/outmail.c
index 508d857b..8f01c486 100644
--- a/util/outmail.c
+++ b/util/outmail.c
@@ -218,7 +218,7 @@ void parseserver(char *sx, char **name, int *port)
int main(int argc, char **argv, char **envp) {
int ch;
- signal(SIGHUP, wakeup);
+ Signal(SIGHUP, wakeup);
initsetproctitle(argc, argv, envp);
if(chdir(BBSHOME))
diff --git a/util/xchatd.c b/util/xchatd.c
index 862ecf2c..22be9620 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);
}
@@ -3148,7 +3148,7 @@ start_daemon()
for (fd = 1; fd < NSIG; fd++)
{
- signal(fd, SIG_IGN);
+ Signal(fd, SIG_IGN);
}
#endif
@@ -3297,16 +3297,16 @@ main()
log_init();
- signal(SIGBUS, SIG_IGN);
- signal(SIGSEGV, SIG_IGN);
- signal(SIGPIPE, SIG_IGN);
- signal(SIGURG, SIG_IGN);
+ Signal(SIGBUS, SIG_IGN);
+ Signal(SIGSEGV, SIG_IGN);
+ Signal(SIGPIPE, SIG_IGN);
+ Signal(SIGURG, SIG_IGN);
- signal(SIGCHLD, reaper);
- signal(SIGTERM, abort_server);
+ Signal(SIGCHLD, reaper);
+ Signal(SIGTERM, abort_server);
#ifdef SERVER_USAGE
- signal(SIGPROF, server_usage);
+ Signal(SIGPROF, server_usage);
#endif
/* ----------------------------- */