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/socketaddr.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/socketaddr.c')
-rw-r--r-- | otherlibs/unix/socketaddr.c | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/otherlibs/unix/socketaddr.c b/otherlibs/unix/socketaddr.c deleted file mode 100644 index 1cb9115a07..0000000000 --- a/otherlibs/unix/socketaddr.c +++ /dev/null @@ -1,81 +0,0 @@ -#include <mlvalues.h> -#include <alloc.h> -#include <memory.h> -#include <str.h> -#include <errno.h> -#include "unix.h" - -#ifdef HAS_SOCKETS - -#include "socketaddr.h" - -value alloc_inet_addr(a) - unsigned long a; -{ - value res; - res = alloc(1, Abstract_tag); - GET_INET_ADDR(res) = a; - return res; -} - -void get_sockaddr(a) - value a; -{ - switch(Tag_val(a)) { - case 0: /* ADDR_UNIX */ - { value path; - mlsize_t len; - path = Field(a, 0); - len = string_length(path); - sock_addr.s_unix.sun_family = AF_UNIX; - if (len >= sizeof(sock_addr.s_unix.sun_path)) { - unix_error(ENAMETOOLONG, "", path); - } - bcopy(String_val(path), sock_addr.s_unix.sun_path, (int) len + 1); - sock_addr_len = sizeof(sock_addr.s_unix.sun_family) + len; - break; - } - case 1: /* ADDR_INET */ - { - char * p; - int n; - for (p = (char *) &sock_addr.s_inet, n = sizeof(sock_addr.s_inet); - n > 0; p++, n--) - *p = 0; - sock_addr.s_inet.sin_family = AF_INET; - sock_addr.s_inet.sin_addr.s_addr = GET_INET_ADDR(Field(a, 0)); - sock_addr.s_inet.sin_port = htons(Int_val(Field(a, 1))); - sock_addr_len = sizeof(struct sockaddr_in); - break; - } - } -} - -value alloc_sockaddr() -{ - value res; - switch(sock_addr.s_gen.sa_family) { - case AF_UNIX: - { Push_roots(n, 1); - n[0] = copy_string(sock_addr.s_unix.sun_path); - res = alloc(1, 0); - Field(res,0) = n[0]; - Pop_roots(); - break; - } - case AF_INET: - { Push_roots(a, 1); - a[0] = alloc_inet_addr(sock_addr.s_inet.sin_addr.s_addr); - res = alloc(2, 1); - Field(res,0) = a[0]; - Field(res,1) = Val_int(ntohs(sock_addr.s_inet.sin_port)); - Pop_roots(); - break; - } - default: - unix_error(EAFNOSUPPORT, "", Nothing); - } - return res; -} - -#endif |