summaryrefslogtreecommitdiffstats
path: root/contrib/amd/libamu/xutil.c
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>1999-01-13 19:23:16 +0000
committerobrien <obrien@FreeBSD.org>1999-01-13 19:23:16 +0000
commit48ce32b887a1c63d23a479560edd101bcc8da00a (patch)
treeaf783f983bbe37aea4e83736c517007ce480d664 /contrib/amd/libamu/xutil.c
parentf6d96f9002b701ad54ce6b730e937efc48628725 (diff)
parentc9384f1d982e4695904ef82271714a049cd32827 (diff)
downloadFreeBSD-src-48ce32b887a1c63d23a479560edd101bcc8da00a.zip
FreeBSD-src-48ce32b887a1c63d23a479560edd101bcc8da00a.tar.gz
This commit was generated by cvs2svn to compensate for changes in r42629,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/amd/libamu/xutil.c')
-rw-r--r--contrib/amd/libamu/xutil.c68
1 files changed, 57 insertions, 11 deletions
diff --git a/contrib/amd/libamu/xutil.c b/contrib/amd/libamu/xutil.c
index 35e7f91..d069f7a 100644
--- a/contrib/amd/libamu/xutil.c
+++ b/contrib/amd/libamu/xutil.c
@@ -17,7 +17,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
+ * must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: xutil.c,v 1.1 1997-1998/01/11 21:06:22 ezk Exp ezk $
+ * $Id: xutil.c,v 1.2 1998/12/27 06:25:24 ezk Exp $
*
*/
@@ -50,6 +50,15 @@
FILE *logfp = stderr; /* Log errors to stderr initially */
+static char *am_progname = "unknown"; /* "amd" */
+static char am_hostname[MAXHOSTNAMELEN + 1] = "unknown"; /* Hostname */
+pid_t am_mypid = -1; /* process ID */
+serv_state amd_state; /* amd's state */
+int foreground = 1; /* 1 == this is the top-level server */
+#ifdef DEBUG
+int debug_flags = 0;
+#endif /* DEBUG */
+
#ifdef HAVE_SYSLOG
int syslogging;
#endif /* HAVE_SYSLOG */
@@ -113,6 +122,43 @@ struct opt_tab xlog_opt[] =
};
+void
+am_set_progname(char *pn)
+{
+ am_progname = pn;
+}
+
+
+const char *
+am_get_progname(void)
+{
+ return am_progname;
+}
+
+
+void
+am_set_hostname(char *hn)
+{
+ strncpy(am_hostname, hn, MAXHOSTNAMELEN);
+ am_hostname[MAXHOSTNAMELEN] = '\0';
+}
+
+
+const char *
+am_get_hostname(void)
+{
+ return am_hostname;
+}
+
+
+pid_t
+am_set_mypid(void)
+{
+ am_mypid = getpid();
+ return am_mypid;
+}
+
+
voidp
xmalloc(int len)
{
@@ -209,7 +255,7 @@ checkup_mem(void)
if (orig_mem_bytes == 0)
mem_bytes = orig_mem_bytes = uordbytes;
else {
- fprintf(logfp, "%s[%ld]: ", progname, (long) mypid);
+ fprintf(logfp, "%s[%ld]: ", am_get_progname(), (long) am_mypid);
if (mem_bytes < uordbytes) {
fprintf(logfp, "ALLOC: %ld bytes", uordbytes - mem_bytes);
} else {
@@ -225,7 +271,7 @@ checkup_mem(void)
/*
- * Take a log format string and expand occurences of %m
+ * Take a log format string and expand occurrences of %m
* with the current error code taken from errno.
*/
static void
@@ -298,9 +344,9 @@ show_time_host_and_name(int lvl)
break;
}
fprintf(logfp, "%15.15s %s %s[%ld]/%s ",
- last_ctime + 4, hostname,
- progname,
- (long) mypid,
+ last_ctime + 4, am_get_hostname(),
+ am_get_progname(),
+ (long) am_mypid,
sev);
}
@@ -530,7 +576,7 @@ cmdoption(char *s, struct opt_tab *optb, int *flags)
* This will log to stderr when parsing the command line
* since any -l option will not yet have taken effect.
*/
- plog(XLOG_USER, "option \"%s\" not recognised", s);
+ plog(XLOG_USER, "option \"%s\" not recognized", s);
errs++;
}
@@ -672,7 +718,7 @@ get_syslog_facility(const char *logfile)
* Change current logfile
*/
int
-switch_to_logfile(char *logfile)
+switch_to_logfile(char *logfile, int old_umask)
{
FILE *new_logfp = stderr;
@@ -688,7 +734,7 @@ switch_to_logfile(char *logfile)
#ifdef HAVE_SYSLOG
syslogging = 1;
new_logfp = stderr;
- openlog(progname,
+ openlog(am_get_progname(),
LOG_PID
# ifdef LOG_CONS
| LOG_CONS
@@ -705,7 +751,7 @@ switch_to_logfile(char *logfile)
#endif /* not HAVE_SYSLOG */
} else {
- (void) umask(orig_umask);
+ (void) umask(old_umask);
new_logfp = fopen(logfile, "a");
umask(0);
}
OpenPOWER on IntegriCloud