Richard W.M. Jones
2009-Nov-25 15:02 UTC
[Libguestfs] [PATCH] daemon/Win32: Replace setenv with Win32 equivalent.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/ -------------- next part -------------->From bbcbfb99656f5de9b8f9e42aa4fba0f733a11b54 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Wed, 25 Nov 2009 14:53:17 +0000 Subject: [PATCH 4/7] daemon/Win32: Replace setenv with Win32 equivalent. --- daemon/guestfsd.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index f31f1f2..64cf87f 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -20,6 +20,10 @@ #define _BSD_SOURCE /* for daemon(3) */ +#ifdef HAVE_WINDOWS_H +#include <windows.h> +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -167,6 +171,9 @@ main (int argc, char *argv[]) perror ("sigaction SIGPIPE"); /* but try to continue anyway ... */ #endif +#ifdef WIN32 +#define setenv(n,v,f) _putenv(n "=" v) +#endif /* Set up a basic environment. After we are called by /init the * environment is essentially empty. * https://bugzilla.redhat.com/show_bug.cgi?id=502074#c5 -- 1.6.5.2
Jim Meyering
2009-Nov-25 17:51 UTC
[Libguestfs] [PATCH] daemon/Win32: Replace setenv with Win32 equivalent.
Richard W.M. Jones wrote:> Subject: [PATCH 4/7] daemon/Win32: Replace setenv with Win32 equivalent....> +#ifdef HAVE_WINDOWS_H > +#include <windows.h> > +#endif > + > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > @@ -167,6 +171,9 @@ main (int argc, char *argv[]) > perror ("sigaction SIGPIPE"); /* but try to continue anyway ... */ > #endif > > +#ifdef WIN32 > +#define setenv(n,v,f) _putenv(n "=" v) > +#endif > /* Set up a basic environment. After we are called by /init the > * environment is essentially empty. > * https://bugzilla.redhat.com/show_bug.cgi?id=502074#c5ACK, It's slightly more readable with nesting-reflecting indentation: #ifdef HAVE_WINDOWS_H # include <windows.h> #endif ... #ifdef WIN32 # define setenv(n,v,f) _putenv(n "=" v) #endif