Add #defines needed by OpenSolaris, fix breakage by the #defines
[qemu] / cmd.c
diff --git a/cmd.c b/cmd.c
index f3f4385..d86ba7c 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++;