diff options
Diffstat (limited to 'gcc/ada/3wsocthi.ads')
-rw-r--r-- | gcc/ada/3wsocthi.ads | 161 |
1 files changed, 131 insertions, 30 deletions
diff --git a/gcc/ada/3wsocthi.ads b/gcc/ada/3wsocthi.ads index 63c8a5ea715..0fb5e4a798d 100644 --- a/gcc/ada/3wsocthi.ads +++ b/gcc/ada/3wsocthi.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2001 Ada Core Technologies, Inc. -- +-- Copyright (C) 2001-2003 Ada Core Technologies, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -26,11 +26,16 @@ -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- --- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ --- This version is for NT. +-- This package provides a target dependent thin interface to the sockets +-- layer for use by the GNAT.Sockets package (g-socket.ads). This package +-- should not be directly with'ed by an applications program. + +-- This version is for NT with Interfaces.C.Pointers; with Interfaces.C.Strings; @@ -41,8 +46,6 @@ with System; package GNAT.Sockets.Thin is - -- ??? far more comments required ??? - package C renames Interfaces.C; use type C.int; @@ -54,23 +57,15 @@ package GNAT.Sockets.Thin is function Socket_Errno return Integer; -- Returns last socket error number. + procedure Set_Socket_Errno (Errno : Integer); + -- Set last socket error number. + function Socket_Error_Message (Errno : Integer) return String; -- Returns the error message string for the error number Errno. If -- Errno is not known it returns "Unknown system error". - type Socket_Fd_Array is array (C.unsigned range 1 .. 64) of C.int; - pragma Convention (C, Socket_Fd_Array); - - type Fd_Set is record - fd_count : C.unsigned; - fd_array : Socket_Fd_Array; - end record; - pragma Convention (C, Fd_Set); - - Null_Fd_Set : constant Fd_Set := (0, (others => 0)); - - type Fd_Set_Access is access all Fd_Set; - pragma Convention (C, Fd_Set_Access); + subtype Fd_Set_Access is System.Address; + No_Fd_Set : constant Fd_Set_Access := System.Null_Address; type Timeval_Unit is new C.long; pragma Convention (C, Timeval_Unit); @@ -142,6 +137,31 @@ package GNAT.Sockets.Thin is pragma Convention (C, Sockaddr_In_Access); -- Access to internet socket address + procedure Set_Length + (Sin : Sockaddr_In_Access; + Len : C.int); + pragma Inline (Set_Length); + -- Set Sin.Sin_Length to Len. + -- On this platform, nothing is done as there is no such field. + + procedure Set_Family + (Sin : Sockaddr_In_Access; + Family : C.int); + pragma Inline (Set_Family); + -- Set Sin.Sin_Family to Family + + procedure Set_Port + (Sin : Sockaddr_In_Access; + Port : C.unsigned_short); + pragma Inline (Set_Port); + -- Set Sin.Sin_Port to Port + + procedure Set_Address + (Sin : Sockaddr_In_Access; + Address : In_Addr); + pragma Inline (Set_Address); + -- Set Sin.Sin_Addr to Address + type Hostent is record H_Name : C.Strings.chars_ptr; H_Aliases : Chars_Ptr_Pointers.Pointer; @@ -156,6 +176,19 @@ package GNAT.Sockets.Thin is pragma Convention (C, Hostent_Access); -- Access to host entry + type Servent is record + S_Name : C.Strings.chars_ptr; + S_Aliases : Chars_Ptr_Pointers.Pointer; + S_Port : C.int; + S_Proto : C.Strings.chars_ptr; + end record; + pragma Convention (C, Servent); + -- Service entry + + type Servent_Access is access all Servent; + pragma Convention (C, Servent_Access); + -- Access to service entry + type Two_Int is array (0 .. 1) of C.int; pragma Convention (C, Two_Int); -- Used with pipe() @@ -173,8 +206,8 @@ package GNAT.Sockets.Thin is return C.int; function C_Close - (Fd : C.int) - return C.int; + (Fd : C.int) + return C.int; function C_Connect (S : C.int; @@ -203,6 +236,16 @@ package GNAT.Sockets.Thin is Namelen : access C.int) return C.int; + function C_Getservbyname + (Name : C.char_array; + Proto : C.char_array) + return Servent_Access; + + function C_Getservbyport + (Port : C.int; + Proto : C.char_array) + return Servent_Access; + function C_Getsockname (S : C.int; Name : System.Address; @@ -237,6 +280,12 @@ package GNAT.Sockets.Thin is Nbyte : C.int) return C.int; + function C_Readv + (Socket : C.int; + Iov : System.Address; + Iovcnt : C.int) + return C.int; + function C_Recv (S : C.int; Buf : System.Address; @@ -310,33 +359,78 @@ package GNAT.Sockets.Thin is Nbyte : C.int) return C.int; + function C_Writev + (Socket : C.int; + Iov : System.Address; + Iovcnt : C.int) + return C.int; + function WSAStartup (WS_Version : Interfaces.C.int; WSADataAddress : System.Address) return Interfaces.C.int; - procedure WSACleanup; + procedure Free_Socket_Set + (Set : Fd_Set_Access); + -- Free system-dependent socket set. + + procedure Get_Socket_From_Set + (Set : Fd_Set_Access; + Socket : Int_Access; + Last : Int_Access); + -- Get last socket in Socket and remove it from the socket + -- set. The parameter Last is a maximum value of the largest + -- socket. This hint is used to avoid scanning very large socket + -- sets. After a call to Get_Socket_From_Set, Last is set back to + -- the real largest socket in the socket set. + + procedure Insert_Socket_In_Set + (Set : Fd_Set_Access; + Socket : C.int); + -- Insert socket in the socket set + + function Is_Socket_In_Set + (Set : Fd_Set_Access; + Socket : C.int) + return Boolean; + -- Check whether Socket is in the socket set + + procedure Last_Socket_In_Set + (Set : Fd_Set_Access; + Last : Int_Access); + -- Find the largest socket in the socket set. This is needed for + -- select(). When Last_Socket_In_Set is called, parameter Last is + -- a maximum value of the largest socket. This hint is used to + -- avoid scanning very large socket sets. After the call, Last is + -- set back to the real largest socket in the socket set. + + function New_Socket_Set + (Set : Fd_Set_Access) + return Fd_Set_Access; + -- Allocate a new socket set which is a system-dependent structure + -- and initialize by copying Set if it is non-null, by making it + -- empty otherwise. + + procedure Remove_Socket_From_Set + (Set : Fd_Set_Access; + Socket : C.int); + -- Remove socket from the socket set - procedure Clear (Item : in out Fd_Set; Socket : in C.int); - procedure Empty (Item : in out Fd_Set); - function Is_Empty (Item : Fd_Set) return Boolean; - function Is_Set (Item : Fd_Set; Socket : C.int) return Boolean; - function Max (Item : Fd_Set) return C.int; - procedure Set (Item : in out Fd_Set; Socket : in C.int); + procedure WSACleanup; procedure Finalize; procedure Initialize (Process_Blocking_IO : Boolean := False); private - pragma Import (Stdcall, C_Accept, "accept"); pragma Import (Stdcall, C_Bind, "bind"); pragma Import (Stdcall, C_Close, "closesocket"); - pragma Import (Stdcall, C_Connect, "connect"); pragma Import (Stdcall, C_Gethostbyaddr, "gethostbyaddr"); pragma Import (Stdcall, C_Gethostbyname, "gethostbyname"); pragma Import (Stdcall, C_Gethostname, "gethostname"); pragma Import (Stdcall, C_Getpeername, "getpeername"); + pragma Import (Stdcall, C_Getservbyname, "getservbyname"); + pragma Import (Stdcall, C_Getservbyport, "getservbyport"); pragma Import (Stdcall, C_Getsockname, "getsockname"); pragma Import (Stdcall, C_Getsockopt, "getsockopt"); pragma Import (Stdcall, C_Inet_Addr, "inet_addr"); @@ -345,7 +439,6 @@ private pragma Import (C, C_Read, "_read"); pragma Import (Stdcall, C_Recv, "recv"); pragma Import (Stdcall, C_Recvfrom, "recvfrom"); - pragma Import (Stdcall, C_Select, "select"); pragma Import (Stdcall, C_Send, "send"); pragma Import (Stdcall, C_Sendto, "sendto"); pragma Import (Stdcall, C_Setsockopt, "setsockopt"); @@ -355,7 +448,15 @@ private pragma Import (C, C_System, "_system"); pragma Import (C, C_Write, "_write"); pragma Import (Stdcall, Socket_Errno, "WSAGetLastError"); + pragma Import (Stdcall, Set_Socket_Errno, "WSASetLastError"); pragma Import (Stdcall, WSAStartup, "WSAStartup"); pragma Import (Stdcall, WSACleanup, "WSACleanup"); + pragma Import (C, Free_Socket_Set, "__gnat_free_socket_set"); + pragma Import (C, Get_Socket_From_Set, "__gnat_get_socket_from_set"); + pragma Import (C, Is_Socket_In_Set, "__gnat_is_socket_in_set"); + pragma Import (C, Last_Socket_In_Set, "__gnat_last_socket_in_set"); + pragma Import (C, New_Socket_Set, "__gnat_new_socket_set"); + pragma Import (C, Insert_Socket_In_Set, "__gnat_insert_socket_in_set"); + pragma Import (C, Remove_Socket_From_Set, "__gnat_remove_socket_from_set"); end GNAT.Sockets.Thin; |