aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-04-01 01:18:20 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-04-01 01:18:20 +0000
commit2856dab4770e521a87c18b04ae8ebc209a9b95f9 (patch)
treed4f6495339702c0b6d79816d0bb07ba4b6679ce8 /libbb
parentf443bffd3c24c4b7fcbc0472c75e747e26c24fef (diff)
downloadbusybox-w32-2856dab4770e521a87c18b04ae8ebc209a9b95f9.tar.gz
busybox-w32-2856dab4770e521a87c18b04ae8ebc209a9b95f9.tar.bz2
busybox-w32-2856dab4770e521a87c18b04ae8ebc209a9b95f9.zip
tcpsvd: new applet
It's a GPL-ed 'clone' of Dan Bernstein's tcpserver. Author: Gerrit Pape <pape@smarden.org> http://smarden.sunsite.dk/ipsvd/ size tcpsvd.o text data bss dec hex filename 2571 4 16 2591 a1f tcpsvd.o
Diffstat (limited to 'libbb')
-rw-r--r--libbb/xconnect.c12
-rw-r--r--libbb/xfuncs.c57
2 files changed, 62 insertions, 7 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 118fe3e75..a331e6bc4 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -82,15 +82,15 @@ int xconnect_tcp_v4(struct sockaddr_in *s_addr)
82/* "New" networking API */ 82/* "New" networking API */
83 83
84 84
85int get_nport(const len_and_sockaddr *lsa) 85int get_nport(const struct sockaddr *sa)
86{ 86{
87#if ENABLE_FEATURE_IPV6 87#if ENABLE_FEATURE_IPV6
88 if (lsa->sa.sa_family == AF_INET6) { 88 if (sa->sa_family == AF_INET6) {
89 return lsa->sin6.sin6_port; 89 return ((struct sockaddr_in6*)sa)->sin6_port;
90 } 90 }
91#endif 91#endif
92 if (lsa->sa.sa_family == AF_INET) { 92 if (sa->sa_family == AF_INET) {
93 return lsa->sin.sin_port; 93 return ((struct sockaddr_in*)sa)->sin_port;
94 } 94 }
95 /* What? UNIX socket? IPX?? :) */ 95 /* What? UNIX socket? IPX?? :) */
96 return -1; 96 return -1;
@@ -308,12 +308,10 @@ char* xmalloc_sockaddr2host(const struct sockaddr *sa, socklen_t salen)
308 return sockaddr2str(sa, salen, 0); 308 return sockaddr2str(sa, salen, 0);
309} 309}
310 310
311/* Unused
312char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa, socklen_t salen) 311char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa, socklen_t salen)
313{ 312{
314 return sockaddr2str(sa, salen, IGNORE_PORT); 313 return sockaddr2str(sa, salen, IGNORE_PORT);
315} 314}
316*/
317 315
318char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa, socklen_t salen) 316char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa, socklen_t salen)
319{ 317{
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 68ad3dec4..b08f92d81 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -205,6 +205,63 @@ int wait4pid(int pid)
205 return 0; 205 return 0;
206} 206}
207 207
208int wait_nohang(int *wstat)
209{
210 return waitpid(-1, wstat, WNOHANG);
211}
212
213int wait_pid(int *wstat, int pid)
214{
215 int r;
216
217 do
218 r = waitpid(pid, wstat, 0);
219 while ((r == -1) && (errno == EINTR));
220 return r;
221}
222
223void sig_block(int sig)
224{
225 sigset_t ss;
226 sigemptyset(&ss);
227 sigaddset(&ss, sig);
228 sigprocmask(SIG_BLOCK, &ss, NULL);
229}
230
231void sig_unblock(int sig)
232{
233 sigset_t ss;
234 sigemptyset(&ss);
235 sigaddset(&ss, sig);
236 sigprocmask(SIG_UNBLOCK, &ss, NULL);
237}
238
239#if 0
240void sig_blocknone(void)
241{
242 sigset_t ss;
243 sigemptyset(&ss);
244 sigprocmask(SIG_SETMASK, &ss, NULL);
245}
246#endif
247
248void sig_catch(int sig, void (*f)(int))
249{
250 struct sigaction sa;
251 sa.sa_handler = f;
252 sa.sa_flags = 0;
253 sigemptyset(&sa.sa_mask);
254 sigaction(sig, &sa, NULL);
255}
256
257void sig_pause(void)
258{
259 sigset_t ss;
260 sigemptyset(&ss);
261 sigsuspend(&ss);
262}
263
264
208void xsetenv(const char *key, const char *value) 265void xsetenv(const char *key, const char *value)
209{ 266{
210 if (setenv(key, value, 1)) 267 if (setenv(key, value, 1))