Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Feb 1996 14:06:14 +0100 (MET)
From:      Ollivier Robert <roberto@keltia.freenix.fr>
To:        freebsd-current@FreeBSD.ORG (FreeBSD Current Users' list)
Subject:   newsyslog
Message-ID:  <199602241306.OAA23826@keltia.freenix.fr>

next in thread | raw e-mail | index | archive | help
Hi,

I've modified   newsyslog to be  more  like  the rest  of  the utilities by
creating  a pathnames.h  file and   change a  bit  the symbols'  names. Can
someone review it and/or commit it (although I could do it, I'd rather have
a review on the symbols, I'm not sure if my names are consistent). 

Index: Makefile
===================================================================
RCS file: /spare/FreeBSD-current/src/usr.sbin/newsyslog/Makefile,v
retrieving revision 1.2
diff -u -2 -u -r1.2 Makefile
--- Makefile	1996/01/16 10:32:01	1.2
+++ Makefile	1996/02/24 12:54:27
@@ -3,10 +3,5 @@
 PROG=	newsyslog
 
-CFLAGS+= -DOSF
-CFLAGS+= -DCONF=\"/etc/newsyslog.conf\"
-CFLAGS+= -DPIDFILE=\"/var/run/syslog.pid\"
-CFLAGS+= -DCOMPRESS_PATH=\"/usr/bin/gzip\"
-CFLAGS+= -DCOMPRESS_PROG=\"gzip\"
-CFLAGS+= -DCOMPRESS_POSTFIX=\".gz\"
+CFLAGS+= -DOSF -I.
 
 BINOWN=	root
Index: newsyslog.c
===================================================================
RCS file: /spare/FreeBSD-current/src/usr.sbin/newsyslog/newsyslog.c,v
retrieving revision 1.3
diff -u -2 -u -r1.3 newsyslog.c
--- newsyslog.c	1996/01/16 10:32:04	1.3
+++ newsyslog.c	1996/02/24 12:57:55
@@ -33,20 +33,4 @@
 #endif /* not lint */
 
-#ifndef CONF
-#define CONF "/etc/athena/newsyslog.conf" /* Configuration file */
-#endif
-#ifndef PIDFILE
-#define PIDFILE "/etc/syslog.pid"
-#endif
-#ifndef COMPRESS_PATH
-#define COMPRESS_PATH "/usr/ucb/compress" /* File compression program */
-#endif
-#ifndef COMPRESS_PROG
-#define COMPRESS_PROG "compress"
-#endif
-#ifndef COMPRESS_POSTFIX
-#define COMPRESS_POSTFIX ".Z"
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
@@ -62,4 +46,6 @@
 #include <sys/wait.h>
 
+#include "pathnames.h"
+
 #define kbytes(size)  (((size) + 1023) >> 10)
 #ifdef _IBMR2
@@ -95,5 +81,5 @@
 int     needroot = 1;           /* Root privs are necessary */
 int     noaction = 0;           /* Don't do anything, just show it */
-char    *conf = CONF;           /* Configuration file to use */
+char    *conf = _PATH_NEWSYSLOG;/* Configuration file to use */
 time_t  timenow;
 int     syslog_pid;             /* read in from /etc/syslog.pid */
@@ -188,5 +174,5 @@
         /* Let's find the pid of syslogd */
         syslog_pid = 0;
-        f = fopen(PIDFILE,"r");
+        f = fopen(_PATH_LOGPID,"r");
         if (f && fgets(line,BUFSIZ,f))
                 syslog_pid = atoi(line);
@@ -376,5 +362,5 @@
         (void) sprintf(file1,"%s.%d",log,numdays);
         (void) strcpy(zfile1, file1);
-        (void) strcat(zfile1, COMPRESS_POSTFIX);
+        (void) strcat(zfile1, _SUFX_COMPRESS);
 
         if (noaction) {
@@ -393,6 +379,6 @@
                 (void) strcpy(zfile2, file2);
                 if (lstat(file1, &st)) {
-                        (void) strcat(zfile1, COMPRESS_POSTFIX);
-                        (void) strcat(zfile2, COMPRESS_POSTFIX);
+                        (void) strcat(zfile1, _SUFX_COMPRESS);
+                        (void) strcat(zfile2, _SUFX_COMPRESS);
                         if (lstat(zfile1, &st)) continue;
                 }
@@ -473,6 +459,6 @@
                 err(1, "fork");
         else if (!pid) {
-                (void) execl(COMPRESS_PATH,COMPRESS_PROG,"-f",tmp,0);
-                err(1, COMPRESS_PATH);
+                (void) execl(_PATH_COMPRESS,_NAME_COMPRESS,"-f",tmp,0);
+                err(1, _PATH_COMPRESS);
         }
 }
@@ -494,9 +480,9 @@
 {
         struct stat sb;
-        char tmp[MAXPATHLEN+sizeof(".0")+sizeof(COMPRESS_POSTFIX)+1];
+        char tmp[MAXPATHLEN+sizeof(".0")+sizeof(_SUFX_COMPRESS)+1];
 
         (void) strcpy(tmp,file);
         if (stat(strcat(tmp,".0"),&sb) < 0)
-            if (stat(strcat(tmp,COMPRESS_POSTFIX), &sb) < 0)
+            if (stat(strcat(tmp,_SUFX_COMPRESS), &sb) < 0)
                 return(-1);
         return( (int) (timenow - sb.st_mtime + 1800) / 3600);
--- /dev/null	Thu Feb 22 23:53:45 1996
+++ pathnames.h	Sat Feb 24 13:53:50 1996
@@ -0,0 +1,5 @@
+#define _PATH_NEWSYSLOG     "/etc/newsyslog.conf"
+#define _PATH_LOGPID        "/var/run/syslog.pid"
+#define _PATH_COMPRESS      "/usr/bin/gzip"
+#define _NAME_COMPRESS      "gzip"
+#define _SUFX_COMPRESS      ".gz"
 
-- 
Ollivier ROBERT    -=- The daemon is FREE! -=-    roberto@keltia.frmug.fr.net
   FreeBSD keltia.freenix.fr 2.2-CURRENT #1: Tue Feb 20 01:16:51 MET 1996



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199602241306.OAA23826>