File libPropList-0.10.1.dif of Package libPropList
--- comparing.c
+++ comparing.c
@@ -4,6 +4,7 @@
*/
+#include <string.h>
#include "proplistP.h"
/* forward prototype */
--- filehandling.c
+++ filehandling.c
@@ -11,7 +11,11 @@
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/types.h>
+#ifdef USE_FLOCK
+#include <sys/file.h>
+#else
#include <fcntl.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -75,8 +79,13 @@
free(actual_filename);
return NULL;
}
-#if 0
- if((flock(fd, LOCK_EX))<0)
+#ifdef USE_FLOCK
+ if((flock(fd, LOCK_EX)<0) && (errno != ENOLCK))
+ {
+ close(fd);
+ free(actual_filename);
+ return NULL;
+ }
#endif
#ifdef headache
flk.l_type = F_RDLCK;
@@ -106,7 +115,7 @@
{
close(fd);
MyFree(__FILE__, __LINE__, str);
-#if 0
+#ifdef USE_FLOCK
flock(fd, LOCK_UN);
#endif
#ifdef headache
@@ -117,6 +126,17 @@
}
str[fstat_buf.st_size] = '\0';
+
+#ifdef USE_FLOCK
+ if((flock(fd, LOCK_UN)<0) && (errno != ENOLCK))
+ {
+ close(fd);
+ MyFree(__FILE__, __LINE__, str);
+ fprintf(stderr, "PLGetPropListWithPath(): Couldn't unlock file!\n");
+ return NULL;
+ }
+#endif
+
#ifdef headache
flk.l_type = F_UNLCK;
#if 0