]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/contrib/otherlibs/unix/getsockname.c
update
[l4.git] / l4 / pkg / ocaml / contrib / otherlibs / unix / getsockname.c
1 /***********************************************************************/
2 /*                                                                     */
3 /*                           Objective Caml                            */
4 /*                                                                     */
5 /*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
6 /*                                                                     */
7 /*  Copyright 1996 Institut National de Recherche en Informatique et   */
8 /*  en Automatique.  All rights reserved.  This file is distributed    */
9 /*  under the terms of the GNU Library General Public License, with    */
10 /*  the special exception on linking described in file ../../LICENSE.  */
11 /*                                                                     */
12 /***********************************************************************/
13
14 /* $Id: getsockname.c 6824 2005-03-24 17:20:54Z doligez $ */
15
16 #include <fail.h>
17 #include <mlvalues.h>
18 #include "unixsupport.h"
19
20 #ifdef HAS_SOCKETS
21
22 #include "socketaddr.h"
23
24 CAMLprim value unix_getsockname(value sock)
25 {
26   int retcode;
27   union sock_addr_union addr;
28   socklen_param_type addr_len;
29
30   addr_len = sizeof(addr);
31   retcode = getsockname(Int_val(sock), &addr.s_gen, &addr_len);
32   if (retcode == -1) uerror("getsockname", Nothing);
33   return alloc_sockaddr(&addr, addr_len, -1);
34 }
35
36 #else
37
38 CAMLprim value unix_getsockname(value sock)
39 { invalid_argument("getsockname not implemented"); }
40   
41 #endif