diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-06-01 14:36:14 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-06-01 14:36:14 +0000 |
commit | d04e9b813092162b59016ce10976fb91851b5f85 (patch) | |
tree | 8fcb42c4d67daedc864a6c9b18e2efd366366252 | |
parent | d112f8fa5e28fe21cf375d4dc3307dcfbdb3a300 (diff) | |
download | busybox-w32-d04e9b813092162b59016ce10976fb91851b5f85.tar.gz busybox-w32-d04e9b813092162b59016ce10976fb91851b5f85.tar.bz2 busybox-w32-d04e9b813092162b59016ce10976fb91851b5f85.zip |
- shrink logread a bit.
text data bss dec hex filename
862 26 188 1076 434 logread.o.orig
825 26 188 1039 40f logread.o
-rw-r--r-- | sysklogd/logread.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/sysklogd/logread.c b/sysklogd/logread.c index 73ad5a8fe..54e53a600 100644 --- a/sysklogd/logread.c +++ b/sysklogd/logread.c | |||
@@ -6,24 +6,11 @@ | |||
6 | * | 6 | * |
7 | * Maintainer: Gennady Feldman <gfeldman@gena01.com> as of Mar 12, 2001 | 7 | * Maintainer: Gennady Feldman <gfeldman@gena01.com> as of Mar 12, 2001 |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
22 | * 02111-1307 USA | ||
23 | * | ||
24 | */ | 10 | */ |
25 | 11 | ||
26 | 12 | ||
13 | #include "busybox.h" | ||
27 | #include <stdio.h> | 14 | #include <stdio.h> |
28 | #include <stdlib.h> | 15 | #include <stdlib.h> |
29 | #include <string.h> | 16 | #include <string.h> |
@@ -34,7 +21,6 @@ | |||
34 | #include <signal.h> | 21 | #include <signal.h> |
35 | #include <setjmp.h> | 22 | #include <setjmp.h> |
36 | #include <unistd.h> | 23 | #include <unistd.h> |
37 | #include "busybox.h" | ||
38 | 24 | ||
39 | static const long KEY_ID = 0x414e4547; /*"GENA"*/ | 25 | static const long KEY_ID = 0x414e4547; /*"GENA"*/ |
40 | 26 | ||
@@ -80,7 +66,7 @@ int logread_main(int argc, char **argv) | |||
80 | int i; | 66 | int i; |
81 | int follow=0; | 67 | int follow=0; |
82 | 68 | ||
83 | if (argc == 2 && strcmp(argv[1],"-f")==0) { | 69 | if (argc == 2 && argv[1][0]=='-' && argv[1][1]=='f') { |
84 | follow = 1; | 70 | follow = 1; |
85 | } else { | 71 | } else { |
86 | /* no options, no getopt */ | 72 | /* no options, no getopt */ |
@@ -88,7 +74,7 @@ int logread_main(int argc, char **argv) | |||
88 | bb_show_usage(); | 74 | bb_show_usage(); |
89 | } | 75 | } |
90 | 76 | ||
91 | // handle intrrupt signal | 77 | // handle interrupt signal |
92 | if (setjmp(jmp_env)) goto output_end; | 78 | if (setjmp(jmp_env)) goto output_end; |
93 | 79 | ||
94 | // attempt to redefine ^C signal | 80 | // attempt to redefine ^C signal |
@@ -131,9 +117,7 @@ int logread_main(int argc, char **argv) | |||
131 | log_len = buf->tail - i; | 117 | log_len = buf->tail - i; |
132 | if (log_len < 0) | 118 | if (log_len < 0) |
133 | log_len += buf->size; | 119 | log_len += buf->size; |
134 | buf_data = (char *)malloc(log_len); | 120 | buf_data = (char *)xmalloc(log_len); |
135 | if (!buf_data) | ||
136 | error_exit("malloc failed"); | ||
137 | 121 | ||
138 | if (buf->tail < i) { | 122 | if (buf->tail < i) { |
139 | memcpy(buf_data, buf->data+i, buf->size-i); | 123 | memcpy(buf_data, buf->data+i, buf->size-i); |
@@ -178,7 +162,7 @@ static void interrupted(int sig){ | |||
178 | } | 162 | } |
179 | 163 | ||
180 | static void error_exit(const char *str){ | 164 | static void error_exit(const char *str){ |
181 | perror(str); | 165 | bb_perror_msg(str); |
182 | //release all acquired resources | 166 | //release all acquired resources |
183 | if (log_shmid != -1) | 167 | if (log_shmid != -1) |
184 | shmdt(buf); | 168 | shmdt(buf); |