Mercurial > gftp.yaz
comparison lib/misc.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 | 5b681cba67b2 |
children | 63555c9744c2 |
comparison
equal
deleted
inserted
replaced
951:99f8858bbf02 | 952:a490d94a5b8e |
---|---|
928 | 928 |
929 return (ret); | 929 return (ret); |
930 } | 930 } |
931 | 931 |
932 | 932 |
933 struct hostent * | |
934 r_gethostbyname (const char *name, struct hostent *result_buf, int *h_errnop) | |
935 { | |
936 static GStaticMutex hostfunclock = G_STATIC_MUTEX_INIT; | |
937 struct hostent *hent; | |
938 | |
939 if (g_thread_supported ()) | |
940 g_static_mutex_lock (&hostfunclock); | |
941 | |
942 if ((hent = gethostbyname (name)) == NULL) | |
943 { | |
944 if (h_errnop) | |
945 *h_errnop = h_errno; | |
946 } | |
947 else | |
948 { | |
949 *result_buf = *hent; | |
950 hent = result_buf; | |
951 } | |
952 | |
953 if (g_thread_supported ()) | |
954 g_static_mutex_unlock (&hostfunclock); | |
955 | |
956 return (hent); | |
957 } | |
958 | |
959 | |
960 struct servent * | |
961 r_getservbyname (const char *name, const char *proto, | |
962 struct servent *result_buf, int *h_errnop) | |
963 { | |
964 static GStaticMutex servfunclock = G_STATIC_MUTEX_INIT; | |
965 struct servent *sent; | |
966 | |
967 if (g_thread_supported ()) | |
968 g_static_mutex_lock (&servfunclock); | |
969 | |
970 if ((sent = getservbyname (name, proto)) == NULL) | |
971 { | |
972 if (h_errnop) | |
973 *h_errnop = h_errno; | |
974 } | |
975 else | |
976 { | |
977 *result_buf = *sent; | |
978 sent = result_buf; | |
979 } | |
980 | |
981 if (g_thread_supported ()) | |
982 g_static_mutex_unlock (&servfunclock); | |
983 return (sent); | |
984 } | |
985 | |
986 | |
987 char * | 933 char * |
988 base64_encode (char *str) | 934 base64_encode (char *str) |
989 { | 935 { |
990 | 936 |
991 /* The standard to Base64 encoding can be found in RFC2045 */ | 937 /* The standard to Base64 encoding can be found in RFC2045 */ |