diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-08-02 10:55:32 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-08-02 10:55:32 +0000 |
commit | be0c36009a342de3599d498d6f150030b6a75b98 (patch) | |
tree | 5af27e4751ecae51387a99872b66a8cd6e621caa | |
parent | 23b1e5c7df2e619654d0a53785fcdef5072b40ed (diff) | |
download | busybox-w32-be0c36009a342de3599d498d6f150030b6a75b98.tar.gz busybox-w32-be0c36009a342de3599d498d6f150030b6a75b98.tar.bz2 busybox-w32-be0c36009a342de3599d498d6f150030b6a75b98.zip |
More libc5 fixups
-Erik
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | coreutils/dos2unix.c | 5 | ||||
-rw-r--r-- | dos2unix.c | 5 | ||||
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | libbb/libbb.h | 2 | ||||
-rw-r--r-- | libbb/libc5.c (renamed from libbb/daemon.c) | 84 | ||||
-rw-r--r-- | networking/traceroute.c | 90 | ||||
-rw-r--r-- | traceroute.c | 90 |
8 files changed, 270 insertions, 10 deletions
@@ -235,7 +235,7 @@ endif | |||
235 | LIBBB = libbb | 235 | LIBBB = libbb |
236 | LIBBB_LIB = libbb.a | 236 | LIBBB_LIB = libbb.a |
237 | LIBBB_CSRC= ask_confirmation.c chomp.c concat_path_file.c copy_file.c \ | 237 | LIBBB_CSRC= ask_confirmation.c chomp.c concat_path_file.c copy_file.c \ |
238 | copy_file_chunk.c daemon.c device_open.c error_msg.c \ | 238 | copy_file_chunk.c libc5.c device_open.c error_msg.c \ |
239 | error_msg_and_die.c fgets_str.c find_mount_point.c find_pid_by_name.c \ | 239 | error_msg_and_die.c fgets_str.c find_mount_point.c find_pid_by_name.c \ |
240 | find_root_device.c full_read.c full_write.c get_console.c \ | 240 | find_root_device.c full_read.c full_write.c get_console.c \ |
241 | get_last_path_component.c get_line_from_file.c gz_open.c human_readable.c \ | 241 | get_last_path_component.c get_line_from_file.c gz_open.c human_readable.c \ |
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c index 68aee13c5..02b70d915 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c | |||
@@ -34,6 +34,11 @@ | |||
34 | #include <sys/time.h> | 34 | #include <sys/time.h> |
35 | #include "busybox.h" | 35 | #include "busybox.h" |
36 | 36 | ||
37 | /* Teach libc5 what a uint64_t is */ | ||
38 | #if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1) | ||
39 | typedef unsigned long int uint64_t; | ||
40 | #endif | ||
41 | |||
37 | static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | 42 | static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
38 | 43 | ||
39 | // if fn is NULL then input is stdin and output is stdout | 44 | // if fn is NULL then input is stdin and output is stdout |
diff --git a/dos2unix.c b/dos2unix.c index 68aee13c5..02b70d915 100644 --- a/dos2unix.c +++ b/dos2unix.c | |||
@@ -34,6 +34,11 @@ | |||
34 | #include <sys/time.h> | 34 | #include <sys/time.h> |
35 | #include "busybox.h" | 35 | #include "busybox.h" |
36 | 36 | ||
37 | /* Teach libc5 what a uint64_t is */ | ||
38 | #if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1) | ||
39 | typedef unsigned long int uint64_t; | ||
40 | #endif | ||
41 | |||
37 | static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | 42 | static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
38 | 43 | ||
39 | // if fn is NULL then input is stdin and output is stdout | 44 | // if fn is NULL then input is stdin and output is stdout |
diff --git a/include/libbb.h b/include/libbb.h index 70ac36a86..04ed2ae82 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -46,6 +46,8 @@ | |||
46 | typedef unsigned int socklen_t; | 46 | typedef unsigned int socklen_t; |
47 | /* libc5 doesn't implement BSD 4.4 daemon() */ | 47 | /* libc5 doesn't implement BSD 4.4 daemon() */ |
48 | extern int daemon (int nochdir, int noclose); | 48 | extern int daemon (int nochdir, int noclose); |
49 | /* libc5 doesn't implement strtok_r */ | ||
50 | char *strtok_r(char *s, const char *delim, char **ptrptr); | ||
49 | #endif | 51 | #endif |
50 | 52 | ||
51 | /* Some useful definitions */ | 53 | /* Some useful definitions */ |
diff --git a/libbb/libbb.h b/libbb/libbb.h index 70ac36a86..04ed2ae82 100644 --- a/libbb/libbb.h +++ b/libbb/libbb.h | |||
@@ -46,6 +46,8 @@ | |||
46 | typedef unsigned int socklen_t; | 46 | typedef unsigned int socklen_t; |
47 | /* libc5 doesn't implement BSD 4.4 daemon() */ | 47 | /* libc5 doesn't implement BSD 4.4 daemon() */ |
48 | extern int daemon (int nochdir, int noclose); | 48 | extern int daemon (int nochdir, int noclose); |
49 | /* libc5 doesn't implement strtok_r */ | ||
50 | char *strtok_r(char *s, const char *delim, char **ptrptr); | ||
49 | #endif | 51 | #endif |
50 | 52 | ||
51 | /* Some useful definitions */ | 53 | /* Some useful definitions */ |
diff --git a/libbb/daemon.c b/libbb/libc5.c index 6d4169ed5..20295fd4b 100644 --- a/libbb/daemon.c +++ b/libbb/libc5.c | |||
@@ -1,4 +1,77 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | |||
3 | |||
4 | #include <features.h> | ||
5 | #include <string.h> | ||
6 | #include <stdio.h> | ||
7 | #include <fcntl.h> | ||
8 | #include <paths.h> | ||
9 | #include <unistd.h> | ||
10 | |||
11 | |||
12 | #if __GNU_LIBRARY__ < 5 | ||
13 | |||
14 | |||
15 | /* Copyright (C) 1991 Free Software Foundation, Inc. | ||
16 | This file is part of the GNU C Library. | ||
17 | |||
18 | The GNU C Library is free software; you can redistribute it and/or | ||
19 | modify it under the terms of the GNU Library General Public License as | ||
20 | published by the Free Software Foundation; either version 2 of the | ||
21 | License, or (at your option) any later version. | ||
22 | |||
23 | The GNU C Library is distributed in the hope that it will be useful, | ||
24 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
26 | Library General Public License for more details. | ||
27 | |||
28 | You should have received a copy of the GNU Library General Public | ||
29 | License along with the GNU C Library; see the file COPYING.LIB. If | ||
30 | not, write to the Free Software Foundation, Inc., 675 Mass Ave, | ||
31 | Cambridge, MA 02139, USA. */ | ||
32 | |||
33 | /* | ||
34 | * Modified by Manuel Novoa III Mar 1, 2001 | ||
35 | * | ||
36 | * Converted original strtok.c code of strtok to __strtok_r. | ||
37 | * Cleaned up logic and reduced code size. | ||
38 | */ | ||
39 | |||
40 | |||
41 | char *strtok_r(char *s, const char *delim, char **save_ptr) | ||
42 | { | ||
43 | char *token; | ||
44 | |||
45 | token = 0; /* Initialize to no token. */ | ||
46 | |||
47 | if (s == 0) { /* If not first time called... */ | ||
48 | s = *save_ptr; /* restart from where we left off. */ | ||
49 | } | ||
50 | |||
51 | if (s != 0) { /* If not finished... */ | ||
52 | *save_ptr = 0; | ||
53 | |||
54 | s += strspn(s, delim); /* Skip past any leading delimiters. */ | ||
55 | if (*s != '\0') { /* We have a token. */ | ||
56 | token = s; | ||
57 | *save_ptr = strpbrk(token, delim); /* Find token's end. */ | ||
58 | if (*save_ptr != 0) { | ||
59 | /* Terminate the token and make SAVE_PTR point past it. */ | ||
60 | *(*save_ptr)++ = '\0'; | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | |||
65 | return token; | ||
66 | } | ||
67 | |||
68 | /* Basically getdelim() with the delimiter hard wired to '\n' */ | ||
69 | ssize_t getline(char **linebuf, size_t *n, FILE *file) | ||
70 | { | ||
71 | return (getdelim (linebuf, n, '\n', file)); | ||
72 | } | ||
73 | |||
74 | |||
2 | /* | 75 | /* |
3 | * daemon implementation for uClibc | 76 | * daemon implementation for uClibc |
4 | * | 77 | * |
@@ -26,14 +99,6 @@ | |||
26 | * Original copyright notice is retained at the end of this file. | 99 | * Original copyright notice is retained at the end of this file. |
27 | */ | 100 | */ |
28 | 101 | ||
29 | #include <features.h> | ||
30 | #include <fcntl.h> | ||
31 | #include <paths.h> | ||
32 | #include <unistd.h> | ||
33 | |||
34 | |||
35 | #if __GNU_LIBRARY__ < 5 | ||
36 | |||
37 | int daemon( int nochdir, int noclose ) | 102 | int daemon( int nochdir, int noclose ) |
38 | { | 103 | { |
39 | int fd; | 104 | int fd; |
@@ -62,7 +127,6 @@ int daemon( int nochdir, int noclose ) | |||
62 | } | 127 | } |
63 | return(0); | 128 | return(0); |
64 | } | 129 | } |
65 | #endif | ||
66 | 130 | ||
67 | 131 | ||
68 | /*- | 132 | /*- |
@@ -99,3 +163,5 @@ int daemon( int nochdir, int noclose ) | |||
99 | */ | 163 | */ |
100 | 164 | ||
101 | 165 | ||
166 | #endif | ||
167 | |||
diff --git a/networking/traceroute.c b/networking/traceroute.c index f4c67cf41..a3abd0a00 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -81,6 +81,96 @@ | |||
81 | #include <netinet/ip.h> | 81 | #include <netinet/ip.h> |
82 | #include <netinet/ip_icmp.h> | 82 | #include <netinet/ip_icmp.h> |
83 | 83 | ||
84 | |||
85 | /* It turns out that libc5 doesn't have proper icmp support | ||
86 | * built into it header files, so we have to supplement it */ | ||
87 | #if __GNU_LIBRARY__ < 5 | ||
88 | static const int ICMP_MINLEN = 8; /* abs minimum */ | ||
89 | |||
90 | struct icmp_ra_addr | ||
91 | { | ||
92 | u_int32_t ira_addr; | ||
93 | u_int32_t ira_preference; | ||
94 | }; | ||
95 | |||
96 | |||
97 | struct icmp | ||
98 | { | ||
99 | u_int8_t icmp_type; /* type of message, see below */ | ||
100 | u_int8_t icmp_code; /* type sub code */ | ||
101 | u_int16_t icmp_cksum; /* ones complement checksum of struct */ | ||
102 | union | ||
103 | { | ||
104 | u_char ih_pptr; /* ICMP_PARAMPROB */ | ||
105 | struct in_addr ih_gwaddr; /* gateway address */ | ||
106 | struct ih_idseq /* echo datagram */ | ||
107 | { | ||
108 | u_int16_t icd_id; | ||
109 | u_int16_t icd_seq; | ||
110 | } ih_idseq; | ||
111 | u_int32_t ih_void; | ||
112 | |||
113 | /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ | ||
114 | struct ih_pmtu | ||
115 | { | ||
116 | u_int16_t ipm_void; | ||
117 | u_int16_t ipm_nextmtu; | ||
118 | } ih_pmtu; | ||
119 | |||
120 | struct ih_rtradv | ||
121 | { | ||
122 | u_int8_t irt_num_addrs; | ||
123 | u_int8_t irt_wpa; | ||
124 | u_int16_t irt_lifetime; | ||
125 | } ih_rtradv; | ||
126 | } icmp_hun; | ||
127 | #define icmp_pptr icmp_hun.ih_pptr | ||
128 | #define icmp_gwaddr icmp_hun.ih_gwaddr | ||
129 | #define icmp_id icmp_hun.ih_idseq.icd_id | ||
130 | #define icmp_seq icmp_hun.ih_idseq.icd_seq | ||
131 | #define icmp_void icmp_hun.ih_void | ||
132 | #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void | ||
133 | #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu | ||
134 | #define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs | ||
135 | #define icmp_wpa icmp_hun.ih_rtradv.irt_wpa | ||
136 | #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime | ||
137 | union | ||
138 | { | ||
139 | struct | ||
140 | { | ||
141 | u_int32_t its_otime; | ||
142 | u_int32_t its_rtime; | ||
143 | u_int32_t its_ttime; | ||
144 | } id_ts; | ||
145 | struct | ||
146 | { | ||
147 | struct ip idi_ip; | ||
148 | /* options and then 64 bits of data */ | ||
149 | } id_ip; | ||
150 | struct icmp_ra_addr id_radv; | ||
151 | u_int32_t id_mask; | ||
152 | u_int8_t id_data[1]; | ||
153 | } icmp_dun; | ||
154 | #define icmp_otime icmp_dun.id_ts.its_otime | ||
155 | #define icmp_rtime icmp_dun.id_ts.its_rtime | ||
156 | #define icmp_ttime icmp_dun.id_ts.its_ttime | ||
157 | #define icmp_ip icmp_dun.id_ip.idi_ip | ||
158 | #define icmp_radv icmp_dun.id_radv | ||
159 | #define icmp_mask icmp_dun.id_mask | ||
160 | #define icmp_data icmp_dun.id_data | ||
161 | }; | ||
162 | |||
163 | #define ICMP_MINLEN 8 /* abs minimum */ | ||
164 | #define ICMP_UNREACH 3 /* dest unreachable, codes: */ | ||
165 | #define ICMP_TIMXCEED 11 /* time exceeded, code: */ | ||
166 | #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ | ||
167 | #define ICMP_UNREACH_NET 0 /* bad net */ | ||
168 | #define ICMP_UNREACH_HOST 1 /* bad host */ | ||
169 | #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ | ||
170 | #define ICMP_UNREACH_PORT 3 /* bad port */ | ||
171 | #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ | ||
172 | #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ | ||
173 | #endif | ||
84 | 174 | ||
85 | 175 | ||
86 | #define MAXPACKET 65535 /* max ip packet size */ | 176 | #define MAXPACKET 65535 /* max ip packet size */ |
diff --git a/traceroute.c b/traceroute.c index f4c67cf41..a3abd0a00 100644 --- a/traceroute.c +++ b/traceroute.c | |||
@@ -81,6 +81,96 @@ | |||
81 | #include <netinet/ip.h> | 81 | #include <netinet/ip.h> |
82 | #include <netinet/ip_icmp.h> | 82 | #include <netinet/ip_icmp.h> |
83 | 83 | ||
84 | |||
85 | /* It turns out that libc5 doesn't have proper icmp support | ||
86 | * built into it header files, so we have to supplement it */ | ||
87 | #if __GNU_LIBRARY__ < 5 | ||
88 | static const int ICMP_MINLEN = 8; /* abs minimum */ | ||
89 | |||
90 | struct icmp_ra_addr | ||
91 | { | ||
92 | u_int32_t ira_addr; | ||
93 | u_int32_t ira_preference; | ||
94 | }; | ||
95 | |||
96 | |||
97 | struct icmp | ||
98 | { | ||
99 | u_int8_t icmp_type; /* type of message, see below */ | ||
100 | u_int8_t icmp_code; /* type sub code */ | ||
101 | u_int16_t icmp_cksum; /* ones complement checksum of struct */ | ||
102 | union | ||
103 | { | ||
104 | u_char ih_pptr; /* ICMP_PARAMPROB */ | ||
105 | struct in_addr ih_gwaddr; /* gateway address */ | ||
106 | struct ih_idseq /* echo datagram */ | ||
107 | { | ||
108 | u_int16_t icd_id; | ||
109 | u_int16_t icd_seq; | ||
110 | } ih_idseq; | ||
111 | u_int32_t ih_void; | ||
112 | |||
113 | /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ | ||
114 | struct ih_pmtu | ||
115 | { | ||
116 | u_int16_t ipm_void; | ||
117 | u_int16_t ipm_nextmtu; | ||
118 | } ih_pmtu; | ||
119 | |||
120 | struct ih_rtradv | ||
121 | { | ||
122 | u_int8_t irt_num_addrs; | ||
123 | u_int8_t irt_wpa; | ||
124 | u_int16_t irt_lifetime; | ||
125 | } ih_rtradv; | ||
126 | } icmp_hun; | ||
127 | #define icmp_pptr icmp_hun.ih_pptr | ||
128 | #define icmp_gwaddr icmp_hun.ih_gwaddr | ||
129 | #define icmp_id icmp_hun.ih_idseq.icd_id | ||
130 | #define icmp_seq icmp_hun.ih_idseq.icd_seq | ||
131 | #define icmp_void icmp_hun.ih_void | ||
132 | #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void | ||
133 | #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu | ||
134 | #define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs | ||
135 | #define icmp_wpa icmp_hun.ih_rtradv.irt_wpa | ||
136 | #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime | ||
137 | union | ||
138 | { | ||
139 | struct | ||
140 | { | ||
141 | u_int32_t its_otime; | ||
142 | u_int32_t its_rtime; | ||
143 | u_int32_t its_ttime; | ||
144 | } id_ts; | ||
145 | struct | ||
146 | { | ||
147 | struct ip idi_ip; | ||
148 | /* options and then 64 bits of data */ | ||
149 | } id_ip; | ||
150 | struct icmp_ra_addr id_radv; | ||
151 | u_int32_t id_mask; | ||
152 | u_int8_t id_data[1]; | ||
153 | } icmp_dun; | ||
154 | #define icmp_otime icmp_dun.id_ts.its_otime | ||
155 | #define icmp_rtime icmp_dun.id_ts.its_rtime | ||
156 | #define icmp_ttime icmp_dun.id_ts.its_ttime | ||
157 | #define icmp_ip icmp_dun.id_ip.idi_ip | ||
158 | #define icmp_radv icmp_dun.id_radv | ||
159 | #define icmp_mask icmp_dun.id_mask | ||
160 | #define icmp_data icmp_dun.id_data | ||
161 | }; | ||
162 | |||
163 | #define ICMP_MINLEN 8 /* abs minimum */ | ||
164 | #define ICMP_UNREACH 3 /* dest unreachable, codes: */ | ||
165 | #define ICMP_TIMXCEED 11 /* time exceeded, code: */ | ||
166 | #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ | ||
167 | #define ICMP_UNREACH_NET 0 /* bad net */ | ||
168 | #define ICMP_UNREACH_HOST 1 /* bad host */ | ||
169 | #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ | ||
170 | #define ICMP_UNREACH_PORT 3 /* bad port */ | ||
171 | #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ | ||
172 | #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ | ||
173 | #endif | ||
84 | 174 | ||
85 | 175 | ||
86 | #define MAXPACKET 65535 /* max ip packet size */ | 176 | #define MAXPACKET 65535 /* max ip packet size */ |