diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-06-19 17:48:02 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-06-19 17:48:02 +0000 |
commit | 67e32304b1cc0ecddc045c2b0362cec3780d7fd7 (patch) | |
tree | e2b6086f3792b5df8a22c257ec0e7637e4c4dead | |
parent | be5023a84ddcf830148448456f40c0569c4d60d3 (diff) | |
download | busybox-w32-67e32304b1cc0ecddc045c2b0362cec3780d7fd7.tar.gz busybox-w32-67e32304b1cc0ecddc045c2b0362cec3780d7fd7.tar.bz2 busybox-w32-67e32304b1cc0ecddc045c2b0362cec3780d7fd7.zip |
Updated to compile and work with libc5.
-Erik
-rw-r--r-- | sysklogd/syslogd.c | 43 | ||||
-rw-r--r-- | syslogd.c | 43 |
2 files changed, 58 insertions, 28 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index c7906368d..d2fbc3d87 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -24,6 +24,8 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "internal.h" | 26 | #include "internal.h" |
27 | #include <stdio.h> | ||
28 | #include <stdlib.h> | ||
27 | #include <ctype.h> | 29 | #include <ctype.h> |
28 | #include <errno.h> | 30 | #include <errno.h> |
29 | #include <fcntl.h> | 31 | #include <fcntl.h> |
@@ -31,18 +33,32 @@ | |||
31 | #include <paths.h> | 33 | #include <paths.h> |
32 | #include <signal.h> | 34 | #include <signal.h> |
33 | #include <stdarg.h> | 35 | #include <stdarg.h> |
34 | #include <stdio.h> | 36 | #include <time.h> |
35 | #include <sys/klog.h> | 37 | #include <unistd.h> |
36 | #include <sys/socket.h> | 38 | #include <sys/socket.h> |
37 | #include <sys/stat.h> | 39 | #include <sys/stat.h> |
38 | #include <sys/types.h> | 40 | #include <sys/types.h> |
39 | #include <sys/un.h> | 41 | #include <sys/un.h> |
40 | #include <sys/param.h> | 42 | #include <sys/param.h> |
41 | #include <time.h> | 43 | #include <linux/unistd.h> |
42 | #include <unistd.h> | 44 | |
45 | #ifndef socklen_t | ||
46 | typedef unsigned int socklen_t; | ||
47 | #endif | ||
48 | |||
49 | #if __GNU_LIBRARY__ < 5 | ||
50 | |||
51 | #ifndef __alpha__ | ||
52 | # define __NR_klogctl __NR_syslog | ||
53 | static inline _syscall3(int, klogctl, int, type, char *, b, int, len); | ||
54 | #else /* __alpha__ */ | ||
55 | #define klogctl syslog | ||
56 | #endif | ||
57 | |||
58 | #else | ||
59 | # include <sys/klog.h> | ||
60 | #endif | ||
43 | 61 | ||
44 | #define ksyslog klogctl | ||
45 | extern int ksyslog(int type, char *buf, int len); | ||
46 | 62 | ||
47 | 63 | ||
48 | /* SYSLOG_NAMES defined to pull some extra junk from syslog.h */ | 64 | /* SYSLOG_NAMES defined to pull some extra junk from syslog.h */ |
@@ -171,8 +187,7 @@ static void domark(int sig) | |||
171 | } | 187 | } |
172 | 188 | ||
173 | #define BUFSIZE 1023 | 189 | #define BUFSIZE 1023 |
174 | static void serveConnection (int conn) __attribute__ ((noreturn)); | 190 | static int serveConnection (int conn) |
175 | static void serveConnection (int conn) | ||
176 | { | 191 | { |
177 | char buf[ BUFSIZE + 1 ]; | 192 | char buf[ BUFSIZE + 1 ]; |
178 | int n_read; | 193 | int n_read; |
@@ -210,7 +225,7 @@ static void serveConnection (int conn) | |||
210 | /* Now log it */ | 225 | /* Now log it */ |
211 | logMessage (pri, line); | 226 | logMessage (pri, line); |
212 | } | 227 | } |
213 | exit (0); | 228 | return (0); |
214 | } | 229 | } |
215 | 230 | ||
216 | static void doSyslogd (void) __attribute__ ((noreturn)); | 231 | static void doSyslogd (void) __attribute__ ((noreturn)); |
@@ -307,8 +322,8 @@ static void doSyslogd (void) | |||
307 | 322 | ||
308 | static void klogd_signal(int sig) | 323 | static void klogd_signal(int sig) |
309 | { | 324 | { |
310 | ksyslog(7, NULL, 0); | 325 | klogctl(7, NULL, 0); |
311 | ksyslog(0, 0, 0); | 326 | klogctl(0, 0, 0); |
312 | logMessage(0, "Kernel log daemon exiting."); | 327 | logMessage(0, "Kernel log daemon exiting."); |
313 | exit(TRUE); | 328 | exit(TRUE); |
314 | } | 329 | } |
@@ -328,12 +343,12 @@ static void doKlogd (void) | |||
328 | logMessage(0, "klogd started: " | 343 | logMessage(0, "klogd started: " |
329 | "BusyBox v" BB_VER " (" BB_BT ")"); | 344 | "BusyBox v" BB_VER " (" BB_BT ")"); |
330 | 345 | ||
331 | ksyslog(1, NULL, 0); | 346 | klogctl(1, NULL, 0); |
332 | 347 | ||
333 | while (1) { | 348 | while (1) { |
334 | /* Use kernel syscalls */ | 349 | /* Use kernel syscalls */ |
335 | memset(log_buffer, '\0', sizeof(log_buffer)); | 350 | memset(log_buffer, '\0', sizeof(log_buffer)); |
336 | if (ksyslog(2, log_buffer, sizeof(log_buffer)) < 0) { | 351 | if (klogctl(2, log_buffer, sizeof(log_buffer)) < 0) { |
337 | char message[80]; | 352 | char message[80]; |
338 | 353 | ||
339 | if (errno == EINTR) | 354 | if (errno == EINTR) |
@@ -464,7 +479,7 @@ extern int syslogd_main(int argc, char **argv) | |||
464 | doSyslogd(); | 479 | doSyslogd(); |
465 | } | 480 | } |
466 | 481 | ||
467 | exit(TRUE); | 482 | return(TRUE); |
468 | } | 483 | } |
469 | 484 | ||
470 | /* | 485 | /* |
@@ -24,6 +24,8 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "internal.h" | 26 | #include "internal.h" |
27 | #include <stdio.h> | ||
28 | #include <stdlib.h> | ||
27 | #include <ctype.h> | 29 | #include <ctype.h> |
28 | #include <errno.h> | 30 | #include <errno.h> |
29 | #include <fcntl.h> | 31 | #include <fcntl.h> |
@@ -31,18 +33,32 @@ | |||
31 | #include <paths.h> | 33 | #include <paths.h> |
32 | #include <signal.h> | 34 | #include <signal.h> |
33 | #include <stdarg.h> | 35 | #include <stdarg.h> |
34 | #include <stdio.h> | 36 | #include <time.h> |
35 | #include <sys/klog.h> | 37 | #include <unistd.h> |
36 | #include <sys/socket.h> | 38 | #include <sys/socket.h> |
37 | #include <sys/stat.h> | 39 | #include <sys/stat.h> |
38 | #include <sys/types.h> | 40 | #include <sys/types.h> |
39 | #include <sys/un.h> | 41 | #include <sys/un.h> |
40 | #include <sys/param.h> | 42 | #include <sys/param.h> |
41 | #include <time.h> | 43 | #include <linux/unistd.h> |
42 | #include <unistd.h> | 44 | |
45 | #ifndef socklen_t | ||
46 | typedef unsigned int socklen_t; | ||
47 | #endif | ||
48 | |||
49 | #if __GNU_LIBRARY__ < 5 | ||
50 | |||
51 | #ifndef __alpha__ | ||
52 | # define __NR_klogctl __NR_syslog | ||
53 | static inline _syscall3(int, klogctl, int, type, char *, b, int, len); | ||
54 | #else /* __alpha__ */ | ||
55 | #define klogctl syslog | ||
56 | #endif | ||
57 | |||
58 | #else | ||
59 | # include <sys/klog.h> | ||
60 | #endif | ||
43 | 61 | ||
44 | #define ksyslog klogctl | ||
45 | extern int ksyslog(int type, char *buf, int len); | ||
46 | 62 | ||
47 | 63 | ||
48 | /* SYSLOG_NAMES defined to pull some extra junk from syslog.h */ | 64 | /* SYSLOG_NAMES defined to pull some extra junk from syslog.h */ |
@@ -171,8 +187,7 @@ static void domark(int sig) | |||
171 | } | 187 | } |
172 | 188 | ||
173 | #define BUFSIZE 1023 | 189 | #define BUFSIZE 1023 |
174 | static void serveConnection (int conn) __attribute__ ((noreturn)); | 190 | static int serveConnection (int conn) |
175 | static void serveConnection (int conn) | ||
176 | { | 191 | { |
177 | char buf[ BUFSIZE + 1 ]; | 192 | char buf[ BUFSIZE + 1 ]; |
178 | int n_read; | 193 | int n_read; |
@@ -210,7 +225,7 @@ static void serveConnection (int conn) | |||
210 | /* Now log it */ | 225 | /* Now log it */ |
211 | logMessage (pri, line); | 226 | logMessage (pri, line); |
212 | } | 227 | } |
213 | exit (0); | 228 | return (0); |
214 | } | 229 | } |
215 | 230 | ||
216 | static void doSyslogd (void) __attribute__ ((noreturn)); | 231 | static void doSyslogd (void) __attribute__ ((noreturn)); |
@@ -307,8 +322,8 @@ static void doSyslogd (void) | |||
307 | 322 | ||
308 | static void klogd_signal(int sig) | 323 | static void klogd_signal(int sig) |
309 | { | 324 | { |
310 | ksyslog(7, NULL, 0); | 325 | klogctl(7, NULL, 0); |
311 | ksyslog(0, 0, 0); | 326 | klogctl(0, 0, 0); |
312 | logMessage(0, "Kernel log daemon exiting."); | 327 | logMessage(0, "Kernel log daemon exiting."); |
313 | exit(TRUE); | 328 | exit(TRUE); |
314 | } | 329 | } |
@@ -328,12 +343,12 @@ static void doKlogd (void) | |||
328 | logMessage(0, "klogd started: " | 343 | logMessage(0, "klogd started: " |
329 | "BusyBox v" BB_VER " (" BB_BT ")"); | 344 | "BusyBox v" BB_VER " (" BB_BT ")"); |
330 | 345 | ||
331 | ksyslog(1, NULL, 0); | 346 | klogctl(1, NULL, 0); |
332 | 347 | ||
333 | while (1) { | 348 | while (1) { |
334 | /* Use kernel syscalls */ | 349 | /* Use kernel syscalls */ |
335 | memset(log_buffer, '\0', sizeof(log_buffer)); | 350 | memset(log_buffer, '\0', sizeof(log_buffer)); |
336 | if (ksyslog(2, log_buffer, sizeof(log_buffer)) < 0) { | 351 | if (klogctl(2, log_buffer, sizeof(log_buffer)) < 0) { |
337 | char message[80]; | 352 | char message[80]; |
338 | 353 | ||
339 | if (errno == EINTR) | 354 | if (errno == EINTR) |
@@ -464,7 +479,7 @@ extern int syslogd_main(int argc, char **argv) | |||
464 | doSyslogd(); | 479 | doSyslogd(); |
465 | } | 480 | } |
466 | 481 | ||
467 | exit(TRUE); | 482 | return(TRUE); |
468 | } | 483 | } |
469 | 484 | ||
470 | /* | 485 | /* |