g-stheme.adb, [...] (Host_Error_Message): Return a string...
2014-02-24 Thomas Quinot <quinot@adacore.com> * g-stheme.adb, g-socthi-vms.adb, g-socthi-vms.ads, g-socthi-vxworks.adb, g-socthi-vxworks.ads, g-stseme.adb, g-socthi-mingw.adb, g-socthi-mingw.ads, g-socthi.adb, g-socthi.ads, g-socket.adb (Host_Error_Message): Return a string, not a chars_ptr, because on Windows this is a renaming of Socket_Error_Message. From-SVN: r208082
This commit is contained in:
parent
1b31321b18
commit
47752af2e8
12 changed files with 74 additions and 96 deletions
|
@ -1,3 +1,12 @@
|
|||
2014-02-24 Thomas Quinot <quinot@adacore.com>
|
||||
|
||||
* g-stheme.adb, g-socthi-vms.adb, g-socthi-vms.ads,
|
||||
g-socthi-vxworks.adb, g-socthi-vxworks.ads, g-stseme.adb,
|
||||
g-socthi-mingw.adb, g-socthi-mingw.ads, g-socthi.adb,
|
||||
g-socthi.ads, g-socket.adb (Host_Error_Message): Return a string, not
|
||||
a chars_ptr, because on Windows this is a renaming of
|
||||
Socket_Error_Message.
|
||||
|
||||
2014-02-24 Robert Dewar <dewar@adacore.com>
|
||||
|
||||
* a-direct.adb, sem_ch5.adb, a-cfdlli.adb, a-cfhase.adb, a-tags.adb,
|
||||
|
|
|
@ -1709,7 +1709,7 @@ package body GNAT.Sockets is
|
|||
begin
|
||||
raise Host_Error with
|
||||
Err_Code_Image (H_Error)
|
||||
& C.Strings.Value (Host_Error_Messages.Host_Error_Message (H_Error));
|
||||
& Host_Error_Messages.Host_Error_Message (H_Error);
|
||||
end Raise_Host_Error;
|
||||
|
||||
------------------------
|
||||
|
|
|
@ -535,8 +535,7 @@ package body GNAT.Sockets.Thin is
|
|||
-- error messages are provided by Socket_Error_Message, so the default
|
||||
-- separate body for Host_Error_Messages is not used in this case.
|
||||
|
||||
function Host_Error_Message
|
||||
(H_Errno : Integer) return C.Strings.chars_ptr
|
||||
function Host_Error_Message (H_Errno : Integer) return String
|
||||
renames Socket_Error_Message;
|
||||
|
||||
end Host_Error_Messages;
|
||||
|
@ -572,61 +571,62 @@ package body GNAT.Sockets.Thin is
|
|||
|
||||
begin
|
||||
case Errno is
|
||||
when EINTR => Errm := N_EINTR;
|
||||
when EBADF => Errm := N_EBADF;
|
||||
when EACCES => Errm := N_EACCES;
|
||||
when EFAULT => Errm := N_EFAULT;
|
||||
when EINVAL => Errm := N_EINVAL;
|
||||
when EMFILE => Errm := N_EMFILE;
|
||||
when EWOULDBLOCK => Errm := N_EWOULDBLOCK;
|
||||
when EINPROGRESS => Errm := N_EINPROGRESS;
|
||||
when EALREADY => Errm := N_EALREADY;
|
||||
when ENOTSOCK => Errm := N_ENOTSOCK;
|
||||
when EDESTADDRREQ => Errm := N_EDESTADDRREQ;
|
||||
when EMSGSIZE => Errm := N_EMSGSIZE;
|
||||
when EPROTOTYPE => Errm := N_EPROTOTYPE;
|
||||
when ENOPROTOOPT => Errm := N_ENOPROTOOPT;
|
||||
when EPROTONOSUPPORT => Errm := N_EPROTONOSUPPORT;
|
||||
when ESOCKTNOSUPPORT => Errm := N_ESOCKTNOSUPPORT;
|
||||
when EOPNOTSUPP => Errm := N_EOPNOTSUPP;
|
||||
when EPFNOSUPPORT => Errm := N_EPFNOSUPPORT;
|
||||
when EAFNOSUPPORT => Errm := N_EAFNOSUPPORT;
|
||||
when EADDRINUSE => Errm := N_EADDRINUSE;
|
||||
when EADDRNOTAVAIL => Errm := N_EADDRNOTAVAIL;
|
||||
when ENETDOWN => Errm := N_ENETDOWN;
|
||||
when ENETUNREACH => Errm := N_ENETUNREACH;
|
||||
when ENETRESET => Errm := N_ENETRESET;
|
||||
when ECONNABORTED => Errm := N_ECONNABORTED;
|
||||
when ECONNRESET => Errm := N_ECONNRESET;
|
||||
when ENOBUFS => Errm := N_ENOBUFS;
|
||||
when EISCONN => Errm := N_EISCONN;
|
||||
when ENOTCONN => Errm := N_ENOTCONN;
|
||||
when ESHUTDOWN => Errm := N_ESHUTDOWN;
|
||||
when ETOOMANYREFS => Errm := N_ETOOMANYREFS;
|
||||
when ETIMEDOUT => Errm := N_ETIMEDOUT;
|
||||
when ECONNREFUSED => Errm := N_ECONNREFUSED;
|
||||
when ELOOP => Errm := N_ELOOP;
|
||||
when ENAMETOOLONG => Errm := N_ENAMETOOLONG;
|
||||
when EHOSTDOWN => Errm := N_EHOSTDOWN;
|
||||
when EHOSTUNREACH => Errm := N_EHOSTUNREACH;
|
||||
when EINTR => Errm := Error_Messages (N_EINTR);
|
||||
when EBADF => Errm := Error_Messages (N_EBADF);
|
||||
when EACCES => Errm := Error_Messages (N_EACCES);
|
||||
when EFAULT => Errm := Error_Messages (N_EFAULT);
|
||||
when EINVAL => Errm := Error_Messages (N_EINVAL);
|
||||
when EMFILE => Errm := Error_Messages (N_EMFILE);
|
||||
when EWOULDBLOCK => Errm := Error_Messages (N_EWOULDBLOCK);
|
||||
when EINPROGRESS => Errm := Error_Messages (N_EINPROGRESS);
|
||||
when EALREADY => Errm := Error_Messages (N_EALREADY);
|
||||
when ENOTSOCK => Errm := Error_Messages (N_ENOTSOCK);
|
||||
when EDESTADDRREQ => Errm := Error_Messages (N_EDESTADDRREQ);
|
||||
when EMSGSIZE => Errm := Error_Messages (N_EMSGSIZE);
|
||||
when EPROTOTYPE => Errm := Error_Messages (N_EPROTOTYPE);
|
||||
when ENOPROTOOPT => Errm := Error_Messages (N_ENOPROTOOPT);
|
||||
when EPROTONOSUPPORT => Errm := Error_Messages (N_EPROTONOSUPPORT);
|
||||
when ESOCKTNOSUPPORT => Errm := Error_Messages (N_ESOCKTNOSUPPORT);
|
||||
when EOPNOTSUPP => Errm := Error_Messages (N_EOPNOTSUPP);
|
||||
when EPFNOSUPPORT => Errm := Error_Messages (N_EPFNOSUPPORT);
|
||||
when EAFNOSUPPORT => Errm := Error_Messages (N_EAFNOSUPPORT);
|
||||
when EADDRINUSE => Errm := Error_Messages (N_EADDRINUSE);
|
||||
when EADDRNOTAVAIL => Errm := Error_Messages (N_EADDRNOTAVAIL);
|
||||
when ENETDOWN => Errm := Error_Messages (N_ENETDOWN);
|
||||
when ENETUNREACH => Errm := Error_Messages (N_ENETUNREACH);
|
||||
when ENETRESET => Errm := Error_Messages (N_ENETRESET);
|
||||
when ECONNABORTED => Errm := Error_Messages (N_ECONNABORTED);
|
||||
when ECONNRESET => Errm := Error_Messages (N_ECONNRESET);
|
||||
when ENOBUFS => Errm := Error_Messages (N_ENOBUFS);
|
||||
when EISCONN => Errm := Error_Messages (N_EISCONN);
|
||||
when ENOTCONN => Errm := Error_Messages (N_ENOTCONN);
|
||||
when ESHUTDOWN => Errm := Error_Messages (N_ESHUTDOWN);
|
||||
when ETOOMANYREFS => Errm := Error_Messages (N_ETOOMANYREFS);
|
||||
when ETIMEDOUT => Errm := Error_Messages (N_ETIMEDOUT);
|
||||
when ECONNREFUSED => Errm := Error_Messages (N_ECONNREFUSED);
|
||||
when ELOOP => Errm := Error_Messages (N_ELOOP);
|
||||
when ENAMETOOLONG => Errm := Error_Messages (N_ENAMETOOLONG);
|
||||
when EHOSTDOWN => Errm := Error_Messages (N_EHOSTDOWN);
|
||||
when EHOSTUNREACH => Errm := Error_Messages (N_EHOSTUNREACH);
|
||||
|
||||
-- Windows-specific error codes
|
||||
|
||||
when WSASYSNOTREADY => Errm := N_WSASYSNOTREADY;
|
||||
when WSASYSNOTREADY => Errm := Error_Messages (N_WSASYSNOTREADY);
|
||||
when WSAVERNOTSUPPORTED =>
|
||||
Errm := N_WSAVERNOTSUPPORTED;
|
||||
Errm := Error_Messages (N_WSAVERNOTSUPPORTED);
|
||||
when WSANOTINITIALISED =>
|
||||
Errm := N_WSANOTINITIALISED;
|
||||
when WSAEDISCON => Errm := N_WSAEDISCON;
|
||||
Errm := Error_Messages (N_WSANOTINITIALISED);
|
||||
when WSAEDISCON =>
|
||||
Errm := Error_Messages (N_WSAEDISCON);
|
||||
|
||||
-- h_errno values
|
||||
|
||||
when HOST_NOT_FOUND => Errm := N_HOST_NOT_FOUND;
|
||||
when TRY_AGAIN => Errm := N_TRY_AGAIN;
|
||||
when NO_RECOVERY => Errm := N_NO_RECOVERY;
|
||||
when NO_DATA => Errm := N_NO_DATA;
|
||||
when HOST_NOT_FOUND => Errm := Error_Messages (N_HOST_NOT_FOUND);
|
||||
when TRY_AGAIN => Errm := Error_Messages (N_TRY_AGAIN);
|
||||
when NO_RECOVERY => Errm := Error_Messages (N_NO_RECOVERY);
|
||||
when NO_DATA => Errm := Error_Messages (N_NO_DATA);
|
||||
|
||||
when others => Errm := N_OTHERS;
|
||||
when others => Errm := Error_Messages (N_OTHERS);
|
||||
end case;
|
||||
|
||||
return Value (Errm);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
-- This version is for NT
|
||||
|
||||
with Interfaces.C.Strings;
|
||||
with Interfaces.C;
|
||||
|
||||
with GNAT.Sockets.Thin_Common;
|
||||
|
||||
|
@ -66,8 +66,7 @@ package GNAT.Sockets.Thin is
|
|||
|
||||
package Host_Error_Messages is
|
||||
|
||||
function Host_Error_Message
|
||||
(H_Errno : Integer) return C.Strings.chars_ptr;
|
||||
function Host_Error_Message (H_Errno : Integer) return String;
|
||||
-- Returns the error message string for the host error number H_Errno.
|
||||
-- If H_Errno is not known, returns "Unknown system error".
|
||||
|
||||
|
|
|
@ -66,9 +66,6 @@ package body GNAT.Sockets.Thin is
|
|||
-- mode and we spend a period of time Quantum between two attempts on a
|
||||
-- blocking operation.
|
||||
|
||||
Unknown_System_Error : constant C.Strings.chars_ptr :=
|
||||
C.Strings.New_String ("Unknown system error");
|
||||
|
||||
function Syscall_Accept
|
||||
(S : C.int;
|
||||
Addr : System.Address;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
-- This is the Alpha/VMS version
|
||||
|
||||
with Interfaces.C.Strings;
|
||||
with Interfaces.C;
|
||||
|
||||
with GNAT.OS_Lib;
|
||||
with GNAT.Sockets.Thin_Common;
|
||||
|
@ -69,8 +69,7 @@ package GNAT.Sockets.Thin is
|
|||
|
||||
package Host_Error_Messages is
|
||||
|
||||
function Host_Error_Message
|
||||
(H_Errno : Integer) return C.Strings.chars_ptr;
|
||||
function Host_Error_Message (H_Errno : Integer) return String;
|
||||
-- Returns the error message string for the host error number H_Errno.
|
||||
-- If H_Errno is not known, returns "Unknown system error".
|
||||
|
||||
|
|
|
@ -57,9 +57,6 @@ package body GNAT.Sockets.Thin is
|
|||
-- non-blocking mode and we spend a period of time Quantum between
|
||||
-- two attempts on a blocking operation.
|
||||
|
||||
Unknown_System_Error : constant C.Strings.chars_ptr :=
|
||||
C.Strings.New_String ("Unknown system error");
|
||||
|
||||
-----------------------
|
||||
-- Local Subprograms --
|
||||
-----------------------
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
-- This is the version for VxWorks
|
||||
|
||||
with Interfaces.C.Strings;
|
||||
with Interfaces.C;
|
||||
|
||||
with GNAT.OS_Lib;
|
||||
with GNAT.Sockets.Thin_Common;
|
||||
|
@ -67,8 +67,7 @@ package GNAT.Sockets.Thin is
|
|||
|
||||
package Host_Error_Messages is
|
||||
|
||||
function Host_Error_Message
|
||||
(H_Errno : Integer) return C.Strings.chars_ptr;
|
||||
function Host_Error_Message (H_Errno : Integer) return String;
|
||||
-- Returns the error message string for the host error number H_Errno.
|
||||
-- If H_Errno is not known, returns "Unknown system error".
|
||||
|
||||
|
|
|
@ -57,8 +57,6 @@ package body GNAT.Sockets.Thin is
|
|||
-- non-blocking mode and we spend a period of time Quantum between
|
||||
-- two attempts on a blocking operation.
|
||||
|
||||
Unknown_System_Error : constant String := "Unknown system error";
|
||||
|
||||
-- Comments required for following functions ???
|
||||
|
||||
function Syscall_Accept
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
-- This is the default version
|
||||
|
||||
with Interfaces.C.Strings;
|
||||
with Interfaces.C;
|
||||
|
||||
with GNAT.OS_Lib;
|
||||
with GNAT.Sockets.Thin_Common;
|
||||
|
@ -68,8 +68,7 @@ package GNAT.Sockets.Thin is
|
|||
|
||||
package Host_Error_Messages is
|
||||
|
||||
function Host_Error_Message
|
||||
(H_Errno : Integer) return C.Strings.chars_ptr;
|
||||
function Host_Error_Message (H_Errno : Integer) return String;
|
||||
-- Returns the error message string for the host error number H_Errno.
|
||||
-- If H_Errno is not known, returns "Unknown system error".
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
-- --
|
||||
-- B o d y --
|
||||
-- --
|
||||
-- Copyright (C) 2007-2010, AdaCore --
|
||||
-- Copyright (C) 2007-2013, AdaCore --
|
||||
-- --
|
||||
-- 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- --
|
||||
|
@ -36,38 +36,19 @@
|
|||
separate (GNAT.Sockets.Thin)
|
||||
package body Host_Error_Messages is
|
||||
|
||||
package Messages is
|
||||
HOST_NOT_FOUND : aliased char_array := "Host not found" & nul;
|
||||
TRY_AGAIN : aliased char_array := "Try again" & nul;
|
||||
NO_RECOVERY : aliased char_array := "No recovery" & nul;
|
||||
NO_DATA : aliased char_array := "No address" & nul;
|
||||
Unknown_Error : aliased char_array := "Unknown error" & nul;
|
||||
end Messages;
|
||||
|
||||
function Host_Error_Message (H_Errno : Integer) return C.Strings.chars_ptr
|
||||
is
|
||||
use Interfaces.C.Strings;
|
||||
function TCP
|
||||
(P : char_array_access; Nul_Check : Boolean := False) return chars_ptr
|
||||
renames To_Chars_Ptr;
|
||||
|
||||
function Host_Error_Message (H_Errno : Integer) return String is
|
||||
begin
|
||||
case H_Errno is
|
||||
when SOSC.HOST_NOT_FOUND =>
|
||||
return TCP (Messages.HOST_NOT_FOUND'Access);
|
||||
|
||||
return "Host not found";
|
||||
when SOSC.TRY_AGAIN =>
|
||||
return TCP (Messages.TRY_AGAIN'Access);
|
||||
|
||||
return "Try again";
|
||||
when SOSC.NO_RECOVERY =>
|
||||
return TCP (Messages.NO_RECOVERY'Access);
|
||||
|
||||
return "No recovery";
|
||||
when SOSC.NO_DATA =>
|
||||
return TCP (Messages.NO_DATA'Access);
|
||||
|
||||
return "No address";
|
||||
when others =>
|
||||
return TCP (Messages.Unknown_Error'Access);
|
||||
|
||||
return "Unknown error";
|
||||
end case;
|
||||
end Host_Error_Message;
|
||||
|
||||
|
|
|
@ -44,5 +44,5 @@ function Socket_Error_Message
|
|||
(Errno : Integer) return String
|
||||
is
|
||||
begin
|
||||
return Errno_Message (Errno, Default => Unknown_System_Error);
|
||||
return Errno_Message (Errno, Default => "Unknown system error");
|
||||
end Socket_Error_Message;
|
||||
|
|
Loading…
Add table
Reference in a new issue