summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2006-04-12 18:24:37 +0000
committerBernhard Reutner-Fischer2006-04-12 18:24:37 +0000
commit67f641e75b685abe1588b634b409c1ee2ff68c22 (patch)
tree74b3e38f1b7caef23bbf06a92b6e5d05530d50a6 /libbb
parent2c99851181a652358aa3ca58ef38c57e46ae02e4 (diff)
downloadbusybox-67f641e75b685abe1588b634b409c1ee2ff68c22.zip
busybox-67f641e75b685abe1588b634b409c1ee2ff68c22.tar.gz
- patch from Denis Vlasenko to add bb_xbind() and bb_xlisten()
Diffstat (limited to 'libbb')
-rw-r--r--libbb/Makefile.in2
-rw-r--r--libbb/bb_xbind.c18
-rw-r--r--libbb/bb_xlisten.c17
3 files changed, 36 insertions, 1 deletions
diff --git a/libbb/Makefile.in b/libbb/Makefile.in
index 3fb945e..f05bf80 100644
--- a/libbb/Makefile.in
+++ b/libbb/Makefile.in
@@ -30,7 +30,7 @@ LIBBB-y:= \
trim.c u_signal_names.c vdprintf.c verror_msg.c \
vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c xstat.c \
xgethostbyname.c xgethostbyname2.c xreadlink.c xregcomp.c xgetlarg.c \
- bb_xsocket.c bb_xdaemon.c \
+ bb_xsocket.c bb_xdaemon.c bb_xbind.c bb_xlisten.c \
get_terminal_width_height.c fclose_nonstdin.c fflush_stdout_and_exit.c \
getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \
perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
diff --git a/libbb/bb_xbind.c b/libbb/bb_xbind.c
new file mode 100644
index 0000000..8a45af3
--- /dev/null
+++ b/libbb/bb_xbind.c
@@ -0,0 +1,18 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * bb_xbind.c - a bind() which dies on failure with error message
+ *
+ * Copyright (C) 2006 Denis Vlasenko
+ *
+ * Licensed under LGPL, see file docs/lesser.txt in this tarball for details.
+ */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include "libbb.h"
+
+void bb_xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen)
+{
+ if (bind(sockfd, my_addr, addrlen))
+ bb_perror_msg_and_die("bind");
+}
+
diff --git a/libbb/bb_xlisten.c b/libbb/bb_xlisten.c
new file mode 100644
index 0000000..a42d61a
--- /dev/null
+++ b/libbb/bb_xlisten.c
@@ -0,0 +1,17 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * bb_xlisten.c - a listen() which dies on failure with error message
+ *
+ * Copyright (C) 2006 Denis Vlasenko
+ *
+ * Licensed under LGPL, see file docs/lesser.txt in this tarball for details.
+ */
+#include <sys/socket.h>
+#include "libbb.h"
+
+void bb_xlisten(int s, int backlog)
+{
+ if (listen(s, backlog))
+ bb_perror_msg_and_die("listen");
+}
+