summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/main.c20
-rw-r--r--src/usleep.c61
3 files changed, 82 insertions, 1 deletions
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