summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ConfigureChecks.cmake2
-rw-r--r--config.h.cmake33
-rw-r--r--src/libicalss/icaldirset.c16
-rw-r--r--src/libicalss/icalfileset.c10
4 files changed, 39 insertions, 22 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index a032588e..85a4f5cb 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -18,6 +18,8 @@ check_function_exists(access HAVE_ACCESS) #Unix <unistd.h>
check_function_exists(_access HAVE__ACCESS) #Windows <io.h>
check_function_exists(backtrace HAVE_BACKTRACE)
check_function_exists(fork HAVE_FORK)
+check_function_exists(getpid HAVE_GETPID) #Unix <unistd.h>
+check_function_exists(_getpid HAVE__GETPID) #Windows <process.h>
check_function_exists(getpwent HAVE_GETPWENT)
check_function_exists(gmtime_r HAVE_GMTIME_R)
check_function_exists(isspace HAVE_ISSPACE)
diff --git a/config.h.cmake b/config.h.cmake
index aa00e006..2bd97c11 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -84,6 +84,12 @@
/* Define to 1 if you have the `_access' function. */
#cmakedefine HAVE__ACCESS 1
+/* Define to 1 if you have the `getpid' function. */
+#cmakedefine HAVE_GETPID 1
+
+/* Define to 1 if you have the `_getpid' function. */
+#cmakedefine HAVE__GETPID 1
+
/* Define to 1 if you have the `mkdir' function. */
#cmakedefine HAVE_MKDIR 1
@@ -270,7 +276,7 @@ typedef int pid_t;
#endif
#endif
-/* access - function to check user file permissions */
+/* access - system function to check user file permissions */
#if defined(HAVE__ACCESS)
#include <io.h>
#define access _access
@@ -284,6 +290,20 @@ typedef int pid_t;
#endif
#endif
+/* getpid - system function to get process identification */
+#if defined(HAVE__GETPID)
+#include <process.h>
+#define getpid _getpid
+#else
+#if !defined(HAVE_GETPID)
+#error "No get process identification function available"
+#else
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#endif
+#endif
+
/* mkdir - system function to create a directory */
#if defined(HAVE__MKDIR)
#include <direct.h>
@@ -304,11 +324,10 @@ typedef int pid_t;
#else
#if !defined(HAVE_OPEN)
#error "No open file system function available"
-#else
-#if defined(HAVE_FCNTL_H)
-#include <fcntl.h>
#endif
#endif
+#if defined(HAVE_FCNTL_H)
+#include <fcntl.h>
#endif
#if defined(_MSC_VER)
@@ -326,6 +345,12 @@ typedef int pid_t;
#endif
#endif
+#if defined(_MSC_VER)
+#define _S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask))
+#define S_ISDIR(mode) _S_ISTYPE((mode), _S_IFDIR)
+#define S_ISREG(mode) _S_ISTYPE((mode), _S_IFREG)
+#endif
+
/* fork - system function to create a child process */
#if defined(HAVE_FORK)
#if defined(HAVE_UNISTD_H)
diff --git a/src/libicalss/icaldirset.c b/src/libicalss/icaldirset.c
index f8abf84e..f3827328 100644
--- a/src/libicalss/icaldirset.c
+++ b/src/libicalss/icaldirset.c
@@ -54,7 +54,7 @@
#include "icaldirsetimpl.h"
#include "icalfileset.h"
-#include <stdlib.h>
+#include <stdio.h>
#if defined(HAVE_DIRENT_H)
#include <dirent.h>
@@ -69,26 +69,12 @@
#include "icalcluster.h"
#include "icalgauge.h"
-#if !defined(_WIN32)
-#include <unistd.h> /* for stat, getpid */
-#else
-#include <io.h>
-#include <process.h>
-#endif
-
#include <errno.h>
#include <sys/types.h> /* for opendir() */
#include <sys/stat.h> /* for stat */
#include <time.h> /* for clock() */
#include <string.h> /* for strdup */
-#if defined(_MSC_VER)
-#define _S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask))
-#define S_ISDIR(mode) _S_ISTYPE((mode), _S_IFDIR)
-#define S_ISREG(mode) _S_ISTYPE((mode), _S_IFREG)
-#define snprintf _snprintf
-#define strcasecmp stricmp
-#endif
#endif
/** Default options used when NULL is passed to icalset_new() **/
diff --git a/src/libicalss/icalfileset.c b/src/libicalss/icalfileset.c
index 97175f96..575c2ad2 100644
--- a/src/libicalss/icalfileset.c
+++ b/src/libicalss/icalfileset.c
@@ -412,16 +412,20 @@ icalerrorenum icalfileset_commit(icalset *set)
for (c = icalcomponent_get_first_component(fset->cluster, ICAL_ANY_COMPONENT);
c != 0;
c = icalcomponent_get_next_component(fset->cluster, ICAL_ANY_COMPONENT)) {
+#if defined(_MSC_VER)
+ int sz;
+#else
ssize_t sz;
-
+#endif
str = icalcomponent_as_ical_string_r(c);
#if defined(_MSC_VER)
- sz = write(fset->fd, str, (unsigned int)strlen(str));
+ sz = _write(fset->fd, str, (unsigned int)strlen(str));
+ if (sz != (int)strlen(str)) {
#else
sz = write(fset->fd, str, strlen(str));
-#endif
if (sz != (ssize_t)strlen(str)) {
+#endif
perror("write");
icalerror_set_errno(ICAL_FILE_ERROR);
free(str);