changeset 4406:217572342740

[gaim-migrate @ 4675] wgaim_escape_dirsep committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Thu, 23 Jan 2003 19:25:48 +0000
parents cb629f3efee6
children 473b1ea6b616
files src/win32/win32dep.c src/win32/win32dep.h
diffstat 2 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/win32/win32dep.c	Thu Jan 23 19:24:12 2003 +0000
+++ b/src/win32/win32dep.c	Thu Jan 23 19:25:48 2003 +0000
@@ -92,6 +92,33 @@
 	return gaimexe_hInstance;
 }
 
+/* Escape windows dir separators.  This is needed when paths are saved,
+   and on being read back have their '\' chars used as an escape char.
+   Returns and allocated string which needs to be freed.
+*/
+char* wgaim_escape_dirsep( char* filename ) {
+	int sepcount=0;
+	char* ret=NULL;
+	int cnt=0;
+
+	ret = filename;
+	while(*ret) {
+		if(*ret == '\\')
+			sepcount++;
+		ret++;
+	}
+	ret = g_malloc0(strlen(filename) + sepcount + 1);
+	while(*filename) {
+		ret[cnt] = *filename;
+		if(*filename == '\\')
+			ret[++cnt] = '\\';
+		filename++;
+		cnt++;
+	}
+	ret[cnt] = '\0';
+	return ret;
+}
+
 /* Determine whether the specified dll contains the specified procedure.
    If so, load it (if not already loaded). */
 FARPROC wgaim_find_and_loadproc( char* dllname, char* procedure ) {
@@ -210,7 +237,6 @@
 void wgaim_init(void) {
 	WORD wVersionRequested;
 	WSADATA wsaData;
-	int err;
 	char* locale=0;
 	char newenv[128];
 
@@ -226,10 +252,7 @@
 	 */
 	wVersionRequested = MAKEWORD( 2, 2 );
 
-	err = WSAStartup( wVersionRequested, &wsaData );
-	if ( err != 0 ) {
-		return 1;
-	}
+	WSAStartup( wVersionRequested, &wsaData );
 
 	/* Confirm that the winsock DLL supports 2.2 */
 	/* Note that if the DLL supports versions greater than
@@ -240,7 +263,6 @@
 			HIBYTE( wsaData.wVersion ) != 2 ) {
 		debug_printf("Could not find a usable WinSock DLL.  Oh well.\n");
 		WSACleanup( );
-		return 1;
 	}
 
 	/* get default locale */
--- a/src/win32/win32dep.h	Thu Jan 23 19:24:12 2003 +0000
+++ b/src/win32/win32dep.h	Thu Jan 23 19:25:48 2003 +0000
@@ -22,6 +22,7 @@
 FARPROC wgaim_find_and_loadproc(char*, char*);
 HINSTANCE wgaim_hinstance(void);
 extern void wgaim_im_blink(GtkWidget*);
+extern char* wgaim_escape_dirsep(char*);
 
 /* Determine Gaim paths */
 extern char* wgaim_install_dir(void);