]> git.proxmox.com Git - qemu.git/commitdiff
qemu-io: Improve portability (win32 now supported).
authorStefan Weil <weil@mail.berlios.de>
Mon, 31 Aug 2009 20:16:16 +0000 (22:16 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 23 Sep 2009 02:15:57 +0000 (21:15 -0500)
* Add missing include for struct timeval.
* Replace non-portable strsep by local qemu_strsep.
* Use POSIX basename by including libgen.h.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
cmd.c
configure
qemu-io.c

diff --git a/cmd.c b/cmd.c
index f3f4385643e46ee679b61cb28c128ca38b8e79b8..d86ba7ccb421608907c8ec8b3c4eba2c4ae3384d 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -20,6 +20,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
+#include <sys/time.h>
 
 #include "cmd.h"
 
@@ -283,6 +284,26 @@ fetchline(void)
 }
 #endif
 
+static char *qemu_strsep(char **input, const char *delim)
+{
+    char *result = *input;
+    if (result != NULL) {
+    char *p = result;
+    for (p = result; *p != '\0'; p++) {
+        if (strchr(delim, *p)) {
+                break;
+            }
+        }
+        if (*p == '\0') {
+            *input = NULL;
+        } else {
+            *p = '\0';
+            *input = p + 1;
+        }
+    }
+    return result;
+}
+
 char **
 breakline(
        char    *input,
@@ -292,7 +313,7 @@ breakline(
        char    *p;
        char    **rval = calloc(sizeof(char *), 1);
 
-       while (rval && (p = strsep(&input, " ")) != NULL) {
+       while (rval && (p = qemu_strsep(&input, " ")) != NULL) {
                if (!*p)
                        continue;
                c++;
index f1d308787615d8e1288c96893161bad10c346b2c..cac4198453e90846d56a4549d5a81f84de8876d8 100755 (executable)
--- a/configure
+++ b/configure
@@ -1802,6 +1802,8 @@ if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
   tools="qemu-img\$(EXESUF) $tools"
   if [ "$linux" = "yes" ] ; then
       tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
+  elif test "$mingw32" = "yes" ; then
+      tools="qemu-io\$(EXESUF) $tools"
   fi
 fi
 echo "TOOLS=$tools" >> $config_host_mak
index 880378c1b271a7eaee77d984e21cacbb9ca6503a..cd9c9599caf0ecfa348f87af2facea5bfdf753d0 100644 (file)
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -7,10 +7,12 @@
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
+#include <sys/time.h>
 #include <sys/types.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <getopt.h>
+#include <libgen.h>
 
 #include "qemu-common.h"
 #include "block_int.h"