aboutsummaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
authorStefan Weil <weil@mail.berlios.de>2009-08-31 22:16:16 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-09-09 14:57:20 -0500
commitc32d766af127f68bb75ba5689f2f5239227bf559 (patch)
treebb0102921463f768f89f143dda680f42d80b3e82 /cmd.c
parentcc2040f8c22b933df6f3be11a1bf7a6b55327031 (diff)
qemu-io: Improve portability (win32 now supported).
* 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>
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/cmd.c b/cmd.c
index f3f4385643..d86ba7ccb4 100644
--- 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++;