gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r230 - in GNUnet: . src/applications/advertising src/applic


From: durner
Subject: [GNUnet-SVN] r230 - in GNUnet: . src/applications/advertising src/applications/chat src/applications/datastore src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/lib src/applications/fs/module src/applications/sqstore_mysql src/applications/sqstore_sqlite src/conf src/include src/server src/util src/util/win
Date: Thu, 10 Feb 2005 13:08:45 -0800 (PST)

Author: durner
Date: 2005-02-10 13:08:45 -0800 (Thu, 10 Feb 2005)
New Revision: 230

Modified:
   GNUnet/src/applications/advertising/bootstrap.c
   GNUnet/src/applications/chat/Makefile.am
   GNUnet/src/applications/datastore/Makefile.am
   GNUnet/src/applications/fs/ecrs/meta.c
   GNUnet/src/applications/fs/ecrs/unindex.c
   GNUnet/src/applications/fs/ecrs/upload.c
   GNUnet/src/applications/fs/fsui/download.c
   GNUnet/src/applications/fs/lib/Makefile.am
   GNUnet/src/applications/fs/module/ondemand.c
   GNUnet/src/applications/sqstore_mysql/mysqltest.c
   GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
   GNUnet/src/conf/gnunet-win-tool.c
   GNUnet/src/include/platform.h
   GNUnet/src/include/winproc.h
   GNUnet/src/server/Makefile.am
   GNUnet/src/util/logging.c
   GNUnet/src/util/storage.c
   GNUnet/src/util/win/winproc.c
   GNUnet/todo
Log:
Trying to fix MinGW

Modified: GNUnet/src/applications/advertising/bootstrap.c
===================================================================
--- GNUnet/src/applications/advertising/bootstrap.c     2005-02-10 00:42:30 UTC 
(rev 229)
+++ GNUnet/src/applications/advertising/bootstrap.c     2005-02-10 21:08:45 UTC 
(rev 230)
@@ -169,12 +169,13 @@
 
 /**
  * Stop advertising.
+ * @todo [WIN] Check if this works under Windows
  */
 void stopBootstrap() {
   void * unused;
 
   abort_bootstrap = YES;
-#if SOMEBSD || OSX || SOLARIS
+#if SOMEBSD || OSX || SOLARIS || MINGW
   PTHREAD_KILL(&pt, SIGALRM);
 #else
   /* linux */

Modified: GNUnet/src/applications/chat/Makefile.am
===================================================================
--- GNUnet/src/applications/chat/Makefile.am    2005-02-10 00:42:30 UTC (rev 
229)
+++ GNUnet/src/applications/chat/Makefile.am    2005-02-10 21:08:45 UTC (rev 
230)
@@ -21,3 +21,5 @@
   chat.h
 libgnunetmodule_chat_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
+libgnunetmodule_chat_la_LIBADD = \
+  $(LDADD)

Modified: GNUnet/src/applications/datastore/Makefile.am
===================================================================
--- GNUnet/src/applications/datastore/Makefile.am       2005-02-10 00:42:30 UTC 
(rev 229)
+++ GNUnet/src/applications/datastore/Makefile.am       2005-02-10 21:08:45 UTC 
(rev 230)
@@ -15,4 +15,6 @@
   datastore.c 
 libgnunetmodule_datastore_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
+libgnunetmodule_datastore_la_LIBADD = \
+  $(LDADD)
 

Modified: GNUnet/src/applications/fs/ecrs/meta.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/meta.c      2005-02-10 00:42:30 UTC (rev 
229)
+++ GNUnet/src/applications/fs/ecrs/meta.c      2005-02-10 21:08:45 UTC (rev 
230)
@@ -444,11 +444,11 @@
 
   if ( (sizeof(unsigned int) * ic + ic) > dataSize) {
     BREAK();
-    goto ERROR;
+    goto FAILURE;
   }
   if (data[dataSize-1] != '\0') {
     BREAK();
-    goto ERROR;
+    goto FAILURE;
   }
 
   *md = ECRS_createMetaData();
@@ -465,12 +465,12 @@
   }
   if (i < ic) { /* oops */
     ECRS_freeMetaData(*md);
-    goto ERROR;
+    goto FAILURE;
   }
   if (compressed)
     FREE(data);
   return OK;
- ERROR:
+ FAILURE:
   if (compressed) 
     FREE(data);
   return SYSERR; /* size too small */  

Modified: GNUnet/src/applications/fs/ecrs/unindex.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/unindex.c   2005-02-10 00:42:30 UTC (rev 
229)
+++ GNUnet/src/applications/fs/ecrs/unindex.c   2005-02-10 21:08:45 UTC (rev 
230)
@@ -313,7 +313,7 @@
       upcb(filesize, pos, eta, upcbClosure);
     if (tt != NULL)
       if (OK != tt(ttClosure))
-       goto ERROR;
+       goto FAILURE;
     size = DBLOCK_SIZE;
     if (size > filesize - pos) {
       size = filesize - pos;
@@ -327,12 +327,12 @@
       LOG_FILE_STRERROR(LOG_WARNING,
                        "READ", 
                        filename);
-      goto ERROR;
+      goto FAILURE;
     }   
     size = DBLOCK_SIZE + sizeof(DBlock); /* padding! */
     if (tt != NULL)
       if (OK != tt(ttClosure))
-       goto ERROR;
+       goto FAILURE;
     fileBlockGetKey((char*) &dblock[1],
                    size,
                    &chk.key);
@@ -343,7 +343,7 @@
                        &chk,
                        0, /* dblocks are on level 0 */
                        iblocks))
-      goto ERROR;
+      goto FAILURE;
     if (! wasIndexed) {
       fileBlockEncode(db,
                      size,
@@ -353,7 +353,7 @@
       if (OK != FS_delete(sock,
                          value)) {
        FREE(value);
-       goto ERROR;
+       goto FAILURE;
       }
       FREE(value);
     }
@@ -365,7 +365,7 @@
   }
   if (tt != NULL)
     if (OK != tt(ttClosure))
-      goto ERROR;  
+      goto FAILURE;  
   for (i=0;i<treedepth;i++) {
     size = ntohl(iblocks[i]->size) - sizeof(Datastore_Value);
     db = (DBlock*) &iblocks[i];
@@ -379,7 +379,7 @@
                        &chk,
                        i+1, 
                        iblocks))
-      goto ERROR;
+      goto FAILURE;
     fileBlockEncode(db,
                    size,
                    &chk.query,
@@ -387,7 +387,7 @@
     if (OK != FS_delete(sock,
                        value)) {
       FREE(value);
-      goto ERROR;
+      goto FAILURE;
     }
     FREE(value);
     FREE(iblocks[i]);
@@ -401,9 +401,9 @@
       if (OK != FS_unindex(sock,
                           DBLOCK_SIZE,
                           &fileId))
-       goto ERROR;
+       goto FAILURE;
     } else
-      goto ERROR;
+      goto FAILURE;
   }
 
   /* free resources */
@@ -412,7 +412,7 @@
   CLOSE(fd);
   releaseClientSocket(sock);
   return OK;
- ERROR:
+ FAILURE:
   for (i=0;i<treedepth;i++)
     FREENONNULL(iblocks[i]);
   FREE(iblocks);

Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c    2005-02-10 00:42:30 UTC (rev 
229)
+++ GNUnet/src/applications/fs/ecrs/upload.c    2005-02-10 21:08:45 UTC (rev 
230)
@@ -279,7 +279,7 @@
       upcb(filesize, pos, eta, upcbClosure);
     if (tt != NULL)
       if (OK != tt(ttClosure))
-       goto ERROR;
+       goto FAILURE;
     size = DBLOCK_SIZE;
     if (size > filesize - pos) {
       size = filesize - pos;
@@ -292,12 +292,12 @@
                     &db[1], 
                     size)) {
       LOG_FILE_STRERROR(LOG_WARNING, "READ", filename);
-      goto ERROR;
+      goto FAILURE;
     }   
     size = DBLOCK_SIZE; /* padding! */
     if (tt != NULL)
       if (OK != tt(ttClosure))
-       goto ERROR;
+       goto FAILURE;
     fileBlockGetKey((char*) &dblock[1],
                    size,
                    &chk.key);
@@ -308,13 +308,13 @@
                        &chk,
                        0, /* dblocks are on level 0 */
                        iblocks))
-      goto ERROR;
+      goto FAILURE;
     if (doIndex) {
       if (SYSERR == FS_index(sock,
                             &fileId,
                             dblock,
                             pos))
-       goto ERROR;
+       goto FAILURE;
     } else {
       fileBlockEncode(db,
                      size,
@@ -324,7 +324,7 @@
       if (SYSERR == FS_insert(sock,
                              value)) {
        FREE(value);
-       goto ERROR;
+       goto FAILURE;
       }
       FREE(value);
     }
@@ -338,7 +338,7 @@
   }
   if (tt != NULL)
     if (OK != tt(ttClosure))
-      goto ERROR;  
+      goto FAILURE;  
   for (i=0;i<treedepth;i++) {
     size = ntohl(iblocks[i]->size) - sizeof(Datastore_Value);
     if (size == sizeof(DBlock))
@@ -354,7 +354,7 @@
                        &chk,
                        i+1, 
                        iblocks))
-      goto ERROR;
+      goto FAILURE;
     fileBlockEncode(db,
                    size,
                    &chk.query,
@@ -362,7 +362,7 @@
     if (OK != FS_insert(sock,
                        value)) {
       FREE(value);
-      goto ERROR;
+      goto FAILURE;
     }
     FREE(value);
     FREE(iblocks[i]);
@@ -386,7 +386,7 @@
   CLOSE(fd);
   releaseClientSocket(sock);
   return OK;
- ERROR:
+ FAILURE:
   for (i=0;i<treedepth;i++)
     FREENONNULL(iblocks[i]);
   FREE(iblocks);

Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c  2005-02-10 00:42:30 UTC (rev 
229)
+++ GNUnet/src/applications/fs/fsui/download.c  2005-02-10 21:08:45 UTC (rev 
230)
@@ -33,9 +33,6 @@
 #include "gnunet_fsui_lib.h"
 #include "fsui.h"
 
-/* for mmap */
-#include <sys/mman.h>
-
 /**
  * Start to download a file.
  *
@@ -218,7 +215,7 @@
                        "OPEN",
                        dl->filename);
     } else {
-      dirBlock = mmap(NULL, 
+      dirBlock = MMAP(NULL, 
                      totalBytes, 
                      PROT_READ,
                      MAP_SHARED,
@@ -234,7 +231,7 @@
                         dl);
       MUTEX_UNLOCK(&dl->ctx->lock);
       ECRS_freeMetaData(md);
-      munmap(dirBlock, totalBytes);
+      MUNMAP(dirBlock, totalBytes);
       CLOSE(fd);
     }
 

Modified: GNUnet/src/applications/fs/lib/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/lib/Makefile.am  2005-02-10 00:42:30 UTC (rev 
229)
+++ GNUnet/src/applications/fs/lib/Makefile.am  2005-02-10 21:08:45 UTC (rev 
230)
@@ -6,4 +6,5 @@
 libgnunetfs_la_SOURCES = \
   fslib.c 
 libgnunetfs_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la 
\ No newline at end of file
+ $(top_builddir)/src/util/libgnunetutil.la \
+ ../libecrs_core.la

Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c        2005-02-10 00:42:30 UTC 
(rev 229)
+++ GNUnet/src/applications/fs/module/ondemand.c        2005-02-10 21:08:45 UTC 
(rev 230)
@@ -202,7 +202,7 @@
 
   if (ntohl(dbv->size) != sizeof(OnDemandBlock)) {
     BREAK();
-    goto ERROR;
+    goto FAILURE;
   }
   odb = (OnDemandBlock*) dbv;
   fn = getOnDemandFile(&odb->fileId);
@@ -211,7 +211,7 @@
   if (fileHandle == -1) {
     LOG_FILE_STRERROR(LOG_ERROR, "open", fn);
     FREE(fn);
-    goto ERROR;
+    goto FAILURE;
   }
 
 #if TRACK_INDEXED_FILES
@@ -247,7 +247,7 @@
     LOG_FILE_STRERROR(LOG_WARNING, "lseek", fn);
     FREE(fn);
     CLOSE(fileHandle);
-    goto ERROR;
+    goto FAILURE;
   }
   db = MALLOC(sizeof(DBlock) + ntohl(odb->blockSize));
   db->type = htonl(D_BLOCK);
@@ -260,7 +260,7 @@
     FREE(fn);
     FREE(db);
     CLOSE(fileHandle);
-    goto ERROR;
+    goto FAILURE;
   }
   ret = fileBlockEncode(db,
                        ntohl(odb->blockSize) + sizeof(DBlock),
@@ -269,9 +269,9 @@
   FREE(db);
   FREE(fn);
   if (ret == SYSERR)
-    goto ERROR;
+    goto FAILURE;
   return OK;   
- ERROR:
+ FAILURE:
   datastore->del(query,
                 dbv);
   return SYSERR;

Modified: GNUnet/src/applications/sqstore_mysql/mysqltest.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest.c   2005-02-10 00:42:30 UTC 
(rev 229)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest.c   2005-02-10 21:08:45 UTC 
(rev 230)
@@ -10,7 +10,7 @@
 #include "gnunet_sqstore_service.h"
 #include "core.h"
 
-#define ASSERT(x) do { if (! (x)) goto ERROR; } while (0)
+#define ASSERT(x) do { if (! (x)) goto FAILURE; } while (0)
 
 static cron_t now;
 
@@ -112,7 +112,7 @@
   
   api->drop();
   return OK;
- ERROR:
+ FAILURE:
   api->drop();
   return SYSERR;
 }

Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2005-02-10 00:42:30 UTC 
(rev 229)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2005-02-10 21:08:45 UTC 
(rev 230)
@@ -10,7 +10,7 @@
 #include "gnunet_sqstore_service.h"
 #include "core.h"
 
-#define ASSERT(x) do { if (! (x)) goto ERROR; } while (0)
+#define ASSERT(x) do { if (! (x)) goto FAILURE; } while (0)
 
 static cron_t now;
 
@@ -112,7 +112,7 @@
   
   api->drop();
   return OK;
- ERROR:
+ FAILURE:
   api->drop();
   return SYSERR;
 }

Modified: GNUnet/src/conf/gnunet-win-tool.c
===================================================================
--- GNUnet/src/conf/gnunet-win-tool.c   2005-02-10 00:42:30 UTC (rev 229)
+++ GNUnet/src/conf/gnunet-win-tool.c   2005-02-10 21:08:45 UTC (rev 230)
@@ -298,15 +298,15 @@
 void doHash()
 {
   HashCode160 code;
-  HexName hex;
+  EncName hex;
   char *c;
 
   getFileHash(hashFile, &code);
-  hash2hex(&code, &hex);
+  hash2enc(&code, &hex);
   printf("RIPEMD160(%s)= ", hashFile);
   
   /* Flip byte order */
-  c = (char *) &hex;
+  c = (char *) hex.encoding;
   while(*c)
   {
     putchar(*(c + 1));

Modified: GNUnet/src/include/platform.h
===================================================================
--- GNUnet/src/include/platform.h       2005-02-10 00:42:30 UTC (rev 229)
+++ GNUnet/src/include/platform.h       2005-02-10 21:08:45 UTC (rev 230)
@@ -151,7 +151,14 @@
  #define SIOCGIFADDR     _IOW('s', 102, struct ifreq) /* Get if addr */
 #endif
 
+#ifndef MINGW
+#include <sys/mman.h>
+#endif
 
+#ifndef SIGALRM
+ #define SIGALRM 14
+#endif
+
 /**
  * Open a file
  */
@@ -180,6 +187,8 @@
  #define GN_FREAD(b, s, c, f) fread(b, s, c, f)
  #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f)
  #define SYMLINK(a, b) symlink(a, b)
+ #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o)
+ #define MUNMAP(s, l) munmap(s, l);
  #define STRERROR(i) strerror(i)
  #define ACCEPT(s, a, l) accept(s, a, l)
  #define BIND(s, n, l) bind(s, n, l)
@@ -220,6 +229,8 @@
  #define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
  #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
  #define SYMLINK(a, b) _win_symlink(a, b)
+ #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
+ #define MUNMAP(s, l) _win_munmap(s, l);
  #define STRERROR(i) _win_strerror(i)
  #define ACCEPT(s, a, l) _win_accept(s, a, l)
  #define BIND(s, n, l) _win_bind(s, n, l)

Modified: GNUnet/src/include/winproc.h
===================================================================
--- GNUnet/src/include/winproc.h        2005-02-10 00:42:30 UTC (rev 229)
+++ GNUnet/src/include/winproc.h        2005-02-10 21:08:45 UTC (rev 230)
@@ -199,7 +199,12 @@
 #define NO_RECOVERY 3
 #undef NO_ADDRESS
 #define NO_ADDRESS 4
- 
+
+#define PROT_READ   0x1
+#define PROT_WRITE  0x2
+#define MAP_SHARED  0x1
+#define MAP_FIXED   0x10
+
 struct statfs
 {
   long f_type;                  /* type of filesystem (see below) */
@@ -403,6 +408,9 @@
 size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE 
*stream);
 size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream );
 int _win_symlink(const char *path1, const char *path2);
+void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
+                unsigned long long offset);
+int _win_munmap(void *start, size_t length);
 int _win_accept(SOCKET s, struct sockaddr *addr, int *addrlen);
 int _win_bind(SOCKET s, const struct sockaddr *name, int namelen);
 int _win_connect(SOCKET s,const struct sockaddr *name, int namelen);

Modified: GNUnet/src/server/Makefile.am
===================================================================
--- GNUnet/src/server/Makefile.am       2005-02-10 00:42:30 UTC (rev 229)
+++ GNUnet/src/server/Makefile.am       2005-02-10 21:08:45 UTC (rev 230)
@@ -16,6 +16,8 @@
  handler.c handler.h \
  tcpserver.c tcpserver.h \
  version.c version.h
+libgnunetcore_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 gnunetd_SOURCES = \
  gnunetd.c \

Modified: GNUnet/src/util/logging.c
===================================================================
--- GNUnet/src/util/logging.c   2005-02-10 00:42:30 UTC (rev 229)
+++ GNUnet/src/util/logging.c   2005-02-10 21:08:45 UTC (rev 230)
@@ -29,7 +29,10 @@
 
 #include "platform.h"
 #include "gnunet_util.h"
+#ifndef MINGW
 #include <langinfo.h>
+#endif
+#include <time.h>
 
 /**
  * Where to write log information to.
@@ -112,8 +115,8 @@
  * Remove file if it is an old log
  */
 static void removeOldLog(const char * fil,
-                        const char * dir,
-                        struct logfiledef * def) {
+       const char * dir,
+       struct logfiledef * def) {
   struct tm t;
   char * fullname;
   const char * logdate;
@@ -125,15 +128,19 @@
     strcat(fullname, DIR_SEPARATOR_STR);
   strcat(fullname, fil);
   if (0 != strncmp(def->basename,
-                  fullname,
-                  strlen(def->basename))) {
+       fullname,
+       strlen(def->basename))) {
     FREE(fullname);
     return;
   }
   logdate = &fullname[strlen(def->basename)];
   ret = strptime(logdate,
-                nl_langinfo(D_FMT),
-                &t);
+#ifndef MINGW
+     nl_langinfo(D_FMT),
+#else
+     "%Y%m%d",
+#endif
+     &t);
   if ( (ret == NULL) ||
        (ret[0] != '\0') ) {
     FREE(fullname);
@@ -155,12 +162,12 @@
   
   logfilename
     = getConfigurationString(base,
-                            "LOGFILE"); 
+           "LOGFILE"); 
   if (logfilename != NULL) {
     char * fn;
     
     if ( (logfile != stderr) &&
-        (logfile != NULL) ) {
+   (logfile != NULL) ) {
       fclose(logfile);
       logfile = NULL;
     }
@@ -171,7 +178,13 @@
       struct logfiledef def;
       char datestr[80];
       time_t curtime;
+      char *datefmt;
       
+#ifndef MINGW
+      datefmt = nl_langinfo(D_FMT);
+#else
+      datefmt = "%Y%m%d";
+#endif
       time(&curtime);
 #ifdef localtime_r
       localtime_r(&curtime, &def.curtime);
@@ -185,9 +198,9 @@
       strcat(fn, "_");
       def.basename = STRDUP(fn);
       GNUNET_ASSERT(0 != strftime(datestr,
-                                 80,
-                                 nl_langinfo(D_FMT), 
-                                 &def.curtime));
+          80,
+          datefmt, 
+          &def.curtime));
       strcat(fn, datestr);
       
       /* Remove old logs */
@@ -197,8 +210,8 @@
         end--;
       *end = 0;
       scanDirectory(logdir, 
-                   (DirectoryEntryCallback) removeOldLog, 
-                   &def);
+        (DirectoryEntryCallback) removeOldLog, 
+        &def);
       FREE(def.basename);
       FREE(logdir);
     }
@@ -330,11 +343,11 @@
     time(&timetmp);
     tmptr = localtime(&timetmp);
     GNUNET_ASSERT(0 != strftime(timebuf, 
-                               64, 
-                               "%b %d %H:%M:%S ", 
-                               tmptr));
+        64, 
+        "%b %d %H:%M:%S ", 
+        tmptr));
     fputs(timebuf, 
-         logfile);
+    logfile);
   }
 }
 

Modified: GNUnet/src/util/storage.c
===================================================================
--- GNUnet/src/util/storage.c   2005-02-10 00:42:30 UTC (rev 229)
+++ GNUnet/src/util/storage.c   2005-02-10 21:08:45 UTC (rev 230)
@@ -296,8 +296,8 @@
 char * expandFileName(const char * fil) {
   char buffer[512];
   char * fn;
+#ifndef MINGW
   size_t n;
-#ifndef MINGW
   char * fm;
   const char *fil_ptr;
 #else
@@ -676,15 +676,15 @@
     if (len > size - pos)
       len = size - pos;
     if (len != READ(in, buf, len))
-      goto ERROR;
+      goto FAIL;
     if (len != WRITE(out, buf, len))
-      goto ERROR;
+      goto FAIL;
     pos += len;
   }
   CLOSE(in);
   CLOSE(out);
   return OK;
- ERROR:
+ FAIL:
   CLOSE(in);
   CLOSE(out);
   return SYSERR;

Modified: GNUnet/src/util/win/winproc.c
===================================================================
--- GNUnet/src/util/win/winproc.c       2005-02-10 00:42:30 UTC (rev 229)
+++ GNUnet/src/util/win/winproc.c       2005-02-10 21:08:45 UTC (rev 230)
@@ -1791,6 +1791,87 @@
 }
 
 /**
+ * map files into memory
+ * @author Cygwin team
+ * @author Nils Durner
+ * @todo [WIN] Needs testing
+ */
+void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
+                unsigned long long off) {
+  DWORD protect, high, low;
+  HANDLE h, hFile;
+  SECURITY_ATTRIBUTES sec_none;
+  void *base;
+
+  errno = 0;
+
+  switch(access)
+  {
+    case PROT_WRITE:
+      protect = PAGE_READWRITE;
+      break;
+    case PROT_READ:
+      protect = PAGE_READONLY;
+      break;
+    default:
+      protect = PAGE_WRITECOPY;
+      break;
+  }
+  
+  sec_none.nLength = sizeof(SECURITY_ATTRIBUTES);
+  sec_none.bInheritHandle = TRUE;
+  sec_none.lpSecurityDescriptor = NULL;
+  
+  hFile = (HANDLE) _get_osfhandle(fd);
+  
+  h = CreateFileMapping(hFile, &sec_none, protect, 0, 0, NULL);
+  
+  if (! h)
+  {
+    SetErrnoFromWinError(GetLastError());
+    return (void *) -1;
+  }
+  
+  high = off >> 32;
+  low = off & ULONG_MAX;
+  base = NULL;
+  
+  /* If a non-zero start is given, try mapping using the given address first.
+     If it fails and flags is not MAP_FIXED, try again with NULL address. */
+  if (start)
+    base = MapViewOfFileEx(h, access, high, low, len, start);
+  if (!base && !(flags & MAP_FIXED))
+    base = MapViewOfFileEx(h, access, high, low, len, NULL);
+  
+  if (!base || ((flags & MAP_FIXED) && base != start))
+  {
+    if (!base)
+      SetErrnoFromWinError(GetLastError());
+    else
+      errno = EINVAL;
+    
+    CloseHandle(h);
+    return (void *) -1;
+  }
+  
+  return base;
+}
+
+/**
+ * Unmap files from memory
+ * @author Cygwin team
+ * @author Nils Durner
+ * @todo [WIN] Needs testing
+ */
+int _win_munmap(void *start, size_t length)
+{
+  BOOL success = UnmapViewOfFile(start);
+  SetErrnoFromWinError(GetLastError());
+  
+  return success ? 0 : -1;
+}
+
+/**
  * Accepts an incoming connection attempt on a socket
  */
 int _win_accept(SOCKET s, struct sockaddr *addr, int *addrlen)

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-02-10 00:42:30 UTC (rev 229)
+++ GNUnet/todo 2005-02-10 21:08:45 UTC (rev 230)
@@ -19,6 +19,7 @@
   * ECRS-directories (build, iterate)
   * gnunet-directory
   * gnunet-pseudonym
+- Resolve "@todo [WIN]" (Nils)
 
 0.7.0pre1 [4'05] (aka "preview"):
 - topology: do aggressive bootstrap on first start (Christian) [ easy ]
@@ -37,6 +38,7 @@
 0.7.0 [5'05] (aka "compatibility? what's that?"):
 - ecrs-unindex: code cleanup [ easy ]
 - Missing Features:
+   - resolve "FIXME 0.7"
   * configure.ac: flags for mysql, gmp, libgcrypt should ONLY be passed when
     linking the respective modules / libraries (gnunet_util, sqstore_mysql) [ 
tricky ]
   * fsui core (persistence) [ difficult ]





reply via email to

[Prev in Thread] Current Thread [Next in Thread]