From c98047f62764eab650f7495e50d0e1d63d53ac88 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 30 Apr 2002 15:00:48 +0000 Subject: Meilleure distinction handle/socket. Ajout lockf. Revu rename. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4765 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- otherlibs/win32unix/unixsupport.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'otherlibs/win32unix/unixsupport.c') diff --git a/otherlibs/win32unix/unixsupport.c b/otherlibs/win32unix/unixsupport.c index 9f3ae3189..97a9a3674 100644 --- a/otherlibs/win32unix/unixsupport.c +++ b/otherlibs/win32unix/unixsupport.c @@ -22,7 +22,6 @@ #include "unixsupport.h" #include "cst2constr.h" #include -#include /* Heap-allocation of Windows file handles */ @@ -49,9 +48,27 @@ static struct custom_operations win_handle_ops = { value win_alloc_handle(HANDLE h) { - value res = - alloc_custom(&win_handle_ops, sizeof(HANDLE), 0, 1); + value res = alloc_custom(&win_handle_ops, sizeof(struct filedescr), 0, 1); Handle_val(res) = h; + Descr_kind_val(res) = KIND_HANDLE; + return res; +} + +value win_alloc_socket(SOCKET s) +{ + value res = alloc_custom(&win_handle_ops, sizeof(struct filedescr), 0, 1); + Socket_val(res) = s; + Descr_kind_val(res) = KIND_SOCKET; + return res; +} + +value win_alloc_handle_or_socket(HANDLE h) +{ + value res = win_alloc_handle(h); + int opt; + int optlen = sizeof(opt); + if (getsockopt((SOCKET) h, SOL_SOCKET, SO_TYPE, (char *)&opt, &optlen) == 0) + Descr_kind_val(res) = KIND_SOCKET; return res; } -- cgit v1.2.3-70-g09d2