Commit 397bd1c4 authored by Jens Georg's avatar Jens Georg

Fix compile on windows

parent 5936ecf2
......@@ -34,8 +34,9 @@ AM_CONDITIONAL(HAVE_GTEST, [test x$gtest = xyes])
AC_MSG_CHECKING([operating system])
case "$target_os" in
mingw*|cygwin*)
os_win32=yes
AC_MSG_RESULT(Win32)
UUID=uuid
UUID=
;;
darwin*)
AC_MSG_RESULT(Darwin)
......@@ -54,14 +55,16 @@ PKG_CHECK_MODULES(LIBGUPNP, glib-2.0 >= 2.24.0 \
libsoup-2.4 >= 2.28.2 \
libxml-2.0 \
$UUID)
PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
AC_ARG_WITH([context_manager],
AM_CONDITIONAL(OS_WIN32, test "x$os_win32" = "xyes")
if test "x$os_win32" = "xno"; then
AC_ARG_WITH([context_manager],
AS_HELP_STRING(
[--with-context-manager=@<:@network-manager/connman/unix/linux@:>@],
[Context Manager backend to use]),,
[with_context_manager="none"])
fi
if test "x$with_context_manager" = "xnone"; then
case "$target_os" in
......
LTVERSION = 4:0:0
if OS_WIN32
WIN32_LDFLAGS = -no-undefined
else
CONTEXT_MANAGER_IMPL = gupnp-unix-context-manager.c \
gupnp-unix-context-manager.h
gupnp-unix-context-manager.h
if USE_NETWORK_MANAGER
CONTEXT_MANAGER_IMPL += gupnp-network-manager.c \
gupnp-network-manager.h
......@@ -13,6 +16,7 @@ CONTEXT_MANAGER_IMPL += gupnp-connman-manager.c \
CONTEXT_MANAGER_CFLAGS = -DUSE_CONNMAN
endif
endif
endif
if HAVE_NETLINK
CONTEXT_MANAGER_IMPL += \
......@@ -79,7 +83,7 @@ gupnp-marshal.h: gupnp-marshal.list
BUILT_SOURCES = gupnp-marshal.c gupnp-marshal.h
libgupnp_1_0_la_LDFLAGS = -version-info $(LTVERSION)
libgupnp_1_0_la_LDFLAGS = -version-info $(LTVERSION) $(WIN32_LDFLAGS)
libgupnp_1_0_la_SOURCES = $(introspection_sources) \
http-headers.c \
......
......@@ -37,6 +37,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <libsoup/soup-address.h>
#include <glib.h>
#include <glib/gstdio.h>
#include "gupnp.h"
......@@ -336,7 +337,8 @@ gupnp_context_manager_create (guint port)
#endif
GUPnPContextManager *impl;
GType impl_type = G_TYPE_INVALID;
#ifdef G_OS_WIN32
#else
#ifdef USE_NETWORK_MANAGER
#include "gupnp-network-manager.h"
system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
......@@ -360,7 +362,7 @@ gupnp_context_manager_create (guint port)
#else
impl_type = GUPNP_TYPE_UNIX_CONTEXT_MANAGER;
#endif
#endif /* G_OS_WIN32 */
impl = g_object_new (impl_type,
"port", port,
NULL);
......
......@@ -40,9 +40,10 @@
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#ifndef G_OS_WIN32
#include <sys/utsname.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <libsoup/soup-address.h>
......@@ -115,6 +116,10 @@ static GInitableIface* initable_parent_iface = NULL;
static char *
make_server_id (void)
{
#ifdef G_OS_WIN32
return g_strdup_printf ("Microsoft Windows UPnP/1.0 GUPnP/%s",
VERSION);
#else
struct utsname sysinfo;
uname (&sysinfo);
......@@ -123,6 +128,7 @@ make_server_id (void)
sysinfo.sysname,
sysinfo.release,
VERSION);
#endif
}
static void
......@@ -547,19 +553,19 @@ _gupnp_context_get_server_url (GUPnPContext *context)
* gupnp_context_new:
* @main_context: (allow-none): Deprecated: 0.17.2: Always set to %NULL. If you
* want to use a different context, use g_main_context_push_thread_default().
* @interface: (allow-none): The network interface to use, or %NULL to
* @iface: (allow-none): The network interface to use, or %NULL to
* auto-detect.
* @port: Port to run on, or 0 if you don't care what port is used.
* @error: A location to store a #GError, or %NULL
*
* Create a new #GUPnPContext with the specified @main_context, @interface and
* Create a new #GUPnPContext with the specified @main_context, @iface and
* @port.
*
* Return value: A new #GUPnPContext object, or %NULL on an error
**/
GUPnPContext *
gupnp_context_new (GMainContext *main_context,
const char *interface,
const char *iface,
guint port,
GError **error)
{
......@@ -571,7 +577,7 @@ gupnp_context_new (GMainContext *main_context,
return g_initable_new (GUPNP_TYPE_CONTEXT,
NULL,
error,
"interface", interface,
"interface", iface,
"port", port,
NULL);
}
......
......@@ -80,7 +80,7 @@ struct _GUPnPContextClass {
GUPnPContext *
gupnp_context_new (GMainContext *main_context,
const char *interface,
const char *iface,
guint port,
GError **error);
......
......@@ -30,7 +30,10 @@
#include <gobject/gvaluecollector.h>
#include <gmodule.h>
#include <libsoup/soup-date.h>
#ifdef G_OS_WIN32
#else
#include <uuid/uuid.h>
#endif
#include <string.h>
#include "gupnp-service.h"
#include "gupnp-root-device.h"
......@@ -1077,6 +1080,9 @@ subscription_response (GUPnPService *service,
static char *
generate_sid (void)
{
#ifdef G_OS_WIN32
return NULL;
#else
uuid_t id;
char out[39];
......@@ -1084,6 +1090,7 @@ generate_sid (void)
uuid_unparse (id, out);
return g_strdup_printf ("uuid:%s", out);
#endif
}
/* Subscription expired */
......
......@@ -24,6 +24,7 @@
#include <string.h>
#include <locale.h>
#include <signal.h>
#include <glib.h>
GMainLoop *main_loop;
......@@ -95,7 +96,9 @@ main (int argc, char **argv)
GError *error;
GUPnPContext *context;
GUPnPControlPoint *cp;
#ifndef G_OS_WIN32
struct sigaction sig_action;
#endif /* G_OS_WIN32 */
g_type_init ();
setlocale (LC_ALL, "");
......@@ -134,10 +137,14 @@ main (int argc, char **argv)
main_loop = g_main_loop_new (NULL, FALSE);
#ifndef G_OS_WIN32
/* Hook the handler for SIGTERM */
memset (&sig_action, 0, sizeof (sig_action));
sig_action.sa_handler = interrupt_signal_handler;
sigaction (SIGINT, &sig_action, NULL);
#else
signal(SIGINT, interrupt_signal_handler);
#endif /* G_OS_WIN32 */
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
......
......@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <glib.h>
GMainLoop *main_loop;
......@@ -235,7 +236,9 @@ main (int argc, char **argv)
GUPnPContext *context;
GUPnPControlPoint *cp;
GOptionContext *option_context;
#ifndef G_OS_WIN32
struct sigaction sig_action;
#endif /* G_OS_WIN32 */
option_context = g_option_context_new ("- test GUPnP introspection");
g_option_context_add_main_entries (option_context,
......@@ -282,9 +285,13 @@ main (int argc, char **argv)
main_loop = g_main_loop_new (NULL, FALSE);
/* Hook the handler for SIGTERM */
#ifndef G_OS_WIN32
memset (&sig_action, 0, sizeof (sig_action));
sig_action.sa_handler = interrupt_signal_handler;
sigaction (SIGINT, &sig_action, NULL);
#else
signal(SIGINT,interrupt_signal_handler);
#endif /* G_OS_WIN32 */
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
......
......@@ -24,6 +24,7 @@
#include <string.h>
#include <locale.h>
#include <signal.h>
#include <glib.h>
GMainLoop *main_loop;
......@@ -151,7 +152,9 @@ main (int argc, char **argv)
GError *error;
GUPnPContext *context;
GUPnPControlPoint *cp;
#ifndef G_OS_WIN32
struct sigaction sig_action;
#endif /* G_OS_WIN32 */
g_type_init ();
setlocale (LC_ALL, "");
......@@ -184,9 +187,13 @@ main (int argc, char **argv)
main_loop = g_main_loop_new (NULL, FALSE);
/* Hook the handler for SIGTERM */
#ifndef G_OS_WIN32
memset (&sig_action, 0, sizeof (sig_action));
sig_action.sa_handler = interrupt_signal_handler;
sigaction (SIGINT, &sig_action, NULL);
#else
signal(SIGINT,interrupt_signal_handler);
#endif /* G_OS_WIN32 */
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
......
......@@ -62,7 +62,9 @@ main (int argc, char **argv)
GUPnPContext *context;
GUPnPRootDevice *dev;
GUPnPServiceInfo *content_dir;
#ifndef G_OS_WIN32
struct sigaction sig_action;
#endif /* G_OS_WIN32 */
if (argc < 2) {
g_printerr ("Usage: %s DESCRIPTION_FILE\n", argv[0]);
......@@ -119,9 +121,13 @@ main (int argc, char **argv)
main_loop = g_main_loop_new (NULL, FALSE);
/* Hook the handler for SIGTERM */
#ifndef G_OS_WIN32
memset (&sig_action, 0, sizeof (sig_action));
sig_action.sa_handler = interrupt_signal_handler;
sigaction (SIGINT, &sig_action, NULL);
#else
signal(SIGINT, interrupt_signal_handler);
#endif /* G_OS_WIN32 */
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment