[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r21997 - gnunet/src/util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r21997 - gnunet/src/util |
Date: |
Thu, 14 Jun 2012 14:02:43 +0200 |
Author: grothoff
Date: 2012-06-14 14:02:43 +0200 (Thu, 14 Jun 2012)
New Revision: 21997
Modified:
gnunet/src/util/disk.c
Log:
-LRN: implement get_handle_from_native for W32
Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c 2012-06-14 11:45:00 UTC (rev 21996)
+++ gnunet/src/util/disk.c 2012-06-14 12:02:43 UTC (rev 21997)
@@ -1783,21 +1783,45 @@
struct GNUNET_DISK_FileHandle *
GNUNET_DISK_get_handle_from_native (FILE *fd)
{
-#if MINGW
- // FIXME: LRN help!
- GNUNET_break (0);
- return NULL;
-#else
struct GNUNET_DISK_FileHandle *fh;
int fno;
+#if MINGW
+ intptr_t osfh;
+#endif
fno = fileno (fd);
if (-1 == fno)
return NULL;
+
+#if MINGW
+ osfh = _get_osfhandle (fno);
+ if (osfh == INVALID_HANDLE_VALUE)
+ return NULL;
+#endif
+
fh = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle));
+
+#if MINGW
+ fh->h = osfh;
+ /* Assume it to be a pipe. TODO: use some kind of detection
+ * function to figure out handle type.
+ * Note that we can't make it overlapped if it isn't already.
+ * (ReOpenFile() is only available in 2003/Vista).
+ * The process that opened this file in the first place (usually a parent
+ * process, if this is stdin/stdout/stderr) must make it overlapped,
+ * otherwise we're screwed, as selecting on non-overlapped handle
+ * will block.
+ */
+ fh->type = GNUNET_PIPE;
+ fh->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
+ fh->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
+ fh->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+ fh->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+#else
fh->fd = fno;
+#endif
+
return fh;
-#endif
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r21997 - gnunet/src/util,
gnunet <=