/* Open a stream to a sub-process.
- Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2009-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Specification. */
#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
+#if HAVE_POPEN
-#undef popen
+# include <errno.h>
+# include <fcntl.h>
+# include <stdlib.h>
+# include <unistd.h>
+
+# undef popen
FILE *
rpl_popen (const char *filename, const char *mode)
errno = saved_errno;
return result;
}
+
+#else
+/* Native Woe32 API. */
+
+# include <string.h>
+
+FILE *
+popen (const char *filename, const char *mode)
+{
+ /* Use binary mode by default. */
+ if (strcmp (mode, "r") == 0)
+ mode = "rb";
+ else if (strcmp (mode, "w") == 0)
+ mode = "wb";
+
+ return _popen (filename, mode);
+}
+
+#endif