Patch Bruno Verlyck 2001-09-12, nettoie le passage des arguments 'level'
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3863 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
dc17aff349
commit
afc895f5b3
|
@ -84,54 +84,56 @@ static int sockopt_optint[] = { SO_LINGER };
|
||||||
|
|
||||||
static int sockopt_float[] = { SO_RCVTIMEO, SO_SNDTIMEO };
|
static int sockopt_float[] = { SO_RCVTIMEO, SO_SNDTIMEO };
|
||||||
|
|
||||||
CAMLprim value getsockopt_int(int *sockopt, value socket, value level, value option)
|
CAMLprim value getsockopt_int(int *sockopt, value socket,
|
||||||
|
int level, value option)
|
||||||
{
|
{
|
||||||
int optval;
|
int optval;
|
||||||
socklen_param_type optsize;
|
socklen_param_type optsize;
|
||||||
|
|
||||||
optsize = sizeof(optval);
|
optsize = sizeof(optval);
|
||||||
if (getsockopt(Int_val(socket), Int_val(level), sockopt[Int_val(option)],
|
if (getsockopt(Int_val(socket), level, sockopt[Int_val(option)],
|
||||||
(void *) &optval, &optsize) == -1)
|
(void *) &optval, &optsize) == -1)
|
||||||
uerror("getsockopt", Nothing);
|
uerror("getsockopt", Nothing);
|
||||||
return Val_int(optval);
|
return Val_int(optval);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value setsockopt_int(int *sockopt, value socket, value level,
|
CAMLprim value setsockopt_int(int *sockopt, value socket, int level,
|
||||||
value option, value status)
|
value option, value status)
|
||||||
{
|
{
|
||||||
int optval = Int_val(status);
|
int optval = Int_val(status);
|
||||||
if (setsockopt(Int_val(socket), Int_val(level), sockopt[Int_val(option)],
|
if (setsockopt(Int_val(socket), level, sockopt[Int_val(option)],
|
||||||
(void *) &optval, sizeof(optval)) == -1)
|
(void *) &optval, sizeof(optval)) == -1)
|
||||||
uerror("setsockopt", Nothing);
|
uerror("setsockopt", Nothing);
|
||||||
return Val_unit;
|
return Val_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_getsockopt_bool(value socket, value option) { /* ML */
|
CAMLprim value unix_getsockopt_bool(value socket, value option) {
|
||||||
return getsockopt_int(sockopt_bool, socket, Val_int(SOL_SOCKET), option);
|
return getsockopt_int(sockopt_bool, socket, SOL_SOCKET, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_setsockopt_bool(value socket, value option, value status)
|
CAMLprim value unix_setsockopt_bool(value socket, value option, value status)
|
||||||
{
|
{
|
||||||
return setsockopt_int(sockopt_bool, socket, Val_int(SOL_SOCKET), option, status);
|
return setsockopt_int(sockopt_bool, socket, SOL_SOCKET, option, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_getsockopt_int(value socket, value option) { /* ML */
|
CAMLprim value unix_getsockopt_int(value socket, value option) {
|
||||||
return getsockopt_int(sockopt_int, socket, Val_int(SOL_SOCKET), option);
|
return getsockopt_int(sockopt_int, socket, SOL_SOCKET, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_setsockopt_int(value socket, value option, value status)
|
CAMLprim value unix_setsockopt_int(value socket, value option, value status)
|
||||||
{
|
{
|
||||||
return setsockopt_int(sockopt_int, socket, Val_int(SOL_SOCKET), option, status);
|
return setsockopt_int(sockopt_int, socket, SOL_SOCKET, option, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value getsockopt_optint(int *sockopt, value socket, value level, value option)
|
CAMLprim value getsockopt_optint(int *sockopt, value socket,
|
||||||
|
int level, value option)
|
||||||
{
|
{
|
||||||
struct linger optval;
|
struct linger optval;
|
||||||
socklen_param_type optsize;
|
socklen_param_type optsize;
|
||||||
value res = Val_int(0); /* None */
|
value res = Val_int(0); /* None */
|
||||||
|
|
||||||
optsize = sizeof(optval);
|
optsize = sizeof(optval);
|
||||||
if (getsockopt(Int_val(socket), Int_val(level), sockopt[Int_val(option)],
|
if (getsockopt(Int_val(socket), level, sockopt[Int_val(option)],
|
||||||
(void *) &optval, &optsize) == -1)
|
(void *) &optval, &optsize) == -1)
|
||||||
uerror("getsockopt_optint", Nothing);
|
uerror("getsockopt_optint", Nothing);
|
||||||
if (optval.l_onoff != 0) {
|
if (optval.l_onoff != 0) {
|
||||||
|
@ -141,15 +143,15 @@ CAMLprim value getsockopt_optint(int *sockopt, value socket, value level, value
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value setsockopt_optint(int *sockopt, value socket, value level,
|
CAMLprim value setsockopt_optint(int *sockopt, value socket, int level,
|
||||||
value option, value status)
|
value option, value status)
|
||||||
{
|
{
|
||||||
struct linger optval;
|
struct linger optval;
|
||||||
|
|
||||||
optval.l_onoff = Is_block (status);
|
optval.l_onoff = Is_block (status);
|
||||||
if (optval.l_onoff)
|
if (optval.l_onoff)
|
||||||
optval.l_linger = Int_val (Field (status, 0));
|
optval.l_linger = Int_val (Field (status, 0));
|
||||||
if (setsockopt(Int_val(socket), Int_val(level), sockopt[Int_val(option)],
|
if (setsockopt(Int_val(socket), level, sockopt[Int_val(option)],
|
||||||
(void *) &optval, sizeof(optval)) == -1)
|
(void *) &optval, sizeof(optval)) == -1)
|
||||||
uerror("setsockopt_optint", Nothing);
|
uerror("setsockopt_optint", Nothing);
|
||||||
return Val_unit;
|
return Val_unit;
|
||||||
|
@ -157,28 +159,29 @@ CAMLprim value setsockopt_optint(int *sockopt, value socket, value level,
|
||||||
|
|
||||||
CAMLprim value unix_getsockopt_optint(value socket, value option)
|
CAMLprim value unix_getsockopt_optint(value socket, value option)
|
||||||
{
|
{
|
||||||
return getsockopt_optint(sockopt_optint, socket, Val_int(SOL_SOCKET), option);
|
return getsockopt_optint(sockopt_optint, socket, SOL_SOCKET, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_setsockopt_optint(value socket, value option, value status)
|
CAMLprim value unix_setsockopt_optint(value socket, value option, value status)
|
||||||
{
|
{
|
||||||
return setsockopt_optint(sockopt_optint, socket, Val_int(SOL_SOCKET), option, status);
|
return setsockopt_optint(sockopt_optint, socket, SOL_SOCKET, option, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value getsockopt_float(int *sockopt, value socket, value level, value option)
|
CAMLprim value getsockopt_float(int *sockopt, value socket,
|
||||||
|
int level, value option)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
socklen_param_type optsize;
|
socklen_param_type optsize;
|
||||||
|
|
||||||
optsize = sizeof(tv);
|
optsize = sizeof(tv);
|
||||||
if (getsockopt(Int_val(socket), Int_val(level), sockopt[Int_val(option)],
|
if (getsockopt(Int_val(socket), level, sockopt[Int_val(option)],
|
||||||
(void *) &tv, &optsize) == -1)
|
(void *) &tv, &optsize) == -1)
|
||||||
uerror("getsockopt_float", Nothing);
|
uerror("getsockopt_float", Nothing);
|
||||||
return copy_double((double) tv.tv_sec + (double) tv.tv_usec / 1e6);
|
return copy_double((double) tv.tv_sec + (double) tv.tv_usec / 1e6);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value setsockopt_float(int *sockopt, value socket, value level,
|
CAMLprim value setsockopt_float(int *sockopt, value socket, int level,
|
||||||
value option, value status)
|
value option, value status)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
double tv_f;
|
double tv_f;
|
||||||
|
@ -186,7 +189,7 @@ CAMLprim value setsockopt_float(int *sockopt, value socket, value level,
|
||||||
tv_f = Double_val(status);
|
tv_f = Double_val(status);
|
||||||
tv.tv_sec = (int)tv_f;
|
tv.tv_sec = (int)tv_f;
|
||||||
tv.tv_usec = (int) (1e6 * (tv_f - tv.tv_sec));
|
tv.tv_usec = (int) (1e6 * (tv_f - tv.tv_sec));
|
||||||
if (setsockopt(Int_val(socket), Int_val(level), sockopt[Int_val(option)],
|
if (setsockopt(Int_val(socket), level, sockopt[Int_val(option)],
|
||||||
(void *) &tv, sizeof(tv)) == -1)
|
(void *) &tv, sizeof(tv)) == -1)
|
||||||
uerror("setsockopt_float", Nothing);
|
uerror("setsockopt_float", Nothing);
|
||||||
return Val_unit;
|
return Val_unit;
|
||||||
|
@ -194,12 +197,12 @@ CAMLprim value setsockopt_float(int *sockopt, value socket, value level,
|
||||||
|
|
||||||
CAMLprim value unix_getsockopt_float(value socket, value option)
|
CAMLprim value unix_getsockopt_float(value socket, value option)
|
||||||
{
|
{
|
||||||
return getsockopt_float(sockopt_float, socket, Val_int(SOL_SOCKET), option);
|
return getsockopt_float(sockopt_float, socket, SOL_SOCKET, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_setsockopt_float(value socket, value option, value status)
|
CAMLprim value unix_setsockopt_float(value socket, value option, value status)
|
||||||
{
|
{
|
||||||
return setsockopt_float(sockopt_float, socket, Val_int(SOL_SOCKET), option, status);
|
return setsockopt_float(sockopt_float, socket, SOL_SOCKET, option, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -28,49 +28,51 @@ static int sockopt_optint[] = { SO_LINGER };
|
||||||
|
|
||||||
static int sockopt_float[] = { SO_RCVTIMEO, SO_SNDTIMEO };
|
static int sockopt_float[] = { SO_RCVTIMEO, SO_SNDTIMEO };
|
||||||
|
|
||||||
value getsockopt_int(int *sockopt, value socket, value level, value option)
|
CAMLprim value getsockopt_int(int *sockopt, value socket,
|
||||||
|
int level, value option)
|
||||||
{
|
{
|
||||||
int optval;
|
int optval;
|
||||||
int optsize;
|
int optsize;
|
||||||
|
|
||||||
optsize = sizeof(optval);
|
optsize = sizeof(optval);
|
||||||
if (getsockopt((SOCKET) Handle_val(socket),
|
if (getsockopt((SOCKET) Handle_val(socket),
|
||||||
Int_val(level), sockopt[Int_val(option)],
|
level, sockopt[Int_val(option)],
|
||||||
(void *) &optval, &optsize) == -1)
|
(void *) &optval, &optsize) == -1)
|
||||||
uerror("getsockopt", Nothing);
|
uerror("getsockopt", Nothing);
|
||||||
return Val_int(optval);
|
return Val_int(optval);
|
||||||
}
|
}
|
||||||
|
|
||||||
value setsockopt_int(int *sockopt, value socket, value level,
|
CAMLprim value setsockopt_int(int *sockopt, value socket, int level,
|
||||||
value option, value status)
|
value option, value status)
|
||||||
{
|
{
|
||||||
int optval = Int_val(status);
|
int optval = Int_val(status);
|
||||||
if (setsockopt((SOCKET) Handle_val(socket),
|
if (setsockopt((SOCKET) Handle_val(socket),
|
||||||
Int_val(level), sockopt[Int_val(option)],
|
level, sockopt[Int_val(option)],
|
||||||
(void *) &optval, sizeof(optval)) == -1)
|
(void *) &optval, sizeof(optval)) == -1)
|
||||||
uerror("setsockopt", Nothing);
|
uerror("setsockopt", Nothing);
|
||||||
return Val_unit;
|
return Val_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_getsockopt_bool(value socket, value option) {
|
CAMLprim value unix_getsockopt_bool(value socket, value option) {
|
||||||
return getsockopt_int(sockopt_bool, socket, Val_int(SOL_SOCKET), option);
|
return getsockopt_int(sockopt_bool, socket, SOL_SOCKET, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_setsockopt_bool(value socket, value option, value status)
|
CAMLprim value unix_setsockopt_bool(value socket, value option, value status)
|
||||||
{
|
{
|
||||||
return setsockopt_int(sockopt_bool, socket, Val_int(SOL_SOCKET), option, status);
|
return setsockopt_int(sockopt_bool, socket, SOL_SOCKET, option, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_getsockopt_int(value socket, value option) {
|
CAMLprim value unix_getsockopt_int(value socket, value option) {
|
||||||
return getsockopt_int(sockopt_int, socket, Val_int(SOL_SOCKET), option);
|
return getsockopt_int(sockopt_int, socket, SOL_SOCKET, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_setsockopt_int(value socket, value option, value status)
|
CAMLprim value unix_setsockopt_int(value socket, value option, value status)
|
||||||
{
|
{
|
||||||
return setsockopt_int(sockopt_int, socket, Val_int(SOL_SOCKET), option, status);
|
return setsockopt_int(sockopt_int, socket, SOL_SOCKET, option, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
value getsockopt_optint(int *sockopt, value socket, value level, value option)
|
CAMLprim value getsockopt_optint(int *sockopt, value socket,
|
||||||
|
int level, value option)
|
||||||
{
|
{
|
||||||
struct linger optval;
|
struct linger optval;
|
||||||
int optsize;
|
int optsize;
|
||||||
|
@ -78,7 +80,7 @@ value getsockopt_optint(int *sockopt, value socket, value level, value option)
|
||||||
|
|
||||||
optsize = sizeof(optval);
|
optsize = sizeof(optval);
|
||||||
if (getsockopt((SOCKET) Handle_val(socket),
|
if (getsockopt((SOCKET) Handle_val(socket),
|
||||||
Int_val(level), sockopt[Int_val(option)],
|
level, sockopt[Int_val(option)],
|
||||||
(void *) &optval, &optsize) == -1)
|
(void *) &optval, &optsize) == -1)
|
||||||
uerror("getsockopt_optint", Nothing);
|
uerror("getsockopt_optint", Nothing);
|
||||||
if (optval.l_onoff != 0) {
|
if (optval.l_onoff != 0) {
|
||||||
|
@ -88,8 +90,8 @@ value getsockopt_optint(int *sockopt, value socket, value level, value option)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
value setsockopt_optint(int *sockopt, value socket, value level,
|
CAMLprim value setsockopt_optint(int *sockopt, value socket, int level,
|
||||||
value option, value status)
|
value option, value status)
|
||||||
{
|
{
|
||||||
struct linger optval;
|
struct linger optval;
|
||||||
|
|
||||||
|
@ -97,7 +99,7 @@ value setsockopt_optint(int *sockopt, value socket, value level,
|
||||||
if (optval.l_onoff)
|
if (optval.l_onoff)
|
||||||
optval.l_linger = Int_val (Field (status, 0));
|
optval.l_linger = Int_val (Field (status, 0));
|
||||||
if (setsockopt((SOCKET) Handle_val(socket),
|
if (setsockopt((SOCKET) Handle_val(socket),
|
||||||
Int_val(level), sockopt[Int_val(option)],
|
level, sockopt[Int_val(option)],
|
||||||
(void *) &optval, sizeof(optval)) == -1)
|
(void *) &optval, sizeof(optval)) == -1)
|
||||||
uerror("setsockopt_optint", Nothing);
|
uerror("setsockopt_optint", Nothing);
|
||||||
return Val_unit;
|
return Val_unit;
|
||||||
|
@ -105,31 +107,30 @@ value setsockopt_optint(int *sockopt, value socket, value level,
|
||||||
|
|
||||||
CAMLprim value unix_getsockopt_optint(value socket, value option)
|
CAMLprim value unix_getsockopt_optint(value socket, value option)
|
||||||
{
|
{
|
||||||
return getsockopt_optint(sockopt_optint, socket,
|
return getsockopt_optint(sockopt_optint, socket, SOL_SOCKET, option);
|
||||||
Val_int(SOL_SOCKET), option);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_setsockopt_optint(value socket, value option, value status)
|
CAMLprim value unix_setsockopt_optint(value socket, value option, value status)
|
||||||
{
|
{
|
||||||
return setsockopt_optint(sockopt_optint, socket,
|
return setsockopt_optint(sockopt_optint, socket, SOL_SOCKET, option, status);
|
||||||
Val_int(SOL_SOCKET), option, status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
value getsockopt_float(int *sockopt, value socket, value level, value option)
|
CAMLprim value getsockopt_float(int *sockopt, value socket,
|
||||||
|
int level, value option)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int optsize;
|
int optsize;
|
||||||
|
|
||||||
optsize = sizeof(tv);
|
optsize = sizeof(tv);
|
||||||
if (getsockopt((SOCKET) Handle_val(socket),
|
if (getsockopt((SOCKET) Handle_val(socket),
|
||||||
Int_val(level), sockopt[Int_val(option)],
|
level, sockopt[Int_val(option)],
|
||||||
(void *) &tv, &optsize) == -1)
|
(void *) &tv, &optsize) == -1)
|
||||||
uerror("getsockopt_float", Nothing);
|
uerror("getsockopt_float", Nothing);
|
||||||
return copy_double((double) tv.tv_sec + (double) tv.tv_usec / 1e6);
|
return copy_double((double) tv.tv_sec + (double) tv.tv_usec / 1e6);
|
||||||
}
|
}
|
||||||
|
|
||||||
value setsockopt_float(int *sockopt, value socket, value level,
|
CAMLprim value setsockopt_float(int *sockopt, value socket, int level,
|
||||||
value option, value status)
|
value option, value status)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
double tv_f;
|
double tv_f;
|
||||||
|
@ -138,7 +139,7 @@ value setsockopt_float(int *sockopt, value socket, value level,
|
||||||
tv.tv_sec = (int)tv_f;
|
tv.tv_sec = (int)tv_f;
|
||||||
tv.tv_usec = (int) (1e6 * (tv_f - tv.tv_sec));
|
tv.tv_usec = (int) (1e6 * (tv_f - tv.tv_sec));
|
||||||
if (setsockopt((SOCKET) Handle_val(socket),
|
if (setsockopt((SOCKET) Handle_val(socket),
|
||||||
Int_val(level), sockopt[Int_val(option)],
|
level, sockopt[Int_val(option)],
|
||||||
(void *) &tv, sizeof(tv)) == -1)
|
(void *) &tv, sizeof(tv)) == -1)
|
||||||
uerror("setsockopt_float", Nothing);
|
uerror("setsockopt_float", Nothing);
|
||||||
return Val_unit;
|
return Val_unit;
|
||||||
|
@ -146,11 +147,11 @@ value setsockopt_float(int *sockopt, value socket, value level,
|
||||||
|
|
||||||
CAMLprim value unix_getsockopt_float(value socket, value option)
|
CAMLprim value unix_getsockopt_float(value socket, value option)
|
||||||
{
|
{
|
||||||
return getsockopt_float(sockopt_float, socket, Val_int(SOL_SOCKET), option);
|
return getsockopt_float(sockopt_float, socket, SOL_SOCKET, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMLprim value unix_setsockopt_float(value socket, value option, value status)
|
CAMLprim value unix_setsockopt_float(value socket, value option, value status)
|
||||||
{
|
{
|
||||||
return setsockopt_float(sockopt_float, socket, Val_int(SOL_SOCKET), option, status);
|
return setsockopt_float(sockopt_float, socket, SOL_SOCKET, option, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue