Mercurial > gftp.yaz
diff lib/sockutils.c @ 952:a490d94a5b8e
2008-03-28 Brian Masney <masneyb@gftp.org>
* lib/Makefile.am lib/misc.c lib/socket-connect.c
lib/socket-connect-getaddrinfo.c lib/socket-connect-gethostbyname.c
lib/sockutils.c lib/gftp.h - cleaned up more of the socket functions
and split them up into their own files. Cleanups and bug fixes to the
DNS lookup code.
| author | masneyb |
|---|---|
| date | Fri, 28 Mar 2008 11:44:36 +0000 |
| parents | c7d7a081cd9c |
| children |
line wrap: on
line diff
--- a/lib/sockutils.c Sat Mar 08 11:36:14 2008 +0000 +++ b/lib/sockutils.c Fri Mar 28 11:44:36 2008 +0000 @@ -358,3 +358,30 @@ return (0); } + +struct servent * +r_getservbyname (const char *name, const char *proto, + struct servent *result_buf, int *h_errnop) +{ + static GStaticMutex servfunclock = G_STATIC_MUTEX_INIT; + struct servent *sent; + + if (g_thread_supported ()) + g_static_mutex_lock (&servfunclock); + + if ((sent = getservbyname (name, proto)) == NULL) + { + if (h_errnop) + *h_errnop = h_errno; + } + else + { + *result_buf = *sent; + sent = result_buf; + } + + if (g_thread_supported ()) + g_static_mutex_unlock (&servfunclock); + return (sent); +} +
