summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/win32unix')
-rw-r--r--otherlibs/win32unix/README2
-rw-r--r--otherlibs/win32unix/lockf.c218
-rw-r--r--otherlibs/win32unix/read.c8
-rw-r--r--otherlibs/win32unix/rename.c6
-rw-r--r--otherlibs/win32unix/sockopt.c14
-rw-r--r--otherlibs/win32unix/windir.c2
-rw-r--r--otherlibs/win32unix/write.c38
7 files changed, 144 insertions, 144 deletions
diff --git a/otherlibs/win32unix/README b/otherlibs/win32unix/README
index 6b6eebfdf..237aa627d 100644
--- a/otherlibs/win32unix/README
+++ b/otherlibs/win32unix/README
@@ -91,7 +91,7 @@ diff -c -r d:/msdev/crt/src/osfinfo.c crt/src/osfinfo.c
! return -1;
}
+ #else
-+ /* Windows 95 lossage */
++ /* Windows 95 lossage */
+ if (isdev == FILE_TYPE_UNKNOWN) isdev = FILE_TYPE_PIPE;
+ #endif
diff --git a/otherlibs/win32unix/lockf.c b/otherlibs/win32unix/lockf.c
index c2c9c3507..918305281 100644
--- a/otherlibs/win32unix/lockf.c
+++ b/otherlibs/win32unix/lockf.c
@@ -57,7 +57,7 @@ puts a lock on a region of the file opened as fd. The region starts at the curre
#endif
static void set_file_pointer(HANDLE h, LARGE_INTEGER dest,
- PLARGE_INTEGER cur, DWORD method)
+ PLARGE_INTEGER cur, DWORD method)
{
LONG high = dest.HighPart;
DWORD ret = SetFilePointer(h, dest.LowPart, &high, method);
@@ -70,95 +70,95 @@ static void set_file_pointer(HANDLE h, LARGE_INTEGER dest,
CAMLprim value unix_lockf(value fd, value cmd, value span)
{
- int ret;
- OVERLAPPED overlap;
- DWORD l_start;
- DWORD l_len;
- HANDLE h;
- OSVERSIONINFO VersionInfo;
- LARGE_INTEGER cur_position;
- LARGE_INTEGER end_position;
- LARGE_INTEGER offset_position;
-
- VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- if(GetVersionEx(&VersionInfo) == 0)
- {
- invalid_argument("lockf only supported on WIN32_NT platforms: could not determine current platform.");
- }
+ int ret;
+ OVERLAPPED overlap;
+ DWORD l_start;
+ DWORD l_len;
+ HANDLE h;
+ OSVERSIONINFO VersionInfo;
+ LARGE_INTEGER cur_position;
+ LARGE_INTEGER end_position;
+ LARGE_INTEGER offset_position;
+
+ VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ if(GetVersionEx(&VersionInfo) == 0)
+ {
+ invalid_argument("lockf only supported on WIN32_NT platforms: could not determine current platform.");
+ }
/* file locking only exists on NT versions */
- if(VersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT)
- {
- invalid_argument("lockf only supported on WIN32_NT platforms");
- }
-
- h = Handle_val(fd);
-
- overlap.Offset = 0;
- overlap.OffsetHigh = 0;
- overlap.hEvent = 0;
- l_len = Long_val(span);
-
- offset_position.HighPart = 0;
- cur_position.HighPart = 0;
- end_position.HighPart = 0;
- offset_position.LowPart = 0;
- cur_position.LowPart = 0;
- end_position.LowPart = 0;
-
- if(l_len == 0)
- {
+ if(VersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT)
+ {
+ invalid_argument("lockf only supported on WIN32_NT platforms");
+ }
+
+ h = Handle_val(fd);
+
+ overlap.Offset = 0;
+ overlap.OffsetHigh = 0;
+ overlap.hEvent = 0;
+ l_len = Long_val(span);
+
+ offset_position.HighPart = 0;
+ cur_position.HighPart = 0;
+ end_position.HighPart = 0;
+ offset_position.LowPart = 0;
+ cur_position.LowPart = 0;
+ end_position.LowPart = 0;
+
+ if(l_len == 0)
+ {
/* save current pointer */
- set_file_pointer(h,offset_position,&cur_position,FILE_CURRENT);
+ set_file_pointer(h,offset_position,&cur_position,FILE_CURRENT);
/* set to end and query */
- set_file_pointer(h,offset_position,&end_position,FILE_END);
- l_len = end_position.LowPart;
+ set_file_pointer(h,offset_position,&end_position,FILE_END);
+ l_len = end_position.LowPart;
/* restore previous current pointer */
- set_file_pointer(h,cur_position,NULL,FILE_BEGIN);
- }
- else
- {
- if (l_len < 0)
- {
- set_file_pointer(h,offset_position,&cur_position,FILE_CURRENT);
- l_len = abs(l_len);
- if(l_len > cur_position.LowPart)
- {
- errno = EINVAL;
- uerror("lockf", Nothing);
- return Val_unit;
- }
- overlap.Offset = cur_position.LowPart - l_len;
- }
- }
+ set_file_pointer(h,cur_position,NULL,FILE_BEGIN);
+ }
+ else
+ {
+ if (l_len < 0)
+ {
+ set_file_pointer(h,offset_position,&cur_position,FILE_CURRENT);
+ l_len = abs(l_len);
+ if(l_len > cur_position.LowPart)
+ {
+ errno = EINVAL;
+ uerror("lockf", Nothing);
+ return Val_unit;
+ }
+ overlap.Offset = cur_position.LowPart - l_len;
+ }
+ }
switch (Int_val(cmd))
- {
- case 0: /* F_ULOCK */
- if(UnlockFileEx(h, 0, l_len,0,&overlap) == 0)
- {
- errno = EACCES;
- ret = -1;
- }
- break;
- case 1: /* F_LOCK */
+ {
+ case 0: /* F_ULOCK */
+ if(UnlockFileEx(h, 0, l_len,0,&overlap) == 0)
+ {
+ errno = EACCES;
+ ret = -1;
+ }
+ break;
+ case 1: /* F_LOCK */
/* this should block until write lock is obtained */
- if(LockFileEx(h,LOCKFILE_EXCLUSIVE_LOCK,0,l_len,0,&overlap) == 0)
- {
- errno = EACCES;
- ret = -1;
- }
- break;
- case 2: /* F_TLOCK */
+ if(LockFileEx(h,LOCKFILE_EXCLUSIVE_LOCK,0,l_len,0,&overlap) == 0)
+ {
+ errno = EACCES;
+ ret = -1;
+ }
+ break;
+ case 2: /* F_TLOCK */
/*
* this should return immediately if write lock can-not
* be obtained.
*/
- if(LockFileEx(h,LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,0,l_len,0,&overlap) == 0)
- {
- errno = EACCES;
- ret = -1;
- }
- break;
- case 3: /* F_TEST */
+ if(LockFileEx(h,LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,0,l_len,0,&overlap) == 0)
+ {
+ errno = EACCES;
+ ret = -1;
+ }
+ break;
+ case 3: /* F_TEST */
/*
* I'm doing this by aquiring an immediate write
* lock and then releasing it. It is not clear that
@@ -166,40 +166,40 @@ CAMLprim value unix_lockf(value fd, value cmd, value span)
* it is not clear the nature of the lock test performed
* by ocaml (unix) currently.
*/
- if(LockFileEx(h,LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,0,l_len,0,&overlap) == 0)
- {
- errno = EACCES;
- ret = -1;
- }
- else
- {
- UnlockFileEx(h, 0, l_len,0,&overlap);
- ret = 0;
- }
- break;
- case 4: /* F_RLOCK */
+ if(LockFileEx(h,LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,0,l_len,0,&overlap) == 0)
+ {
+ errno = EACCES;
+ ret = -1;
+ }
+ else
+ {
+ UnlockFileEx(h, 0, l_len,0,&overlap);
+ ret = 0;
+ }
+ break;
+ case 4: /* F_RLOCK */
/* this should block until read lock is obtained */
- if(LockFileEx(h,0,0,l_len,0,&overlap) == 0)
- {
- errno = EACCES;
- ret = -1;
- }
- break;
- case 5: /* F_TRLOCK */
+ if(LockFileEx(h,0,0,l_len,0,&overlap) == 0)
+ {
+ errno = EACCES;
+ ret = -1;
+ }
+ break;
+ case 5: /* F_TRLOCK */
/*
* this should return immediately if read lock can-not
* be obtained.
*/
- if(LockFileEx(h,LOCKFILE_FAIL_IMMEDIATELY,0,l_len,0,&overlap) == 0)
- {
- errno = EACCES;
- ret = -1;
- }
- break;
- default:
- errno = EINVAL;
- ret = -1;
- }
+ if(LockFileEx(h,LOCKFILE_FAIL_IMMEDIATELY,0,l_len,0,&overlap) == 0)
+ {
+ errno = EACCES;
+ ret = -1;
+ }
+ break;
+ default:
+ errno = EINVAL;
+ ret = -1;
+ }
if (ret == -1) uerror("lockf", Nothing);
return Val_unit;
}
diff --git a/otherlibs/win32unix/read.c b/otherlibs/win32unix/read.c
index 2c727173e..704cec2c7 100644
--- a/otherlibs/win32unix/read.c
+++ b/otherlibs/win32unix/read.c
@@ -34,8 +34,8 @@ CAMLprim value unix_read(value fd, value buf, value ofs, value len)
ret = recv(s, iobuf, numbytes, 0);
leave_blocking_section();
if (ret == SOCKET_ERROR) {
- win32_maperr(WSAGetLastError());
- uerror("read", Nothing);
+ win32_maperr(WSAGetLastError());
+ uerror("read", Nothing);
}
numread = ret;
} else {
@@ -45,8 +45,8 @@ CAMLprim value unix_read(value fd, value buf, value ofs, value len)
ret = ReadFile(h, iobuf, numbytes, &numread, NULL);
leave_blocking_section();
if (! ret) {
- win32_maperr(GetLastError());
- uerror("read", Nothing);
+ win32_maperr(GetLastError());
+ uerror("read", Nothing);
}
}
memmove (&Byte(buf, Long_val(ofs)), iobuf, numread);
diff --git a/otherlibs/win32unix/rename.c b/otherlibs/win32unix/rename.c
index 51139485b..d84bcd66a 100644
--- a/otherlibs/win32unix/rename.c
+++ b/otherlibs/win32unix/rename.c
@@ -20,10 +20,10 @@
CAMLprim value unix_rename(value path1, value path2)
{
if (MoveFileEx(String_val(path1), String_val(path2),
- MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH |
- MOVEFILE_COPY_ALLOWED) == 0) {
+ MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH |
+ MOVEFILE_COPY_ALLOWED) == 0) {
win32_maperr(GetLastError());
uerror("rename", path1);
- }
+ }
return Val_unit;
}
diff --git a/otherlibs/win32unix/sockopt.c b/otherlibs/win32unix/sockopt.c
index a9572de79..13d6a03e3 100644
--- a/otherlibs/win32unix/sockopt.c
+++ b/otherlibs/win32unix/sockopt.c
@@ -37,7 +37,7 @@ CAMLprim value getsockopt_int(int *sockopt, value socket,
optsize = sizeof(optval);
if (getsockopt(Socket_val(socket),
level, sockopt[Int_val(option)],
- (void *) &optval, &optsize) == -1)
+ (void *) &optval, &optsize) == -1)
uerror("getsockopt", Nothing);
return Val_int(optval);
}
@@ -48,7 +48,7 @@ CAMLprim value setsockopt_int(int *sockopt, value socket, int level,
int optval = Int_val(status);
if (setsockopt(Socket_val(socket),
level, sockopt[Int_val(option)],
- (void *) &optval, sizeof(optval)) == -1)
+ (void *) &optval, sizeof(optval)) == -1)
uerror("setsockopt", Nothing);
return Val_unit;
}
@@ -76,12 +76,12 @@ CAMLprim value getsockopt_optint(int *sockopt, value socket,
{
struct linger optval;
int optsize;
- value res = Val_int(0); /* None */
+ value res = Val_int(0); /* None */
optsize = sizeof(optval);
if (getsockopt(Socket_val(socket),
level, sockopt[Int_val(option)],
- (void *) &optval, &optsize) == -1)
+ (void *) &optval, &optsize) == -1)
uerror("getsockopt_optint", Nothing);
if (optval.l_onoff != 0) {
res = alloc_small(1, 0);
@@ -100,7 +100,7 @@ CAMLprim value setsockopt_optint(int *sockopt, value socket, int level,
optval.l_linger = Int_val (Field (status, 0));
if (setsockopt(Socket_val(socket),
level, sockopt[Int_val(option)],
- (void *) &optval, sizeof(optval)) == -1)
+ (void *) &optval, sizeof(optval)) == -1)
uerror("setsockopt_optint", Nothing);
return Val_unit;
}
@@ -124,7 +124,7 @@ CAMLprim value getsockopt_float(int *sockopt, value socket,
optsize = sizeof(tv);
if (getsockopt(Socket_val(socket),
level, sockopt[Int_val(option)],
- (void *) &tv, &optsize) == -1)
+ (void *) &tv, &optsize) == -1)
uerror("getsockopt_float", Nothing);
return copy_double((double) tv.tv_sec + (double) tv.tv_usec / 1e6);
}
@@ -140,7 +140,7 @@ CAMLprim value setsockopt_float(int *sockopt, value socket, int level,
tv.tv_usec = (int) (1e6 * (tv_f - tv.tv_sec));
if (setsockopt(Socket_val(socket),
level, sockopt[Int_val(option)],
- (void *) &tv, sizeof(tv)) == -1)
+ (void *) &tv, sizeof(tv)) == -1)
uerror("setsockopt_float", Nothing);
return Val_unit;
}
diff --git a/otherlibs/win32unix/windir.c b/otherlibs/win32unix/windir.c
index 13a7edec3..0a681e76c 100644
--- a/otherlibs/win32unix/windir.c
+++ b/otherlibs/win32unix/windir.c
@@ -36,7 +36,7 @@ CAMLprim value win_findfirst(name)
if (err == ERROR_NO_MORE_FILES)
raise_end_of_file();
else {
- win32_maperr(err);
+ win32_maperr(err);
uerror("opendir", Nothing);
}
}
diff --git a/otherlibs/win32unix/write.c b/otherlibs/win32unix/write.c
index 5c0e54e3d..8571ff679 100644
--- a/otherlibs/win32unix/write.c
+++ b/otherlibs/win32unix/write.c
@@ -34,26 +34,26 @@ CAMLprim value unix_write(value fd, value buf, value vofs, value vlen)
numbytes = len > UNIX_BUFFER_SIZE ? UNIX_BUFFER_SIZE : len;
memmove (iobuf, &Byte(buf, ofs), numbytes);
if (Descr_kind_val(fd) == KIND_SOCKET) {
- int ret;
- SOCKET s = Socket_val(fd);
- enter_blocking_section();
- ret = send(s, iobuf, numbytes, 0);
- leave_blocking_section();
- if (ret == SOCKET_ERROR) {
- win32_maperr(WSAGetLastError());
- uerror("write", Nothing);
- }
- numwritten = ret;
+ int ret;
+ SOCKET s = Socket_val(fd);
+ enter_blocking_section();
+ ret = send(s, iobuf, numbytes, 0);
+ leave_blocking_section();
+ if (ret == SOCKET_ERROR) {
+ win32_maperr(WSAGetLastError());
+ uerror("write", Nothing);
+ }
+ numwritten = ret;
} else {
- BOOL ret;
- HANDLE h = Handle_val(fd);
- enter_blocking_section();
- ret = WriteFile(h, iobuf, numbytes, &numwritten, NULL);
- leave_blocking_section();
- if (! ret) {
- win32_maperr(GetLastError());
- uerror("write", Nothing);
- }
+ BOOL ret;
+ HANDLE h = Handle_val(fd);
+ enter_blocking_section();
+ ret = WriteFile(h, iobuf, numbytes, &numwritten, NULL);
+ leave_blocking_section();
+ if (! ret) {
+ win32_maperr(GetLastError());
+ uerror("write", Nothing);
+ }
}
written += numwritten;
ofs += numwritten;