diff options
author | Michael Roth <mdroth@linux.vnet.ibm.com> | 2012-01-19 22:04:34 -0600 |
---|---|---|
committer | Michael Roth <mdroth@linux.vnet.ibm.com> | 2012-02-23 15:40:16 -0600 |
commit | d8ca685acbd06b5cccd9fcd7866ded1f453b8311 (patch) | |
tree | 96257a1f3db5f9a434068951bdde63ceb594de31 /qemu-ga.c | |
parent | c216e5add11d3539810657e5524881fb0bd25d91 (diff) |
qemu-ga: fixes for win32 build of qemu-ga
Various stubs and #ifdefs to compile for Windows using mingw
cross-build. Still has 1 linker error due to a dependency on the
forthcoming win32 versions of the GAChannel/transport class.
Diffstat (limited to 'qemu-ga.c')
-rw-r--r-- | qemu-ga.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -15,7 +15,9 @@ #include <stdbool.h> #include <glib.h> #include <getopt.h> +#ifndef _WIN32 #include <syslog.h> +#endif #include "json-streamer.h" #include "json-parser.h" #include "qint.h" @@ -44,6 +46,7 @@ struct GAState { static struct GAState *ga_state; +#ifndef _WIN32 static void quit_handler(int sig) { g_debug("received signal num %d, quitting", sig); @@ -73,6 +76,7 @@ static gboolean register_signal_handlers(void) } return true; } +#endif static void usage(const char *cmd) { @@ -87,7 +91,9 @@ static void usage(const char *cmd) " -f, --pidfile specify pidfile (default is %s)\n" " -v, --verbose log extra debugging information\n" " -V, --version print version information and exit\n" +#ifndef _WIN32 " -d, --daemonize become a daemon\n" +#endif " -b, --blacklist comma-separated list of RPCs to disable (no spaces, \"?\"" " to list available RPCs)\n" " -h, --help display this help and exit\n" @@ -143,9 +149,13 @@ static void ga_log(const gchar *domain, GLogLevelFlags level, } level &= G_LOG_LEVEL_MASK; +#ifndef _WIN32 if (domain && strcmp(domain, "syslog") == 0) { syslog(LOG_INFO, "%s: %s", level_str, msg); } else if (level & s->log_level) { +#else + if (level & s->log_level) { +#endif g_get_current_time(&time); fprintf(s->log_file, "%lu.%lu: %s: %s\n", time.tv_sec, time.tv_usec, level_str, msg); @@ -153,6 +163,7 @@ static void ga_log(const gchar *domain, GLogLevelFlags level, } } +#ifndef _WIN32 static void become_daemon(const char *pidfile) { pid_t pid, sid; @@ -203,6 +214,7 @@ fail: g_critical("failed to daemonize"); exit(EXIT_FAILURE); } +#endif static int send_response(GAState *s, QObject *payload) { @@ -466,10 +478,12 @@ int main(int argc, char **argv) } } +#ifndef _WIN32 if (daemonize) { g_debug("starting daemon"); become_daemon(pidfile); } +#endif s = g_malloc0(sizeof(GAState)); s->log_file = log_file; @@ -482,10 +496,12 @@ int main(int argc, char **argv) ga_command_state_init_all(s->command_state); json_message_parser_init(&s->parser, process_event); ga_state = s; +#ifndef _WIN32 if (!register_signal_handlers()) { g_critical("failed to register signal handlers"); goto out_bad; } +#endif s->main_loop = g_main_loop_new(NULL, false); if (!channel_init(ga_state, method, path)) { |