[gmime] Add our own unistd.h for Windows builds



commit 6e8c89f26b0e411580b623472e9d6bcb471fb664
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Sat Sep 19 20:57:54 2009 -0400

    Add our own unistd.h for Windows builds
    
    Instead of littering code with #ifdef HAVE_UNISTD_H,
    simply implement our own unistd.h for Windows to
    make our lives a whole lot simpler.

 build/vs2008/basic-example.vcproj |    4 ++--
 build/vs2008/config-win32.h.in    |    6 +++---
 build/vs2008/gmime.vcproj         |    4 ++--
 build/vs2008/imap-example.vcproj  |    4 ++--
 build/vs2008/test-cat.vcproj      |    4 ++--
 build/vs2008/test-headers.vcproj  |    4 ++--
 build/vs2008/test-iconv.vcproj    |    4 ++--
 build/vs2008/test-mbox.vcproj     |    4 ++--
 build/vs2008/test-mime.vcproj     |    4 ++--
 build/vs2008/test-streams.vcproj  |    4 ++--
 build/vs2008/unistd.h             |   19 +++++++++++++++++++
 build/vs2008/uudecode.vcproj      |    4 ++--
 build/vs2008/uuencode.vcproj      |    4 ++--
 configure.ac                      |    2 +-
 gmime/gmime-multipart.c           |    4 +---
 gmime/gmime-stream-fs.c           |    5 -----
 gmime/gmime-stream-pipe.c         |    5 -----
 gmime/gmime-stream.h              |    4 ++--
 gmime/gmime-utils.c               |    4 ----
 src/uudecode.c                    |    6 ------
 src/uuencode.c                    |    5 -----
 tests/test-best.c                 |    2 +-
 tests/test-cat.c                  |   10 +++++-----
 tests/test-mbox.c                 |    6 +++---
 tests/test-parser.c               |    4 ++--
 tests/test-partial.c              |    2 +-
 tests/test-pgp.c                  |    4 ++--
 tests/test-pgpmime.c              |    2 +-
 tests/test-streams.c              |   22 +++++++++++-----------
 29 files changed, 74 insertions(+), 82 deletions(-)
---
diff --git a/build/vs2008/basic-example.vcproj b/build/vs2008/basic-example.vcproj
index 9186a51..a87a401 100644
--- a/build/vs2008/basic-example.vcproj
+++ b/build/vs2008/basic-example.vcproj
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -119,7 +119,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
diff --git a/build/vs2008/config-win32.h.in b/build/vs2008/config-win32.h.in
index 6adf701..1a6663e 100644
--- a/build/vs2008/config-win32.h.in
+++ b/build/vs2008/config-win32.h.in
@@ -113,9 +113,6 @@
 /* Define if struct tm has a tm_gmtoff member */
 /* #undef HAVE_TM_GMTOFF */
 
-/* Define to 1 if you have the <unistd.h> header file. */
-/* #undef HAVE_UNISTD_H */
-
 /* Define if struct utsname has a domainname member */
 /* #undef HAVE_UTSNAME_DOMAINNAME */
 
@@ -180,6 +177,9 @@
 /* #undef inline */
 #endif
 
+/* Define to `int' if <sys/types.h> does not define. */
+#define mode_t int
+
 /* Define to `unsigned long int' if <poll.h> does not define. */
 #define nfds_t unsigned long int
 
diff --git a/build/vs2008/gmime.vcproj b/build/vs2008/gmime.vcproj
index 35b72a8..98fb586 100644
--- a/build/vs2008/gmime.vcproj
+++ b/build/vs2008/gmime.vcproj
@@ -25,7 +25,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Generating config.h ..."
-				CommandLine="if exist ..\..\config.h goto DONE_CONFIG_H&#x0D;&#x0A;copy config-win32.h ..\..\config.h&#x0D;&#x0A;:DONE_CONFIG_H&#x0D;&#x0A;"
+				CommandLine="if exist ..\..\config.h goto DONE_CONFIG_H&#x0D;&#x0A;copy config-win32.h ..\..\config.h&#x0D;&#x0A;:DONE_CONFIG_H&#x0D;&#x0A;if exist ..\..\unistd.h goto DONE_UNISTD_H&#x0D;&#x0A;copy unistd.h ..\..\unistd.h&#x0D;&#x0A;:DONE_UNISTD_H&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -89,7 +89,7 @@
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="if exist ..\..\config.h goto DONE_CONFIG_H&#x0D;&#x0A;copy config-win32.h ..\..\config.h&#x0D;&#x0A;:DONE_CONFIG_H&#x0D;&#x0A;"
+				CommandLine="if exist ..\..\config.h goto DONE_CONFIG_H&#x0D;&#x0A;copy config-win32.h ..\..\config.h&#x0D;&#x0A;:DONE_CONFIG_H&#x0D;&#x0A;if exist ..\..\unistd.h goto DONE_UNISTD_H&#x0D;&#x0A;copy unistd.h ..\..\unistd.h&#x0D;&#x0A;:DONE_UNISTD_H&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
diff --git a/build/vs2008/imap-example.vcproj b/build/vs2008/imap-example.vcproj
index b2b0232..93c0521 100644
--- a/build/vs2008/imap-example.vcproj
+++ b/build/vs2008/imap-example.vcproj
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -119,7 +119,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
diff --git a/build/vs2008/test-cat.vcproj b/build/vs2008/test-cat.vcproj
index 189841e..e3c696f 100644
--- a/build/vs2008/test-cat.vcproj
+++ b/build/vs2008/test-cat.vcproj
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -119,7 +119,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
diff --git a/build/vs2008/test-headers.vcproj b/build/vs2008/test-headers.vcproj
index ac4c220..961ed20 100644
--- a/build/vs2008/test-headers.vcproj
+++ b/build/vs2008/test-headers.vcproj
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -119,7 +119,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
diff --git a/build/vs2008/test-iconv.vcproj b/build/vs2008/test-iconv.vcproj
index 9b0e8b6..dc6821d 100644
--- a/build/vs2008/test-iconv.vcproj
+++ b/build/vs2008/test-iconv.vcproj
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -119,7 +119,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
diff --git a/build/vs2008/test-mbox.vcproj b/build/vs2008/test-mbox.vcproj
index 4fcbcf3..7f4faf8 100644
--- a/build/vs2008/test-mbox.vcproj
+++ b/build/vs2008/test-mbox.vcproj
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -119,7 +119,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
diff --git a/build/vs2008/test-mime.vcproj b/build/vs2008/test-mime.vcproj
index b51b700..76ff21c 100644
--- a/build/vs2008/test-mime.vcproj
+++ b/build/vs2008/test-mime.vcproj
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -119,7 +119,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
diff --git a/build/vs2008/test-streams.vcproj b/build/vs2008/test-streams.vcproj
index 367e39d..3a60348 100644
--- a/build/vs2008/test-streams.vcproj
+++ b/build/vs2008/test-streams.vcproj
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -119,7 +119,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
diff --git a/build/vs2008/unistd.h b/build/vs2008/unistd.h
new file mode 100644
index 0000000..fe4a90e
--- /dev/null
+++ b/build/vs2008/unistd.h
@@ -0,0 +1,19 @@
+/**
+ * unistd.h: Emulation of some standard UNIX APIs
+ **/
+
+#include <process.h>
+#include <io.h>
+
+/* Map the Windows equivalents to the POSIX function names */
+#define open(path,flags,mode) _open(path,flags,mode)
+#define close(fd) _close(fd)
+#define read(fd,buf,n) _read(fd,buf,n)
+#define write(fd,buf,n) _write(fd,buf,n)
+#define lseek(fd,offset,whence) _lseek(fd,offset,whence)
+#define dup(fd) _dup(fd)
+#define getpid() _getpid()
+
+/* Implement some useful sys/stat.h macros that Windows doesn't seem to have */
+#define S_ISDIR(mode) ((mode) & _S_IFDIR)
+#define S_ISREG(mode) ((mode) & _S_IFREG)
diff --git a/build/vs2008/uudecode.vcproj b/build/vs2008/uudecode.vcproj
index 297b9eb..13a0f3a 100644
--- a/build/vs2008/uudecode.vcproj
+++ b/build/vs2008/uudecode.vcproj
@@ -42,7 +42,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -118,7 +118,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
diff --git a/build/vs2008/uuencode.vcproj b/build/vs2008/uuencode.vcproj
index e23c006..14be48a 100644
--- a/build/vs2008/uuencode.vcproj
+++ b/build/vs2008/uuencode.vcproj
@@ -42,7 +42,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -118,7 +118,7 @@
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
 				AdditionalIncludeDirectories="&quot;..\..\&quot;; &quot;..\..\util&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;G_DISABLE_DEPRECATED;G_LOG_DOMAIN=\&quot;GMime\&quot;"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
diff --git a/configure.ac b/configure.ac
index 6470174..e2dcb73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,7 +158,6 @@ AC_CHECK_HEADERS(sys/param.h)
 AC_CHECK_HEADERS(winsock2.h)
 AC_CHECK_HEADERS(string.h)
 AC_CHECK_HEADERS(stdlib.h)
-AC_CHECK_HEADERS(unistd.h)
 AC_CHECK_HEADERS(netdb.h)
 AC_CHECK_HEADERS(regex.h)
 AC_CHECK_HEADERS(time.h)
@@ -167,6 +166,7 @@ AC_CHECK_HEADERS(poll.h)
 AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_TYPE_SSIZE_T
+AC_TYPE_MODE_T
 
 dnl Check for nfds_t - used by poll()
 AC_MSG_CHECKING(for nfds_t)
diff --git a/gmime/gmime-multipart.c b/gmime/gmime-multipart.c
index a5d26d8..4062d56 100644
--- a/gmime/gmime-multipart.c
+++ b/gmime/gmime-multipart.c
@@ -27,9 +27,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <string.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
 #include <fcntl.h>
 #include <errno.h>
 #include <time.h>
@@ -718,7 +716,7 @@ g_mime_multipart_get_count (GMimeMultipart *multipart)
 static void
 read_random_pool (unsigned char *buffer, size_t bytes)
 {
-#ifdef HAVE_UNISTD_H
+#ifdef __unix__
 	size_t nread = 0;
 	ssize_t n;
 	int fd;
diff --git a/gmime/gmime-stream-fs.c b/gmime/gmime-stream-fs.c
index 5bcdd16..0a6c694 100644
--- a/gmime/gmime-stream-fs.c
+++ b/gmime/gmime-stream-fs.c
@@ -27,14 +27,9 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
 #include <fcntl.h>
 #include <errno.h>
-#ifdef G_OS_WIN32
-#include <io.h>
-#endif
 
 #include "gmime-stream-fs.h"
 
diff --git a/gmime/gmime-stream-pipe.c b/gmime/gmime-stream-pipe.c
index 28c6dd2..adb9792 100644
--- a/gmime/gmime-stream-pipe.c
+++ b/gmime/gmime-stream-pipe.c
@@ -27,14 +27,9 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
 #include <fcntl.h>
 #include <errno.h>
-#ifdef G_OS_WIN32
-#include <io.h>
-#endif
 
 #include "gmime-stream-pipe.h"
 
diff --git a/gmime/gmime-stream.h b/gmime/gmime-stream.h
index 3076af4..82418f5 100644
--- a/gmime/gmime-stream.h
+++ b/gmime/gmime-stream.h
@@ -83,7 +83,7 @@ typedef struct {
 struct _GMimeStream {
 	GObject parent_object;
 	
-	/* Note: these are private fields!! */
+	/* <private> */
 	GMimeStream *super_stream;
 	
 	gint64 position;
@@ -132,7 +132,7 @@ ssize_t   g_mime_stream_printf       (GMimeStream *stream, const char *fmt, ...)
 
 ssize_t   g_mime_stream_write_to_stream (GMimeStream *src, GMimeStream *dest);
 
-ssize_t    g_mime_stream_writev (GMimeStream *stream, GMimeStreamIOVector *vector, size_t count);
+ssize_t   g_mime_stream_writev (GMimeStream *stream, GMimeStreamIOVector *vector, size_t count);
 
 G_END_DECLS
 
diff --git a/gmime/gmime-utils.c b/gmime/gmime-utils.c
index 60f0c75..0df8583 100644
--- a/gmime/gmime-utils.c
+++ b/gmime/gmime-utils.c
@@ -39,14 +39,10 @@
 #include <sys/utsname.h>    /* for uname() */
 #endif
 #include <sys/types.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>         /* Unix header for getpid() */
-#endif
 #ifdef G_OS_WIN32
 #include <winsock2.h>
 #include <ws2tcpip.h>
-#include <process.h>
-#define getpid() _getpid()
 #endif
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
diff --git a/src/uudecode.c b/src/uudecode.c
index 6068fd1..3fd7b4d 100644
--- a/src/uudecode.c
+++ b/src/uudecode.c
@@ -29,15 +29,9 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
 #include <fcntl.h>
 #include <errno.h>
-#ifdef G_OS_WIN32
-#include <io.h>
-typedef int mode_t;
-#endif
 
 #ifdef HAVE_GETOPT_H
 #define _GNU_SOURCE
diff --git a/src/uuencode.c b/src/uuencode.c
index bcfa3f2..672fea3 100644
--- a/src/uuencode.c
+++ b/src/uuencode.c
@@ -59,14 +59,9 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
 #include <fcntl.h>
 #include <errno.h>
-#ifdef G_OS_WIN32
-#include <io.h>
-#endif
 
 #ifdef HAVE_GETOPT_H
 #define _GNU_SOURCE
diff --git a/tests/test-best.c b/tests/test-best.c
index c1eaad5..17bb7bf 100644
--- a/tests/test-best.c
+++ b/tests/test-best.c
@@ -35,7 +35,7 @@ int main (int argc, char **argv)
 	GMimeFilterBest *best;
 	int fd;
 	
-	if ((fd = open (argv[1], O_RDONLY)) == -1)
+	if ((fd = open (argv[1], O_RDONLY, 0)) == -1)
 		return 0;
 	
 	g_mime_init (0);
diff --git a/tests/test-cat.c b/tests/test-cat.c
index 9a00542..2f0baa5 100644
--- a/tests/test-cat.c
+++ b/tests/test-cat.c
@@ -225,7 +225,7 @@ test_cat_write (GMimeStream *whole, struct _StreamPart *parts, int bounded)
 	part = parts;
 	while (part != NULL) {
 		d(fprintf (stderr, "checking substream %s\n", part->filename));
-		if ((fd = open (part->filename, O_RDONLY)) == -1) {
+		if ((fd = open (part->filename, O_RDONLY, 0)) == -1) {
 			ex = exception_new ("could not open `%s': %s", part->filename, g_strerror (errno));
 			throw (ex);
 		}
@@ -271,7 +271,7 @@ test_cat_read (GMimeStream *whole, struct _StreamPart *parts, int bounded)
 		d(fprintf (stderr, "adding %s start=%lld, end=%lld...\n",
 			   part->filename, part->pstart, part->pend));
 		
-		if ((fd = open (part->filename, O_RDONLY)) == -1) {
+		if ((fd = open (part->filename, O_RDONLY, 0)) == -1) {
 			ex = exception_new ("could not open `%s': %s", part->filename, g_strerror (errno));
 			g_object_unref (cat);
 			throw (ex);
@@ -318,7 +318,7 @@ test_cat_seek (GMimeStream *whole, struct _StreamPart *parts, int bounded)
 		d(fprintf (stderr, "adding %s start=%lld, end=%lld...\n",
 			   part->filename, part->pstart, part->pend));
 		
-		if ((fd = open (part->filename, O_RDONLY)) == -1) {
+		if ((fd = open (part->filename, O_RDONLY, 0)) == -1) {
 			ex = exception_new ("could not open `%s': %s", part->filename, g_strerror (errno));
 			g_object_unref (cat);
 			throw (ex);
@@ -379,7 +379,7 @@ test_cat_substream (GMimeStream *whole, struct _StreamPart *parts, int bounded)
 		d(fprintf (stderr, "adding %s start=%lld, end=%lld...\n",
 			   part->filename, part->pstart, part->pend));
 		
-		if ((fd = open (part->filename, O_RDONLY)) == -1) {
+		if ((fd = open (part->filename, O_RDONLY, 0)) == -1) {
 			ex = exception_new ("could not open `%s': %s", part->filename, g_strerror (errno));
 			g_object_unref (cat);
 			throw (ex);
@@ -482,7 +482,7 @@ int main (int argc, char **argv)
 		
 		if (S_ISREG (st.st_mode)) {
 			/* test a particular input file */
-			if ((fd = open (argv[i], O_RDONLY)) == -1)
+			if ((fd = open (argv[i], O_RDONLY, 0)) == -1)
 				return EXIT_FAILURE;
 			
 			filename = g_strdup (argv[i]);
diff --git a/tests/test-mbox.c b/tests/test-mbox.c
index ea36143..6a5d17b 100644
--- a/tests/test-mbox.c
+++ b/tests/test-mbox.c
@@ -300,14 +300,14 @@ int main (int argc, char **argv)
 			
 			testsuite_check ("%s", dent->d_name);
 			try {
-				if ((fd = open (input, O_RDONLY)) == -1) {
+				if ((fd = open (input, O_RDONLY, 0)) == -1) {
 					throw (exception_new ("could not open `%s': %s",
 							      input, g_strerror (errno)));
 				}
 				
 				istream = g_mime_stream_fs_new (fd);
 				
-				if ((fd = open (output, O_RDONLY)) == -1) {
+				if ((fd = open (output, O_RDONLY, 0)) == -1) {
 					throw (exception_new ("could not open `%s': %s",
 							      output, g_strerror (errno)));
 				}
@@ -380,7 +380,7 @@ int main (int argc, char **argv)
 		closedir (dir);
 	} else if (S_ISREG (st.st_mode)) {
 		/* manually run test on a single file */
-		if ((fd = open (path, O_RDONLY)) == -1)
+		if ((fd = open (path, O_RDONLY, 0)) == -1)
 			goto exit;
 		
 		istream = g_mime_stream_fs_new (fd);
diff --git a/tests/test-parser.c b/tests/test-parser.c
index f2562ff..42e31ea 100644
--- a/tests/test-parser.c
+++ b/tests/test-parser.c
@@ -24,9 +24,9 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <unistd.h>
 #include <fcntl.h>
 #include <time.h>
 
@@ -178,7 +178,7 @@ int main (int argc, char **argv)
 	else
 		return 0;
 	
-	if ((fd = open (filename, O_RDONLY)) == -1)
+	if ((fd = open (filename, O_RDONLY, 0)) == -1)
 		return 0;
 	
 #ifdef STREAM_MMAP
diff --git a/tests/test-partial.c b/tests/test-partial.c
index 1fbf10c..c1dbe98 100644
--- a/tests/test-partial.c
+++ b/tests/test-partial.c
@@ -79,7 +79,7 @@ int main (int argc, char **argv)
 	
 	partials = g_ptr_array_new ();
 	for (i = 1; i < argc; i++) {
-		if ((fd = open (argv[i], O_RDONLY)) == -1)
+		if ((fd = open (argv[i], O_RDONLY, 0)) == -1)
 			return -1;
 		
 		stream = g_mime_stream_fs_new (fd);
diff --git a/tests/test-pgp.c b/tests/test-pgp.c
index 74b4269..7a55ffd 100644
--- a/tests/test-pgp.c
+++ b/tests/test-pgp.c
@@ -176,7 +176,7 @@ test_export (GMimeCipherContext *ctx, const char *path)
 	GPtrArray *keys;
 	int fd;
 	
-	if ((fd = open (path, O_RDONLY)) == -1)
+	if ((fd = open (path, O_RDONLY, 0)) == -1)
 		throw (exception_new ("open() failed: %s", g_strerror (errno)));
 	
 	ostream = g_mime_stream_fs_new (fd);
@@ -236,7 +236,7 @@ import_key (GMimeCipherContext *ctx, const char *path)
 	Exception *ex;
 	int fd;
 	
-	if ((fd = open (path, O_RDONLY)) == -1)
+	if ((fd = open (path, O_RDONLY, 0)) == -1)
 		throw (exception_new ("open() failed: %s", g_strerror (errno)));
 	
 	stream = g_mime_stream_fs_new (fd);
diff --git a/tests/test-pgpmime.c b/tests/test-pgpmime.c
index 932fbb8..181f062 100644
--- a/tests/test-pgpmime.c
+++ b/tests/test-pgpmime.c
@@ -377,7 +377,7 @@ import_key (GMimeCipherContext *ctx, const char *path)
 	Exception *ex;
 	int fd;
 	
-	if ((fd = open (path, O_RDONLY)) == -1)
+	if ((fd = open (path, O_RDONLY, 0)) == -1)
 		throw (exception_new ("open() failed: %s", g_strerror (errno)));
 	
 	stream = g_mime_stream_fs_new (fd);
diff --git a/tests/test-streams.c b/tests/test-streams.c
index 8874771..f0e64e1 100644
--- a/tests/test-streams.c
+++ b/tests/test-streams.c
@@ -158,7 +158,7 @@ test_stream_buffer_gets (const char *filename)
 	GMimeStream *stream, *buffered = NULL;
 	int fd;
 	
-	if ((fd = open (filename, O_RDONLY)) == -1) {
+	if ((fd = open (filename, O_RDONLY, 0)) == -1) {
 		v(fprintf (stderr, "failed to open %s", filename));
 		return;
 	}
@@ -203,7 +203,7 @@ test_stream_mem (const char *filename)
 	GMimeStream *stream, *fstream;
 	int fd;
 	
-	if ((fd = open (filename, O_RDONLY)) == -1) {
+	if ((fd = open (filename, O_RDONLY, 0)) == -1) {
 		v(fprintf (stderr, "failed to open %s: %s\n", filename, g_strerror (errno)));
 		return;
 	}
@@ -246,10 +246,10 @@ check_stream_fs (const char *input, const char *output, const char *filename, gi
 	Exception *ex = NULL;
 	int fd[2];
 	
-	if ((fd[0] = open (input, O_RDONLY)) == -1)
+	if ((fd[0] = open (input, O_RDONLY, 0)) == -1)
 		return FALSE;
 	
-	if ((fd[1] = open (output, O_RDONLY)) == -1) {
+	if ((fd[1] = open (output, O_RDONLY, 0)) == -1) {
 		close (fd[0]);
 		return FALSE;
 	}
@@ -312,10 +312,10 @@ check_stream_mmap (const char *input, const char *output, const char *filename,
 	Exception *ex = NULL;
 	int fd[2];
 	
-	if ((fd[0] = open (input, O_RDONLY)) == -1)
+	if ((fd[0] = open (input, O_RDONLY, 0)) == -1)
 		return FALSE;
 	
-	if ((fd[1] = open (output, O_RDONLY)) == -1) {
+	if ((fd[1] = open (output, O_RDONLY, 0)) == -1) {
 		close (fd[0]);
 		return FALSE;
 	}
@@ -345,10 +345,10 @@ check_stream_buffer_block (const char *input, const char *output, const char *fi
 	Exception *ex = NULL;
 	int fd[2];
 	
-	if ((fd[0] = open (input, O_RDONLY)) == -1)
+	if ((fd[0] = open (input, O_RDONLY, 0)) == -1)
 		return FALSE;
 	
-	if ((fd[1] = open (output, O_RDONLY)) == -1) {
+	if ((fd[1] = open (output, O_RDONLY, 0)) == -1) {
 		close (fd[0]);
 		return FALSE;
 	}
@@ -380,10 +380,10 @@ check_stream_buffer_cache (const char *input, const char *output, const char *fi
 	Exception *ex = NULL;
 	int fd[2];
 	
-	if ((fd[0] = open (input, O_RDONLY)) == -1)
+	if ((fd[0] = open (input, O_RDONLY, 0)) == -1)
 		return FALSE;
 	
-	if ((fd[1] = open (output, O_RDONLY)) == -1) {
+	if ((fd[1] = open (output, O_RDONLY, 0)) == -1) {
 		close (fd[0]);
 		return FALSE;
 	}
@@ -419,7 +419,7 @@ check_stream_gio (const char *input, const char *output, const char *filename, g
 	if (!(file = g_file_new_for_path (input)))
 		return FALSE;
 	
-	if ((fd = open (output, O_RDONLY)) == -1) {
+	if ((fd = open (output, O_RDONLY, 0)) == -1) {
 		g_object_unref (file);
 		return FALSE;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]