-
Notifications
You must be signed in to change notification settings - Fork 19
/
pts.c
46 lines (38 loc) · 872 Bytes
/
pts.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#define EXTUNIX_WANT_PTS
#include "config.h"
#if defined(EXTUNIX_HAVE_PTS)
CAMLprim value caml_extunix_posix_openpt(value flags)
{
CAMLparam1(flags);
int ret, cv_flags;
cv_flags = extunix_open_flags(flags);
ret = posix_openpt(cv_flags);
if(ret == -1)
uerror("posix_openpt", Nothing);
CAMLreturn(Val_int(ret));
}
CAMLprim value caml_extunix_grantpt(value fd)
{
CAMLparam1(fd);
if(grantpt(Int_val(fd)) == -1)
uerror("grantpt", Nothing);
CAMLreturn(Val_unit);
}
CAMLprim value caml_extunix_unlockpt(value fd)
{
CAMLparam1(fd);
if(unlockpt(Int_val(fd)) == -1)
uerror("unlockpt", Nothing);
CAMLreturn(Val_unit);
}
CAMLprim value caml_extunix_ptsname(value fd)
{
CAMLparam1(fd);
CAMLlocal1(ret);
char *name = ptsname(Int_val(fd));
if(name == 0)
uerror("ptsname", Nothing);
ret = caml_copy_string(name);
CAMLreturn(ret);
}
#endif /* HAVE_PTS */