diff -ur logjam-4.5.1-dist/src/cmdline.c logjam-4.5.1-win32-src/src/cmdline.c
--- logjam-4.5.1-dist/src/cmdline.c	Wed Aug 24 03:55:54 2005
+++ logjam-4.5.1-win32-src/src/cmdline.c	Sun Sep  4 23:51:04 2005
@@ -61,7 +61,7 @@
 
 static void command_dispatch(Cmdline *cmdline, Command *commands, const char *help, int argc, gchar *argv[]);
 
-#ifndef HAVE_UNISTD_H
+#ifdef G_OS_WIN32
 /* this is a lame function. it isn't available on windows. */
 static gchar*
 getpass(const gchar* prompt) {
@@ -77,7 +77,7 @@
 	buf[63] = '\0';
 	return buf;
 }
-#endif /* HAVE_UNISTD_H */
+#endif /* G_OS_WIN32 */
 
 static void
 print_header(void) {
diff -ur logjam-4.5.1-dist/src/get_cmd_out.c logjam-4.5.1-win32-src/src/get_cmd_out.c
--- logjam-4.5.1-dist/src/get_cmd_out.c	Wed Aug 24 04:14:08 2005
+++ logjam-4.5.1-win32-src/src/get_cmd_out.c	Mon Sep  5 20:32:08 2005
@@ -14,78 +14,75 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#include <sys/types.h>
-#include <sys/wait.h>
+#ifdef G_OS_WIN32
+#include <windows.h>
+#else
+#include <signal.h>
+#endif
 
 struct mypopen_t {
-	int fd;
-	pid_t pid;
+	GIOChannel *chan;
+	GPid pid;
+	gint status;
 	gboolean cancelled;
+	gboolean done;
+	GString *output;
 };
 
 /* An analogue of popen(command, "r").
  * A bit more useful since we know child PID.
  */
-gboolean mypopen_r(const char *command, struct mypopen_t *p)
+gboolean mypopen_r(const char *command, struct mypopen_t *p, GError **err)
 {
-	int fds[2];
-	/* parent fd is fds[0], child fd is fds[1] */
-
-	if (pipe(fds) == -1)
-		return FALSE;
-
-	if ((p->pid = fork()) == -1)
+	gint argc;
+	gchar **argv;
+	gboolean ret;
+	gint fd;
+	
+	ret = g_shell_parse_argv((gchar*)command, &argc, &argv, err);
+	if (ret)
+	{
+		ret = g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD,
+					 NULL, NULL, &(p->pid), NULL, &fd, NULL, err);
+		g_strfreev(argv);
+		if (ret)
+		{
+			p->chan = g_io_channel_unix_new(fd);
+			return TRUE;
+		} else
+		{
+			return FALSE;
+		}
+	} else
 	{
-		close(fds[0]);
-		close(fds[1]);
 		return FALSE;
 	}
-
-	if (p->pid == 0) {
-		/* Child */
-		close(fds[0]);
-		dup2(fds[1], 1);
-		close(fds[1]);
-		execl("/bin/sh", "sh", "-c", command, NULL);
-		/* if execl failed, exit with code 127 */
-		exit(127);
-	}
-	/* Parent */
-	close(fds[1]);
-	p->fd = fds[0];
-	return TRUE;
 }
 
-int mypclose(const struct mypopen_t *p)
+void mypclose(GPid pid, gint status, gpointer data)
 {
-	int ret, status;
-
-/*	fprintf(stderr, "mypclose: pid=%lu, fd=%d\n", p->pid, p->fd); */
+	struct mypopen_t *p = (struct mypopen_t *) data;
 
-	close(p->fd);
-	do {
-		ret = waitpid(p->pid, &status, 0);
-	} while ((ret == -1) && (errno == EINTR));
-
-/*	fprintf(stderr, "waitpid returned %d; errno = %d; "
-			"status = %d; exit = %d; signaled = %d\n",
-			ret, errno, status, WEXITSTATUS(status),
-			WIFSIGNALED(status)); */
-	if (ret == -1)
-		return -1;
-	return WEXITSTATUS(status);
+	p->done = TRUE;
+	p->status = status;
+	g_spawn_close_pid(p->pid);
 }
 
 /* Callback function for "Cancel" button of 'command is running' window
  */
 static void
 cancel_cb(struct mypopen_t *p) {
+	/* platform-specific like whoa */
 	p->cancelled = TRUE;
+#ifdef G_OS_WIN32
+	TerminateProcess(p->pid, 0);
+#else
 	if (p->pid)
 		kill(p->pid, SIGTERM);
 	/* FIXME: should we send SIGKILL some time later
 	 * if process still exists?
 	 */
+#endif
 }
 
 /* Dialog showing that command is being executed.
@@ -127,46 +124,55 @@
 /* Callback function for gtk_input_add_full(). Reads data from the
  * file descriptor. Calls gtk_quit if there's nothing to read.
  */
-void pipe_read_cb(gpointer data, gint source, GdkInputCondition condition) {
-	gchar buf[BUFSIZ];
-	ssize_t c;
-
-	c = read(source, buf, sizeof(buf));
-	if (c == 0) /* EOF */
+gboolean pipe_read_cb(GIOChannel *source, GIOCondition cond, gpointer data) {
+	struct mypopen_t *p = (struct mypopen_t *) data;
+	GIOStatus stat;
+	gchar to_add[1024];
+	gsize bytes_read;
+	GError *err = NULL;
+	
+	stat = g_io_channel_read_chars(source, to_add, 1024, &bytes_read, &err);
+	if (stat == G_IO_STATUS_NORMAL) 
+	{
+		g_string_append_len(p->output, to_add, bytes_read);
+		return TRUE;
+	} else if(p->done)
+	{
+		g_io_channel_close(p->chan);
 		gtk_main_quit();
-	else
-		g_string_append_len((GString *)data, buf, c);
+	}
+	if(err != NULL)
+		g_free(err);
+	return FALSE;
 }
 
 GString * get_command_output(const char *command, GError **err,
 		GtkWindow *parent){
 	GtkWidget *win;
-	GString *output;
 	int ret;
 	guint evid;
 	struct mypopen_t pd;
 
+	pd.output = g_string_new("");
 	pd.cancelled = FALSE;
-	if (mypopen_r(command, &pd) == FALSE) {
-		g_set_error(err, 0, 0, _("command failed: %s"),
-				g_strerror(errno));
+	if (mypopen_r(command, &pd, err) == FALSE) {
+		/* display error? */
 		return NULL;
 	}
+	g_child_watch_add(pd.pid, mypclose, &pd);
 
 /*	fprintf(stderr, "before read: pid=%lu, fd=%d\n", pd.pid, pd.fd); */
-	output = g_string_sized_new(BUFSIZ);
-	evid = gtk_input_add_full(pd.fd, GDK_INPUT_READ,
-			pipe_read_cb, NULL, output, NULL);
+	evid = g_io_add_watch(pd.chan, G_IO_IN|G_IO_PRI,
+			      &pipe_read_cb, &pd);
 
 	win = command_is_running(command, &pd, parent);
 	gtk_main();
 
 	gtk_input_remove(evid);
 	gtk_widget_destroy(win);
-	ret = mypclose(&pd);
 	if (pd.cancelled)
 	{
-		g_string_free(output, TRUE);
+		g_string_free(pd.output, TRUE);
 		return NULL;
 	}
 	/* Positive 'ret' values are command exit code, while negative one
@@ -174,14 +180,14 @@
 	 * Let's ignore all non-zero exit codes but 127, since 127
 	 * means "command not found" from sh. Ugly hack?
 	 */
-	if (ret < 0) {
-		g_string_free(output, TRUE);
+	if (pd.status < 0) {
+		g_string_free(pd.output, TRUE);
 		g_set_error(err, 0, 0, _("command failed: %s"),
 				g_strerror(errno));
 		return NULL;
-	} else if (ret == 127)
+	} else if (pd.status == 127)
 	{
-		g_string_free(output, TRUE);
+		g_string_free(pd.output, TRUE);
 		/* Set err->code to 127 so caller will know that command
 		 * was not found. It is probably a spelling error
 		 * in command string and in this case caller should not
@@ -191,5 +197,5 @@
 		g_set_error(err, 0, 127, _("command not found"));
 		return NULL;
 	}
-	return output;
+	return pd.output;
 }
diff -ur logjam-4.5.1-dist/src/journalstore_sqlite.c logjam-4.5.1-win32-src/src/journalstore_sqlite.c
--- logjam-4.5.1-dist/src/journalstore_sqlite.c	Wed Aug 24 04:16:16 2005
+++ logjam-4.5.1-win32-src/src/journalstore_sqlite.c	Mon Sep  5 20:33:12 2005
@@ -13,6 +13,33 @@
 #include "conf.h"
 #include "journalstore.h"
 
+#ifndef HAVE_TIMEGM
+time_t timegm (struct tm *tm) {
+	time_t ret;
+	char *tz;
+	
+	tz = getenv("TZ");
+	putenv("TZ=UTC");
+	tzset();
+	ret = mktime(tm);
+	if (tz) {
+		char *putstr = g_strdup_printf("TZ=%s", tz);
+		putenv(putstr);
+		g_free(putstr);
+	} else {
+		putenv("TZ=");
+	}
+	tzset();
+	return ret;
+}
+
+struct tm *gmtime_r(const time_t *clock, struct tm *result) {
+	struct tm *temp = gmtime(clock);
+	memcpy(result, temp, sizeof(struct tm));
+	return temp;
+}
+#endif /* HAVE_TIMEGM */
+
 struct _JournalStore {
 	JamAccount *account;
 	sqlite3 *db;
diff -ur logjam-4.5.1-dist/src/journalstore_xml.c logjam-4.5.1-win32-src/src/journalstore_xml.c
--- logjam-4.5.1-dist/src/journalstore_xml.c	Wed Aug 24 03:25:06 2005
+++ logjam-4.5.1-win32-src/src/journalstore_xml.c	Mon Sep  5 07:43:50 2005
@@ -31,6 +31,7 @@
 #define JOURNAL_STORE_INDEX_VERSION 3
 #define JOURNAL_STORE_XML_VERSION 2
 
+
 struct _JournalStore {
 	JamAccount *account;
 
@@ -54,9 +55,30 @@
 	return js->account;
 }
 
+#ifndef HAVE_TIMEGM
+time_t timegm (struct tm *tm) {
+	time_t ret;
+	char *tz;
+	
+	tz = getenv("TZ");
+	putenv("TZ=UTC");
+	tzset();
+	ret = mktime(tm);
+	if (tz) {
+		char *putstr = g_strdup_printf("TZ=%s", tz);
+		putenv(putstr);
+		g_free(putstr);
+	} else {
+		putenv("TZ=");
+	}
+	tzset();
+	return ret;
+}
+#endif
+
 #define index_at(idx, i) g_array_index(idx, time_t, i)
-#define index_get(idx, i) ntohl(index_at(idx, i))
-#define index_set(idx, i, val) index_at(idx, i) = htonl(val)
+#define index_get(idx, i) g_ntohl(index_at(idx, i))
+#define index_set(idx, i, val) index_at(idx, i) = g_htonl(val)
 
 static gboolean
 index_load(JournalStore *js, GError **err) {
diff -ur logjam-4.5.1-dist/src/music.c logjam-4.5.1-win32-src/src/music.c
--- logjam-4.5.1-dist/src/music.c	Mon Feb 21 13:10:04 2005
+++ logjam-4.5.1-win32-src/src/music.c	Mon Sep  5 20:39:10 2005
@@ -21,6 +21,9 @@
 
 MusicSource
 music_current_source(void) {
+#ifdef G_OS_WIN32
+      return MUSIC_SOURCE_NONE;
+#else
 	int i;
 
 	if (!conf.music_command)
@@ -32,6 +35,7 @@
 			return i;
 	}
 	return MUSIC_SOURCE_CUSTOM;
+#endif
 }
 
 GQuark
diff -ur logjam-4.5.1-dist/src/network-win32.c logjam-4.5.1-win32-src/src/network-win32.c
--- logjam-4.5.1-dist/src/network-win32.c	Mon Feb 21 13:41:24 2005
+++ logjam-4.5.1-win32-src/src/network-win32.c	Sun Sep  4 23:38:54 2005
@@ -13,7 +13,7 @@
 #include <io.h>
 #include <fcntl.h>
 
-#include "protocol.h"
+#include "network.h"
 #include "conf.h"
 #include "util.h"
 #include "network-internal.h"

