diff libpurple/util.c @ 27863:57727a140609

propagate from branch 'im.pidgin.pidgin' (head 97e156c1c2ef4aabc8926ff845b42b911a476dd0) to branch 'im.pidgin.pidgin.yaz' (head 5af759d36dbdbfc7fb196a56607aec7a61a8d2a8)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 18 Jul 2008 08:45:31 +0000
parents 28a7992d37b2 399975ad001c
children b522393714d6
line wrap: on
line diff
--- a/libpurple/util.c	Fri Jul 11 18:29:35 2008 +0000
+++ b/libpurple/util.c	Fri Jul 18 08:45:31 2008 +0000
@@ -4725,6 +4725,24 @@
 	return g_string_free(string, FALSE);
 }
 
+const gchar *
+purple_get_host_name(void)
+{
+#if GLIB_CHECK_VERSION(2,8,0)
+	return g_get_host_name();
+#else
+	static char hostname[256];
+	int ret = gethostname(hostname, sizeof(hostname));
+	hostname[sizeof(hostname) - 1] = '\0';
+
+	if (ret == -1 || hostname[0] == '\0') {
+		purple_debug_info("purple_get_host_name: ", "could not find host name");
+		return "localhost";
+	} else {
+		return hostname;
+	}
+#endif
+}
 
 #ifdef _WIN32
 void botch_ucs(gchar *ucs_src, gsize len)
@@ -4744,33 +4762,33 @@
  		switch(*(ucs+i)){
  		case 0x00:
  			switch(*(ucs+i+1)){
- 			case 0xa2:	// ¢
+ 			case 0xa2:	// ¡ñ
  				*(ucs+i) = 0xff;
  				*(ucs+i+1) = 0xe0;
  				break;
- 			case 0xa3:	// £
+ 			case 0xa3:	// ¡ò
  				*(ucs+i) = 0xff;
 				*(ucs+i+1) = 0xe1;
  				break;
- 			case 0xac:	// ¬
+ 			case 0xac:	// ¢Ì
  				*(ucs+i) = 0xff;
  				*(ucs+i+1) = 0xe2;
  				break;
  			}
  			break;
- 		case 0x20:	// ‖
+ 		case 0x20:	// ¡Â
  			if(*(ucs+i+1) == 0x16){
  				*(ucs+i) = 0x22;
 				*(ucs+i+1) = 0x25;
  			}
  			break;
- 		case 0x22:	// −
+ 		case 0x22:	// ¡Ý
  			if(*(ucs+i+1) == 0x12){
  				*(ucs+i) = 0xff;
  				*(ucs+i+1) = 0x0d;
  			}
  			break;
- 		case 0x30:	// 〜
+ 		case 0x30:	// ¡Á
  			if(*(ucs+i+1) == 0x1c){
  				*(ucs+i) = 0xff;
  				*(ucs+i+1) = 0x5e;
@@ -4800,7 +4818,7 @@
 		switch(*(ucs+i)){
 		case 0x22:
 			switch(*(ucs+i+1)){
-			case 0x25:	// ‖
+			case 0x25:	// ¡Â
 				*(ucs+i) = 0x20;
 				*(ucs+i+1) = 0x16;
 				break;
@@ -4808,23 +4826,23 @@
 			break;
 		case 0xff:
 			switch(*(ucs+i+1)){
-			case 0x0d:	// −
+			case 0x0d:	// ¡Ý
 				*(ucs+i) = 0x22;
 				*(ucs+i+1) = 0x12;
 				break;
-			case 0x5e:	// 〜
+			case 0x5e:	// ¡Á
 				*(ucs+i) = 0x30;
 				*(ucs+i+1) = 0x1c;
 				break;
-			case 0xe0:	// ¢
+			case 0xe0:	// ¡ñ
 				*(ucs+i) = 0x00;
 				*(ucs+i+1) = 0xa2;
 				break;
-			case 0xe1:	// £
+			case 0xe1:	// ¡ò
 				*(ucs+i) = 0x00;
 				*(ucs+i+1) = 0xa3;
 				break;
-			case 0xe2:	// ¬
+			case 0xe2:	// ¢Ì
 				*(ucs+i) = 0x00;
 				*(ucs+i+1) = 0xac;
 				break;
@@ -4868,7 +4886,7 @@
 		switch(*(utf+i)){
 		case 0xe2:
 			if(*(utf+i+1) == 0x88) {
-				if(*(utf+i+2) == 0xa5) {	// ‖
+				if(*(utf+i+2) == 0xa5) {	// ¡Â
 					*(utf+i) = 0xe2;
 					*(utf+i+1) = 0x80;
 					*(utf+i+2) = 0x96;
@@ -4878,14 +4896,14 @@
 		case 0xef:
 			switch(*(utf+i+1)){
 			case 0xbc:
-				if(*(utf+i+2) == 0x8d) {	// −
+				if(*(utf+i+2) == 0x8d) {	// ¡Ý
 					*(utf+i) = 0xe2;
 					*(utf+i+1) = 0x88;
 					*(utf+i+2) = 0x92;
 				}
 				break;
 			case 0xbd:
-				if(*(utf+i+2) == 0x9e) {	// 〜
+				if(*(utf+i+2) == 0x9e) {	// ¡Á
 					*(utf+i) = 0xe3;
 					*(utf+i+1) = 0x80;
 					*(utf+i+2) = 0x9c;
@@ -4893,21 +4911,21 @@
 				break;
 			case 0xbf:
 				switch(*(utf+i+2)){
-			       case 0xa0:	// ¢
+			       case 0xa0:	// ¡ñ
 				       *(utf+i) = 0xc2;
 				       *(utf+i+1) = 0xa2;
 				       memmove(utf+i+2, utf+i+3,
 					       len-i-3); //shorten by 1byte
 				       bytes--;
 				       break;
-			       case 0xa1:	// £
+			       case 0xa1:	// ¡ò
 				       *(utf+i) = 0xc2;
 				       *(utf+i+1) = 0xa3;
 				       memmove(utf+i+2, utf+i+3,
 					       len-i-3); //shorten by 1byte
 				       bytes--;
 				       break;
-			       case 0xa2:	// ¬
+			       case 0xa2:	// ¢Ì
 				       *(utf+i) = 0xc2;
 				       *(utf+i+1) = 0xac;
 				       memmove(utf+i+2, utf+i+3,
@@ -4950,31 +4968,31 @@
 	if(len == -1)
 		len = strlen(msg);
 	g_return_val_if_fail(len > 0, NULL);
-	
+
 	bytes = len;
 
 	utf = g_malloc0(bytes*3/2+1); /* new length might be 3/2 in the worst case */
 	memcpy(utf, msg, bytes);
-	
+
  	for(i=0;i<bytes;i++){
  		switch(*(utf+i)){
  		case 0xc2:
  			switch(*(utf+i+1)){
- 			case 0xa2:	// ¢
+ 			case 0xa2:	// ¡ñ
  				*(utf+i) = 0xef;
  				*(utf+i+1) = 0xbf;
 				memmove(utf+i+3, utf+i+2, bytes-i-2);
 				*(utf+i+2) = 0xa0;
 				bytes++;
  				break;
- 			case 0xa3:	// £
+ 			case 0xa3:	// ¡ò
  				*(utf+i) = 0xef;
  				*(utf+i+1) = 0xbf;
 				memmove(utf+i+3, utf+i+2, bytes-i-2);
 				*(utf+i+2) = 0xa1;
 				bytes++;
  				break;
- 			case 0xac:	// ¬
+ 			case 0xac:	// ¢Ì
  				*(utf+i) = 0xef;
  				*(utf+i+1) = 0xbf;
 				memmove(utf+i+3, utf+i+2, bytes-i-2);
@@ -4985,14 +5003,14 @@
  			break;
  		case 0xe2:
 			switch(*(utf+i+1)){
-			case 0x80:	// ‖
+			case 0x80:	// ¡Â
 				if(*(utf+i+2) == 0x96){
 					*(utf+i) = 0xe2;
 					*(utf+i+1) = 0x88;
 					*(utf+i+2) = 0xa5;
 				}
 				break;
-			case 0x88:	// −
+			case 0x88:	// ¡Ý
 				if(*(utf+i+1) == 0x92){
 					*(utf+i) = 0xef;
 					*(utf+i+1) = 0xbc;
@@ -5001,7 +5019,7 @@
 				break;
 			}
 			break;
- 		case 0xe3:	// 〜
+ 		case 0xe3:	// ¡Á
  			if(*(utf+i+1) == 0x80){
 				if(*(utf+i+2) == 0x9c){
 					*(utf+i) = 0xef;