diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-19 19:24:06 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-19 19:24:06 +0000 |
commit | 1c1085caec1e039147e737dd6fbdd0de1f77cf31 (patch) | |
tree | 26a1f1080be5f9f44c72b45b72aae743d74685dd | |
parent | 55ff27793a2a50a13b7aed21deab3b97d7efb142 (diff) | |
download | busybox-w32-1c1085caec1e039147e737dd6fbdd0de1f77cf31.tar.gz busybox-w32-1c1085caec1e039147e737dd6fbdd0de1f77cf31.tar.bz2 busybox-w32-1c1085caec1e039147e737dd6fbdd0de1f77cf31.zip |
Split error messages into separate files.
Update libbb.h, per suggestion from Vladimir, to include __attribute__((format
(printf ...))) stuff
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@2145 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | include/libbb.h | 8 | ||||
-rw-r--r-- | libbb/Makefile | 11 | ||||
-rw-r--r-- | libbb/error_msg.c | 48 | ||||
-rw-r--r-- | libbb/error_msg_and_die.c | 53 | ||||
-rw-r--r-- | libbb/libbb.h | 8 | ||||
-rw-r--r-- | libbb/perror_msg.c | 51 | ||||
-rw-r--r-- | libbb/perror_msg_and_die.c | 52 | ||||
-rw-r--r-- | libbb/verror_msg.c | 51 | ||||
-rw-r--r-- | libbb/vperror_msg.c | 51 |
10 files changed, 285 insertions, 53 deletions
@@ -110,6 +110,8 @@ OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2> | |||
110 | 110 | ||
111 | WARNINGS = -Wall | 111 | WARNINGS = -Wall |
112 | 112 | ||
113 | ARFLAGS = -r | ||
114 | |||
113 | # | 115 | # |
114 | #-------------------------------------------------------- | 116 | #-------------------------------------------------------- |
115 | # If you're going to do a lot of builds with a non-vanilla configuration, | 117 | # If you're going to do a lot of builds with a non-vanilla configuration, |
@@ -233,7 +235,8 @@ mode_string.c parse_mode.c parse_number.c print_file.c process_escape_sequence.c | |||
233 | my_getgrgid.c my_getpwnamegid.c my_getpwuid.c my_getgrnam.c my_getpwnam.c \ | 235 | my_getgrgid.c my_getpwnamegid.c my_getpwuid.c my_getgrnam.c my_getpwnam.c \ |
234 | recursive_action.c safe_read.c safe_strncpy.c syscalls.c \ | 236 | recursive_action.c safe_read.c safe_strncpy.c syscalls.c \ |
235 | syslog_msg_with_name.c time_string.c trim.c vdprintf.c wfopen.c xfuncs.c \ | 237 | syslog_msg_with_name.c time_string.c trim.c vdprintf.c wfopen.c xfuncs.c \ |
236 | xregcomp.c | 238 | xregcomp.c error_msg_and_die.c perror_msg.c perror_msg_and_die.c \ |
239 | verror_msg.c vperror_msg.c | ||
237 | LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC)) | 240 | LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC)) |
238 | LIBBB_CFLAGS = -I$(LIBBB_DIR) | 241 | LIBBB_CFLAGS = -I$(LIBBB_DIR) |
239 | 242 | ||
diff --git a/include/libbb.h b/include/libbb.h index a85987d9e..4c23b2b80 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -68,11 +68,15 @@ static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); } | |||
68 | 68 | ||
69 | 69 | ||
70 | extern void show_usage(void) __attribute__ ((noreturn)); | 70 | extern void show_usage(void) __attribute__ ((noreturn)); |
71 | extern void error_msg(const char *s, ...); | 71 | extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); |
72 | extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn)); | 72 | extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); |
73 | extern void perror_msg(const char *s, ...); | 73 | extern void perror_msg(const char *s, ...); |
74 | extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn)); | 74 | extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn)); |
75 | 75 | ||
76 | /* These two are used internally -- you shouldn't need to use them */ | ||
77 | extern void verror_msg(const char *s, va_list p); | ||
78 | extern void vperror_msg(const char *s, va_list p); | ||
79 | |||
76 | const char *mode_string(int mode); | 80 | const char *mode_string(int mode); |
77 | const char *time_string(time_t timeVal); | 81 | const char *time_string(time_t timeVal); |
78 | int is_directory(const char *name, const int followLinks, struct stat *statBuf); | 82 | int is_directory(const char *name, const int followLinks, struct stat *statBuf); |
diff --git a/libbb/Makefile b/libbb/Makefile new file mode 100644 index 000000000..a9ea76947 --- /dev/null +++ b/libbb/Makefile | |||
@@ -0,0 +1,11 @@ | |||
1 | # Silly wrapper makefile. This Makefile is _not_ used by the build system for | ||
2 | # busybox, it is just to make working on libbb more conveinient. | ||
3 | # -Erik Andersen | ||
4 | |||
5 | all: | ||
6 | make -C .. libbb.a | ||
7 | |||
8 | clean: | ||
9 | - rm -rf libbb.a | ||
10 | - find -name \*.o -exec rm -f {} \; | ||
11 | |||
diff --git a/libbb/error_msg.c b/libbb/error_msg.c index 7773d32a2..c7d5fdb98 100644 --- a/libbb/error_msg.c +++ b/libbb/error_msg.c | |||
@@ -31,15 +31,6 @@ | |||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | #include "libbb.h" | 32 | #include "libbb.h" |
33 | 33 | ||
34 | extern const char *applet_name; | ||
35 | |||
36 | static void verror_msg(const char *s, va_list p) | ||
37 | { | ||
38 | fflush(stdout); | ||
39 | fprintf(stderr, "%s: ", applet_name); | ||
40 | vfprintf(stderr, s, p); | ||
41 | } | ||
42 | |||
43 | extern void error_msg(const char *s, ...) | 34 | extern void error_msg(const char *s, ...) |
44 | { | 35 | { |
45 | va_list p; | 36 | va_list p; |
@@ -50,45 +41,6 @@ extern void error_msg(const char *s, ...) | |||
50 | putc('\n', stderr); | 41 | putc('\n', stderr); |
51 | } | 42 | } |
52 | 43 | ||
53 | extern void error_msg_and_die(const char *s, ...) | ||
54 | { | ||
55 | va_list p; | ||
56 | |||
57 | va_start(p, s); | ||
58 | verror_msg(s, p); | ||
59 | va_end(p); | ||
60 | putc('\n', stderr); | ||
61 | exit(EXIT_FAILURE); | ||
62 | } | ||
63 | |||
64 | static void vperror_msg(const char *s, va_list p) | ||
65 | { | ||
66 | int err=errno; | ||
67 | if(s == 0) s = ""; | ||
68 | verror_msg(s, p); | ||
69 | if (*s) s = ": "; | ||
70 | fprintf(stderr, "%s%s\n", s, strerror(err)); | ||
71 | } | ||
72 | |||
73 | extern void perror_msg(const char *s, ...) | ||
74 | { | ||
75 | va_list p; | ||
76 | |||
77 | va_start(p, s); | ||
78 | vperror_msg(s, p); | ||
79 | va_end(p); | ||
80 | } | ||
81 | |||
82 | extern void perror_msg_and_die(const char *s, ...) | ||
83 | { | ||
84 | va_list p; | ||
85 | |||
86 | va_start(p, s); | ||
87 | vperror_msg(s, p); | ||
88 | va_end(p); | ||
89 | exit(EXIT_FAILURE); | ||
90 | } | ||
91 | |||
92 | 44 | ||
93 | /* END CODE */ | 45 | /* END CODE */ |
94 | /* | 46 | /* |
diff --git a/libbb/error_msg_and_die.c b/libbb/error_msg_and_die.c new file mode 100644 index 000000000..b950ee00c --- /dev/null +++ b/libbb/error_msg_and_die.c | |||
@@ -0,0 +1,53 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Utility routines. | ||
4 | * | ||
5 | * Copyright (C) tons of folks. Tracking down who wrote what | ||
6 | * isn't something I'm going to worry about... If you wrote something | ||
7 | * here, please feel free to acknowledge your work. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
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 02111-1307 USA | ||
22 | * | ||
23 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell | ||
24 | * Permission has been granted to redistribute this code under the GPL. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <errno.h> | ||
30 | #include <string.h> | ||
31 | #include <stdlib.h> | ||
32 | #include "libbb.h" | ||
33 | |||
34 | extern void error_msg_and_die(const char *s, ...) | ||
35 | { | ||
36 | va_list p; | ||
37 | |||
38 | va_start(p, s); | ||
39 | verror_msg(s, p); | ||
40 | va_end(p); | ||
41 | putc('\n', stderr); | ||
42 | exit(EXIT_FAILURE); | ||
43 | } | ||
44 | |||
45 | |||
46 | /* END CODE */ | ||
47 | /* | ||
48 | Local Variables: | ||
49 | c-file-style: "linux" | ||
50 | c-basic-offset: 4 | ||
51 | tab-width: 4 | ||
52 | End: | ||
53 | */ | ||
diff --git a/libbb/libbb.h b/libbb/libbb.h index a85987d9e..4c23b2b80 100644 --- a/libbb/libbb.h +++ b/libbb/libbb.h | |||
@@ -68,11 +68,15 @@ static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); } | |||
68 | 68 | ||
69 | 69 | ||
70 | extern void show_usage(void) __attribute__ ((noreturn)); | 70 | extern void show_usage(void) __attribute__ ((noreturn)); |
71 | extern void error_msg(const char *s, ...); | 71 | extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); |
72 | extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn)); | 72 | extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); |
73 | extern void perror_msg(const char *s, ...); | 73 | extern void perror_msg(const char *s, ...); |
74 | extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn)); | 74 | extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn)); |
75 | 75 | ||
76 | /* These two are used internally -- you shouldn't need to use them */ | ||
77 | extern void verror_msg(const char *s, va_list p); | ||
78 | extern void vperror_msg(const char *s, va_list p); | ||
79 | |||
76 | const char *mode_string(int mode); | 80 | const char *mode_string(int mode); |
77 | const char *time_string(time_t timeVal); | 81 | const char *time_string(time_t timeVal); |
78 | int is_directory(const char *name, const int followLinks, struct stat *statBuf); | 82 | int is_directory(const char *name, const int followLinks, struct stat *statBuf); |
diff --git a/libbb/perror_msg.c b/libbb/perror_msg.c new file mode 100644 index 000000000..18c71ab1c --- /dev/null +++ b/libbb/perror_msg.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Utility routines. | ||
4 | * | ||
5 | * Copyright (C) tons of folks. Tracking down who wrote what | ||
6 | * isn't something I'm going to worry about... If you wrote something | ||
7 | * here, please feel free to acknowledge your work. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
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 02111-1307 USA | ||
22 | * | ||
23 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell | ||
24 | * Permission has been granted to redistribute this code under the GPL. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <errno.h> | ||
30 | #include <string.h> | ||
31 | #include <stdlib.h> | ||
32 | #include "libbb.h" | ||
33 | |||
34 | extern void perror_msg(const char *s, ...) | ||
35 | { | ||
36 | va_list p; | ||
37 | |||
38 | va_start(p, s); | ||
39 | vperror_msg(s, p); | ||
40 | va_end(p); | ||
41 | } | ||
42 | |||
43 | |||
44 | /* END CODE */ | ||
45 | /* | ||
46 | Local Variables: | ||
47 | c-file-style: "linux" | ||
48 | c-basic-offset: 4 | ||
49 | tab-width: 4 | ||
50 | End: | ||
51 | */ | ||
diff --git a/libbb/perror_msg_and_die.c b/libbb/perror_msg_and_die.c new file mode 100644 index 000000000..9d304a26b --- /dev/null +++ b/libbb/perror_msg_and_die.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Utility routines. | ||
4 | * | ||
5 | * Copyright (C) tons of folks. Tracking down who wrote what | ||
6 | * isn't something I'm going to worry about... If you wrote something | ||
7 | * here, please feel free to acknowledge your work. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
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 02111-1307 USA | ||
22 | * | ||
23 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell | ||
24 | * Permission has been granted to redistribute this code under the GPL. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <errno.h> | ||
30 | #include <string.h> | ||
31 | #include <stdlib.h> | ||
32 | #include "libbb.h" | ||
33 | |||
34 | extern void perror_msg_and_die(const char *s, ...) | ||
35 | { | ||
36 | va_list p; | ||
37 | |||
38 | va_start(p, s); | ||
39 | vperror_msg(s, p); | ||
40 | va_end(p); | ||
41 | exit(EXIT_FAILURE); | ||
42 | } | ||
43 | |||
44 | |||
45 | /* END CODE */ | ||
46 | /* | ||
47 | Local Variables: | ||
48 | c-file-style: "linux" | ||
49 | c-basic-offset: 4 | ||
50 | tab-width: 4 | ||
51 | End: | ||
52 | */ | ||
diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c new file mode 100644 index 000000000..b5278cfb7 --- /dev/null +++ b/libbb/verror_msg.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Utility routines. | ||
4 | * | ||
5 | * Copyright (C) tons of folks. Tracking down who wrote what | ||
6 | * isn't something I'm going to worry about... If you wrote something | ||
7 | * here, please feel free to acknowledge your work. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
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 02111-1307 USA | ||
22 | * | ||
23 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell | ||
24 | * Permission has been granted to redistribute this code under the GPL. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <errno.h> | ||
30 | #include <string.h> | ||
31 | #include <stdlib.h> | ||
32 | #include "libbb.h" | ||
33 | |||
34 | extern const char *applet_name; | ||
35 | |||
36 | extern void verror_msg(const char *s, va_list p) | ||
37 | { | ||
38 | fflush(stdout); | ||
39 | fprintf(stderr, "%s: ", applet_name); | ||
40 | vfprintf(stderr, s, p); | ||
41 | } | ||
42 | |||
43 | |||
44 | /* END CODE */ | ||
45 | /* | ||
46 | Local Variables: | ||
47 | c-file-style: "linux" | ||
48 | c-basic-offset: 4 | ||
49 | tab-width: 4 | ||
50 | End: | ||
51 | */ | ||
diff --git a/libbb/vperror_msg.c b/libbb/vperror_msg.c new file mode 100644 index 000000000..ca9361e45 --- /dev/null +++ b/libbb/vperror_msg.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Utility routines. | ||
4 | * | ||
5 | * Copyright (C) tons of folks. Tracking down who wrote what | ||
6 | * isn't something I'm going to worry about... If you wrote something | ||
7 | * here, please feel free to acknowledge your work. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
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 02111-1307 USA | ||
22 | * | ||
23 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell | ||
24 | * Permission has been granted to redistribute this code under the GPL. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <errno.h> | ||
30 | #include <string.h> | ||
31 | #include <stdlib.h> | ||
32 | #include "libbb.h" | ||
33 | |||
34 | extern void vperror_msg(const char *s, va_list p) | ||
35 | { | ||
36 | int err=errno; | ||
37 | if(s == 0) s = ""; | ||
38 | verror_msg(s, p); | ||
39 | if (*s) s = ": "; | ||
40 | fprintf(stderr, "%s%s\n", s, strerror(err)); | ||
41 | } | ||
42 | |||
43 | |||
44 | /* END CODE */ | ||
45 | /* | ||
46 | Local Variables: | ||
47 | c-file-style: "linux" | ||
48 | c-basic-offset: 4 | ||
49 | tab-width: 4 | ||
50 | End: | ||
51 | */ | ||