Skip to content

Commit

Permalink
qemu-io: Improve portability (win32 now supported).
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
  • Loading branch information
Stefan Weil authored and Anthony Liguori committed Sep 9, 2009
1 parent cc2040f commit c32d766
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <sys/time.h>

#include "cmd.h"

Expand Down Expand Up @@ -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,
Expand All @@ -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++;
Expand Down
2 changes: 2 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,8 @@ if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
if [ "$check_utests" = "yes" ]; then
tools="check-qint check-qstring check-qdict $tools"
fi
elif test "$mingw32" = "yes" ; then
tools="qemu-io\$(EXESUF) $tools"
fi
fi
echo "TOOLS=$tools" >> $config_host_mak
Expand Down
2 changes: 2 additions & 0 deletions qemu-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c32d766

Please sign in to comment.