im.pidgin.pidgin: 87a81ecce720018f2f6c6d2983c0259ae3c88814

datallah at pidgin.im datallah at pidgin.im
Mon Nov 26 18:45:38 EST 2007


-----------------------------------------------------------------
Revision: 87a81ecce720018f2f6c6d2983c0259ae3c88814
Ancestor: 5865eb4a45b2c059f8cd82ebd88bcca28ec72bd7
Author: datallah at pidgin.im
Date: 2007-11-26T23:39:42
Branch: im.pidgin.pidgin

Modified files:
        libpurple/win32/libc_interface.c

ChangeLog: 

Better error messages for common Winsock errors. This was Kevin's wonderful idea.

-------------- next part --------------
============================================================
--- libpurple/win32/libc_interface.c	f9aa0b6233a6ceb59fe4d5941c038de6e2bf6393
+++ libpurple/win32/libc_interface.c	7b490aa1339e9ffafcc9793123b3d8b31e6b8ffc
@@ -28,6 +28,7 @@
 #include <sys/stat.h>
 #include <time.h>
 #include <glib.h>
+#include "config.h"
 #include "debug.h"
 #include "libc_internal.h"
 #if GLIB_CHECK_VERSION(2,6,0)
@@ -38,6 +39,26 @@
 #define g_stat stat
 #endif
 
+#ifdef ENABLE_NLS
+#  include <locale.h>
+#  include <libintl.h>
+#  define _(String) ((const char *)dgettext(PACKAGE, String))
+#  ifdef gettext_noop
+#    define N_(String) gettext_noop (String)
+#  else
+#    define N_(String) (String)
+#  endif
+#else
+#  include <locale.h>
+#  define N_(String) (String)
+#  ifndef _
+#    define _(String) ((const char *)String)
+#  endif
+#  define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
+#  define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
+#endif
+
+
 static char errbuf[1024];
 
 /* helpers */
@@ -294,15 +315,25 @@ struct hostent* wpurple_gethostbyname(co
 }
 
 /* string.h */
-char* wpurple_strerror( int errornum ) {
-	if( errornum > WSABASEERR ) {
-		sprintf( errbuf, "Windows socket error #%d", errornum );
-		return errbuf;
+char* wpurple_strerror(int errornum) {
+	if (errornum > WSABASEERR) {
+		switch(errornum) {
+			case WSAECONNABORTED: /* 10053 */
+				snprintf(errbuf, sizeof(errbuf), _("Connection interrupted by other software on your computer."));
+			case WSAECONNRESET: /* 10054 */
+				snprintf(errbuf, sizeof(errbuf), _("Remote host closed connection."));
+			case WSAETIMEDOUT: /* 10060 */
+				snprintf(errbuf, sizeof(errbuf), _("Connection timed out."));
+			case WSAECONNREFUSED: /*10061 */
+				snprintf(errbuf, sizeof(errbuf), _("Connection refused."));
+			default:
+				snprintf(errbuf, sizeof(errbuf), "Windows socket error #%d", errornum);
+		}
+	} else {
+		const char *tmp = g_strerror(errornum);
+		snprintf(errbuf, sizeof(errbuf), tmp);
 	}
-	else
-		/* Nothing is supposed to modify what is returned by strerror,
-		   but it isn't const for some reason */
-		return (char *)g_strerror( errornum );
+	return errbuf;
 }
 
 /* unistd.h */
@@ -409,7 +440,7 @@ int wpurple_gettimeofday(struct timeval 
 
 	if (p != 0) {
 		_ftime(&timebuffer);
-	   	p->tv_sec = timebuffer.time;			/* seconds since 1-1-1970 */
+		p->tv_sec = timebuffer.time;			/* seconds since 1-1-1970 */
 		p->tv_usec = timebuffer.millitm*1000; 	/* microseconds */
 	}
 


More information about the Commits mailing list