[Mono-list] Some patches regarding Win32Exception

Jaroslaw Kowalski jarek@atm.com.pl
Tue, 14 May 2002 08:45:37 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C1FB23.B8186C40
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_000C_01C1FB23.B8186C40"


------=_NextPart_001_000C_01C1FB23.B8186C40
Content-Type: text/plain;
	charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

Hi!

I'd like to contribute some error descriptions for =
System.ComponentModel.Win32Exception.cs
(included in patch1.txt)

I'd also like to contribute a small PERL utility =
"update_win32_errors.pl" that, when executed at the top level of source =
code (which is below mono and mcs and gtk-sharp) will scan through all =
"*.c" source files in mono looking for WSASetLastError(...) and =
SetLastError(...) calls and for all errors that are not handled in =
Win32Exception.cs it will generate the appropriate source code to =
stdout.

The code needs to be pasted into Win32Exception.cs and error codes need =
to be replaced with their descriptions.

I'm also sending a patch to sockets.c to check for bind() EADDRINUSE =
error (Address already in use, perhaps the most common bind() error) =
(patch2.txt)

BTW. I'm not sure if all error texts should be in "Win32Exception.cs" =
instead of "SocketException.cs", but it's very easy to fix.

Regards,

Jarek

------=_NextPart_001_000C_01C1FB23.B8186C40
Content-Type: text/html;
	charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-2">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'd like to contribute some error =
descriptions for=20
System.ComponentModel.Win32Exception.cs</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>(included in patch1.txt)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'd also like to contribute a small =
PERL utility=20
"update_win32_errors.pl" that, when executed at the top level of source =
code=20
</FONT><FONT face=3DArial size=3D2>(which is below mono and mcs and =
gtk-sharp) will=20
scan through all "*.c" source files in mono looking for =
WSASetLastError(...) and=20
SetLastError(...) calls and for all errors that are not handled in=20
Win32Exception.cs it will generate the appropriate source code to=20
stdout.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The code needs to be pasted into =
Win32Exception.cs=20
and error codes need to be replaced with their =
descriptions.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm also sending a patch to sockets.c =
to&nbsp;check=20
for&nbsp;bind() EADDRINUSE error (Address already in use, perhaps the =
most=20
common bind() error) (patch2.txt)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>BTW. I'm not sure if all error texts =
should be in=20
"Win32Exception.cs" instead of&nbsp;"SocketException.cs", but it's very =
easy to=20
fix.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Regards,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Jarek</FONT></DIV></BODY></HTML>

------=_NextPart_001_000C_01C1FB23.B8186C40--

------=_NextPart_000_000B_01C1FB23.B8186C40
Content-Type: text/plain;
	name="patch1.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="patch1.txt"

Index: Win32Exception.cs=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: =
/mono/mcs/class/System/System.ComponentModel/Win32Exception.cs,v=0A=
retrieving revision 1.3=0A=
diff -u -r1.3 Win32Exception.cs=0A=
--- Win32Exception.cs	27 Apr 2002 18:52:58 -0000	1.3=0A=
+++ Win32Exception.cs	14 May 2002 06:28:49 -0000=0A=
@@ -72,6 +72,37 @@=0A=
 				       Locale.GetText("proto no supported"));=0A=
 			w32_errors.Add(10044,=0A=
 				       Locale.GetText("socket not supproted"));=0A=
+			w32_errors.Add(10004,=0A=
+			    Locale.GetText("interrupted"));=0A=
+=0A=
+			w32_errors.Add(10013,=0A=
+			    Locale.GetText("Access denied"));=0A=
+			w32_errors.Add(11002,=0A=
+			    Locale.GetText("A temporary error occurred on an  authoritative  =
name  server. Try  again later."));=0A=
+			w32_errors.Add(10022,=0A=
+			    Locale.GetText("Invalid arguments"));=0A=
+			w32_errors.Add(10050,=0A=
+			    Locale.GetText("Network subsystem is down"));=0A=
+			w32_errors.Add(10051,=0A=
+			    Locale.GetText("Network is unreachable"));=0A=
+			w32_errors.Add(10061,=0A=
+			    Locale.GetText("Connection refused"));=0A=
+			w32_errors.Add(10045,=0A=
+			    Locale.GetText("Operation not supported"));=0A=
+			w32_errors.Add(10038,=0A=
+			    Locale.GetText("The descriptor is not a socket"));=0A=
+			w32_errors.Add(10055,=0A=
+			    Locale.GetText("Not enough buffer space is available"));=0A=
+			w32_errors.Add(10056,=0A=
+			    Locale.GetText("Socket is already connected"));=0A=
+			w32_errors.Add(10048,=0A=
+			    Locale.GetText("Address already in use"));=0A=
+			w32_errors.Add(10057,=0A=
+			    Locale.GetText("The socket is not connected"));=0A=
+			w32_errors.Add(10058,=0A=
+			    Locale.GetText("The socket has been shut down"));=0A=
+			w32_errors.Add(10093,=0A=
+			    Locale.GetText("Winsock not initialized"));=0A=
 		}=0A=
 =0A=
 		private static string W32ErrorMessage(int error_code) {=0A=

------=_NextPart_000_000B_01C1FB23.B8186C40
Content-Type: application/x-perl;
	name="update_win32_errors.pl"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="update_win32_errors.pl"

#!/usr/bin/perl=0A=
$WIN32_EXCEPTION_CS=3D"mcs/class/System/System.ComponentModel/Win32Except=
ion.cs";=0A=
$MONO_IO_ERROR=3D"mcs/class/corlib/System.IO/MonoIOError.cs";=0A=
$MONO_SRC_DIR=3D"mono";=0A=
=0A=
open(IN, "<$MONO_IO_ERROR");=0A=
while (<IN>)=0A=
{=0A=
    if (m/\s+([A-Z]\S+)\s+\=3D\s+(\d+)/)=0A=
    {=0A=
        my $id =3D $1;=0A=
        my $val =3D $2;=0A=
=0A=
        $id2value{$id} =3D $val;=0A=
        $value2id{$val} =3D $id;=0A=
    };=0A=
};=0A=
close(IN);=0A=
=0A=
$command =3D "grep SetLastError `find $MONO_SRC_DIR -name \'*.c\' =
-print`";=0A=
@files =3D `$command`;=0A=
=0A=
for (@files)=0A=
{=0A=
    if (m/SetLastError\(([A-Z].*?)\)/)=0A=
    {=0A=
        my $id =3D $1;=0A=
        my $val =3D $id2value{$id} || die "Symbol $id not defined in =
$MONO_IO_ERROR";=0A=
=0A=
        $used_id{$id} =3D 1;=0A=
        $used_val{$val} =3D 1;=0A=
    };=0A=
};=0A=
=0A=
open(IN, "<$WIN32_EXCEPTION_CS");=0A=
while (<IN>)=0A=
{=0A=
    if (m/w32_errors\.Add\((\d+),/)=0A=
    {=0A=
        my $err =3D $1;=0A=
=0A=
        $already_added{$err} =3D 1;=0A=
    };=0A=
};=0A=
close(IN);=0A=
=0A=
for $val (keys %used_val)=0A=
{=0A=
    if (!$already_added{$val})=0A=
    {=0A=
#        print "val: $val " . $value2id{$val} . "\n";=0A=
         $id =3D $value2id{$val};=0A=
=0A=
print qq!\t\t\tw32_errors.Add($val,\n!;=0A=
print qq!\t\t\t    Locale.GetText("$id"));\n!;=0A=
    };=0A=
};
------=_NextPart_000_000B_01C1FB23.B8186C40
Content-Type: text/plain;
	name="patch2.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="patch2.txt"

Index: sockets.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/io-layer/sockets.c,v=0A=
retrieving revision 1.10=0A=
diff -u -r1.10 sockets.c=0A=
--- sockets.c	9 May 2002 13:10:18 -0000	1.10=0A=
+++ sockets.c	14 May 2002 06:36:11 -0000=0A=
@@ -348,6 +348,11 @@=0A=
 		case EFAULT:=0A=
 			WSASetLastError(WSAEFAULT);=0A=
 			break;=0A=
+	=0A=
+		case EADDRINUSE:=0A=
+			WSASetLastError(WSAEADDRINUSE);=0A=
+			break;=0A=
+=0A=
 		case EROFS:=0A=
 		case ENAMETOOLONG:=0A=
 		case ENOENT:=0A=

------=_NextPart_000_000B_01C1FB23.B8186C40--