summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.hgignore7
-rw-r--r--ChangeLog8
-rw-r--r--configure.ac9
-rw-r--r--src/Makefile.am2
-rw-r--r--src/main.c20
-rw-r--r--src/usleep.c61
6 files changed, 105 insertions, 2 deletions
diff --git a/.hgignore b/.hgignore
index 750dab1..4db0bed 100644
--- a/.hgignore
+++ b/.hgignore
@@ -5,17 +5,22 @@
Makefile\.in$
^config\.guess$
^config\.sub$
+^config\.h
+^config\.log
+^config\.status
^configure$
^compile$
^depcomp$
^install-sh$
^ltmain.sh$
+^Makefile$
^missing$
^libtool$
^src/\.deps
-^src/virt-viewer$
+^src/virt-viewer(.exe)?$
^src/.*\.o
^src/Makefile$
+^stamp-h1$
^virt-viewer\.spec$
^config.h.in$
^man/Makefile$
diff --git a/ChangeLog b/ChangeLog
index 64740c1..63018de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-03-10 "Richard W.M. Jones" <rjones@redhat.com>
+
+ * configure.ac, src/Makefile.am, src/main.c, src/usleep.c: Support
+ for building on Windows using MinGW compiler toolchain (or
+ for cross-compiling using the same).
+
+ * .hgignore: Ignore some generated files.
+
2008-03-09 "Daniel P. Berrange <berrange@redhat.com>
* autobuild.sh, configure.ac, virt-viewer.spec.in:
diff --git a/configure.ac b/configure.ac
index 1e1a5a1..7030e2f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,8 @@ AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_LIBTOOL
+AC_CONFIG_LIBOBJ_DIR([src])
+
AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions])
VIRT_VIEWER_COMPILE_WARNINGS(maximum)
@@ -19,6 +21,13 @@ PKG_CHECK_MODULES(LIBVIRT, libvirt >= 0.2.0)
PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.10.0)
PKG_CHECK_MODULES(GTKVNC, gtk-vnc-1.0 >= 0.3.5)
+dnl Decide if this platform can support the SSH tunnel feature.
+AC_CHECK_HEADERS([sys/socket.h sys/un.h windows.h])
+AC_CHECK_FUNCS([fork socketpair])
+
+dnl Do we need to replace the usleep function (Windows).
+AC_REPLACE_FUNCS([usleep])
+
dnl --enable-plugin to enable the browser plugin.
NSPR_REQUIRED=4.0.0
FIREFOX_PLUGIN_REQUIRED=1.5.0
diff --git a/src/Makefile.am b/src/Makefile.am
index a92e2f3..c6315b2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,5 +2,5 @@
bin_PROGRAMS = virt-viewer
virt_viewer_SOURCES = main.c viewer.h
-virt_viewer_LDADD = @GTKVNC_LIBS@ @GTK2_LIBS@ @LIBXML2_LIBS@ @LIBVIRT_LIBS@
+virt_viewer_LDADD = @GTKVNC_LIBS@ @GTK2_LIBS@ @LIBXML2_LIBS@ @LIBVIRT_LIBS@ @LIBOBJS@
virt_viewer_CFLAGS = @GTKVNC_CFLAGS@ @GTK2_CFLAGS@ @LIBXML2_CFLAGS@ @LIBVIRT_CFLAGS@ @WARN_CFLAGS@
diff --git a/src/main.c b/src/main.c
index 0252023..f9a9073 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,11 +32,25 @@
#include <libvirt/libvirt.h>
#include <libxml/xpath.h>
#include <libxml/uri.h>
+
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
#include "viewer.h"
+#ifndef HAVE_USLEEP
+int usleep (unsigned int usecs);
+#endif
+
// #define DEBUG 1
#ifdef DEBUG
#define DEBUG_LOG(s, ...) fprintf(stderr, (s), ## __VA_ARGS__)
@@ -716,6 +730,8 @@ static int viewer_extract_host(const char *uristr, char **host, char **transport
return 0;
}
+#if defined(HAVE_SOCKETPAIR) && defined(HAVE_FORK)
+
static int viewer_open_tunnel(const char **cmd)
{
int fd[2];
@@ -775,6 +791,8 @@ static int viewer_open_tunnel_ssh(const char *sshhost, int sshport, const char *
return viewer_open_tunnel(cmd);
}
+#endif /* defined(HAVE_SOCKETPAIR) && defined(HAVE_FORK) */
+
int
viewer_start (const char *uri, const char *name,
int direct, int waitvnc, int set_verbose,
@@ -850,8 +868,10 @@ viewer_start (const char *uri, const char *name,
}
DEBUG_LOG("Remote host is %s and transport %s user %s\n", host, transport ? transport : "", user ? user : "");
+#if defined(HAVE_SOCKETPAIR) && defined(HAVE_FORK)
if (transport && strcasecmp(transport, "ssh") == 0 && !direct)
fd = viewer_open_tunnel_ssh(host, port, user, vncport);
+#endif
vnc = vnc_display_new();
window = viewer_build_window (VNC_DISPLAY(vnc),
diff --git a/src/usleep.c b/src/usleep.c
new file mode 100644
index 0000000..95a09c5
--- /dev/null
+++ b/src/usleep.c
@@ -0,0 +1,61 @@
+/*
+ * Virt Viewer: A virtual machine console viewer
+ *
+ * Copyright (C) 2008 Red Hat.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Richard W.M. Jones <rjones@redhat.com>
+ */
+
+/* Replacement usleep function, only used on platforms which lack
+ * this system or library function.
+ */
+
+#include <config.h>
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
+#ifdef WIN32
+
+int
+usleep (unsigned int usecs)
+{
+ unsigned int msecs = usecs / 1000;
+ if (msecs < 1)
+ Sleep (1);
+ else
+ Sleep (msecs);
+}
+
+#else
+
+int
+usleep (unsigned int usecs)
+{
+ /* This sucks, but everything has sleep and it's not
+ * really that critical how long we sleep for in the
+ * main code.
+ */
+ unsigned int secs = usecs / 1000000;
+ if (secs < 1)
+ sleep (1);
+ else
+ sleep (secs);
+}
+
+#endif