changeset 10589:0f7452b1f777

[gaim-migrate @ 11994] Use GLib 2.6's gstdio functions. This should fix gaim not liking non-ascii filenames in win32. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 11 Feb 2005 05:10:40 +0000
parents 529111933c9c
children 896efbdc74e2
files plugins/filectl.c plugins/gaim-remote/remote.c plugins/mailchk.c plugins/spellchk.c plugins/tcl/tcl.c src/Makefile.mingw src/buddyicon.c src/desktopitem.c src/ft.c src/gtkaccount.c src/gtkconv.c src/gtkdebug.c src/gtkimhtml.c src/gtkmain.c src/gtkprefs.c src/gtkthemes.c src/internal.h src/log.c src/protocols/msn/directconn.c src/protocols/msn/msn.c src/protocols/msn/notification.c src/protocols/msn/session.c src/protocols/msn/slplink.c src/protocols/msn/slpmsg.c src/protocols/msn/user.c src/protocols/oscar/oscar.c src/protocols/rendezvous/rendezvous.c src/protocols/silc/buddy.c src/protocols/silc/ft.c src/protocols/silc/ops.c src/protocols/silc/pk.c src/protocols/silc/util.c src/protocols/toc/toc.c src/protocols/trepia/trepia.c src/protocols/yahoo/yahoo_picture.c src/protocols/zephyr/ZGetWGPort.c src/protocols/zephyr/ZVariables.c src/protocols/zephyr/zephyr.c src/util.c src/win32/libc_interface.c src/win32/libc_interface.h src/win32/untar.c src/win32/win32dep.c
diffstat 43 files changed, 219 insertions(+), 319 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/filectl.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/plugins/filectl.c	Fri Feb 11 05:10:40 2005 +0000
@@ -47,7 +47,7 @@
 
 	sprintf(filename, "%s" G_DIR_SEPARATOR_S "control", gaim_user_dir());
 
-	file = fopen(filename, "r+");
+	file = g_fopen(filename, "r+");
 	while (fgets(buffer, sizeof(buffer), file)) {
 
 		/* Read the next command */
@@ -131,7 +131,7 @@
 
 	fclose(file);
 
-	if (stat (filename, &finfo) != 0)
+	if (g_stat(filename, &finfo) != 0)
 		return;
 	mtime = finfo.st_mtime;
 }
@@ -148,7 +148,7 @@
 
 	sprintf(filename, "%s" G_DIR_SEPARATOR_S "control", gaim_user_dir());
 
-	if ((stat(filename, &finfo) == 0) && (finfo.st_size > 0))
+	if ((g_stat(filename, &finfo) == 0) && (finfo.st_size > 0))
 		run_commands();
 }
 
@@ -164,7 +164,7 @@
 
 	sprintf(filename, "%s" G_DIR_SEPARATOR_S "control", gaim_user_dir());
 
-	if ((stat(filename, &finfo) == 0) && (finfo.st_size > 0))
+	if ((g_stat(filename, &finfo) == 0) && (finfo.st_size > 0))
 	{
 		if (mtime != finfo.st_mtime) {
 			gaim_debug_info("filectl", "control changed, checking\n");
--- a/plugins/gaim-remote/remote.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/plugins/gaim-remote/remote.c	Fri Feb 11 05:10:40 2005 +0000
@@ -798,7 +798,7 @@
 	g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d",
 			g_get_tmp_dir(), g_get_user_name(), gaim_session);
 
-	unlink(buf);
+	g_unlink(buf);
 
 	gaim_debug_misc("core", "Removed core\n");
 
--- a/plugins/mailchk.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/plugins/mailchk.c	Fri Feb 11 05:10:40 2005 +0000
@@ -29,7 +29,7 @@
 	if (!filename)
 		filename = g_strconcat("/var/spool/mail/", g_get_user_name(), NULL);
 
-	if (stat(filename, &s) < 0) {
+	if (g_stat(filename, &s) < 0) {
 		g_free(filename);
 		return -1;
 	}
--- a/plugins/spellchk.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/plugins/spellchk.c	Fri Feb 11 05:10:40 2005 +0000
@@ -343,11 +343,11 @@
 	if(fclose(f)) {
 		gaim_debug(GAIM_DEBUG_ERROR, "spellchk",
 				   "Error writing to %s: %m\n", tempfilename);
-		unlink(tempfilename);
+		g_unlink(tempfilename);
 		g_free(name);
 		return;
 	}
-	rename(tempfilename, name);
+	g_rename(tempfilename, name);
 	g_free(name);
 }
 
--- a/plugins/tcl/tcl.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/plugins/tcl/tcl.c	Fri Feb 11 05:10:40 2005 +0000
@@ -161,8 +161,7 @@
 	const char *next;
 	int len, found = 0, err = 0, nelems;
 	gboolean status = FALSE;
-
-	if ((fp = fopen(plugin->path, "r")) == NULL)
+	if ((fp = g_fopen(plugin->path, "r")) == NULL)
 		return FALSE;
 	if (fstat(fileno(fp), &st)) {
 		fclose(fp);
--- a/src/Makefile.mingw	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/Makefile.mingw	Fri Feb 11 05:10:40 2005 +0000
@@ -175,7 +175,7 @@
 			-lws2_32 \
 			-liberty \
 			-lwinmm \
-			-lzdll \
+			-lz \
 			-lidletrack \
 			-lnss3 \
 			-lnspr4 \
--- a/src/buddyicon.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/buddyicon.c	Fri Feb 11 05:10:40 2005 +0000
@@ -225,7 +225,7 @@
 	{
 		gaim_debug_info("buddy icons", "Creating icon cache directory.\n");
 
-		if (mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0)
+		if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0)
 		{
 			gaim_debug_error("buddy icons",
 							 "Unable to create directory %s: %s\n",
@@ -233,7 +233,7 @@
 		}
 	}
 
-	if ((file = fopen(filename, "wb")) != NULL)
+	if ((file = g_fopen(filename, "wb")) != NULL)
 	{
 		fwrite(data, 1, len, file);
 		fclose(file);
@@ -243,12 +243,12 @@
 
 	if (old_icon != NULL)
 	{
-		if(!stat(old_icon, &st))
-			unlink(old_icon);
+		if(!g_stat(old_icon, &st))
+			g_unlink(old_icon);
 		else {
 			filename = g_build_filename(dirname, old_icon, NULL);
-			if(!stat(filename, &st))
-				unlink(filename);
+			if(!g_stat(filename, &st))
+				g_unlink(filename);
 			g_free(filename);
 		}
 	}
@@ -373,13 +373,13 @@
 		if ((file = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon")) == NULL)
 			return NULL;
 
-		if (!stat(file, &st))
+		if (!g_stat(file, &st))
 			filename = g_strdup(file);
 		else
 			filename = g_build_filename(gaim_buddy_icons_get_cache_dir(), file, NULL);
 
-		if (!stat(filename, &st)) {
-			FILE *f = fopen(filename, "rb");
+		if (!g_stat(filename, &st)) {
+			FILE *f = g_fopen(filename, "rb");
 			if (f) {
 				char *data = g_malloc(st.st_size);
 				fread(data, 1, st.st_size, f);
--- a/src/desktopitem.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/desktopitem.c	Fri Feb 11 05:10:40 2005 +0000
@@ -1150,7 +1150,7 @@
 
 	g_return_val_if_fail (filename != NULL, NULL);
 
-	dfile = fopen(filename, "r");
+	dfile = g_fopen(filename, "r");
 	if (!dfile) {
 		printf ("Can't open %s: %s", filename, strerror(errno));
 		return NULL;
--- a/src/ft.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/ft.c	Fri Feb 11 05:10:40 2005 +0000
@@ -171,7 +171,7 @@
 
 	xfer = (GaimXfer *)user_data;
 
-	if (stat(filename, &st) != 0) {
+	if (g_stat(filename, &st) != 0) {
 		/* File not found. */
 		if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
 			gaim_xfer_request_accepted(xfer, filename);
@@ -370,7 +370,7 @@
 			return;
 		}
 
-		if (stat(filename, &st) == -1) {
+		if (g_stat(filename, &st) == -1) {
 		  	gaim_xfer_show_file_error(xfer, filename);
 			gaim_xfer_unref(xfer);
 			return;
@@ -792,7 +792,7 @@
 {
 	GaimXferType type = gaim_xfer_get_type(xfer);
 
-	xfer->dest_fp = fopen(gaim_xfer_get_local_filename(xfer),
+	xfer->dest_fp = g_fopen(gaim_xfer_get_local_filename(xfer),
 						  type == GAIM_XFER_RECEIVE ? "wb" : "rb");
 
 	if (xfer->dest_fp == NULL) {
--- a/src/gtkaccount.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/gtkaccount.c	Fri Feb 11 05:10:40 2005 +0000
@@ -304,7 +304,7 @@
 		GTK_FILE_SELECTION(dialog->icon_filesel)));
 #endif /* FILECHOOSER */
 
-	if (!filename || stat(filename, &st))
+	if (!filename || g_stat(filename, &st))
 	{
 		g_free(filename);
 		return;
@@ -520,7 +520,7 @@
 	format = gdk_pixbuf_get_file_info (path, &width, &height);
 #else
 	loader = gdk_pixbuf_loader_new();
-	if (!stat(path, &st) && (file = fopen(path, "rb")) != NULL) {
+	if (!g_stat(path, &st) && (file = g_fopen(path, "rb")) != NULL) {
 		data = g_malloc(st.st_size);
 		fread(data, 1, st.st_size, file);
 		fclose(file);
@@ -599,7 +599,7 @@
 		if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) {
 			gaim_debug_info("buddyicon", "Creating icon cache directory.\n");
 
-			if (mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) {
+			if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) {
 				gaim_debug_error("buddyicon",
 								 "Unable to create directory %s: %s\n",
 								 dirname, strerror(errno));
--- a/src/gtkconv.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/gtkconv.c	Fri Feb 11 05:10:40 2005 +0000
@@ -869,7 +869,7 @@
 	FILE *fp;
 	const char *name;
 
-	if ((fp = fopen(filename, "w+")) == NULL) {
+	if ((fp = g_fopen(filename, "w+")) == NULL) {
 		gaim_notify_error(conv, NULL, _("Unable to open file."), NULL);
 		return;
 	}
@@ -2520,7 +2520,7 @@
 	const void *data;
 	size_t len;
 
-	if ((fp = fopen(filename, "wb")) == NULL) {
+	if ((fp = g_fopen(filename, "wb")) == NULL) {
 		gaim_notify_error(conv, NULL, _("Unable to open file."), NULL);
 		return;
 	}
--- a/src/gtkdebug.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/gtkdebug.c	Fri Feb 11 05:10:40 2005 +0000
@@ -173,7 +173,7 @@
 	FILE *fp;
 	char *tmp;
 
-	if ((fp = fopen(filename, "w+")) == NULL) {
+	if ((fp = g_fopen(filename, "w+")) == NULL) {
 		gaim_notify_error(win, NULL, _("Unable to open file."), NULL);
 		return;
 	}
--- a/src/gtkimhtml.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/gtkimhtml.c	Fri Feb 11 05:10:40 2005 +0000
@@ -153,7 +153,7 @@
 
 	gaim_debug_info("imhtml clipboard", "from clipboard: %s\n", clipboard);
 
-	fd = fopen("e:\\gaimcb.txt", "wb");
+	fd = g_fopen("e:\\gaimcb.txt", "wb");
 	fprintf(fd, "%s", clipboard);
 	fclose(fd);
 #endif
--- a/src/gtkmain.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/gtkmain.c	Fri Feb 11 05:10:40 2005 +0000
@@ -404,7 +404,7 @@
 	basebuf = g_find_program_in_path(argv0);
 
 	/* But we still need to deal with symbolic links */
-	lstat(basebuf, &st);
+	g_lstat(basebuf, &st);
 	while ((st.st_mode & S_IFLNK) == S_IFLNK) {
 		linkbuf = g_malloc(1024);
 		readlink(basebuf, linkbuf, 1024);
@@ -423,7 +423,7 @@
 		g_free(linkbuf);
 		g_free(basebuf);
 		basebuf = fullbuf;
-		lstat(basebuf, &st);
+		g_lstat(basebuf, &st);
 	}
 
 	fullname = basebuf;
--- a/src/gtkprefs.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/gtkprefs.c	Fri Feb 11 05:10:40 2005 +0000
@@ -519,7 +519,7 @@
 
 	theme_install_theme(path, data);
 
-	unlink(path);
+	g_unlink(path);
 	g_free(path);
 }
 
--- a/src/gtkthemes.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/gtkthemes.c	Fri Feb 11 05:10:40 2005 +0000
@@ -62,7 +62,7 @@
 
 void load_smiley_theme(const char *file, gboolean load)
 {
-	FILE *f = fopen(file, "r");
+	FILE *f = g_fopen(file, "r");
 	char buf[256];
 	char *i;
 	struct smiley_theme *theme=NULL;
@@ -232,7 +232,7 @@
 			}
 			g_dir_close(dir);
 		} else if (l == 1) {
-			mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
+			g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
 		}
 		g_free(probedirs[l]);
 	}
--- a/src/internal.h	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/internal.h	Fri Feb 11 05:10:40 2005 +0000
@@ -121,11 +121,28 @@
 #define PATHSIZE 1024
 
 #include <glib.h>
+#if GLIB_CHECK_VERSION(2,6,0)
+#	include <glib/gstdio.h>
+#endif
 
 #ifdef _WIN32
 #include "win32dep.h"
 #endif
 
+#if !GLIB_CHECK_VERSION(2,6,0)
+#	define g_freopen freopen
+#	define g_fopen fopen
+#	define g_rmdir rmdir
+#	define g_remove remove
+#	define g_unlink unlink
+#	define g_lstat lstat
+#	define g_stat stat
+#	define g_mkdir mkdir
+#	define g_rename rename
+#	define g_open open
+#endif
+
+
 /* ugly ugly ugly */
 /* This is a workaround for the fact that G_GINT64_MODIFIER and G_GSIZE_FORMAT
  * are only defined in Glib >= 2.4 */
--- a/src/log.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/log.c	Fri Feb 11 05:10:40 2005 +0000
@@ -392,7 +392,7 @@
 
 		log->logger_data = data = g_new0(struct generic_logger_data, 1);
 
-		data->file = fopen(path, "a");
+		data->file = g_fopen(path, "a");
 		if (!data->file) {
 			gaim_debug(GAIM_DEBUG_ERROR, "log",
 					"Could not create log file %s\n", path);
@@ -447,7 +447,7 @@
 	struct stat st;
 	struct generic_logger_data *data = log->logger_data;
 
-	if (!data->path || stat(data->path, &st))
+	if (!data->path || g_stat(data->path, &st))
 		st.st_size = 0;
 
 	return st.st_size;
@@ -490,7 +490,7 @@
 		char *filename = g_build_filename(dir, date, NULL);
 		g_free(dir);
 
-		log->logger_data = fopen(filename, "a");
+		log->logger_data = g_fopen(filename, "a");
 		if (!log->logger_data) {
 			gaim_debug(GAIM_DEBUG_ERROR, "log", "Could not create log file %s\n", filename);
 			g_free(filename);
@@ -851,7 +851,7 @@
 	g_free(logfile);
 	g_free(pathstr);
 
-	if (!(file = fopen(gaim_stringref_value(pathref), "rb"))) {
+	if (!(file = g_fopen(gaim_stringref_value(pathref), "rb"))) {
 		gaim_stringref_unref(pathref);
 		return NULL;
 	}
@@ -962,7 +962,7 @@
 	int size;
 	struct stat st;
 
-	if (stat(pathstr, &st))
+	if (g_stat(pathstr, &st))
 		size = 0;
 	else
 		size = st.st_size;
@@ -976,7 +976,7 @@
 static char * old_logger_read (GaimLog *log, GaimLogReadFlags *flags)
 {
 	struct old_logger_data *data = log->logger_data;
-	FILE *file = fopen(gaim_stringref_value(data->pathref), "rb");
+	FILE *file = g_fopen(gaim_stringref_value(data->pathref), "rb");
 	char *read = g_malloc(data->length + 1);
 	fseek(file, data->offset, SEEK_SET);
 	fread(read, data->length, 1, file);
--- a/src/protocols/msn/directconn.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/msn/directconn.c	Fri Feb 11 05:10:40 2005 +0000
@@ -187,7 +187,7 @@
 	char *str;
 	str = g_strdup_printf("%s/msntest/w%.4d.bin", g_get_home_dir(), directconn->c);
 
-	FILE *tf = fopen(str, "w");
+	FILE *tf = g_fopen(str, "w");
 	fwrite(buffer, 1, buf_size, tf);
 	fclose(tf);
 
@@ -206,7 +206,7 @@
 	char *str;
 	str = g_strdup_printf("/home/revo/msntest/w%.4d.bin", directconn->c);
 
-	FILE *tf = fopen(str, "w");
+	FILE *tf = g_fopen(str, "w");
 	fwrite(&len, 1, sizeof(len), tf);
 	fwrite(data, 1, len, tf);
 	fclose(tf);
@@ -329,7 +329,7 @@
 #ifdef DEBUG_DC
 		str = g_strdup_printf("/home/revo/msntest/r%.4d.bin", directconn->c);
 
-		FILE *tf = fopen(str, "w");
+		FILE *tf = g_fopen(str, "w");
 		fwrite(body, 1, len, tf);
 		fclose(tf);
 
--- a/src/protocols/msn/msn.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/msn/msn.c	Fri Feb 11 05:10:40 2005 +0000
@@ -354,7 +354,7 @@
 
 	slplink = xfer->data;
 
-	if ((fp = fopen(filename, "rb")) == NULL)
+	if ((fp = g_fopen(filename, "rb")) == NULL)
 	{
 		GaimAccount *account;
 		GaimConnection *gc;
--- a/src/protocols/msn/notification.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/msn/notification.c	Fri Feb 11 05:10:40 2005 +0000
@@ -915,7 +915,7 @@
 
 	if (session->passport_info.file != NULL)
 	{
-		unlink(session->passport_info.file);
+		g_unlink(session->passport_info.file);
 		g_free(session->passport_info.file);
 	}
 
@@ -968,7 +968,7 @@
 							 "Error closing temp passport file: %s\n",
 							 strerror(errno));
 
-			unlink(session->passport_info.file);
+			g_unlink(session->passport_info.file);
 			g_free(session->passport_info.file);
 			session->passport_info.file = NULL;
 		}
--- a/src/protocols/msn/session.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/msn/session.c	Fri Feb 11 05:10:40 2005 +0000
@@ -87,7 +87,7 @@
 
 	if (session->passport_info.file != NULL)
 	{
-		unlink(session->passport_info.file);
+		g_unlink(session->passport_info.file);
 		g_free(session->passport_info.file);
 	}
 
--- a/src/protocols/msn/slplink.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/msn/slplink.c	Fri Feb 11 05:10:40 2005 +0000
@@ -46,7 +46,7 @@
 	dir = send ? "send" : "recv";
 	c = send ? m_sc++ : m_rc++;
 	tmp = g_strdup_printf("%s/msntest/%s/%03d", g_get_home_dir(), dir, c);
-	tf = fopen(tmp, "wb");
+	tf = g_fopen(tmp, "wb");
 	pload = msn_message_gen_payload(msg, &pload_size);
 	fwrite(pload, 1, pload_size, tf);
 	fclose(tf);
@@ -502,7 +502,7 @@
 					if (xfer != NULL)
 					{
 						slpmsg->fp =
-							fopen(gaim_xfer_get_local_filename(slpmsg->slpcall->xfer),
+							g_fopen(gaim_xfer_get_local_filename(slpmsg->slpcall->xfer),
 								  "wb");
 					}
 				}
@@ -636,7 +636,7 @@
 	glong uni_len = 0;
 	gsize len;
 
-	if (stat(file_path, &st) == 0)
+	if (g_stat(file_path, &st) == 0)
 		size = st.st_size;
 
 	if(!file_name) {
--- a/src/protocols/msn/slpmsg.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/msn/slpmsg.c	Fri Feb 11 05:10:40 2005 +0000
@@ -114,9 +114,9 @@
 {
 	struct stat st;
 
-	slpmsg->fp = fopen(file_name, "rb");
+	slpmsg->fp = g_fopen(file_name, "rb");
 
-	if (stat(file_name, &st) == 0)
+	if (g_stat(file_name, &st) == 0)
 		slpmsg->size = st.st_size;
 }
 
--- a/src/protocols/msn/user.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/msn/user.c	Fri Feb 11 05:10:40 2005 +0000
@@ -170,11 +170,11 @@
 
 	g_return_if_fail(user != NULL);
 
-	if (filename == NULL || stat(filename, &st) == -1)
+	if (filename == NULL || g_stat(filename, &st) == -1)
 	{
 		msn_user_set_object(user, NULL);
 	}
-	else if ((fp = fopen(filename, "rb")) != NULL)
+	else if ((fp = g_fopen(filename, "rb")) != NULL)
 	{
 		unsigned char *buf;
 		SHA_CTX ctx;
--- a/src/protocols/oscar/oscar.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/oscar/oscar.c	Fri Feb 11 05:10:40 2005 +0000
@@ -3362,9 +3362,9 @@
 		FILE *file;
 		struct stat st;
 
-		if (!stat(iconfile, &st)) {
+		if (!g_stat(iconfile, &st)) {
 			char *buf = g_malloc(st.st_size);
-			file = fopen(iconfile, "rb");
+			file = g_fopen(iconfile, "rb");
 			if (file) {
 				/* XXX - Use g_file_get_contents() */
 				int len = fread(buf, 1, st.st_size, file);
@@ -4695,9 +4695,9 @@
 		const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc));
 		if (iconfile == NULL) {
 			aim_ssi_delicon(od->sess);
-		} else if (!stat(iconfile, &st)) {
+		} else if (!g_stat(iconfile, &st)) {
 			char *buf = g_malloc(st.st_size);
-			FILE *file = fopen(iconfile, "rb");
+			FILE *file = g_fopen(iconfile, "rb");
 			if (file) {
 				/* XXX - Use g_file_get_contents()? */
 				fread(buf, 1, st.st_size, file);
@@ -5542,8 +5542,8 @@
 			bi->ico_need = FALSE;
 		}
 
-		if (iconfile && !stat(iconfile, &st)) {
-			FILE *file = fopen(iconfile, "rb");
+		if (iconfile && !g_stat(iconfile, &st)) {
+			FILE *file = g_fopen(iconfile, "rb");
 			if (file) {
 				char *buf = g_malloc(st.st_size);
 				/* XXX - Use g_file_get_contents()? */
@@ -6846,9 +6846,9 @@
 					const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc));
 					if (iconfile == NULL) {
 						aim_ssi_delicon(od->sess);
-					} else if (!stat(iconfile, &st)) {
+					} else if (!g_stat(iconfile, &st)) {
 						char *buf = g_malloc(st.st_size);
-						FILE *file = fopen(iconfile, "rb");
+						FILE *file = g_fopen(iconfile, "rb");
 						if (file) {
 							/* XXX - Use g_file_get_contents()? */
 							fread(buf, 1, st.st_size, file);
@@ -7431,9 +7431,9 @@
 
 	if (iconfile == NULL) {
 		aim_ssi_delicon(od->sess);
-	} else if (!stat(iconfile, &st)) {
+	} else if (!g_stat(iconfile, &st)) {
 		char *buf = g_malloc(st.st_size);
-		file = fopen(iconfile, "rb");
+		file = g_fopen(iconfile, "rb");
 		if (file) {
 			md5_state_t *state;
 			char md5[16];
--- a/src/protocols/rendezvous/rendezvous.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/rendezvous/rendezvous.c	Fri Feb 11 05:10:40 2005 +0000
@@ -503,10 +503,10 @@
 
 	g_return_val_if_fail(filename != NULL, NULL);
 
-	if (stat(filename, &st))
+	if (g_stat(filename, &st))
 		return NULL;
 
-	if (!(file = fopen(filename, "rb")))
+	if (!(file = g_fopen(filename, "rb")))
 		return NULL;
 
 	*length = st.st_size;
--- a/src/protocols/silc/buddy.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/silc/buddy.c	Fri Feb 11 05:10:40 2005 +0000
@@ -917,10 +917,10 @@
 			return;
 
 		/* Create dir if it doesn't exist */
-		if ((stat(filename, &st)) == -1) {
+		if ((g_stat(filename, &st)) == -1) {
 			if (errno == ENOENT) {
 				if (pw->pw_uid == geteuid())
-					mkdir(filename, 0755);
+					g_mkdir(filename, 0755);
 			}
 		}
 
--- a/src/protocols/silc/ft.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/silc/ft.c	Fri Feb 11 05:10:40 2005 +0000
@@ -155,7 +155,7 @@
 	const char *name;
 
 	name = gaim_xfer_get_local_filename(x);
-	unlink(name);
+	g_unlink(name);
 	xfer->completion(name, xfer->completion_context);
 }
 
--- a/src/protocols/silc/ops.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/silc/ops.c	Fri Feb 11 05:10:40 2005 +0000
@@ -1467,7 +1467,7 @@
 	case SILC_CLIENT_CONN_SUCCESS_RESUME:
 		gaim_connection_set_state(gc, GAIM_CONNECTED);
 		serv_finish_login(gc);
-		unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
+		g_unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
 
 		/* Send any UMODEs configured for account */
 		reject_watch = gaim_account_get_bool(sg->account, "reject-watch", FALSE);
@@ -1487,7 +1487,7 @@
 		break;
 	case SILC_CLIENT_CONN_ERROR:
 		gaim_connection_error(gc, _("Error during connecting to SILC Server"));
-		unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
+		g_unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
 		break;
 
 	case SILC_CLIENT_CONN_ERROR_KE:
@@ -1502,7 +1502,7 @@
 		gaim_connection_error(gc,
 				      _("Resuming detached session failed. "
 					"Press Reconnect to create new connection."));
-		unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
+		g_unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
 		break;
 
 	case SILC_CLIENT_CONN_ERROR_TIMEOUT:
@@ -1529,7 +1529,7 @@
 	SilcGaim sg = gc->proto_data;
 
 	if (sg->resuming && !sg->detaching)
-		unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
+		g_unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
 
 	sg->conn = NULL;
 
@@ -1820,7 +1820,7 @@
 
 	/* Save the detachment data to file. */
 	file = silcgaim_session_file(gaim_account_get_username(sg->account));
-	unlink(file);
+	g_unlink(file);
 	silc_file_writefile(file, detach_data, detach_data_len);
 }
 
--- a/src/protocols/silc/pk.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/silc/pk.c	Fri Feb 11 05:10:40 2005 +0000
@@ -216,7 +216,7 @@
 	babbleprint = verify->babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
 
 	/* Check whether this key already exists */
-	if (stat(ipf, &st) < 0 && (!hostf || stat(hostf, &st) < 0)) {
+	if (g_stat(ipf, &st) < 0 && (!hostf || g_stat(hostf, &st) < 0)) {
 		/* Key does not exist, ask user to verify the key and save it */
 		silcgaim_verify_ask(name ? name : entity,
 				    fingerprint, babbleprint, verify);
--- a/src/protocols/silc/util.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/silc/util.c	Fri Feb 11 05:10:40 2005 +0000
@@ -91,11 +91,11 @@
 	/*
 	 * Check ~/.silc directory
 	 */
-	if ((stat(filename, &st)) == -1) {
+	if ((g_stat(filename, &st)) == -1) {
 		/* If dir doesn't exist */
 		if (errno == ENOENT) {
 			if (pw->pw_uid == geteuid()) {
-				if ((mkdir(filename, 0755)) == -1) {
+				if ((g_mkdir(filename, 0755)) == -1) {
 					gaim_debug_error("silc", "Couldn't create '%s' directory\n", filename);
 					return FALSE;
 				}
@@ -122,11 +122,11 @@
 	/*
 	 * Check ~./silc/serverkeys directory
 	 */
-	if ((stat(servfilename, &st)) == -1) {
+	if ((g_stat(servfilename, &st)) == -1) {
 		/* If dir doesn't exist */
 		if (errno == ENOENT) {
 			if (pw->pw_uid == geteuid()) {
-				if ((mkdir(servfilename, 0755)) == -1) {
+				if ((g_mkdir(servfilename, 0755)) == -1) {
 					gaim_debug_error("silc", "Couldn't create '%s' directory\n", servfilename);
 					return FALSE;
 				}
@@ -145,11 +145,11 @@
 	/*
 	 * Check ~./silc/clientkeys directory
 	 */
-	if ((stat(clientfilename, &st)) == -1) {
+	if ((g_stat(clientfilename, &st)) == -1) {
 		/* If dir doesn't exist */
 		if (errno == ENOENT) {
 			if (pw->pw_uid == geteuid()) {
-				if ((mkdir(clientfilename, 0755)) == -1) {
+				if ((g_mkdir(clientfilename, 0755)) == -1) {
 					gaim_debug_error("silc", "Couldn't create '%s' directory\n", clientfilename);
 					return FALSE;
 				}
@@ -168,11 +168,11 @@
 	/*
 	 * Check ~./silc/friends directory
 	 */
-	if ((stat(friendsfilename, &st)) == -1) {
+	if ((g_stat(friendsfilename, &st)) == -1) {
 		/* If dir doesn't exist */
 		if (errno == ENOENT) {
 			if (pw->pw_uid == geteuid()) {
-				if ((mkdir(friendsfilename, 0755)) == -1) {
+				if ((g_mkdir(friendsfilename, 0755)) == -1) {
 					gaim_debug_error("silc", "Couldn't create '%s' directory\n", friendsfilename);
 					return FALSE;
 				}
@@ -196,7 +196,7 @@
 	g_snprintf(file_private_key, sizeof(file_public_key) - 1, "%s",
 		   gaim_prefs_get_string("/plugins/prpl/silc/privkey"));
 
-	if ((stat(file_public_key, &st)) == -1) {
+	if ((g_stat(file_public_key, &st)) == -1) {
 		/* If file doesn't exist */
 		if (errno == ENOENT) {
 			gaim_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5);
@@ -205,7 +205,7 @@
 					     file_public_key, file_private_key, NULL,
 					     (gc->account->password == NULL) ? "" : gc->account->password,
 						 NULL, NULL, NULL, FALSE);
-			stat(file_public_key, &st);
+			g_stat(file_public_key, &st);
 		} else {
 			gaim_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n",
 							 file_public_key, strerror(errno));
@@ -221,7 +221,7 @@
 	}
 #endif
 
-	if ((stat(file_private_key, &st)) == -1) {
+	if ((g_stat(file_private_key, &st)) == -1) {
 		/* If file doesn't exist */
 		if (errno == ENOENT) {
 			gaim_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5);
@@ -230,7 +230,7 @@
 					     file_public_key, file_private_key, NULL,
 					     (gc->account->password == NULL) ? "" : gc->account->password,
 						 NULL, NULL, NULL, FALSE);
-			stat(file_private_key, &st);
+			g_stat(file_private_key, &st);
 		} else {
 			gaim_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n",
 							 file_private_key, strerror(errno));
--- a/src/protocols/toc/toc.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/toc/toc.c	Fri Feb 11 05:10:40 2005 +0000
@@ -1689,7 +1689,7 @@
 		write(source, ft, 256);
 
 		if (ft->files == 1) {
-			ft->file = fopen(ft->filename, "w");
+			ft->file = g_fopen(ft->filename, "w");
 			if (!ft->file) {
 				buf = g_strdup_printf(_("Could not open %s for writing!"), ft->filename);
 				gaim_notify_error(ft->gc, NULL, buf, strerror(errno));
@@ -1704,7 +1704,7 @@
 			}
 		} else {
 			buf = g_strdup_printf("%s/%s", ft->filename, ft->hdr.name);
-			ft->file = fopen(buf, "w");
+			ft->file = g_fopen(buf, "w");
 			g_free(buf);
 			if (!ft->file) {
 				buf = g_strdup_printf("Could not open %s/%s for writing!", ft->filename,
@@ -1852,7 +1852,7 @@
 		read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8));
 		debug_header(ft);
 
-		stat(ft->filename, &st);
+		g_stat(ft->filename, &st);
 		fortime = localtime(&st.st_mtime);
 		basename = g_path_get_basename(ft->filename);
 		g_snprintf(buf, sizeof(buf), "%2d/%2d/%4d %2d:%2d %8ld %s\r\n",
@@ -1994,7 +1994,7 @@
 		return;
 	ft = g_new0(struct file_transfer, 1);
 	ft->filename = g_strdup(dirname);
-	ft->file = fopen(ft->filename, "r");
+	ft->file = g_fopen(ft->filename, "r");
 	if (!ft->file) {
 		buf = g_strdup_printf("Unable to open %s for transfer.", ft->filename);
 		gaim_notify_error(ft->gc, NULL, buf, NULL);
@@ -2003,7 +2003,7 @@
 		g_free(ft);
 		return;
 	}
-	if (stat(dirname, &ft->st)) {
+	if (g_stat(dirname, &ft->st)) {
 		buf = g_strdup_printf("Unable to examine %s.", dirname);
 		gaim_notify_error(ft->gc, NULL, buf, NULL);
 		g_free(buf);
--- a/src/protocols/trepia/trepia.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/trepia/trepia.c	Fri Feb 11 05:10:40 2005 +0000
@@ -1154,10 +1154,10 @@
 	TrepiaSession *session = gc->proto_data;
 	struct stat sb;
 
-	if (!stat(filename, &sb)) {
+	if (!g_stat(filename, &sb)) {
 		FILE *fp;
 
-		if ((fp = fopen(filename, "rb")) != NULL) {
+		if ((fp = g_fopen(filename, "rb")) != NULL) {
 			char *buf = g_malloc(sb.st_size + 1);
 			char *temp;
 			char *out_buf;
--- a/src/protocols/yahoo/yahoo_picture.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/yahoo/yahoo_picture.c	Fri Feb 11 05:10:40 2005 +0000
@@ -466,8 +466,8 @@
 		if (yd->logged_in)
 			yahoo_send_picture_update(gc, 0);
 		/* TODO: check if we're connected and tell everyone we ain't not one no more */
-	} else if (!stat(iconfile, &st)) {
-		file = fopen(iconfile, "rb");
+	} else if (!g_stat(iconfile, &st)) {
+		file = g_fopen(iconfile, "rb");
 		if (file) {
 			GString *s = g_string_sized_new(st.st_size);
 			size_t len;
--- a/src/protocols/zephyr/ZGetWGPort.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/zephyr/ZGetWGPort.c	Fri Feb 11 05:10:40 2005 +0000
@@ -4,7 +4,7 @@
  *	Created by:	Robert French
  *
  *	$Source$
- *	$Author: chipx86 $
+ *	$Author: datallah $
  *
  *	Copyright (c) 1987 by the Massachusetts Institute of Technology.
  *	For copying and distribution information, see the file
@@ -29,7 +29,7 @@
 	(void) sprintf(name, "/tmp/wg.%d", getuid());
 	envptr = name;
     } 
-    if (!(fp = fopen(envptr, "r")))
+    if (!(fp = g_fopen(envptr, "r")))
 	return (-1);
 
     /* if fscanf fails, return -1 via wgport */
--- a/src/protocols/zephyr/ZVariables.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/zephyr/ZVariables.c	Fri Feb 11 05:10:40 2005 +0000
@@ -5,7 +5,7 @@
  *	Created by:	Robert French
  *
  *	$Source$
- *	$Author: chipx86 $
+ *	$Author: datallah $
  *
  *	Copyright (c) 1987 by the Massachusetts Institute of Technology.
  *	For copying and distribution information, see the file
@@ -59,9 +59,9 @@
     (void) strcpy(varfilebackup, varfile);
     (void) strcat(varfilebackup, ".backup");
 	
-    if (!(fpout = fopen(varfilebackup, "w")))
+    if (!(fpout = g_fopen(varfilebackup, "w")))
 	return (errno);
-    if ((fpin = fopen(varfile, "r")) != NULL) {
+    if ((fpin = g_fopen(varfile, "r")) != NULL) {
 	while (fgets(varbfr, sizeof varbfr, fpin) != (char *) 0) {
 	    if (varbfr[strlen(varbfr)-1] < ' ')
 		varbfr[strlen(varbfr)-1] = '\0';
@@ -78,7 +78,7 @@
 	fprintf(fpout, "%s = %s\n", var, value);
     if (fclose(fpout) == EOF)
 	    return(EIO);		/* can't rely on errno */
-    if (rename(varfilebackup, varfile))
+    if (g_rename(varfilebackup, varfile))
 	return (errno);
     return (ZERR_NONE);
 }	
@@ -95,9 +95,9 @@
     (void) strcpy(varfilebackup, varfile);
     (void) strcat(varfilebackup, ".backup");
 	
-    if (!(fpout = fopen(varfilebackup, "w")))
+    if (!(fpout = g_fopen(varfilebackup, "w")))
 	return (errno);
-    if ((fpin = fopen(varfile, "r")) != NULL) {
+    if ((fpin = g_fopen(varfile, "r")) != NULL) {
 	while (fgets(varbfr, sizeof varbfr, fpin) != (char *) 0) {
 	    if (varbfr[strlen(varbfr)-1] < ' ')
 		varbfr[strlen(varbfr)-1] = '\0';
@@ -108,7 +108,7 @@
     } 
     if (fclose(fpout) == EOF)
 	    return(EIO);		/* errno isn't reliable */
-    if (rename(varfilebackup, varfile))
+    if (g_rename(varfilebackup, varfile))
 	return (errno);
     return (ZERR_NONE);
 }	
@@ -143,7 +143,7 @@
     static char varbfr[512];
     int i;
 	
-    fp = fopen(fn, "r");
+    fp = g_fopen(fn, "r");
     if (!fp)
 	return ((char *)0);
 
--- a/src/protocols/zephyr/zephyr.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/protocols/zephyr/zephyr.c	Fri Feb 11 05:10:40 2005 +0000
@@ -1327,7 +1327,7 @@
 	gchar buff[BUFSIZ];
 
 	fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir());
-	f = fopen(fname, "r");
+	f = g_fopen(fname, "r");
 	if (f) {
 		char **triple;
 		char *recip;
@@ -1423,7 +1423,7 @@
 	}
 
 	filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL);
-	if ((fd = fopen(filename, "r")) != NULL) {
+	if ((fd = g_fopen(filename, "r")) != NULL) {
 		while (fgets(buff, BUFSIZ, fd)) {
 			strip_comments(buff);
 			if (buff[0]) {
@@ -1777,7 +1777,7 @@
 	char **triple;
 
 	fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir());
-	fd = fopen(fname, "w");
+	fd = g_fopen(fname, "w");
 
 	if (!fd) {
 		g_free(fname);
@@ -1839,7 +1839,7 @@
 	FILE *fd;
 	zephyr_account* zephyr = gc->proto_data;
 	fname = g_strdup_printf("%s/.anyone", gaim_home_dir());
-	fd = fopen(fname, "w");
+	fd = g_fopen(fname, "w");
 	if (!fd) {
 		g_free(fname);
 		return;
--- a/src/util.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/util.c	Fri Feb 11 05:10:40 2005 +0000
@@ -1928,7 +1928,7 @@
 			return -1;
 		}
 
-		if (mkdir(dir, mode) < 0) {
+		if (g_mkdir(dir, mode) < 0) {
 			gaim_debug_warning("build_dir", "mkdir: %s\n", strerror(errno));
 			g_strfreev(components);
 			g_free(dir);
@@ -1963,7 +1963,7 @@
 	/* Ensure the user directory exists */
 	if (!g_file_test(user_dir, G_FILE_TEST_IS_DIR))
 	{
-		if (mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
+		if (g_mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
 		{
 			gaim_debug_error("util", "Error creating directory %s: %s\n",
 							 user_dir, strerror(errno));
@@ -1977,7 +1977,7 @@
 	/* Remove an old temporary file, if one exists */
 	if (g_file_test(filename_temp, G_FILE_TEST_EXISTS))
 	{
-		if (unlink(filename_temp) == -1)
+		if (g_unlink(filename_temp) == -1)
 		{
 			gaim_debug_error("util", "Error removing old file %s: %s\n",
 							 filename_temp, strerror(errno));
@@ -1985,7 +1985,7 @@
 	}
 
 	/* Open file */
-	file = fopen(filename_temp, "wb");
+	file = g_fopen(filename_temp, "wb");
 	if (file == NULL)
 	{
 		gaim_debug_error("util", "Error opening file %s for writing: %s\n",
@@ -2020,7 +2020,7 @@
 		return FALSE;
 	}
 	/* Use stat to be absolutely sure. */
-	if ((stat(filename_temp, &st) == -1) || (st.st_size != real_size))
+	if ((g_stat(filename_temp, &st) == -1) || (st.st_size != real_size))
 	{
 		gaim_debug_error("util", "Error writing data to file %s: "
 						 "Incomplete file written; is your disk full?\n",
@@ -2040,7 +2040,7 @@
 	/* Remove the old file, if it exists */
 	if (g_file_test(filename_full, G_FILE_TEST_EXISTS))
 	{
-		if (unlink(filename_full) == -1)
+		if (g_unlink(filename_full) == -1)
 		{
 			gaim_debug_error("util", "Error removing old file %s: %s\n",
 							 filename_full, strerror(errno));
@@ -2048,7 +2048,7 @@
 	}
 
 	/* Rename to the REAL name */
-	if (rename(filename_temp, filename_full) == -1)
+	if (g_rename(filename_temp, filename_full) == -1)
 	{
 		gaim_debug_error("util", "Error renaming %s to %s: %s\n",
 						 filename_temp, filename_full, strerror(errno));
@@ -2161,7 +2161,7 @@
 						   "Problem creating the template\n");
 			else
 			{
-				if( (fp = fopen( result, binary?"wb+":"w+")) == NULL ) {
+				if( (fp = g_fopen( result, binary?"wb+":"w+")) == NULL ) {
 					gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp",
 							   "Couldn't fopen() %s\n", result);
 				}
--- a/src/win32/libc_interface.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/win32/libc_interface.c	Fri Feb 11 05:10:40 2005 +0000
@@ -31,9 +31,13 @@
 #include <sys/timeb.h>
 #include <sys/stat.h>
 #include <time.h>
+#include <glib.h>
 #include "debug.h"
 #include "libc_internal.h"
 
+#if !GLIB_CHECK_VERSION(2,6,0)
+#	define g_remove remove
+#endif
 /*
  *  PROTOS
  */
@@ -215,47 +219,6 @@
 		return strerror( errornum );
 }
 
-/* From glibc 2.2.5 */
-char* wgaim_strsep(char **stringp, const char *delim) {
-	char *begin, *end;
-
-	begin = *stringp;
-	if (begin == NULL)
-		return NULL;
-	
-	/* A frequent case is when the delimiter string contains only one
-	   character.  Here we don't need to call the expensive `strpbrk'
-	   function and instead work using `strchr'.  */
-	if (delim[0] == '\0' || delim[1] == '\0') {
-		char ch = delim[0];
-		
-		if (ch == '\0')
-			end = NULL;
-		else {
-			if (*begin == ch)
-				end = begin;
-			else if (*begin == '\0')
-				end = NULL;
-			else
-				end = strchr (begin + 1, ch);
-		}
-	}
-	else
-		/* Find the end of the token.  */
-		end = strpbrk (begin, delim);
-	
-	if (end) {
-		/* Terminate the token and set *STRINGP past NUL character.  */
-		*end++ = '\0';
-		*stringp = end;
-	}
-	else
-		/* No more delimiters; this is the last token.  */
-		*stringp = NULL;
-
-	return begin;
-}
-
 /* unistd.h */
 
 /*
@@ -349,6 +312,7 @@
 
 /* stdio.h */
 
+#if !GLIB_CHECK_VERSION(2,6,0)
 int wgaim_rename (const char *oldname, const char *newname) {
 	struct _stat oldstat, newstat;
 
@@ -379,7 +343,7 @@
 				}
 				/* newname is not a dir */
 				else {
-					remove(newname);
+					g_remove(newname);
 					return rename(oldname, newname);
 				}
 			}
@@ -395,6 +359,7 @@
 	}
 
 }
+#endif
 
 /* time.h */
 
--- a/src/win32/libc_interface.h	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/win32/libc_interface.h	Fri Feb 11 05:10:40 2005 +0000
@@ -27,6 +27,7 @@
 #include <io.h>
 #include <errno.h>
 #include "libc_internal.h"
+#include <glib.h>
 
 /* sys/socket.h */
 extern int wgaim_socket(int namespace, int style, int protocol);
@@ -67,7 +68,9 @@
 #define fcntl( fd, command, val ) \
 wgaim_fcntl( fd, command, val )
 
-#define open( args... ) _open( args )
+#if !GLIB_CHECK_VERSION(2,6,0)
+#	define open( args... ) _open( args )
+#endif
 
 /* arpa/inet.h */
 extern int wgaim_inet_aton(const char *name, struct in_addr *addr);
@@ -90,10 +93,6 @@
 #define strerror( errornum ) \
 wgaim_strerror( errornum )
 
-extern char* wgaim_strsep(char **stringp, const char *delim);
-#define strsep( stringp, delim ) \
-wgaim_strsep( stringp, delim )
-
 #define bzero( dest, size ) memset( dest, 0, size )
 
 /* unistd.h */
@@ -126,12 +125,18 @@
 #define snprintf _snprintf
 #define vsnprintf _vsnprintf
 
+#if !GLIB_CHECK_VERSION(2,6,0)
+/* I think that this can probably go away, in favor of g_rename() */
 extern int wgaim_rename(const char *oldname, const char *newname);
 #define rename( oldname, newname ) \
 wgaim_rename( oldname, newname )
+#endif
 
 /* sys/stat.h */
+
+#if !GLIB_CHECK_VERSION(2,6,0)
 #define mkdir(a,b) _mkdir((a))
+#endif
 #define fchmod(a,b)
 
 /* time.h */
--- a/src/win32/untar.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/win32/untar.c	Fri Feb 11 05:10:40 2005 +0000
@@ -78,8 +78,17 @@
 #endif
 #include "debug.h"
 #include "untar.h"
+#include <glib.h>
 
+#if GLIB_CHECK_VERSION(2,6,0)
+#	include <glib/gstdio.h>
+#else
 #define mkdir(a,b) _mkdir((a))
+#define g_mkdir mkdir
+#define g_fopen fopen
+#define g_unlink unlink
+#endif
+
 #define untar_error( error, args... )      gaim_debug(GAIM_DEBUG_ERROR, "untar", error, ## args )
 #define untar_warning( warning, args... )  gaim_debug(GAIM_DEBUG_WARNING, "untar", warning, ## args )
 #define untar_verbose( args... )           gaim_debug(GAIM_DEBUG_INFO, "untar", ## args )
@@ -153,7 +162,7 @@
 	}
 
 	/* first try creating it the easy way */
-	fp = fopen(name, CONVERT ? "w" : "wb");
+	fp = g_fopen(name, CONVERT ? "w" : "wb");
 	if (fp)
 		return fp;
 
@@ -169,11 +178,11 @@
 		if (name[i] == '/')
 		{
 			name[i] = '\0';
-			(void)mkdir(name, 0777);
+			(void)g_mkdir(name, 0777);
 			name[i] = '/';
 		}
 	}
-	fp = fopen(name, CONVERT ? "w" : "wb");
+	fp = g_fopen(name, CONVERT ? "w" : "wb");
 	if (!fp)
 		untar_error("Error opening: %s\n", name);
 	return fp;
@@ -192,7 +201,7 @@
 	int	c;
 
 	/* Open the source file.  We do this first to make sure it exists */
-	fpsrc = fopen(src, "rb");
+	fpsrc = g_fopen(src, "rb");
 	if (!fpsrc)
 	{
 		untar_error("Error opening: %s\n", src);
@@ -211,7 +220,7 @@
 # ifndef _WEAK_POSIX
 	/* first try to link it over, instead of copying */
 	fclose(fpdst);
-	unlink(dst);
+	g_unlink(dst);
 	if (sym)
 	{
 		if (symlink(src, dst))
@@ -229,7 +238,7 @@
 	}
 
 	/* Dang.  Reopen the destination again */
-	fpdst = fopen(dst, "wb");
+	fpdst = g_fopen(dst, "wb");
 	/* This *can't* fail */
 
 # endif /* _WEAK_POSIX */
@@ -521,7 +530,7 @@
 #ifdef _POSIX_SOURCE
 			else if (mkdir(nbuf, mode) == 0)
 #else
-			else if (mkdir(nbuf, 0755) == 0)
+			else if (g_mkdir(nbuf, 0755) == 0)
 #endif
 				n2 = " created";
 			else
@@ -578,7 +587,7 @@
 	untarops = options;
 	/* open the archive */
 	inname = filename;
-	infp = fopen(filename, "rb");
+	infp = g_fopen(filename, "rb");
 	if (!infp)
 	{
 		untar_error("Error opening: %s\n", filename);
--- a/src/win32/win32dep.c	Fri Feb 11 03:51:26 2005 +0000
+++ b/src/win32/win32dep.c	Fri Feb 11 05:10:40 2005 +0000
@@ -27,9 +27,16 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <winuser.h>
+#include <shlobj.h>
 
 #include <gtk/gtk.h>
 #include <glib.h>
+#if GLIB_CHECK_VERSION(2,6,0)
+#	include <glib/gstdio.h>
+#else
+#	define g_fopen fopen
+#	define g_unlink unlink
+#endif
 #include <gdk/gdkwin32.h>
 
 #include "gaim.h"
@@ -56,16 +63,14 @@
  */
 
 /* For shfolder.dll */
-typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATH)(HWND, int, HANDLE, DWORD, LPTSTR);
+typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHA)(HWND, int, HANDLE, DWORD, LPSTR);
+typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHW)(HWND, int, HANDLE, DWORD, LPWSTR);
 
 typedef enum {
     SHGFP_TYPE_CURRENT  = 0,   // current value for user, verify it exists
     SHGFP_TYPE_DEFAULT  = 1,   // default value, may not exist
 } SHGFP_TYPE;
 
-#define CSIDL_APPDATA 0x001a
-#define CSIDL_FLAG_CREATE 0x8000
-
 /* flash info */
 typedef BOOL (CALLBACK* LPFNFLASHWINDOWEX)(PFLASHWINFO);
 
@@ -78,7 +83,7 @@
 /*
  * LOCALS
  */
-static char app_data_dir[MAX_PATH] = "C:";
+static char app_data_dir[MAX_PATH + 1] = "C:";
 static char install_dir[MAXPATHLEN];
 static char lib_dir[MAXPATHLEN];
 static char locale_dir[MAXPATHLEN];
@@ -94,7 +99,8 @@
  *  PROTOS
  */
 LPFNFLASHWINDOWEX MyFlashWindowEx = NULL;
-LPFNSHGETFOLDERPATH MySHGetFolderPath = NULL;
+LPFNSHGETFOLDERPATHA MySHGetFolderPathA = NULL;
+LPFNSHGETFOLDERPATHW MySHGetFolderPathW = NULL;
 
 FARPROC wgaim_find_and_loadproc(char*, char*);
 extern void wgaim_gtkspell_init();
@@ -142,136 +148,15 @@
 	MyFlashWindowEx = (LPFNFLASHWINDOWEX)wgaim_find_and_loadproc("user32.dll", "FlashWindowEx" );
 }
 
-#if 0
-static char* base_name(char* path) {
-        char *tmp = path;
-        char *prev = NULL;
-
-        while((tmp=strchr(tmp, '\\'))) {
-                prev = tmp;
-                tmp += 1;
-        }
-        if(prev)
-                return ++prev;
-        else
-                return NULL;
-}
-#endif
-
-BOOL folder_exists(char *folder) {
-        BOOL ret = FALSE;
-        WIN32_FIND_DATA fileinfo;
-        HANDLE fh;
-
-        memset(&fileinfo, 0, sizeof(WIN32_FIND_DATA));
-        if((fh=FindFirstFile(folder, &fileinfo))) {
-                if(fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
-                        ret = TRUE;
-                        SetLastError(ERROR_SUCCESS);
-                }
-                else
-                        SetLastError(ERROR_FILE_EXISTS);
-                FindClose(fh);
-        }
-        return ret;
-}
-
-/* Recursively create directories in the dest path */
-static BOOL CreateDirectoryR(char *dest) {
-        static BOOL start = TRUE;
-        BOOL ret = FALSE;
-
-        if(!dest)
-                return ret;
-
-        if(start) {
-                char *str = g_strdup(dest);
-                start = FALSE;
-                ret = CreateDirectoryR(str);
-                g_free(str);
-                start = TRUE;
-        }
-        else {
-                char *tmp1 = dest;
-                char *tmp=NULL;
-
-                while((tmp1=strchr(tmp1, '\\'))) {
-                        tmp = tmp1;
-                        tmp1+=1;
-                }
-                
-                if(tmp) {
-                        tmp[0] = '\0';
-                        CreateDirectoryR(dest);
-                        tmp[0] = '\\';
-                        if(CreateDirectory(dest, NULL) == 0 && GetLastError() != ERROR_ALREADY_EXISTS) {
-                                gaim_debug(GAIM_DEBUG_ERROR, "wgaim",
-                                           "Error creating directory: %s. Errno: %u\n", 
-                                           dest, (UINT)GetLastError());
-                        }
-                        else
-                                ret = TRUE;
-                }
-        }
-        return ret;
-}
-
-#if 0
-static BOOL move_folder(char *src, char* dest, char* copytitle, BOOL overwrite) {
-        char *tsrc, *tdest;
-        SHFILEOPSTRUCT dirmove;
-        BOOL ret = FALSE;
-
-        g_return_val_if_fail(src!=NULL, ret);
-        g_return_val_if_fail(dest!=NULL, ret);
-
-        if(!folder_exists(src)) {
-                gaim_debug(GAIM_DEBUG_WARNING, "wgaim", 
-                           "move_folder: Source folder %s, does not exist\n", src);
-                return ret;
-        }
-        if(!overwrite) {
-                char *dstpath = g_strdup_printf("%s\\%s", dest, base_name(src));
-
-                if(folder_exists(dstpath)) {
-                        gaim_debug(GAIM_DEBUG_WARNING, "wgaim", 
-                                   "move_folder: Destination Folder %s, already exists\n", dstpath);
-                        g_free(dstpath);
-                        return ret;
-                }
-                g_free(dstpath);
-        }
-
-        /* Create dest folder if it doesn't exist */
-        if(!CreateDirectoryR(dest)) {
-                gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Error creating directory: %s\n", dest);
-                return ret;
-        }
-
-        tsrc = g_strdup_printf("%s%c", src, '\0');
-        tdest = g_strdup_printf("%s%c", dest, '\0');
-
-        memset(&dirmove, 0, sizeof(SHFILEOPSTRUCT));
-        dirmove.wFunc = FO_MOVE;
-        dirmove.pFrom = tsrc;
-        dirmove.pTo = tdest;
-        dirmove.fFlags = FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS;
-        dirmove.hNameMappings = 0;
-        dirmove.lpszProgressTitle = copytitle;
-
-        if(SHFileOperation(&dirmove)==0)
-                ret = TRUE;
-
-        g_free(tsrc);
-        g_free(tdest);
-        return ret;
-}
-#endif
-
 static void wgaim_debug_print(GaimDebugLevel level, const char *category, const char *format, va_list args) {
-        char *str = g_strdup_vprintf(format, args);
-        printf("%s%s%s", category?category:"", category?": ":"",str);
-        g_free(str);
+	char *str = NULL;
+	if (args != NULL) {
+		str = g_strdup_vprintf(format, args);
+	} else {
+		str = g_strdup(format);
+	}
+	printf("%s%s%s", category?category:"", category?": ":"",str);
+	g_free(str);
 }
 
 static GaimDebugUiOps ops =  {
@@ -448,7 +333,7 @@
 	int ret;
 
 	if((fin = gzopen(in, "rb"))) {
-		if(!(fout = fopen(out, "wb"))) {
+		if(!(fout = g_fopen(out, "wb"))) {
 			gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error opening file: %s\n", out);
 			gzclose(fin);
 			return 0;
@@ -491,7 +376,7 @@
 			gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failure untaring %s\n", tmpfile);
 			ret=0;
 		}
-		unlink(tmpfile);
+		g_unlink(tmpfile);
 		return ret;
 	}
 	else {
@@ -569,13 +454,33 @@
         /* Set app data dir, used by gaim_home_dir */
         newenv = (char*)g_getenv("GAIMHOME");
         if(!newenv) {
-                if((MySHGetFolderPath = (LPFNSHGETFOLDERPATH)wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"))) {
-                        MySHGetFolderPath(NULL,
-                                          CSIDL_APPDATA, 
-                                          NULL, SHGFP_TYPE_CURRENT, app_data_dir);
-                }
-                else
-                        strcpy(app_data_dir, "C:");
+#if GLIB_CHECK_VERSION(2,6,0)
+		if ((MySHGetFolderPathW = (LPFNSHGETFOLDERPATHW) wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathW"))) {
+			wchar_t utf_16_dir[MAX_PATH +1];
+			char *temp;
+			MySHGetFolderPathW(NULL, CSIDL_APPDATA, NULL,
+					SHGFP_TYPE_CURRENT, utf_16_dir);
+			temp = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL);
+			g_strlcpy(app_data_dir, temp, sizeof(app_data_dir));
+			g_free(temp);
+		} else if ((MySHGetFolderPathA = (LPFNSHGETFOLDERPATHA) wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"))) {
+			char locale_dir[MAX_PATH + 1];
+			char *temp;
+			MySHGetFolderPathA(NULL, CSIDL_APPDATA, NULL,
+					SHGFP_TYPE_CURRENT, locale_dir);
+			temp = g_locale_to_utf8(locale_dir, -1, NULL, NULL, NULL);
+			g_strlcpy(app_data_dir, temp, sizeof(app_data_dir));
+			g_free(temp);
+		}
+#else
+		if ((MySHGetFolderPathA = (LPFNSHGETFOLDERPATHA) wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"))) {
+			MySHGetFolderPathA(NULL, CSIDL_APPDATA, NULL,
+					SHGFP_TYPE_CURRENT, app_data_dir);
+		}
+#endif
+		else {
+			strcpy(app_data_dir, "C:");
+		}
         }
         else {
                 g_strlcpy(app_data_dir, newenv, sizeof(app_data_dir));