Specification of package Tgx.System_Ios
========================================================================= --
=== === --
=== Top Graph'X CORBA Implementation === --
=== === --
=== Copyright (c) 1996, Top Graph'X. === --
=== === --
=== --- Copyright Notice --- === --
=== === --
=== This software is protected as an unpublished work under the === --
=== Copyright Act of 1976. All rights reserved. Top Graph'X. === --
=== === --
========================================================================= --
modif_{0} : JM : 05/02/02 : added for Miop
with System ;
with Interfaces.C ;
with Ada.Unchecked_Conversion ;
package Tgx.System_Ios is
X_32_Bits : constant := 32 / System.Storage_Unit ;
type Byte_Order is (Little_Endian, Big_Endian) ;
This_Machine_Byte_Order : constant Byte_Order :=
Byte_Order'val (1 - System.Bit_Order'pos (System.Default_Bit_Order)) ;
type Integer_32 is range - 2 ** 31 .. (2 ** 31) - 1;
subtype Int_Ptr is Integer_32;
subtype Descriptor is Integer_32 range 0 .. 1023 ;
subtype Handle is Integer_32 ;
--HP700 I_Fionread : constant Integer_32 := 16#4004667f# ;
--HP700 I_Fionbio : constant Integer_32 := 16#8004667e# ;
Tgx/Impl/tgx-posix-file_status.adb
--MacX I_Fionread : constant Integer_32 := 16#4004667f# ;
--MacX I_Fionbio : constant Integer_32 := 16#8004667e# ;
--Osf1 I_Fionread : constant Integer_32 := 16#4004667f# ;
--Osf1 I_Fionbio : constant Integer_32 := 16#8004667e# ;
old Osf1 Stat_Record_size : constant := 832;
Non erroneous "errno" values
EINTR, EWOULDBLOCK, EAGAIN (errno.h)
Interrupted : constant := 4 ;
Would_Block : constant := 11 ;
Again : constant := 11 ;
Hostent_Record_size : constant := 160 ;
Ip_Mreqn_size : constant := 96;
Stat_Record_size : constant := 768;
One_Tick : Duration := 0.02 ;
Fd_Setsize : constant := 64 ;
type Event_Mask is mod 2 ** 16 ;
for Event_Mask'size use 16 ;
Pollin : constant := 1;
POLLOUT (poll.h)
Pollout : constant := 4;
Pollerr : constant := 8;
Pollhup : constant := 16;
type Poll_Record is
record
Fd : Handle ;
Required : Event_Mask ;
Events : Event_Mask ;
end record ;
for Poll_Record use
record
Fd at 0 range 0 .. 31 ;
Required at 0 range 32 .. 47 ;
Events at 0 range 48 .. 63 ;
end record ;
type Poll_Array is array (Descriptor range <>) of Poll_Record ;
type Ioctl_Mode is range 0 .. 255 ;
for Ioctl_Mode'size use 8 ;
Ioc_Void : constant Ioctl_Mode := 16#20# ;
Ioc_Out : constant Ioctl_Mode := 16#40# ;
Ioc_In : constant Ioctl_Mode := 16#80# ;
Ioc_Inout : constant Ioctl_Mode := Ioc_In + Ioc_Out ;
type Param_Size is range 0 .. 255 ;
for Param_Size'size use 8 ;
type Ioctl_Code is range 0 .. 255 ;
for Ioctl_Code'size use 8 ;
type Ioctl_Flag is
record
Mode : Ioctl_Mode ;
Size : Param_Size ;
Char : Character ;
Code : Ioctl_Code ;
end record ;
Little_Endian representation
for Ioctl_Flag use
record
Mode at 0 range 24 .. 31 ;
Size at 0 range 16 .. 23 ;
Char at 0 range 8 .. 15 ;
Code at 0 range 0 .. 7 ;
end record ;
function To_Int is new Ada.Unchecked_Conversion
( Source => Ioctl_Flag,
Target => Integer_32 ) ;
Fionread : constant Ioctl_Flag :=
( Mode => Ioc_Out, Size => 4, Char => 'f', Code => 127) ;
Fionbio : constant Ioctl_Flag :=
( Mode => Ioc_In, Size => 4, Char => 'f', Code => 126) ;
FIONREAD, FIONBIO (ioctl.h)
I_Fionread : constant Integer_32 := 16#541b# ;
I_Fionbio : constant Integer_32 := 16#5421# ;
function To_Address is new Ada.Unchecked_Conversion
( Source => Integer_32,
Target => System.Address ) ;
C_Null : constant System.Address := To_Address (0) ;
subtype String_8 is String (1 .. 8) ;
type Socket_Address_Family is ( Af_Unspec, Af_Unix, Af_Inet ) ;
for Socket_Address_Family use ( Af_Unspec => 0,
Af_Unix => 1,
Af_Inet => 2) ;
for Socket_Address_Family'size use 16 ;
Ip : constant := 0 ;
Tcp_Code : constant := 6 ;
SOL_SOCKET (socket.h)
Soc_Code : constant := 1 ;
SOCK_STREAM (socket.h)
Sock_Stream : constant := 1 ;
So_Sndbuf : constant := 16#7# ;
So_Rcvbuf : constant := 16#8# ;
modif_{0}
SOCK_DGRAM (socket.h)
Sock_Datagram : constant := 2 ;
Multicast information (in.h)
Ip_Multicast_Ttl : constant := 33 ;
Ip_Multicast_Loop : constant := 34 ;
Ip_Add_Membership : constant := 35 ;
Ip_Drop_Membership : constant := 36 ;
end_{0}
Tcp_No_Delay : constant := 1 ;
SO_REUSEADDR (socket.h)
Reuse_Addr : constant := 2 ;
SO_KEEPALIVE (socket.h)
Keepalive : constant := 9 ;
SO_LINGER (socket.h)
Linger_On_Close : constant := 13 ;
Msg_Peek : constant := 2 ;
type Internet_Address is new Integer_32 ;
type Internet_Address_Pointer is access Internet_Address ;
type Internet_Table is access Internet_Address_Pointer ;
modif_{0}
Inaddr_Any : constant Internet_Address := 0 ;
end_{0}
type Byte is mod 2 ** 8 ;
for Byte'size use 8 ;
type Two_Bytes is array (1 .. 2) of Byte ;
for Two_Bytes'size use 16 ;
type Four_Bytes is array (1 .. 4) of Byte ;
for Four_Bytes'size use 32 ;
type Word is mod 2 ** 16 ;
for Word'size use 16 ;
function To_Word is new Ada.Unchecked_Conversion
( Source => Two_Bytes,
Target => Word ) ;
function To_Bytes is new Ada.Unchecked_Conversion
( Source => Word,
Target => Two_Bytes ) ;
function To_Int is new Ada.Unchecked_Conversion
( Source => Four_Bytes, Target => Integer_32) ;
function To_Bytes is new Ada.Unchecked_Conversion
( Source => Integer_32,
Target => Four_Bytes ) ;
subtype Port is Word ;
type Internet_Record is
record
Sin_Family : Socket_Address_Family ;
Sin_Port : Port ;
Sin_Addr : Internet_Address;
Sin_Chars : String_8 := (others => Ascii.Nul);
end record;
for Internet_Record use
record
Sin_Family at 0 * X_32_Bits range 0 .. 15 ;
Sin_Port at 0 * X_32_Bits range 16 .. 31 ;
Sin_Addr at 1 * X_32_Bits range 0 .. 31 ;
Sin_Chars at 2 * X_32_Bits range 0 .. 63 ;
end record;
subtype Unix_Socket_Name is String (1 .. 92) ;
type Unix_Socket is
record
Sun_Family : Socket_Address_Family;
Sun_Path : Unix_Socket_Name;
end record;
for Unix_Socket use
record
Sun_Family at 0 * X_32_Bits range 0 .. 15 ;
Sun_Path at 0 * X_32_Bits range 16 .. 8 * 94 - 1 ;
end record ;
subtype Nt_Socket_Name is String (1 .. 14) ;
type Nt_Socket is
record
Sa_Family : Socket_Address_Family;
Sa_Path : Nt_Socket_Name;
end record;
for Nt_Socket use
record
Sa_Family at 0 * X_32_Bits range 0 .. 15 ;
Sa_Path at 0 * X_32_Bits range 16 .. 8 * 16 - 1 ;
end record ;
type Time_Value is
record
Seconds : Integer_32 ;
Micro_Seconds : Integer_32 ;
end record ;
type Hostent_Record;
type Hostent is access Hostent_Record;
type Hostent_Record is
record
H_Name : System.Address;
H_Aliases : System.Address;
H_Addrtype : Integer_32;
H_Length : Integer_32;
H_Address : Internet_Table;
end record;
struct hostent (netdb.h)
for Hostent_Record use
record
H_Name at 0 * X_32_Bits range 0 .. 31 ;
H_Aliases at 1 * X_32_Bits range 0 .. 31 ;
H_Addrtype at 2 * X_32_Bits range 0 .. 31 ;
H_Length at 3 * X_32_Bits range 0 .. 31 ;
H_Address at 4 * X_32_Bits range 0 .. 31 ;
end record;
for Hostent_Record'size use Hostent_Record_size;
type Ip_Mreqn is
record
Imr_Multiaddr : Internet_Address ; IP multicast group address
Imr_Address : Internet_Address ; IP address of local interface
Imr_Ifindex : Integer_32 := 0 ; interface index
end record ;
for Ip_Mreqn'size use Ip_Mreqn_size;
type Linger_Struct is
record
Onoff : Integer_32 ; Linger active
How_Long : Integer_32 ; How long to linger for (n/100 s)
end record ;
Socket name can be :
on Unix systems '"/tmp/.X11-unix/X" & Server'
on HP may be '"/usr/spool/sockets/X11/" & Server ' will work
Unix_Server_Path : aliased constant String := "/tmp/.X11-unix/X" ;
Hp_Server_Path : aliased constant String := "/usr/spool/sockets/X11/" ;
function Socket ( Family : in Integer_32;
Kind : in Integer_32;
Protocol : in Integer_32 ) return Integer_32;
pragma Import (C, Socket, "socket");
function Set_Socket_Options ( Socket : in Integer_32;
Level : in Integer_32;
Option : in Integer_32;
Value : in System.Address;
Length : in Integer_32) return Integer_32;
pragma Import (C, Set_Socket_Options, "setsockopt");
function Get_Socket_Options ( Socket : in Integer_32;
Level : in Integer_32;
Option : in Integer_32;
Value : in System.Address;
Length : in System.Address) return Integer_32;
pragma Import (C, Get_Socket_Options, "getsockopt");
function Get_Host_Name ( Name : in System.Address ;
Length : in Integer_32)
return Integer_32;
pragma Import (C, Get_Host_Name, "gethostname");
function Get_Host_By_Name (Name : in System.Address)
return Int_Ptr;
pragma Import (C, Get_Host_By_Name, "gethostbyname");
function To_Hostent is new Ada.Unchecked_Conversion
( Source => Integer_32,
Target => Hostent ) ;
procedure Close ( The_Fd : in Integer_32 ) ;
pragma Import (C, Close, "close" ) ;
function C_Read ( The_Fd : in Integer_32 ;
The_Address : in System.Address ;
The_Length : in Integer_32
) return Integer_32 ;
pragma Import (C, C_Read, "read" ) ;
function C_Recv ( The_Fd : in Integer_32 ;
The_Address : in System.Address ;
The_Length : in Integer_32 ;
The_Flags : in Integer_32 := 0 )
return Integer_32 ;
pragma Import (C, C_Recv, "recv" ) ;
modif_{0} : added for UDP Datagram (Miop)
function C_Recv_From ( The_Fd : in Integer_32 ;
The_Address : in Standard.System.Address ;
The_Length : in Integer_32 ;
The_Flags : in Integer_32 := 0 ;
From : in System.Address ;
From_Length : in System.Address)
return Integer_32 ;
pragma Import (C, C_Recv_From, "recvfrom" ) ;
end{0}
function C_Write ( The_Fd : in Integer_32 ;
The_Address : in System.Address ;
The_Length : in Integer_32
) return Integer_32 ;
pragma Import (C, C_Write, "write" ) ;
modif_{0} : added for UDP Datagram (Miop)
function Send_To ( The_Fd : in Integer_32 ;
The_Address : in System.Address ;
The_Length : in Integer_32 ;
The_Flags : in Integer_32 := 0 ;
To : in System.Address ;
To_Length : in Integer_32 )
return Integer_32 ;
pragma Import (C, Send_To , "sendto" ) ;
end{0}
function Get_Last_Error return Integer_32 ;
procedure Set_Last_Error (Errno : in Integer_32) ;
function Errno_Addr return System.Address ;
pragma Import (C, Errno_Addr, "__errno_location");
procedure Print_Error ( P_Err : in Standard.String);
pragma Import (C, Print_Error, "perror");
function Shutdown (S : in Integer_32; How : in Integer_32)
return Integer_32;
pragma Import (C, Shutdown, "shutdown");
function Unlink (Name : in System.Address)
return Integer_32;
pragma Import (C, Unlink, "unlink");
function S_Accept ( Fd : in Integer_32;
Adr : in System.Address;
Len : in System.Address) return Integer_32;
pragma Import (C, S_Accept, "accept");
function Bind ( Fd : in Integer_32;
Adr : in System.Address;
Len : in Integer_32) return Integer_32;
pragma Import (C, Bind, "bind");
function Get_Sock_Name ( Fd : in Integer_32;
Adr : in System.Address;
Len : in System.Address) return Integer_32;
pragma Import (C, Get_Sock_Name , "getsockname");
function Connect ( Fd : in Integer_32;
Adr : in System.Address;
Len : in Integer_32) return Integer_32;
pragma Import (C, Connect, "connect");
function Ioctl ( Fd : in Integer_32 ;
Flag : in Integer_32 ;
Arg : in System.Address ) return Integer_32 ;
pragma Import (C, Ioctl, "ioctl");
function Listen ( Fd : in Integer_32;
Len : in Integer_32) return Integer_32;
pragma Import (C, Listen, "listen");
function Unix_Select ( Size : in Integer_32;
Read_Set : in System.Address;
Write_Set : in System.Address;
Excep_Set : in System.Address;
Time_Out : in System.Address) return Integer_32;
pragma Import (C, Unix_Select, "select");
function Poll ( Set : in System.Address;
Num : in Integer_32;
Time_Out : in Integer_32) return Integer_32;
pragma Import (C, Poll, "poll");
function C_Pipe (Pipe : in System.Address) return Integer_32 ;
pragma Import (C, C_Pipe, "pipe" ) ;
function Execute (Command : in String) return Integer_32 ;
pragma Import (C, Execute, "system");
function Host_To_Net_Short (X : in Word) return Word ;
end Tgx.System_Ios ;
List of definition uses
This page was generated by PrismTech's ada2html on Friday Mai 12 2006 16:18