diff options
author | No author <no_author@ocaml.org> | 1995-06-15 16:08:54 +0000 |
---|---|---|
committer | No author <no_author@ocaml.org> | 1995-06-15 16:08:54 +0000 |
commit | 77b1c8b89fd8940a63b17c41eb37161e5d159831 (patch) | |
tree | 43dbfb3982d9166b717199cb8faa97bdce30add7 /otherlibs/unix/gethost.c | |
parent | ba79d4bd1f01a70b892c69f6a5e6e86714a023d6 (diff) | |
download | ocaml-unlabeled-1.2.2.tar.gz |
This commit was manufactured by cvs2svn to create branchunlabeled-1.2.2
'unlabeled-1.2.2'.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/unlabeled-1.2.2@37 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/unix/gethost.c')
-rw-r--r-- | otherlibs/unix/gethost.c | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/otherlibs/unix/gethost.c b/otherlibs/unix/gethost.c deleted file mode 100644 index 096b28fe50..0000000000 --- a/otherlibs/unix/gethost.c +++ /dev/null @@ -1,76 +0,0 @@ -#include <mlvalues.h> -#include <alloc.h> -#include <memory.h> -#include <fail.h> -#include "unix.h" - -#ifdef HAS_SOCKETS - -#include "socketaddr.h" -#include <netdb.h> - -static int entry_h_length; - -extern int socket_domain_table[]; - -static value alloc_one_addr(a) - char * a; -{ - bcopy(a, &sock_addr.s_inet.sin_addr, entry_h_length); - return alloc_inet_addr(sock_addr.s_inet.sin_addr.s_addr); -} - -static value alloc_host_entry(entry) - struct hostent * entry; -{ - value res; - Push_roots(r, 4); - - r[0] = copy_string(entry->h_name); - r[1] = copy_string_array(entry->h_aliases); - entry_h_length = entry->h_length; -#ifdef h_addr - r[2] = alloc_array(alloc_one_addr, entry->h_addr_list); -#else - r[3] = alloc_one_addr(entry->h_addr); - r[2] = alloc_tuple(1); - Field(r[2], 0) = r[3]; -#endif - res = alloc_tuple(4); - Field(res, 0) = r[0]; - Field(res, 1) = r[1]; - Field(res, 2) = entry->h_addrtype == PF_UNIX ? Atom(0) : Atom(1); - Field(res, 3) = r[2]; - Pop_roots(); - return res; -} - -value unix_gethostbyaddr(a) /* ML */ - value a; -{ - struct in_addr in_addr; - struct hostent * entry; - in_addr.s_addr = GET_INET_ADDR(a); - entry = gethostbyaddr((char *) &in_addr, sizeof(in_addr), 0); - if (entry == (struct hostent *) NULL) mlraise(Atom(NOT_FOUND_EXN)); - return alloc_host_entry(entry); -} - -value unix_gethostbyname(name) /* ML */ - value name; -{ - struct hostent * entry; - entry = gethostbyname(String_val(name)); - if (entry == (struct hostent *) NULL) mlraise(Atom(NOT_FOUND_EXN)); - return alloc_host_entry(entry); -} - -#else - -value unix_gethostbyaddr() -{ invalid_argument("gethostbyaddr not implemented"); } - -value unix_gethostbyname() -{ invalid_argument("gethostbyname not implemented"); } - -#endif |