summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/libugly/getservbyport_r.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/dietlibc/libugly/getservbyport_r.c')
-rw-r--r--mdk-stage1/dietlibc/libugly/getservbyport_r.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/mdk-stage1/dietlibc/libugly/getservbyport_r.c b/mdk-stage1/dietlibc/libugly/getservbyport_r.c
new file mode 100644
index 000000000..9c0f21bdf
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/getservbyport_r.c
@@ -0,0 +1,13 @@
+#include <string.h>
+#include <netdb.h>
+
+extern int getservbyport_r(int port,const char* proto,
+ struct servent *res, char *buf, size_t buflen,
+ struct servent **res_sig) {
+ while (!getservent_r(res,buf,buflen,res_sig))
+ if (port==res->s_port && !strcmp(res->s_proto,proto)) goto ok;
+ *res_sig=0;
+ok:
+ endservent();
+ return *res_sig?0:-1;
+}