aboutsummaryrefslogtreecommitdiff
path: root/sysklogd
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-08-22 18:41:20 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-08-22 18:41:20 +0000
commit9fef17dec333e17b1f24bc729d3b16725f4ccc75 (patch)
tree87eca9d8c978b9ea4736e05e4c480d51097e0319 /sysklogd
parent7c58e9be69b2a3f52977879b1a300579c9914b29 (diff)
downloadbusybox-w32-9fef17dec333e17b1f24bc729d3b16725f4ccc75.tar.gz
busybox-w32-9fef17dec333e17b1f24bc729d3b16725f4ccc75.tar.bz2
busybox-w32-9fef17dec333e17b1f24bc729d3b16725f4ccc75.zip
Run through indent, fix comments
Diffstat (limited to 'sysklogd')
-rw-r--r--sysklogd/klogd.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c
index 5eb13578b..4686a3429 100644
--- a/sysklogd/klogd.c
+++ b/sysklogd/klogd.c
@@ -33,9 +33,9 @@
33 33
34#include <stdio.h> 34#include <stdio.h>
35#include <stdlib.h> 35#include <stdlib.h>
36#include <signal.h> /* for our signal() handlers */ 36#include <signal.h> /* for our signal() handlers */
37#include <string.h> /* strncpy() */ 37#include <string.h> /* strncpy() */
38#include <errno.h> /* errno and friends */ 38#include <errno.h> /* errno and friends */
39#include <unistd.h> 39#include <unistd.h>
40#include <ctype.h> 40#include <ctype.h>
41#include <sys/syslog.h> 41#include <sys/syslog.h>
@@ -54,13 +54,13 @@ static void klogd_signal(int sig)
54{ 54{
55 klogctl(7, NULL, 0); 55 klogctl(7, NULL, 0);
56 klogctl(0, 0, 0); 56 klogctl(0, 0, 0);
57 //logMessage(0, "Kernel log daemon exiting."); 57 /* logMessage(0, "Kernel log daemon exiting."); */
58 syslog_msg(LOG_DAEMON, 0, "Kernel log daemon exiting."); 58 syslog_msg(LOG_DAEMON, 0, "Kernel log daemon exiting.");
59 exit(TRUE); 59 exit(TRUE);
60} 60}
61 61
62static void doKlogd (void) __attribute__ ((noreturn)); 62static void doKlogd(void) __attribute__ ((noreturn));
63static void doKlogd (void) 63static void doKlogd(void)
64{ 64{
65 int priority = LOG_INFO; 65 int priority = LOG_INFO;
66 char log_buffer[4096]; 66 char log_buffer[4096];
@@ -87,30 +87,32 @@ static void doKlogd (void)
87 87
88 if (errno == EINTR) 88 if (errno == EINTR)
89 continue; 89 continue;
90 snprintf(message, 79, "klogd: Error return from sys_sycall: %d - %s.\n", 90 snprintf(message, 79,
91 errno, strerror(errno)); 91 "klogd: Error return from sys_sycall: %d - %s.\n", errno,
92 strerror(errno));
92 syslog_msg(LOG_DAEMON, LOG_SYSLOG | LOG_ERR, message); 93 syslog_msg(LOG_DAEMON, LOG_SYSLOG | LOG_ERR, message);
93 exit(1); 94 exit(1);
94 } 95 }
95 96
96 /* klogctl buffer parsing modelled after code in dmesg.c */ 97 /* klogctl buffer parsing modelled after code in dmesg.c */
97 start=&log_buffer[0]; 98 start = &log_buffer[0];
98 lastc='\0'; 99 lastc = '\0';
99 for (i=0; i<n; i++) { 100 for (i = 0; i < n; i++) {
100 if (lastc == '\0' && log_buffer[i] == '<') { 101 if (lastc == '\0' && log_buffer[i] == '<') {
101 priority = 0; 102 priority = 0;
102 i++; 103 i++;
103 while (isdigit(log_buffer[i])) { 104 while (isdigit(log_buffer[i])) {
104 priority = priority*10+(log_buffer[i]-'0'); 105 priority = priority * 10 + (log_buffer[i] - '0');
105 i++; 106 i++;
106 } 107 }
107 if (log_buffer[i] == '>') i++; 108 if (log_buffer[i] == '>')
109 i++;
108 start = &log_buffer[i]; 110 start = &log_buffer[i];
109 } 111 }
110 if (log_buffer[i] == '\n') { 112 if (log_buffer[i] == '\n') {
111 log_buffer[i] = '\0'; /* zero terminate this message */ 113 log_buffer[i] = '\0'; /* zero terminate this message */
112 syslog_msg(LOG_DAEMON, LOG_KERN | priority, start); 114 syslog_msg(LOG_DAEMON, LOG_KERN | priority, start);
113 start = &log_buffer[i+1]; 115 start = &log_buffer[i + 1];
114 priority = LOG_INFO; 116 priority = LOG_INFO;
115 } 117 }
116 lastc = log_buffer[i]; 118 lastc = log_buffer[i];
@@ -127,11 +129,11 @@ extern int klogd_main(int argc, char **argv)
127 /* do normal option parsing */ 129 /* do normal option parsing */
128 while ((opt = getopt(argc, argv, "n")) > 0) { 130 while ((opt = getopt(argc, argv, "n")) > 0) {
129 switch (opt) { 131 switch (opt) {
130 case 'n': 132 case 'n':
131 doFork = FALSE; 133 doFork = FALSE;
132 break; 134 break;
133 default: 135 default:
134 show_usage(); 136 show_usage();
135 } 137 }
136 } 138 }
137 139
@@ -140,11 +142,11 @@ extern int klogd_main(int argc, char **argv)
140 if (daemon(0, 1) < 0) 142 if (daemon(0, 1) < 0)
141 perror_msg_and_die("daemon"); 143 perror_msg_and_die("daemon");
142#else 144#else
143 error_msg_and_die("daemon not supported"); 145 error_msg_and_die("daemon not supported");
144#endif 146#endif
145 } 147 }
146 doKlogd(); 148 doKlogd();
147 149
148 return EXIT_SUCCESS; 150 return EXIT_SUCCESS;
149} 151}
150 152