1995-08-09 08:06:35 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* 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. */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1995-05-08 08:18:32 -07:00
|
|
|
#include <mlvalues.h>
|
|
|
|
#include <fail.h>
|
1996-09-04 07:15:31 -07:00
|
|
|
#include "unixsupport.h"
|
1995-05-08 08:18:32 -07:00
|
|
|
|
|
|
|
#ifdef HAS_SOCKETS
|
|
|
|
|
|
|
|
#include "socketaddr.h"
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value unix_inet_addr_of_string(value s)
|
1995-05-08 08:18:32 -07:00
|
|
|
{
|
2001-06-19 03:03:33 -07:00
|
|
|
#ifdef HAS_INET_ATON
|
|
|
|
struct in_addr address;
|
|
|
|
if (inet_aton(String_val(s), &address) == 0)
|
|
|
|
failwith("inet_addr_of_string");
|
|
|
|
return alloc_inet_addr(address.s_addr);
|
|
|
|
#else
|
1996-11-25 05:31:19 -08:00
|
|
|
unsigned int address;
|
1995-05-08 08:18:32 -07:00
|
|
|
address = inet_addr(String_val(s));
|
1996-11-25 05:31:19 -08:00
|
|
|
if (address == (unsigned int) -1) failwith("inet_addr_of_string");
|
1995-05-08 08:18:32 -07:00
|
|
|
return alloc_inet_addr(address);
|
2001-06-19 03:03:33 -07:00
|
|
|
#endif
|
1995-05-08 08:18:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value unix_inet_addr_of_string(value s)
|
1995-05-08 08:18:32 -07:00
|
|
|
{ invalid_argument("inet_addr_of_string not implemented"); }
|
|
|
|
|
|
|
|
#endif
|