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 */
|
|
|
|
/* under the terms of the GNU Library General Public License. */
|
1996-09-04 07:17:43 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <mlvalues.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
|
|
|
|
value val_process_id;
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value win_startup(unit)
|
1996-09-04 07:17:43 -07:00
|
|
|
value unit;
|
|
|
|
{
|
|
|
|
WSADATA wsaData;
|
|
|
|
int i;
|
|
|
|
HANDLE h;
|
|
|
|
|
|
|
|
(void) WSAStartup(MAKEWORD(2, 0), &wsaData);
|
|
|
|
DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(),
|
|
|
|
GetCurrentProcess(), &h, 0, TRUE,
|
|
|
|
DUPLICATE_SAME_ACCESS);
|
|
|
|
val_process_id = Val_int(h);
|
|
|
|
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value win_cleanup(unit)
|
1996-09-04 07:17:43 -07:00
|
|
|
value unit;
|
|
|
|
{
|
|
|
|
(void) WSACleanup();
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
1997-09-04 06:45:56 -07:00
|
|
|
static int std_handles[3] = {
|
|
|
|
STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, STD_ERROR_HANDLE
|
|
|
|
};
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value win_stdhandle(value nhandle)
|
1997-09-03 07:38:02 -07:00
|
|
|
{
|
1997-09-04 06:45:56 -07:00
|
|
|
return win_alloc_handle(GetStdHandle(std_handles[Int_val(nhandle)]));
|
1997-09-03 07:38:02 -07:00
|
|
|
}
|