diff src/browser.c @ 1250:b5783215b245

[gaim-migrate @ 1260] decklin's clean up of the account editor, much needed. indent -kr -i8 -l105 -ncs -cp7 -npcs -T GtkWidget -T gpointer -T AppletCallbackFunc -T GtkFunction -T gaim_plugin_remove -T name -T FILE -T gchar -T user_opts -T GdkEvent -T GtkObject ... did about.c, aim.c, away.c, browser.c, buddy_chat.c, gaimrc.c, html.c, idle.c, multi.c. Need to do buddy.c, conversation.c, dialogs.c, oscar.c, perl.c, plugins.c, prefs.c, proxy.c, prpl.c, rvous.c, server.c, sound.c, toc.c, util.c. not doing gtkhtml.c because it's a piece of crap anyway, or *ticker.c because they're syd's. got rid of debug_buff, just debug_printf now. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 13 Dec 2000 20:18:35 +0000
parents 2e0e157b49a0
children 9cff8ff01d37
line wrap: on
line diff
--- a/src/browser.c	Wed Dec 13 06:39:24 2000 +0000
+++ b/src/browser.c	Wed Dec 13 20:18:35 2000 +0000
@@ -60,59 +60,56 @@
 #define MOZILLA_COMMAND_PROP   "_MOZILLA_COMMAND"
 #define MOZILLA_RESPONSE_PROP  "_MOZILLA_RESPONSE"
 
-static GdkAtom XA_MOZILLA_VERSION  = 0;
-static GdkAtom XA_MOZILLA_LOCK     = 0;
-static GdkAtom XA_MOZILLA_COMMAND  = 0;
+static GdkAtom XA_MOZILLA_VERSION = 0;
+static GdkAtom XA_MOZILLA_LOCK = 0;
+static GdkAtom XA_MOZILLA_COMMAND = 0;
 static GdkAtom XA_MOZILLA_RESPONSE = 0;
 
 
 static int netscape_lock;
 
 
-static Window
-VirtualRootWindowOfScreen(screen)
-        Screen *screen;
+static Window VirtualRootWindowOfScreen(screen)
+Screen *screen;
 {
-        static Screen *save_screen = (Screen *)0;
-        static Window root = (Window)0;
+	static Screen *save_screen = (Screen *) 0;
+	static Window root = (Window) 0;
 
-        if (screen != save_screen) {
-                Display *dpy = DisplayOfScreen(screen);
-                Atom __SWM_VROOT = None;
-                unsigned int i;
-                Window rootReturn, parentReturn, *children;
-                unsigned int numChildren;
+	if (screen != save_screen) {
+		Display *dpy = DisplayOfScreen(screen);
+		Atom __SWM_VROOT = None;
+		unsigned int i;
+		Window rootReturn, parentReturn, *children;
+		unsigned int numChildren;
 
-                root = RootWindowOfScreen(screen);
+		root = RootWindowOfScreen(screen);
 
-                /* go look for a virtual root */
-                __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
-                if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
-                                 &children, &numChildren)) {
-                        for (i = 0; i < numChildren; i++) {
-                                Atom actual_type;
-                                int actual_format;
-                                unsigned long nitems, bytesafter;
-                                Window *newRoot = (Window *)0;
+		/* go look for a virtual root */
+		__SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
+		if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) {
+			for (i = 0; i < numChildren; i++) {
+				Atom actual_type;
+				int actual_format;
+				unsigned long nitems, bytesafter;
+				Window *newRoot = (Window *) 0;
 
-                                if (XGetWindowProperty(dpy, children[i],
-                                        __SWM_VROOT, 0, 1, False, XA_WINDOW,
-                                        &actual_type, &actual_format,
-                                        &nitems, &bytesafter,
-                                        (unsigned char **) &newRoot) == Success
-                                    && newRoot) {
-                                    root = *newRoot;
-                                    break;
-                                }
-                        }
-                        if (children)
-                                XFree((char *)children);
-                }
+				if (XGetWindowProperty(dpy, children[i],
+						       __SWM_VROOT, 0, 1, False, XA_WINDOW,
+						       &actual_type, &actual_format,
+						       &nitems, &bytesafter,
+						       (unsigned char **)&newRoot) == Success && newRoot) {
+					root = *newRoot;
+					break;
+				}
+			}
+			if (children)
+				XFree((char *)children);
+		}
 
-                save_screen = screen;
-        }
+		save_screen = screen;
+	}
 
-        return root;
+	return root;
 }
 
 /* The following code is Copyright (C) 1989 X Consortium */
@@ -121,68 +118,67 @@
 
 /* Find a window with WM_STATE, else return win itself, as per ICCCM */
 
-static Window GClientWindow (dpy, win)
-    Display *dpy;
-    Window win;
+static Window GClientWindow(dpy, win)
+Display *dpy;
+Window win;
 {
-    Atom WM_STATE;
-    Atom type = None;
-    int format;
-    unsigned long nitems, after;
-    unsigned char *data;
-    Window inf;
+	Atom WM_STATE;
+	Atom type = None;
+	int format;
+	unsigned long nitems, after;
+	unsigned char *data;
+	Window inf;
 
-    WM_STATE = XInternAtom(dpy, "WM_STATE", True);
-    if (!WM_STATE)
-        return win;
-    XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType,
-                       &type, &format, &nitems, &after, &data);
-    if (type)
-    {
+	WM_STATE = XInternAtom(dpy, "WM_STATE", True);
+	if (!WM_STATE)
+		return win;
+	XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType,
+			   &type, &format, &nitems, &after, &data);
+	if (type) {
+		XFree(data);
+		return win;
+	}
+
+	inf = TryChildren(dpy, win, WM_STATE);
+	if (!inf)
+		inf = win;
+
 	XFree(data);
-	return win;
-    }
 
-    inf = TryChildren(dpy, win, WM_STATE);
-    if (!inf)
-        inf = win;
-
-    XFree(data);
-
-    return inf;
+	return inf;
 }
 
 static
-Window TryChildren (dpy, win, WM_STATE)
-    Display *dpy;
-    Window win;
-    Atom WM_STATE;
+Window TryChildren(dpy, win, WM_STATE)
+Display *dpy;
+Window win;
+Atom WM_STATE;
 {
-    Window root, parent;
-    Window *children;
-    unsigned int nchildren;
-    unsigned int i;
-    Atom type = None;
-    int format;
-    unsigned long nitems, after;
-    unsigned char *data;
-    Window inf = 0;
+	Window root, parent;
+	Window *children;
+	unsigned int nchildren;
+	unsigned int i;
+	Atom type = None;
+	int format;
+	unsigned long nitems, after;
+	unsigned char *data;
+	Window inf = 0;
 
-    if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
-        return 0;
-    for (i = 0; !inf && (i < nchildren); i++) {
-        XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False,
-                           AnyPropertyType, &type, &format, &nitems,
-                           &after, &data);
-        if (type)
-            inf = children[i];
+	if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
+		return 0;
+	for (i = 0; !inf && (i < nchildren); i++) {
+		XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False,
+				   AnyPropertyType, &type, &format, &nitems, &after, &data);
+		if (type)
+			inf = children[i];
 
-	XFree(data);
-    }
-    for (i = 0; !inf && (i < nchildren); i++)
-        inf = TryChildren(dpy, children[i], WM_STATE);
-    if (children) XFree((char *)children);
-    return inf;
+		XFree(data);
+	}
+	for (i = 0; !inf && (i < nchildren); i++)
+		inf = TryChildren(dpy, children[i], WM_STATE);
+	if (children)
+		XFree((char *)children);
+	return inf;
 }
 
 /* END X Consortium code */
@@ -194,332 +190,270 @@
 	if (!XA_MOZILLA_VERSION)
 		XA_MOZILLA_VERSION = gdk_atom_intern(MOZILLA_VERSION_PROP, 0);
 	if (!XA_MOZILLA_LOCK)
-                XA_MOZILLA_LOCK = gdk_atom_intern(MOZILLA_LOCK_PROP, 0);
-        if (! XA_MOZILLA_COMMAND)
-                XA_MOZILLA_COMMAND = gdk_atom_intern(MOZILLA_COMMAND_PROP, 0);
-	if (! XA_MOZILLA_RESPONSE)
+		XA_MOZILLA_LOCK = gdk_atom_intern(MOZILLA_LOCK_PROP, 0);
+	if (!XA_MOZILLA_COMMAND)
+		XA_MOZILLA_COMMAND = gdk_atom_intern(MOZILLA_COMMAND_PROP, 0);
+	if (!XA_MOZILLA_RESPONSE)
 		XA_MOZILLA_RESPONSE = gdk_atom_intern(MOZILLA_RESPONSE_PROP, 0);
 }
 
 static GdkWindow *mozilla_remote_find_window()
 {
-        int i;
-        Window root = VirtualRootWindowOfScreen(DefaultScreenOfDisplay(gdk_display));
-        Window root2, parent, *kids;
-        unsigned int nkids;
-        Window result = 0;
-        Window tenative = 0;
-        unsigned char *tenative_version = 0;
+	int i;
+	Window root = VirtualRootWindowOfScreen(DefaultScreenOfDisplay(gdk_display));
+	Window root2, parent, *kids;
+	unsigned int nkids;
+	Window result = 0;
+	Window tenative = 0;
+	unsigned char *tenative_version = 0;
 
-        if (!XQueryTree (gdk_display, root, &root2, &parent, &kids, &nkids))
-        {
-            sprintf (debug_buff, "%s: XQueryTree failed on display %s\n", progname,
-                     DisplayString (gdk_display));
-			debug_print(debug_buff);
-            return NULL;
-        }
+	if (!XQueryTree(gdk_display, root, &root2, &parent, &kids, &nkids)) {
+		debug_printf("%s: XQueryTree failed on display %s\n", progname,
+			     DisplayString(gdk_display));
+		return NULL;
+	}
 
-        /* root != root2 is possible with virtual root WMs. */
+	/* root != root2 is possible with virtual root WMs. */
 
-        if (!(kids && nkids)) {
-                sprintf (debug_buff, "%s: root window has no children on display %s\n",
-                         progname, DisplayString (gdk_display));
-		debug_print(debug_buff);
-            	return NULL;
-        }
+	if (!(kids && nkids)) {
+		debug_printf("%s: root window has no children on display %s\n",
+			     progname, DisplayString(gdk_display));
+		return NULL;
+	}
 
-        for (i = nkids-1; i >= 0; i--)
-        {
-                Atom type;
-                int format;
-                unsigned long nitems, bytesafter;
-                unsigned char *version = 0;
-                Window w = GClientWindow (gdk_display, kids[i]);
-                int status = XGetWindowProperty (gdk_display, w, XA_MOZILLA_VERSION,
-                                                 0, (65536 / sizeof (long)),
-                                                 False, XA_STRING,
-                                                 &type, &format, &nitems, &bytesafter,
-                                                 &version);
+	for (i = nkids - 1; i >= 0; i--) {
+		Atom type;
+		int format;
+		unsigned long nitems, bytesafter;
+		unsigned char *version = 0;
+		Window w = GClientWindow(gdk_display, kids[i]);
+		int status = XGetWindowProperty(gdk_display, w, XA_MOZILLA_VERSION,
+						0, (65536 / sizeof(long)),
+						False, XA_STRING,
+						&type, &format, &nitems, &bytesafter,
+						&version);
 
-                if (! version)
-                        continue;
+		if (!version)
+			continue;
 
-                if (strcmp ((char *) version, expected_mozilla_version) &&
-                    !tenative)
-                {
-                        tenative = w;
-                        tenative_version = version;
-                        continue;
-                }
-                XFree(version);
-                if (status == Success && type != None)
-                {
-                        result = w;
-                        break;
-                }
-        }
+		if (strcmp((char *)version, expected_mozilla_version) && !tenative) {
+			tenative = w;
+			tenative_version = version;
+			continue;
+		}
+		XFree(version);
+		if (status == Success && type != None) {
+			result = w;
+			break;
+		}
+	}
 
 	XFree(kids);
 
-        if (result && tenative)
-        {
-            sprintf (debug_buff,
-                         "%s: warning: both version %s (0x%x) and version\n"
-                         "\t%s (0x%x) are running.  Using version %s.\n",
-                         progname, tenative_version, (unsigned int) tenative,
-                         expected_mozilla_version, (unsigned int) result,
-                         expected_mozilla_version);
-			debug_print(debug_buff);
-            XFree(tenative_version);
-            return gdk_window_foreign_new(result);
-        }
-        else if (tenative)
-        {
-            sprintf (debug_buff,
-                     "%s: warning: expected version %s but found version\n"
-                     "\t%s (0x%x) instead.\n",
-                     progname, expected_mozilla_version,
-                     tenative_version, (unsigned int) tenative);
-			debug_print(debug_buff);
-            XFree(tenative_version);
-            return gdk_window_foreign_new(tenative);
-        }
-        else if (result)
-        {
-                return gdk_window_foreign_new(result);
-        }
-        else
-        {
-            sprintf (debug_buff, "%s: not running on display %s\n", progname,
-                     DisplayString (gdk_display));
-			debug_print(debug_buff);
-            return NULL;
-        }
+	if (result && tenative) {
+		debug_printf("%s: warning: both version %s (0x%x) and version\n"
+			     "\t%s (0x%x) are running.  Using version %s.\n",
+			     progname, tenative_version, (unsigned int)tenative,
+			     expected_mozilla_version, (unsigned int)result, expected_mozilla_version);
+		XFree(tenative_version);
+		return gdk_window_foreign_new(result);
+	} else if (tenative) {
+		debug_printf("%s: warning: expected version %s but found version\n"
+			     "\t%s (0x%x) instead.\n",
+			     progname, expected_mozilla_version,
+			     tenative_version, (unsigned int)tenative);
+		XFree(tenative_version);
+		return gdk_window_foreign_new(tenative);
+	} else if (result) {
+		return gdk_window_foreign_new(result);
+	} else {
+		debug_printf("%s: not running on display %s\n", progname, DisplayString(gdk_display));
+		return NULL;
+	}
 }
 
 
 static char *lock_data = 0;
 
-static void mozilla_remote_obtain_lock (GdkWindow *window)
+static void mozilla_remote_obtain_lock(GdkWindow * window)
 {
-        Bool locked = False;
+	Bool locked = False;
 
-        if (!lock_data) {
-		lock_data = (char *)g_malloc (255);
-		sprintf (lock_data, "pid%d@", getpid ());
-		if (gethostname (lock_data + strlen (lock_data), 100)) {
+	if (!lock_data) {
+		lock_data = (char *)g_malloc(255);
+		sprintf(lock_data, "pid%d@", getpid());
+		if (gethostname(lock_data + strlen(lock_data), 100)) {
 			return;
 		}
 	}
 
-        do {
-                int result;
-                GdkAtom actual_type;
-                gint actual_format;
+	do {
+		int result;
+		GdkAtom actual_type;
+		gint actual_format;
 		gint nitems;
-                unsigned char *data = 0;
+		unsigned char *data = 0;
+
+		result = gdk_property_get(window, XA_MOZILLA_LOCK,
+					  XA_STRING, 0,
+					  (65536 / sizeof(long)), 0,
+					  &actual_type, &actual_format, &nitems, &data);
+		if (result != Success || actual_type == None) {
+			/* It's not now locked - lock it. */
+			debug_printf("%s: (writing " MOZILLA_LOCK_PROP
+				     " \"%s\" to 0x%x)\n", progname, lock_data, (unsigned int)window);
 
-                result = gdk_property_get (window, XA_MOZILLA_LOCK,
-					   XA_STRING, 0,
-					   (65536 / sizeof (long)), 0,
-					   &actual_type, &actual_format,
-					   &nitems, &data);
-                if (result != Success || actual_type == None)
-                {
-                        /* It's not now locked - lock it. */
-                    sprintf (debug_buff, "%s: (writing " MOZILLA_LOCK_PROP
-                             " \"%s\" to 0x%x)\n",
-                             progname, lock_data, (unsigned int) window);
-					debug_print(debug_buff);
+			gdk_property_change(window, XA_MOZILLA_LOCK, XA_STRING,
+					    8, PropModeReplace,
+					    (unsigned char *)lock_data, strlen(lock_data));
+			locked = True;
+		}
 
-					gdk_property_change(window, XA_MOZILLA_LOCK, XA_STRING,
-						    8, PropModeReplace,
-						    (unsigned char *) lock_data,
-					   		strlen (lock_data));
-                    locked = True;
-                }
-
-                if (!locked) {
-                        /* Then just fuck it. */
-                        if (data)
-                                g_free(data);
-                        return;
-                }
-                if (data)
-                        g_free(data);
-        } while (!locked);
+		if (!locked) {
+			/* Then just fuck it. */
+			if (data)
+				g_free(data);
+			return;
+		}
+		if (data)
+			g_free(data);
+	} while (!locked);
 }
 
 
-static void mozilla_remote_free_lock (GdkWindow *window)
+static void mozilla_remote_free_lock(GdkWindow * window)
 {
-        int result = 0;
-        GdkAtom actual_type;
-        gint actual_format;
-        gint nitems;
-        unsigned char *data = 0;
+	int result = 0;
+	GdkAtom actual_type;
+	gint actual_format;
+	gint nitems;
+	unsigned char *data = 0;
 
-       	sprintf (debug_buff, "%s: (deleting " MOZILLA_LOCK_PROP
-           	     " \"%s\" from 0x%x)\n",
-               	 progname, lock_data, (unsigned int) window);
-		debug_print(debug_buff);
+	debug_printf("%s: (deleting " MOZILLA_LOCK_PROP
+		     " \"%s\" from 0x%x)\n", progname, lock_data, (unsigned int)window);
 
-		result = gdk_property_get(window, XA_MOZILLA_LOCK, XA_STRING,
-				  0, (65536 / sizeof (long)),
-				  1, &actual_type, &actual_format,
-				  &nitems, &data);
-        if (result != Success)
-        {
-             sprintf (debug_buff, "%s: unable to read and delete " MOZILLA_LOCK_PROP
-                     " property\n",
-                     progname);
-		   	 debug_print(debug_buff);
-           	 return;
-        }
-        else if (!data || !*data)
-        {
-              sprintf (debug_buff, "%s: invalid data on " MOZILLA_LOCK_PROP
-               	     " of window 0x%x.\n",
-                   	 progname, (unsigned int) window);
-			  debug_print(debug_buff);
-              return;
-        }
-        else if (strcmp ((char *) data, lock_data))
-        {
-            sprintf (debug_buff, "%s: " MOZILLA_LOCK_PROP
-                     " was stolen!  Expected \"%s\", saw \"%s\"!\n",
-                     progname, lock_data, data);
-			debug_print(debug_buff);
-            return;
-        }
+	result = gdk_property_get(window, XA_MOZILLA_LOCK, XA_STRING,
+				  0, (65536 / sizeof(long)),
+				  1, &actual_type, &actual_format, &nitems, &data);
+	if (result != Success) {
+		debug_printf("%s: unable to read and delete " MOZILLA_LOCK_PROP " property\n", progname);
+		return;
+	} else if (!data || !*data) {
+		debug_printf("%s: invalid data on " MOZILLA_LOCK_PROP
+			     " of window 0x%x.\n", progname, (unsigned int)window);
+		return;
+	} else if (strcmp((char *)data, lock_data)) {
+		debug_printf("%s: " MOZILLA_LOCK_PROP
+			     " was stolen!  Expected \"%s\", saw \"%s\"!\n", progname, lock_data, data);
+		return;
+	}
 
-        if (data)
-                g_free(data);
+	if (data)
+		g_free(data);
 }
 
 
-static int
-mozilla_remote_command (GdkWindow *window, const char *command,
-                        Bool raise_p)
+static int mozilla_remote_command(GdkWindow * window, const char *command, Bool raise_p)
 {
-        int result = 0;
-        Bool done = False;
-        char *new_command = 0;
+	int result = 0;
+	Bool done = False;
+	char *new_command = 0;
 
-        /* The -noraise option is implemented by passing a "noraise" argument
-         to each command to which it should apply.
-         */
-        if (!raise_p)
-        {
-                char *close;
-                new_command = g_malloc (strlen (command) + 20);
-                strcpy (new_command, command);
-                close = strrchr (new_command, ')');
-                if (close)
-                        strcpy (close, ", noraise)");
-                else
-                        strcat (new_command, "(noraise)");
-                command = new_command;
-        }
+	/* The -noraise option is implemented by passing a "noraise" argument
+	   to each command to which it should apply.
+	 */
+	if (!raise_p) {
+		char *close;
+		new_command = g_malloc(strlen(command) + 20);
+		strcpy(new_command, command);
+		close = strrchr(new_command, ')');
+		if (close)
+			strcpy(close, ", noraise)");
+		else
+			strcat(new_command, "(noraise)");
+		command = new_command;
+	}
 
-       	sprintf (debug_buff, "%s: (writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x)\n",
-           	     progname, command, (unsigned int) window);
-		debug_print(debug_buff);
+	debug_printf("%s: (writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x)\n",
+		     progname, command, (unsigned int)window);
 
 	gdk_property_change(window, XA_MOZILLA_COMMAND, XA_STRING, 8,
-			    GDK_PROP_MODE_REPLACE, (unsigned char *) command,
-			    strlen (command));
+			    GDK_PROP_MODE_REPLACE, (unsigned char *)command, strlen(command));
 
 	while (!done) {
-                GdkEvent *event;
-		
-                event = gdk_event_get();
-		
+		GdkEvent *event;
+
+		event = gdk_event_get();
+
 		if (!event)
 			continue;
-		
+
 		if (event->any.window != window) {
 			gtk_main_do_event(event);
 			continue;
 		}
 
-                if (event->type == GDK_DESTROY &&
-                    event->any.window == window) {
+		if (event->type == GDK_DESTROY && event->any.window == window) {
 
-						/* Print to warn user...*/
-						sprintf (debug_buff, "%s: window 0x%x was destroyed.\n",
-								 progname, (unsigned int) window);
-						debug_print(debug_buff);
-						result = 6;
-						goto DONE;
+			/* Print to warn user... */
+			debug_printf("%s: window 0x%x was destroyed.\n", progname, (unsigned int)window);
+			result = 6;
+			goto DONE;
 		} else if (event->type == GDK_PROPERTY_NOTIFY &&
-                         event->property.state == GDK_PROPERTY_NEW_VALUE &&
-                         event->property.window == window &&
-                         event->property.atom == XA_MOZILLA_RESPONSE) {
+			   event->property.state == GDK_PROPERTY_NEW_VALUE &&
+			   event->property.window == window &&
+			   event->property.atom == XA_MOZILLA_RESPONSE) {
 			GdkAtom actual_type;
 			gint actual_format, nitems;
 			unsigned char *data = 0;
 
-			result = gdk_property_get (window, XA_MOZILLA_RESPONSE,
-						   XA_STRING, 0,
-						   (65536 / sizeof (long)),
-						   1,
-						   &actual_type, &actual_format,
-						   &nitems, &data);
+			result = gdk_property_get(window, XA_MOZILLA_RESPONSE,
+						  XA_STRING, 0,
+						  (65536 / sizeof(long)),
+						  1, &actual_type, &actual_format, &nitems, &data);
 
-			
+
 			if (result == Success && data && *data) {
-				sprintf (debug_buff, "%s: (server sent " MOZILLA_RESPONSE_PROP
-					 " \"%s\" to 0x%x.)\n",
-					 progname, data, (unsigned int) window);
-				debug_print(debug_buff);
+				debug_printf("%s: (server sent " MOZILLA_RESPONSE_PROP
+					     " \"%s\" to 0x%x.)\n",
+					     progname, data, (unsigned int)window);
 			}
 
 			if (result != Success) {
-				sprintf (debug_buff, "%s: failed reading " MOZILLA_RESPONSE_PROP
-					 " from window 0x%0x.\n",
-					 progname, (unsigned int) window);
-				debug_print(debug_buff);
+				debug_printf("%s: failed reading " MOZILLA_RESPONSE_PROP
+					     " from window 0x%0x.\n", progname, (unsigned int)window);
 				result = 6;
 				done = True;
-			} else if (!data || strlen((char *) data) < 5) {
-				sprintf (debug_buff, "%s: invalid data on " MOZILLA_RESPONSE_PROP
-					 " property of window 0x%0x.\n",
-					 progname, (unsigned int) window);
-				debug_print(debug_buff);
+			} else if (!data || strlen((char *)data) < 5) {
+				debug_printf("%s: invalid data on " MOZILLA_RESPONSE_PROP
+					     " property of window 0x%0x.\n",
+					     progname, (unsigned int)window);
 				result = 6;
 				done = True;
-			} else if (*data == '1') { /* positive preliminary reply */
-				sprintf (debug_buff, "%s: %s\n", progname, data + 4);
-				debug_print(debug_buff);
+			} else if (*data == '1') {	/* positive preliminary reply */
+				debug_printf("%s: %s\n", progname, data + 4);
 				/* keep going */
 				done = False;
-			} else if (!strncmp ((char *)data, "200", 3)) {
+			} else if (!strncmp((char *)data, "200", 3)) {
 				result = 0;
 				done = True;
 			} else if (*data == '2') {
-				sprintf (debug_buff, "%s: %s\n", progname, data + 4);
-				debug_print(debug_buff);
+				debug_printf("%s: %s\n", progname, data + 4);
 				result = 0;
 				done = True;
 			} else if (*data == '3') {
-				sprintf (debug_buff, "%s: internal error: "
-					 "server wants more information?  (%s)\n",
-					 progname, data);
-				debug_print(debug_buff);
+				debug_printf("%s: internal error: "
+					     "server wants more information?  (%s)\n", progname, data);
 				result = 3;
 				done = True;
 			} else if (*data == '4' || *data == '5') {
-				sprintf (debug_buff, "%s: %s\n", progname, data + 4);
-				debug_print(debug_buff);
+				debug_printf("%s: %s\n", progname, data + 4);
 				result = (*data - '0');
 				done = True;
 			} else {
-				sprintf (debug_buff,
-					 "%s: unrecognised " MOZILLA_RESPONSE_PROP
-					 " from window 0x%x: %s\n",
-					 progname, (unsigned int) window, data);
-				debug_print(debug_buff);
+				debug_printf("%s: unrecognised " MOZILLA_RESPONSE_PROP
+					     " from window 0x%x: %s\n",
+					     progname, (unsigned int)window, data);
 				result = 6;
 				done = True;
 			}
@@ -527,22 +461,20 @@
 			if (data)
 				g_free(data);
 		}
-		else if (event->type == GDK_PROPERTY_NOTIFY &&
-                         event->property.window == window &&
-                         event->property.state == GDK_PROPERTY_DELETE &&
-                         event->property.atom == XA_MOZILLA_COMMAND) {
-                        sprintf (debug_buff, "%s: (server 0x%x has accepted "
-                                 MOZILLA_COMMAND_PROP ".)\n",
-                                 progname, (unsigned int) window);
-						debug_print(debug_buff);
+			else if (event->type == GDK_PROPERTY_NOTIFY &&
+				 event->property.window == window &&
+				 event->property.state == GDK_PROPERTY_DELETE &&
+				 event->property.atom == XA_MOZILLA_COMMAND) {
+			debug_printf("%s: (server 0x%x has accepted "
+				     MOZILLA_COMMAND_PROP ".)\n", progname, (unsigned int)window);
 		}
 		gdk_event_free(event);
 	}
 
-DONE:
+      DONE:
 
 	if (new_command)
-		g_free (new_command);
+		g_free(new_command);
 
 	return result;
 }
@@ -550,40 +482,40 @@
 
 gint check_netscape(char *msg)
 {
-        int status;
-        GdkWindow *window;
+	int status;
+	GdkWindow *window;
 
-        mozilla_remote_init_atoms ();
-        window = mozilla_remote_find_window();
+	mozilla_remote_init_atoms();
+	window = mozilla_remote_find_window();
 
-        if (window && (((GdkWindowPrivate *)window)->destroyed == FALSE)) {
+	if (window && (((GdkWindowPrivate *) window)->destroyed == FALSE)) {
 
-		XSelectInput(gdk_display, ((GdkWindowPrivate *)window)->xwindow,
-			     (PropertyChangeMask|StructureNotifyMask));
+		XSelectInput(gdk_display, ((GdkWindowPrivate *) window)->xwindow,
+			     (PropertyChangeMask | StructureNotifyMask));
 
-		
-                mozilla_remote_obtain_lock(window);
+
+		mozilla_remote_obtain_lock(window);
 
-                status = mozilla_remote_command(window, msg, False);
+		status = mozilla_remote_command(window, msg, False);
 
-                if (status != 6)
-                        mozilla_remote_free_lock(window);
+		if (status != 6)
+			mozilla_remote_free_lock(window);
 
-                gtk_timeout_add(1000, (GtkFunction)clean_pid, NULL);
+		gtk_timeout_add(1000, (GtkFunction)clean_pid, NULL);
 
-                netscape_lock = 0;
-		
+		netscape_lock = 0;
+
 		g_free(msg);
-                return FALSE;
-        } else
-                return TRUE;
+		return FALSE;
+	} else
+		return TRUE;
 }
 
 
 static void netscape_command(char *command)
 {
-        int status;
-        pid_t pid;
+	int status;
+	pid_t pid;
 	GdkWindow *window;
 
 	if (netscape_lock)
@@ -596,10 +528,10 @@
 	mozilla_remote_init_atoms();
 	window = mozilla_remote_find_window();
 
-	if (window && (((GdkWindowPrivate *)window)->destroyed == FALSE)) {
+	if (window && (((GdkWindowPrivate *) window)->destroyed == FALSE)) {
 
-		XSelectInput(gdk_display, ((GdkWindowPrivate *)window)->xwindow,
-			     (PropertyChangeMask|StructureNotifyMask));
+		XSelectInput(gdk_display, ((GdkWindowPrivate *) window)->xwindow,
+			     (PropertyChangeMask | StructureNotifyMask));
 
 		mozilla_remote_obtain_lock(window);
 
@@ -609,8 +541,8 @@
 			mozilla_remote_free_lock(window);
 
 		netscape_lock = 0;
-		
-		gdk_window_destroy (window);
+
+		gdk_window_destroy(window);
 	} else {
 		pid = fork();
 		if (pid == 0) {
@@ -619,9 +551,9 @@
 
 			args[0] = g_strdup("netscape");
 			args[1] = NULL;
-                        e = execvp(args[0], args);
-                        printf("Hello%d\n", getppid());
-                        
+			e = execvp(args[0], args);
+			printf("Hello%d\n", getppid());
+
 			_exit(0);
 		} else {
 			char *tmp = g_strdup(command);
@@ -631,10 +563,11 @@
 
 }
 
-void open_url(GtkWidget *w, char *url) {
+void open_url(GtkWidget *w, char *url)
+{
 
 	if (web_browser == BROWSER_NETSCAPE) {
-                char *command = g_malloc(1024);
+		char *command = g_malloc(1024);
 
 		g_snprintf(command, 1024, "OpenURL(%s)", url);
 
@@ -650,7 +583,7 @@
 
 			args[0] = g_strdup("kfmclient");
 			args[1] = g_strdup("openURL");
-                        args[2] = url;;
+			args[2] = url;;
 			args[3] = NULL;
 
 			execvp(args[0], args);
@@ -679,18 +612,19 @@
 			args[2] = command;
 			args[3] = NULL;
 
-                        execvp(args[0], args);
+			execvp(args[0], args);
 
 			_exit(0);
 		} else {
 			gtk_timeout_add(1000, (GtkFunction)clean_pid, NULL);
 		}
-        }
+	}
 }
 
-void add_bookmark(GtkWidget *w, char *url) {
+void add_bookmark(GtkWidget *w, char *url)
+{
 	if (web_browser == BROWSER_NETSCAPE) {
-                char *command = g_malloc(1024);
+		char *command = g_malloc(1024);
 
 		g_snprintf(command, 1024, "AddBookmark(%s)", url);
 
@@ -699,9 +633,10 @@
 	}
 }
 
-void open_url_nw(GtkWidget *w, char *url) {
+void open_url_nw(GtkWidget *w, char *url)
+{
 	if (web_browser == BROWSER_NETSCAPE) {
-                char *command = g_malloc(1024);
+		char *command = g_malloc(1024);
 
 		g_snprintf(command, 1024, "OpenURL(%s, new-window)", url);
 
@@ -716,9 +651,15 @@
 
 /* Sooner or later, I shall support Windows clicking! */
 
-void add_bookmark(GtkWidget *w, char *url) { }
-void open_url_nw(GtkWidget *w, char *url) { }
-void open_url(GtkWidget *w, char *url) { }
+void add_bookmark(GtkWidget *w, char *url)
+{
+}
+void open_url_nw(GtkWidget *w, char *url)
+{
+}
+void open_url(GtkWidget *w, char *url)
+{
+}
 
 
-#endif _WIN32
+#endif	/* _WIN32 */