1996-09-04 07:17:43 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Objective Caml */
|
|
|
|
/* */
|
|
|
|
/* Xavier Leroy and Pascal Cuoq, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
1996-09-04 07:17:43 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2002-08-07 04:49:10 -07:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
1997-09-04 06:45:56 -07:00
|
|
|
#include <wtypes.h>
|
1997-09-03 07:38:02 -07:00
|
|
|
#include <winbase.h>
|
1996-09-04 07:17:43 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <direct.h>
|
|
|
|
#include <process.h>
|
2002-04-30 08:00:48 -07:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <winsock.h>
|
1996-09-04 07:17:43 -07:00
|
|
|
|
2002-04-30 08:00:48 -07:00
|
|
|
struct filedescr {
|
|
|
|
union {
|
|
|
|
HANDLE handle;
|
|
|
|
SOCKET socket;
|
|
|
|
} fd;
|
|
|
|
enum { KIND_HANDLE, KIND_SOCKET } kind;
|
2003-01-06 06:52:57 -08:00
|
|
|
int crt_fd;
|
2002-04-30 08:00:48 -07:00
|
|
|
};
|
1997-09-03 07:38:02 -07:00
|
|
|
|
2002-04-30 08:00:48 -07:00
|
|
|
#define Handle_val(v) (((struct filedescr *) Data_custom_val(v))->fd.handle)
|
|
|
|
#define Socket_val(v) (((struct filedescr *) Data_custom_val(v))->fd.socket)
|
|
|
|
#define Descr_kind_val(v) (((struct filedescr *) Data_custom_val(v))->kind)
|
2003-01-06 06:52:57 -08:00
|
|
|
#define CRT_fd_val(v) (((struct filedescr *) Data_custom_val(v))->crt_fd)
|
2002-04-30 08:00:48 -07:00
|
|
|
|
|
|
|
extern value win_alloc_handle_or_socket(HANDLE);
|
1997-09-03 07:38:02 -07:00
|
|
|
extern value win_alloc_handle(HANDLE);
|
2002-04-30 08:00:48 -07:00
|
|
|
extern value win_alloc_socket(SOCKET);
|
1997-09-03 07:38:02 -07:00
|
|
|
|
2003-01-06 06:52:57 -08:00
|
|
|
#define NO_CRT_FD (-1)
|
1996-09-04 07:17:43 -07:00
|
|
|
#define Nothing ((value) 0)
|
|
|
|
|
2005-09-22 07:21:50 -07:00
|
|
|
extern void win32_maperr(DWORD errcode);
|
1997-09-02 09:01:39 -07:00
|
|
|
extern void unix_error (int errcode, char * cmdname, value arg);
|
|
|
|
extern void uerror (char * cmdname, value arg);
|
|
|
|
extern value unix_freeze_buffer (value);
|
|
|
|
|
|
|
|
#define UNIX_BUFFER_SIZE 16384
|