Static-ify a variable. make du work with all the human-readable variants
[oweals/busybox.git] / syslogd.c
index 4217c362f140f5f6a8d2e3923faf921cfdc6e64d..8049fc5d1675777c5b599b1631808f03f21e491e 100644 (file)
--- a/syslogd.c
+++ b/syslogd.c
@@ -2,7 +2,7 @@
 /*
  * Mini syslogd implementation for busybox
  *
- * Copyright (C) 1999,2000 by Lineo, inc.
+ * Copyright (C) 1999,2000,2001 by Lineo, inc.
  * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
  *
  * Copyright (C) 2000 by Karl M. Hegbloom <karlheg@debian.org>
@@ -23,7 +23,6 @@
  *
  */
 
-#include "busybox.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -34,6 +33,7 @@
 #include <signal.h>
 #include <stdarg.h>
 #include <time.h>
+#include <string.h>
 #include <unistd.h>
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -41,7 +41,8 @@
 #include <sys/param.h>
 
 #if ! defined __GLIBC__ && ! defined __UCLIBC__
-
+#include <sys/syscall.h>
+#include <linux/unistd.h>
 typedef unsigned int socklen_t;
 
 #ifndef __alpha__
@@ -54,6 +55,7 @@ static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
 #else
 # include <sys/klog.h>
 #endif
+#include "busybox.h"
 
 
 
@@ -165,7 +167,7 @@ static void logMessage (int pri, char *msg)
 #ifdef BB_FEATURE_REMOTE_LOG
        /* send message to remote logger */
        if ( -1 != remotefd){
-#define IOV_COUNT 2
+static const int IOV_COUNT = 2;
                struct iovec iov[IOV_COUNT];
                struct iovec *v = iov;
 
@@ -180,7 +182,7 @@ static void logMessage (int pri, char *msg)
 
                if ( -1 == writev(remotefd,iov, IOV_COUNT)){
                        error_msg_and_die("syslogd: cannot write to remote file handle on" 
-                                       "%s:%d\n",RemoteHost,RemotePort);
+                                       "%s:%d",RemoteHost,RemotePort);
                }
        }
        if (local_logging == TRUE)
@@ -206,10 +208,10 @@ static void domark(int sig)
        }
 }
 
-#define BUFSIZE 1023
+static const int BUFSIZE = 1023;
 static int serveConnection (int conn)
 {
-       char   buf[ BUFSIZE + 1 ];
+       RESERVE_BB_BUFFER(buf, BUFSIZE + 1);
        int    n_read;
 
        while ((n_read = read (conn, buf, BUFSIZE )) > 0) {
@@ -262,13 +264,13 @@ static void init_RemoteLog (void){
   remotefd = socket(AF_INET, SOCK_DGRAM, 0);
 
   if (remotefd < 0) {
-    error_msg_and_die("syslogd: cannot create socket\n");
+    error_msg_and_die("syslogd: cannot create socket");
   }
 
   hostinfo = (struct hostent *) gethostbyname(RemoteHost);
 
   if (!hostinfo) {
-    error_msg_and_die("syslogd: cannot resolve remote host name [%s]\n", RemoteHost);
+    error_msg_and_die("syslogd: cannot resolve remote host name [%s]", RemoteHost);
   }
 
   remoteaddr.sin_family = AF_INET;
@@ -280,7 +282,7 @@ static void init_RemoteLog (void){
      for future operations
   */
   if ( 0 != (connect(remotefd, (struct sockaddr *) &remoteaddr, len))){
-    error_msg_and_die("syslogd: cannot connect to remote host %s:%d\n", RemoteHost, RemotePort);
+    error_msg_and_die("syslogd: cannot connect to remote host %s:%d", RemoteHost, RemotePort);
   }
 
 }
@@ -296,7 +298,7 @@ static void doSyslogd (void)
        int sock_fd;
        fd_set fds;
 
-       char lfile[BUFSIZ];
+       RESERVE_BB_BUFFER(lfile, BUFSIZ);
 
        /* Set up signal handlers. */
        signal (SIGINT,  quit_signal);
@@ -517,7 +519,7 @@ extern int syslogd_main(int argc, char **argv)
                                break;
 #endif
                        default:
-                               usage(syslogd_usage);
+                               show_usage();
                }
        }