gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3217 - in GNUnet: . src/applications/chat src/applications


From: grothoff
Subject: [GNUnet-SVN] r3217 - in GNUnet: . src/applications/chat src/applications/dht/tools src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/lib src/applications/fs/module src/applications/fs/tools src/applications/gap src/applications/session src/applications/sqstore_mysql src/applications/tbench src/applications/testbed src/applications/vpn src/include src/util/network_client
Date: Tue, 8 Aug 2006 12:56:49 -0700 (PDT)

Author: grothoff
Date: 2006-08-08 12:56:16 -0700 (Tue, 08 Aug 2006)
New Revision: 3217

Modified:
   GNUnet/src/applications/chat/gnunet-chat.c
   GNUnet/src/applications/dht/tools/dht-query.c
   GNUnet/src/applications/dht/tools/dht_api.c
   GNUnet/src/applications/dht/tools/dhttest2.c
   GNUnet/src/applications/fs/ecrs/download.c
   GNUnet/src/applications/fs/ecrs/ecrstest.c
   GNUnet/src/applications/fs/ecrs/indexinfo.c
   GNUnet/src/applications/fs/ecrs/keyspace.c
   GNUnet/src/applications/fs/ecrs/namespace.c
   GNUnet/src/applications/fs/ecrs/searchtest.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/fsui/file_info.c
   GNUnet/src/applications/fs/fsui/fsui.c
   GNUnet/src/applications/fs/fsui/upload.c
   GNUnet/src/applications/fs/lib/fslib.c
   GNUnet/src/applications/fs/lib/fslibtest.c
   GNUnet/src/applications/fs/module/ondemand.c
   GNUnet/src/applications/fs/tools/gnunet-delete.c
   GNUnet/src/applications/fs/tools/gnunet-directory.c
   GNUnet/src/applications/gap/gaptest.c
   GNUnet/src/applications/session/sessiontest.c
   GNUnet/src/applications/sqstore_mysql/mysql.c
   GNUnet/src/applications/tbench/tbenchtest.c
   GNUnet/src/applications/tbench/tbenchtest_udp.c
   GNUnet/src/applications/testbed/commands.c
   GNUnet/src/applications/testbed/testbed.c
   GNUnet/src/applications/vpn/gnunet-vpn.c
   GNUnet/src/include/gnunet_ecrs_lib.h
   GNUnet/src/include/gnunet_fs_lib.h
   GNUnet/src/include/gnunet_util_network_client.h
   GNUnet/src/util/network_client/tcpio.c
   GNUnet/src/util/network_client/tcpiotest.c
   GNUnet/todo
Log:
various I70 hacking

Modified: GNUnet/src/applications/chat/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/gnunet-chat.c  2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/chat/gnunet-chat.c  2006-08-08 19:56:16 UTC (rev 
3217)
@@ -98,11 +98,11 @@
 }
 
 static void * receiveThread(void * arg) {
-  GNUNET_TCP_SOCKET * sock = arg;
+  struct ClientServerConnection * sock = arg;
   CS_chat_MESSAGE * buffer;
 
   buffer = MALLOC(MAX_BUFFER_SIZE);
-  while (OK == readFromSocket(sock,
+  while (OK == connection_read(sock,
                              (CS_MESSAGE_HEADER **)&buffer)) {
     char timebuf[64];
     time_t timetmp;
@@ -138,7 +138,7 @@
  * @return return value from gnunetsearch: 0: ok, -1: error
  */
 int main(int argc, char ** argv) {
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   PTHREAD_T messageReceiveThread;
   void * unused;
   CS_chat_MESSAGE msg;
@@ -177,7 +177,7 @@
         strlen(nick));
 
   /* send first "Hi!" message to gnunetd to indicate "join" */
-  if (SYSERR == writeToSocket(sock,
+  if (SYSERR == connection_write(sock,
                              &msg.header))
     errexit(_("Could not send join message to gnunetd\n"));
 
@@ -186,7 +186,7 @@
     memset(&msg.message, 0, 1024);
     if (NULL == fgets(&msg.message[0], 1024, stdin))
       break;
-    if (SYSERR == writeToSocket(sock,
+    if (SYSERR == connection_write(sock,
                                &msg.header))
       errexit(_("Could not send message to gnunetd\n"));
   }

Modified: GNUnet/src/applications/dht/tools/dht-query.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht-query.c       2006-08-08 15:35:12 UTC 
(rev 3216)
+++ GNUnet/src/applications/dht/tools/dht-query.c       2006-08-08 19:56:16 UTC 
(rev 3217)
@@ -123,7 +123,7 @@
   return OK;
 }
 
-static void do_get(GNUNET_TCP_SOCKET * sock,
+static void do_get(struct ClientServerConnection * sock,
                   const char * key) {
   int ret;
   HashCode512 hc;
@@ -149,7 +149,7 @@
           key);
 }
 
-static void do_put(GNUNET_TCP_SOCKET * sock,
+static void do_put(struct ClientServerConnection * sock,
                   const char * key,
                   char * value) {
   DataContainer * dc;
@@ -181,7 +181,7 @@
   FREE(dc);
 }
 
-static void do_remove(GNUNET_TCP_SOCKET * sock,
+static void do_remove(struct ClientServerConnection * sock,
                      const char * key,
                      char * value) {
   DataContainer * dc;
@@ -219,7 +219,7 @@
   int count;
   char ** commands;
   int i;
-  GNUNET_TCP_SOCKET * handle;
+  struct ClientServerConnection * handle;
 
   if (SYSERR == initUtil(argc, argv, &parseOptions))
     return 0;

Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2006-08-08 19:56:16 UTC (rev 
3217)
@@ -41,7 +41,7 @@
    * The socket that was used to join GNUnet to receive
    * requests for this table.
    */
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   /**
    * The thread that is processing the requests received
    * from GNUnet on sock.
@@ -91,7 +91,7 @@
 /**
  * Send an ACK message of the given value to gnunetd.
  */
-static int sendAck(GNUNET_TCP_SOCKET * sock,
+static int sendAck(struct ClientServerConnection * sock,
                   DHT_TableId * table,
                   int value) {
   CS_dht_reply_ack_MESSAGE msg;
@@ -102,7 +102,7 @@
   msg.header.type = htons(CS_PROTO_dht_REPLY_ACK);
   msg.status = htonl(value);
   msg.table = *table;
-  return writeToSocket(sock,
+  return connection_write(sock,
                       &msg.header);
 }
 
@@ -121,7 +121,7 @@
   memcpy(&reply->data,
         value,
         ntohl(value->size));
-  if (OK != writeToSocket(list->sock,
+  if (OK != connection_write(list->sock,
                          &reply->header)) {
     GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
        _("Failed to send `%s'.  Closing connection.\n"),
@@ -165,10 +165,10 @@
 
     ok = NO;
     /* send 'join' message via socket! */
-    if (OK == writeToSocket(list->sock,
+    if (OK == connection_write(list->sock,
                            &req.header)) {
       reply = NULL;
-      if (OK == readFromSocket(list->sock,
+      if (OK == connection_read(list->sock,
                               &reply)) {
        if (OK == checkACK(reply))
          ok = YES;
@@ -184,7 +184,7 @@
     }
 
     buffer = NULL;
-    while (OK == readFromSocket(list->sock,
+    while (OK == connection_read(list->sock,
                                &buffer)) {
       GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
          "Received message of type %d from gnunetd\n",
@@ -477,7 +477,7 @@
   CS_dht_request_leave_MESSAGE req;
   CS_MESSAGE_HEADER * reply;
   int ret;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
 
   list = NULL;
   MUTEX_LOCK(&lock);
@@ -508,10 +508,10 @@
   ret = SYSERR;
   sock = getClientSocket();
   if (sock != NULL) {
-    if (OK == writeToSocket(sock,
+    if (OK == connection_write(sock,
                            &req.header)) {
       reply = NULL;
-      if (OK == readFromSocket(sock,
+      if (OK == connection_read(sock,
                               &reply)) {
        if (OK == checkACK(reply))
          ret = OK;     
@@ -572,7 +572,7 @@
                cron_t timeout,
                DataProcessor processor,
                void * closure) {
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   CS_dht_request_get_MESSAGE * req;
   CS_dht_reply_results_MESSAGE * res;
   CS_MESSAGE_HEADER * reply;
@@ -596,7 +596,7 @@
   memcpy(&req->keys,
         keys,
         keyCount * sizeof(HashCode512));
-  if (OK != writeToSocket(sock,
+  if (OK != connection_write(sock,
                          &req->header)) {
     releaseClientSocket(sock);
     return SYSERR;
@@ -604,7 +604,7 @@
   FREE(req);
   while (1) {
     reply = NULL;
-    if (OK != readFromSocket(sock,
+    if (OK != connection_read(sock,
                             &reply)) {
       releaseClientSocket(sock);
       return SYSERR;
@@ -661,7 +661,7 @@
                unsigned int prio,
                cron_t timeout,
                const DataContainer * value) {
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   CS_dht_request_put_MESSAGE * req;
   CS_MESSAGE_HEADER * reply;
   int ret;
@@ -691,10 +691,10 @@
         &value[1],
         ntohl(value->size) - sizeof(DataContainer));
   ret = SYSERR;
-  if (OK == writeToSocket(sock,
+  if (OK == connection_write(sock,
                          &req->header))
     reply = NULL;
-    if (OK == readFromSocket(sock,
+    if (OK == connection_read(sock,
                             &reply)) {
       if (OK == checkACK(reply))
        ret = OK;
@@ -719,7 +719,7 @@
                   const HashCode512 * key,
                   cron_t timeout,
                   const DataContainer * value) {
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   CS_dht_request_remove_MESSAGE * req;
   CS_MESSAGE_HEADER * reply;
   int ret;
@@ -742,10 +742,10 @@
           &value[1],
           ntohl(value->size) - sizeof(DataContainer));
   ret = SYSERR;
-  if (OK == writeToSocket(sock,
+  if (OK == connection_write(sock,
                          &req->header))
     reply = NULL;
-    if (OK == readFromSocket(sock,
+    if (OK == connection_read(sock,
                             &reply)) {
       if (OK == checkACK(reply))
        ret = OK;

Modified: GNUnet/src/applications/dht/tools/dhttest2.c
===================================================================
--- GNUnet/src/applications/dht/tools/dhttest2.c        2006-08-08 15:35:12 UTC 
(rev 3216)
+++ GNUnet/src/applications/dht/tools/dhttest2.c        2006-08-08 19:56:16 UTC 
(rev 3217)
@@ -67,7 +67,7 @@
   pid_t sto2;
   int ret;
   int status;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   int left;
   DHT_TableId table;
   DHT_TableId key;

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/ecrs/download.c  2006-08-08 19:56:16 UTC (rev 
3217)
@@ -156,7 +156,7 @@
        ((size_t)st.st_size > filesize ) ) {
     /* if exists and oversized, truncate */
     if (truncate(filename, filesize) != 0) {
-      LOG_FILE_STRERROR(LOG_FAILURE,
+      GE_LOG_STRERROR_FILE(ectx,LOG_FAILURE,
                        "truncate",
                        filename);
       return SYSERR;
@@ -180,7 +180,7 @@
                                O_CREAT|O_RDWR,
                                S_IRUSR|S_IWUSR );
     if (this->handles[i] < 0) {
-      LOG_FILE_STRERROR(LOG_FAILURE,
+      GE_LOG_STRERROR_FILE(ectx,LOG_FAILURE,
                        "open",
                        fn);
       freeIOC(this, NO);
@@ -1004,7 +1004,7 @@
   if (lastmpritime + 10 * cronSECONDS < now) {
     /* only update avg. priority at most every
        10 seconds */
-    GNUNET_TCP_SOCKET * sock;
+    struct ClientServerConnection * sock;
 
     sock = getClientSocket();
     lastmpriority = FS_getAveragePriority(sock);
@@ -1220,7 +1220,7 @@
   if (0 == ECRS_fileSize(uri)) {
     ret = fileopen(filename, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR|S_IWUSR);
     if (ret == -1) {
-      LOG_FILE_STRERROR(LOG_ERROR, "open", filename);
+      GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "open", filename);
       return SYSERR;
     }
     CLOSE(ret);

Modified: GNUnet/src/applications/fs/ecrs/ecrstest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrstest.c  2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/ecrs/ecrstest.c  2006-08-08 19:56:16 UTC (rev 
3217)
@@ -256,7 +256,7 @@
   };
   pid_t daemon;
   int ok;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   struct ECRS_URI * uri;
   int i;
 

Modified: GNUnet/src/applications/fs/ecrs/indexinfo.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/indexinfo.c 2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/ecrs/indexinfo.c 2006-08-08 19:56:16 UTC (rev 
3217)
@@ -40,7 +40,7 @@
  */
 int ECRS_isFileIndexed(const char * filename) {
   HashCode512 hc;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   int ret;
 
   if (SYSERR == getFileHash(filename,
@@ -93,7 +93,7 @@
        continue;
       }
       if (errno != EINVAL) {
-       LOG_FILE_STRERROR(LOG_WARNING,
+       GE_LOG_STRERROR_FILE(ectx,LOG_WARNING,
                          "readlink",
                          fullName);
       }
@@ -134,7 +134,7 @@
                             void * closure) {
   char * tmp;
   char * indexDirectory;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   struct iiC cls;
 
   sock = getClientSocket();

Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c  2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c  2006-08-08 19:56:16 UTC (rev 
3217)
@@ -123,7 +123,7 @@
                       cron_t expirationTime,
                       const struct ECRS_URI * dst,
                       const struct ECRS_MetaData * md) {
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   Datastore_Value * value;
   int ret;
   unsigned int size;

Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2006-08-08 19:56:16 UTC (rev 
3217)
@@ -64,7 +64,7 @@
 
   fileName = getPseudonymFileName(name);
   if (0 != UNLINK(fileName)) {
-    LOG_FILE_STRERROR(LOG_EVERYTHING, "unlink", fileName);
+    GE_LOG_STRERROR_FILE(ectx,LOG_EVERYTHING, "unlink", fileName);
     FREE(fileName);
     return SYSERR;
   } else {
@@ -109,7 +109,7 @@
   char * dst;
   unsigned short len;
   HashCode512 hc;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   Datastore_Value * value;
   Datastore_Value * knvalue;
   unsigned int size;
@@ -357,7 +357,7 @@
                    const struct ECRS_URI * dstU,
                    const struct ECRS_MetaData * md) {
   struct ECRS_URI * uri;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   Datastore_Value * value;
   unsigned int size;
   unsigned int mdsize;

Modified: GNUnet/src/applications/fs/ecrs/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/searchtest.c        2006-08-08 15:35:12 UTC 
(rev 3216)
+++ GNUnet/src/applications/fs/ecrs/searchtest.c        2006-08-08 19:56:16 UTC 
(rev 3217)
@@ -94,7 +94,7 @@
 int main(int argc, char * argv[]){
   pid_t daemon;
   int ok;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   struct ECRS_URI * uri;
   struct ECRS_MetaData * meta;
   struct ECRS_URI * key;

Modified: GNUnet/src/applications/fs/ecrs/unindex.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/unindex.c   2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/ecrs/unindex.c   2006-08-08 19:56:16 UTC (rev 
3217)
@@ -53,7 +53,7 @@
  * to avoid code duplication (move to block.c, pass
  * FS_delete as argument!).
  */
-static int pushBlock(GNUNET_TCP_SOCKET * sock,
+static int pushBlock(struct ClientServerConnection * sock,
                     const CHK * chk,   
                     unsigned int level,
                     Datastore_Value ** iblocks) {
@@ -117,7 +117,7 @@
  */
 static int undoSymlinking(const char * fn,
                          const HashCode512 * fileId,
-                         GNUNET_TCP_SOCKET * sock) {
+                         struct ClientServerConnection * sock) {
   EncName enc;
   char * serverDir;
   char * serverFN;
@@ -129,7 +129,7 @@
 #endif
   if (0 != LSTAT(fn,
                 &buf)) {
-    LOG_FILE_STRERROR(LOG_ERROR, "stat", fn);
+    GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "stat", fn);
     return SYSERR;
   }
 #ifdef S_ISLNK
@@ -155,7 +155,7 @@
         (char*)&enc);
 
   if (0 != UNLINK(serverFN)) {
-    LOG_FILE_STRERROR(LOG_ERROR, "unlink", serverFN);
+    GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "unlink", serverFN);
     FREE(serverFN);
     return SYSERR;
   }
@@ -185,7 +185,7 @@
   Datastore_Value * dblock;
   DBlock * db;
   Datastore_Value * value;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   HashCode512 fileId;
   CHK chk;
   cron_t eta;
@@ -235,7 +235,7 @@
 
   fd = fileopen(filename, O_RDONLY | O_LARGEFILE);
   if (fd == -1) {
-    LOG_FILE_STRERROR(LOG_WARNING, "OPEN", filename);
+    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "OPEN", filename);
     return SYSERR;
   }
   dblock = MALLOC(sizeof(Datastore_Value) + DBLOCK_SIZE + sizeof(DBlock));
@@ -275,7 +275,7 @@
     if (size != READ(fd,
                     &db[1],
                     size)) {
-      LOG_FILE_STRERROR(LOG_WARNING,
+      GE_LOG_STRERROR_FILE(ectx,LOG_WARNING,
                        "READ",
                        filename);
       goto FAILURE;

Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c    2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/ecrs/upload.c    2006-08-08 19:56:16 UTC (rev 
3217)
@@ -46,7 +46,7 @@
  * level+1 and clear the level.  iblocks is guaranteed to be big
  * enough.
  */
-static int pushBlock(GNUNET_TCP_SOCKET * sock,
+static int pushBlock(struct ClientServerConnection * sock,
                      const CHK * chk,
                      unsigned int level,
                      Datastore_Value ** iblocks,
@@ -155,7 +155,7 @@
   Datastore_Value * dblock;
   DBlock * db;
   Datastore_Value * value;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   HashCode512 fileId;
   CHK chk;
   cron_t eta;
@@ -233,7 +233,7 @@
 
   fd = fileopen(filename, O_RDONLY | O_LARGEFILE);
   if (fd == -1) {
-    LOG_FILE_STRERROR(LOG_WARNING, "OPEN", filename);
+    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "OPEN", filename);
     return SYSERR;
   }
 
@@ -275,7 +275,7 @@
     if (size != READ(fd,
                      &db[1],
                      size)) {
-      LOG_FILE_STRERROR(LOG_WARNING,
+      GE_LOG_STRERROR_FILE(ectx,LOG_WARNING,
                         "READ",
                         filename);
       goto FAILURE;

Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c  2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/fsui/download.c  2006-08-08 19:56:16 UTC (rev 
3217)
@@ -254,7 +254,7 @@
     fd = fileopen(fn,
                  O_LARGEFILE | O_RDONLY);
     if (fd == -1) {
-      LOG_FILE_STRERROR(LOG_ERROR,
+      GE_LOG_STRERROR_FILE(ectx,LOG_ERROR,
                        "OPEN",
                        fn);
     } else {
@@ -265,7 +265,7 @@
                      fd,
                      0);
       if (MAP_FAILED == dirBlock) {
-       LOG_FILE_STRERROR(LOG_ERROR, "MMAP", fn);       
+       GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "MMAP", fn);       
       } else {
        /* load directory, start downloads */
        md = NULL;

Modified: GNUnet/src/applications/fs/fsui/file_info.c
===================================================================
--- GNUnet/src/applications/fs/fsui/file_info.c 2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/fsui/file_info.c 2006-08-08 19:56:16 UTC (rev 
3217)
@@ -126,7 +126,7 @@
   fn = getUriDbName();
   fh = fileopen(fn, O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE, S_IRUSR|S_IWUSR);
   if (fh == -1) {
-    LOG_FILE_STRERROR(LOG_WARNING,
+    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING,
                      "open",
                      fn);
   } else {
@@ -154,7 +154,7 @@
   IPC_SEMAPHORE_DOWN(sem);
   fn = getUriDbName();
   if (0 != UNLINK(fn))
-    LOG_FILE_STRERROR(LOG_WARNING,
+    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING,
                      "unlink",
                      fn);
   FREE(fn);
@@ -209,14 +209,14 @@
   if(fd == -1) {
     IPC_SEMAPHORE_UP(sem);
     IPC_SEMAPHORE_DESTROY(sem);
-    LOG_FILE_STRERROR(LOG_WARNING, "open", fn);
+    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "open", fn);
     FREE(fn);
     return SYSERR;              /* error opening URI db */
   }
   result = MMAP(NULL, buf.st_size, PROT_READ, MAP_SHARED, fd, 0);
   if(result == MAP_FAILED) {
     CLOSE(fd);
-    LOG_FILE_STRERROR(LOG_WARNING, "mmap", fn);
+    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "mmap", fn);
     FREE(fn);
     IPC_SEMAPHORE_UP(sem);
     IPC_SEMAPHORE_DESTROY(sem);
@@ -259,7 +259,7 @@
         ECRS_freeMetaData(fi.meta);
         ECRS_freeUri(fi.uri);
         if(0 != MUNMAP(result, buf.st_size))
-          LOG_FILE_STRERROR(LOG_WARNING, "munmap", fn);
+          GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "munmap", fn);
         CLOSE(fd);
         FREE(fn);
         IPC_SEMAPHORE_UP(sem);
@@ -272,7 +272,7 @@
     ECRS_freeUri(fi.uri);
   }
   if(0 != MUNMAP(result, buf.st_size))
-    LOG_FILE_STRERROR(LOG_WARNING, "munmap", fn);
+    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "munmap", fn);
   CLOSE(fd);
   FREE(fn);
   IPC_SEMAPHORE_UP(sem);
@@ -281,7 +281,7 @@
 FORMATERROR:
   GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER, _("Deleted corrupt URI database 
in `%s'."), STATE_NAME);
   if(0 != MUNMAP(result, buf.st_size))
-    LOG_FILE_STRERROR(LOG_WARNING, "munmap", fn);
+    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "munmap", fn);
   CLOSE(fd);
   FREE(fn);
   IPC_SEMAPHORE_UP(sem);

Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c      2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/fsui/fsui.c      2006-08-08 19:56:16 UTC (rev 
3217)
@@ -643,7 +643,7 @@
       UNLINK(fn);
     } else {
       if (errno != ENOENT)
-       LOG_FILE_STRERROR(LOG_ERROR,
+       GE_LOG_STRERROR_FILE(ectx,LOG_ERROR,
                          "open",
                          fn);
     }
@@ -713,7 +713,7 @@
                  O_CREAT|O_TRUNC|O_WRONLY,
                  S_IRUSR|S_IWUSR);
     if (fd == -1) {
-      LOG_FILE_STRERROR(LOG_ERROR,
+      GE_LOG_STRERROR_FILE(ectx,LOG_ERROR,
                        "open",
                        ctx->name);
     } else {

Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c    2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/fsui/upload.c    2006-08-08 19:56:16 UTC (rev 
3217)
@@ -165,11 +165,11 @@
     tempName = STRDUP("/tmp/gnunetdir.XXXXXX");
     handle = mkstemp(tempName);
     if (handle == -1) {
-      LOG_FILE_STRERROR(LOG_ERROR, tempName, "mkstemp");
+      GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, tempName, "mkstemp");
     } else if (len != WRITE(handle,
                            data,
                            len)) {
-      LOG_FILE_STRERROR(LOG_ERROR, tempName, "write");
+      GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, tempName, "write");
     } else {
       closefile(handle);
       utc->filename = tempName;

Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c      2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/lib/fslib.c      2006-08-08 19:56:16 UTC (rev 
3217)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet
-     (C) 2004, 2005 Christian Grothoff (and other contributing authors)
+     (C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -39,9 +39,11 @@
 } SEARCH_HANDLE;
 
 typedef struct FS_SEARCH_CONTEXT {
-  GNUNET_TCP_SOCKET * sock;
-  PTHREAD_T thread;
-  Mutex * lock;
+  struct GC_Configuration * cfg;
+  struct GE_Context * ectx;
+  struct ClientServerConnection * sock;
+  struct PTHREAD * thread;
+  struct MUTEX * lock;
   SEARCH_HANDLE ** handles;
   unsigned int handleCount;
   unsigned int handleSize;
@@ -52,8 +54,9 @@
  * Thread that processes replies from gnunetd and
  * calls the appropriate callback.
  */
-static void * processReplies(SEARCH_CONTEXT * ctx) {
-  CS_MESSAGE_HEADER * hdr;
+static void * processReplies(void * cls) {
+  SEARCH_CONTEXT * ctx = cls;
+  MESSAGE_HEADER * hdr;
   int i;
   int matched;
   CS_fs_reply_content_MESSAGE * rep;
@@ -64,11 +67,12 @@
   delay = 100 * cronMILLIS;
   while (ctx->abort == NO) {
     hdr = NULL;
-    if (OK == readFromSocket(ctx->sock,
-                            &hdr)) {
+    if (OK == connection_read(ctx->sock,
+                             &hdr)) {
 #if DEBUG_FSLIB
-      GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-         "FSLIB: received message from gnunetd\n");
+      GE_LOG(ctx->ectx, 
+            GE_DEBUG | GE_REQUEST | GE_USER,
+            "FSLIB: received message from gnunetd\n");
 #endif
       delay = 100 * cronMILLIS;
       /* verify hdr, if reply, process, otherwise
@@ -76,7 +80,7 @@
         matching callback, call on value */
       if ( (ntohs(hdr->size) < sizeof(CS_fs_reply_content_MESSAGE)) ||
           (ntohs(hdr->type) != CS_PROTO_gap_RESULT) ) {
-       GE_BREAK(ectx, 0);
+       GE_BREAK(ctx->ectx, 0);
        FREE(hdr);
        continue;
       }
@@ -86,7 +90,7 @@
                            (DBlock*)&rep[1],
                            NO, /* gnunetd will have checked already */
                            &query)) {
-       GE_BREAK(ectx, 0);
+       GE_BREAK(ctx->ectx, 0);
        FREE(hdr);
        continue;
       }
@@ -121,14 +125,16 @@
       MUTEX_UNLOCK(ctx->lock);
 #if DEBUG_FSLIB
       if (matched == 0)
-       GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-           "FSLIB: received content but have no pending request\n");
+       GE_LOG(ctx->ectx, 
+              GE_DEBUG | GE_REQUEST | GE_USER,
+              "FSLIB: received content but have no pending request\n");
 #endif
     } else {
 #if DEBUG_FSLIB
-      GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-         "FSLIB: error communicating with gnunetd; sleeping for %ums\n",
-         delay);
+      GE_LOG(ctx->ectx, 
+            GE_DEBUG | GE_REQUEST | GE_USER,
+            "FSLIB: error communicating with gnunetd; sleeping for %ums\n",
+            delay);
 #endif
       PTHREAD_SLEEP(delay);
       delay *= 2;
@@ -140,33 +146,39 @@
   return NULL;
 }
 
-SEARCH_CONTEXT * FS_SEARCH_makeContext(Mutex * lock) {
+SEARCH_CONTEXT * FS_SEARCH_makeContext(struct GE_Context * ectx,
+                                      struct GC_Configuration * cfg,
+                                      struct MUTEX * lock) {
   SEARCH_CONTEXT * ret;
   ret = MALLOC(sizeof(SEARCH_CONTEXT));
+  ret->ectx = ectx;
+  ret->cfg = cfg;
   ret->lock = lock;
-  ret->sock = getClientSocket();
+  ret->sock = client_connection_create(ectx, cfg);
   ret->handles = NULL;
   ret->handleCount = 0;
   ret->handleSize = 0;
   ret->abort = NO;
-  if (0 != PTHREAD_CREATE(&ret->thread,
-                         (PThreadMain) &processReplies,
-                         ret,
-                         64 * 1024))
-    DIE_STRERROR("PTHREAD_CREATE");
+  ret->thread = PTHREAD_CREATE(&processReplies,
+                              ret,
+                              64 * 1024);
+  if (ret->thread == NULL)
+    GE_DIE_STRERROR(ectx,
+                   GE_FATAL | GE_ADMIN | GE_BULK,
+                   "PTHREAD_CREATE");
   return ret;
 }
 
 void FS_SEARCH_destroyContext(struct FS_SEARCH_CONTEXT * ctx) {
   void * unused;
 
-  GE_ASSERT(ectx, ctx->handleCount == 0);
+  GE_ASSERT(ctx->ectx, ctx->handleCount == 0);
   ctx->abort = YES;
-  closeSocketTemporarily(ctx->sock);
-  PTHREAD_JOIN(&ctx->thread,
+  connection_close_temporarily(ctx->sock);
+  PTHREAD_JOIN(ctx->thread,
               &unused);
   ctx->lock = NULL;
-  releaseClientSocket(ctx->sock);
+  connection_destroy(ctx->sock);
   GROW(ctx->handles,
        ctx->handleSize,
        0);
@@ -200,9 +212,10 @@
 
   ret = MALLOC(sizeof(SEARCH_HANDLE));
 #if DEBUG_FSLIB
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "FSLIB: start search (%p)\n",
-      ret);
+  GE_LOG(ctx->ectx,
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "FSLIB: start search (%p)\n",
+        ret);
 #endif
   req = MALLOC(sizeof(CS_fs_request_search_MESSAGE) + (keyCount-1) * 
sizeof(HashCode512));
   req->header.size = htons(sizeof(CS_fs_request_search_MESSAGE) + (keyCount-1) 
* sizeof(HashCode512));
@@ -226,24 +239,27 @@
   ctx->handles[ctx->handleCount++] = ret;
   MUTEX_UNLOCK(ctx->lock);
 #if DEBUG_FSLIB
-  IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-       hash2enc(&req->query[0],
-                &enc));
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "FSLIB: initiating search for `%s' of type %u\n",
-      &enc,
-      type);
+  IF_GELOG(ctx->ectx, 
+          GE_DEBUG | GE_REQUEST | GE_USER,
+          hash2enc(&req->query[0],
+                   &enc));
+  GE_LOG(ctx->ectx,
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "FSLIB: initiating search for `%s' of type %u\n",
+        &enc,
+        type);
 #endif
-  if (OK != writeToSocket(ctx->sock,
+  if (OK != connection_write(ctx->sock,
                          &req->header)) {
     FS_stop_search(ctx,
                   ret);
     return NULL;
   }
 #if DEBUG_FSLIB
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "FSLIB: search started (%p)\n",
-      ret);
+  GE_LOG(ctx->ectx, 
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "FSLIB: search started (%p)\n",
+        ret);
 #endif
   return ret;
 }
@@ -256,13 +272,14 @@
   int i;
 
 #if DEBUG_FSLIB
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "FSLIB: stop search (%p)\n",
-      handle);
+  GE_LOG(ctx->ectx,
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "FSLIB: stop search (%p)\n",
+        handle);
 #endif
   handle->req->header.type = htons(CS_PROTO_gap_QUERY_STOP);
-  writeToSocket(ctx->sock,
-               &handle->req->header);
+  connection_write(ctx->sock,
+                  &handle->req->header);
   MUTEX_LOCK(ctx->lock);
   for (i=ctx->handleCount-1;i>=0;i--)
     if (ctx->handles[i] == handle) {
@@ -272,9 +289,10 @@
   MUTEX_UNLOCK(ctx->lock);
   FREE(handle->req);
 #if DEBUG_FSLIB
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "FSLIB: search stopped (%p)\n",
-      handle);
+  GE_LOG(ctx->ectx,
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "FSLIB: search stopped (%p)\n",
+        handle);
 #endif
   FREE(handle);
 }
@@ -283,17 +301,17 @@
  * What is the current average priority of entries
  * in the routing table like?  Returns -1 on error.
  */
-int FS_getAveragePriority(GNUNET_TCP_SOCKET * sock) {
-  CS_MESSAGE_HEADER req;
+int FS_getAveragePriority(struct ClientServerConnection * sock) {
+  MESSAGE_HEADER req;
   int ret;
 
-  req.size = htons(sizeof(CS_MESSAGE_HEADER));
+  req.size = htons(sizeof(MESSAGE_HEADER));
   req.type = htons(CS_PROTO_gap_GET_AVG_PRIORITY);
-  if (OK != writeToSocket(sock,
-                         &req))
+  if (OK != connection_write(sock,
+                            &req))
     return -1;
-  if (OK != readTCPResult(sock,
-                         &ret))
+  if (OK != connection_read_result(sock,
+                                  &ret))
     return -1;
   return ret;
 }
@@ -304,14 +322,14 @@
  * @param block the block (properly encoded and all)
  * @return OK on success, SYSERR on error
  */
-int FS_insert(GNUNET_TCP_SOCKET * sock,
+int FS_insert(struct ClientServerConnection * sock,
              const Datastore_Value * block) {
   int ret;
   CS_fs_request_insert_MESSAGE * ri;
   unsigned int size;
 
   if (ntohl(block->size) <= sizeof(Datastore_Value)) {
-    GE_BREAK(ectx, 0);
+    GE_BREAK(NULL, 0);
     return SYSERR;
   }
   size = ntohl(block->size) - sizeof(Datastore_Value);
@@ -324,15 +342,15 @@
   memcpy(&ri[1],
         &block[1],
         size);
-  if (OK != writeToSocket(sock,
-                         &ri->header)) {
+  if (OK != connection_write(sock,
+                            &ri->header)) {
     FREE(ri);
     return SYSERR;
   }
   FREE(ri);
 
-  if (OK != readTCPResult(sock,
-                         &ret))
+  if (OK != connection_read_result(sock,
+                                  &ret))
     return SYSERR;
   return ret;
 }
@@ -340,7 +358,7 @@
 /**
  * Initialize to index a file
  */
-int FS_initIndex(GNUNET_TCP_SOCKET * sock,
+int FS_initIndex(struct ClientServerConnection * sock,
                 const HashCode512 * fileHc,
                 const char * fn) {
   int ret;
@@ -360,7 +378,7 @@
   GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
       "Sending index initialization request to gnunetd\n");
 #endif
-  if (OK != writeToSocket(sock,
+  if (OK != connection_write(sock,
         &ri->header)) {
     FREE(ri);
     return SYSERR;
@@ -370,7 +388,7 @@
   GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
       "Waiting for confirmation of index initialization request by gnunetd\n");
 #endif
-  if (OK != readTCPResult(sock,
+  if (OK != connection_read_result(sock,
         &ret))
     return SYSERR;
   return ret;
@@ -384,7 +402,7 @@
  * @param offset the offset of the block into the file
  * @return OK on success, SYSERR on error
  */
-int FS_index(GNUNET_TCP_SOCKET * sock,
+int FS_index(struct ClientServerConnection * sock,
             const HashCode512 * fileHc,        
             const Datastore_Value * block,
             unsigned long long offset) {
@@ -408,7 +426,7 @@
   GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
       "Sending index request to gnunetd\n");
 #endif
-  if (OK != writeToSocket(sock,
+  if (OK != connection_write(sock,
                          &ri->header)) {
     FREE(ri);
     return SYSERR;
@@ -418,7 +436,7 @@
   GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
       "Waiting for confirmation of index request by gnunetd\n");
 #endif
-  if (OK != readTCPResult(sock,
+  if (OK != connection_read_result(sock,
                          &ret))
     return SYSERR;
   return ret;
@@ -432,7 +450,7 @@
  * @return number of items deleted on success,
  *    SYSERR on error
  */
-int FS_delete(GNUNET_TCP_SOCKET * sock,
+int FS_delete(struct ClientServerConnection * sock,
              const Datastore_Value * block) {
   int ret;
   CS_fs_request_delete_MESSAGE * rd;
@@ -445,16 +463,16 @@
   memcpy(&rd[1],
         &block[1],
         size);
-  if (OK != writeToSocket(sock,
+  if (OK != connection_write(sock,
                          &rd->header)) {
     FREE(rd);
-    GE_BREAK(ectx, 0);
+    GE_BREAK(NULL, 0);
     return SYSERR;
   }
   FREE(rd);
-  if (OK != readTCPResult(sock,
+  if (OK != connection_read_result(sock,
                          &ret)) {
-    GE_BREAK(ectx, 0);
+    GE_BREAK(NULL, 0);
     return SYSERR;
   }
   return ret;
@@ -466,7 +484,7 @@
  * @param hc the hash of the entire file
  * @return OK on success, SYSERR on error
  */
-int FS_unindex(GNUNET_TCP_SOCKET * sock,
+int FS_unindex(struct ClientServerConnection * sock,
               unsigned int blocksize,
               const HashCode512 * hc) {
   int ret;
@@ -476,10 +494,10 @@
   ru.header.type = htons(CS_PROTO_gap_UNINDEX);
   ru.blocksize = htonl(blocksize);
   ru.fileId = *hc;
-  if (OK != writeToSocket(sock,
+  if (OK != connection_write(sock,
                          &ru.header))
     return SYSERR;
-  if (OK != readTCPResult(sock,
+  if (OK != connection_read_result(sock,
                          &ret))
     return SYSERR;
   return ret;
@@ -491,7 +509,7 @@
  * @param hc the hash of the entire file
  * @return YES if so, NO if not, SYSERR on error
  */
-int FS_testIndexed(GNUNET_TCP_SOCKET * sock,
+int FS_testIndexed(struct ClientServerConnection * sock,
                   const HashCode512 * hc) {
   RequestTestindex ri;
   int ret;
@@ -500,10 +518,10 @@
   ri.header.type = htons(CS_PROTO_gap_TESTINDEX);
   ri.reserved = htonl(0);
   ri.fileId = *hc;
-  if (OK != writeToSocket(sock,
+  if (OK != connection_write(sock,
                          &ri.header))
     return SYSERR;
-  if (OK != readTCPResult(sock,
+  if (OK != connection_read_result(sock,
                          &ret))
     return SYSERR;
   return ret;

Modified: GNUnet/src/applications/fs/lib/fslibtest.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslibtest.c  2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/fs/lib/fslibtest.c  2006-08-08 19:56:16 UTC (rev 
3217)
@@ -216,7 +216,7 @@
   struct FS_SEARCH_CONTEXT * ctx = NULL;
   struct FS_SEARCH_HANDLE * hnd;
   Mutex lock;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   Datastore_Value * block;
   Datastore_Value * eblock;
   HashCode512 hc;

Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c        2006-08-08 15:35:12 UTC 
(rev 3216)
+++ GNUnet/src/applications/fs/module/ondemand.c        2006-08-08 19:56:16 UTC 
(rev 3217)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2004, 2005 Christian Grothoff (and other contributing 
authors)
+     (C) 2001, 2002, 2004, 2005, 2006 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -67,6 +67,8 @@
 
 static struct GE_Context * ectx;
 
+static CoreAPIForApplication * coreAPI;
+
 static char * getOnDemandFile(const HashCode512 * fileId) {
   EncName enc;
   char * fn;
@@ -114,7 +116,8 @@
   char unavail_key[256];
   HashCode512 linkId;
 
-  if ( (SYSERR == getFileHash(fn,
+  if ( (SYSERR == getFileHash(ectx,
+                             fn,
                              &linkId)) ||
        (! equalsHashCode512(&linkId,
                            fileId)) ) {
@@ -132,8 +135,8 @@
         (char*)&enc);
   UNLINK(serverFN);
   if (0 != SYMLINK(fn, serverFN)) {
-    LOG_FILE_STRERROR(LOG_ERROR, "symlink", fn);
-    LOG_FILE_STRERROR(LOG_ERROR, "symlink", serverFN);
+    GE_LOG_STRERROR_FILE(ectx, GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, 
"symlink", fn);
+    GE_LOG_STRERROR_FILE(ectx, GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, 
"symlink", serverFN);
     FREE(serverFN);
     return NO;
   }
@@ -191,11 +194,12 @@
        "Storing on-demand encoded data in `%s'.\n",
        fn);
 #endif
-    fd = fileopen(fn,
-                 O_LARGEFILE | O_CREAT|O_WRONLY,
-                 S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); /* 644 */
+    fd = disk_file_open(ectx,
+                       fn,
+                       O_LARGEFILE | O_CREAT|O_WRONLY,
+                       S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); /* 644 */
     if(fd == -1) {
-      LOG_FILE_STRERROR(LOG_ERROR, "open", fn);
+      GE_LOG_STRERROR_FILE(ectx,GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, 
"open", fn);
       FREE(fn);
       return SYSERR;
     }
@@ -208,10 +212,10 @@
     if (ret == size - sizeof(DBlock)) {
       ret = OK;
     } else {
-      LOG_FILE_STRERROR(LOG_ERROR, "write", fn);
+      GE_LOG_STRERROR_FILE(ectx,GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, 
"write", fn);
       ret = SYSERR;
     }
-    closefile(fd);
+    CLOSE(fd);
     if (ret == SYSERR) {
       FREE(fn);
       return ret;
@@ -273,7 +277,8 @@
   HashCode512 query;
 };
 
-static void asyncDelJob(struct adJ * job) {
+static void asyncDelJob(void * cls) {
+  struct adJ * job = cls;
   job->datastore->del(&job->query,
                      job->dbv);
   FREE(job->dbv);
@@ -308,10 +313,11 @@
       &enc);
 #endif
   /* schedule for "immediate" execution */
-  addCronJob((CronJob) &asyncDelJob,
-            0,
-            0,
-            job);
+  cron_add_job(coreAPI->cron,
+              &asyncDelJob,
+              0,
+              0,
+              job);
 }
 
 /**
@@ -342,16 +348,17 @@
   odb = (OnDemandBlock*) dbv;
   fn = getOnDemandFile(&odb->fileId);
 
-  fileHandle = fileopen(fn,
-                       O_LARGEFILE | O_RDONLY,
-                       0);
+  fileHandle = disk_file_open(ectx,
+                             fn,
+                             O_LARGEFILE | O_RDONLY,
+                             0);
   if (fileHandle == -1) {
     char unavail_key[256];
     EncName enc;
     cron_t * first_unavail;
     struct stat linkStat;
 
-    LOG_FILE_STRERROR(LOG_ERROR, "open", fn);
+    GE_LOG_STRERROR_FILE(ectx,GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "open", 
fn);
 
     /* Is the symlink there? */
     if (LSTAT(fn, &linkStat) == -1) {
@@ -439,9 +446,12 @@
   if (ntohll(odb->fileOffset) != lseek(fileHandle,
                                       ntohll(odb->fileOffset),
                                       SEEK_SET)) {
-    LOG_FILE_STRERROR(LOG_WARNING, "lseek", fn);
+    GE_LOG_STRERROR_FILE(ectx,
+                        GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
+                        "lseek", 
+                        fn);
     FREE(fn);
-    closefile(fileHandle);
+    CLOSE(fileHandle);
     return SYSERR;
   }
   db = MALLOC(sizeof(DBlock) + ntohl(odb->blockSize));
@@ -451,13 +461,16 @@
              iobuf,
              ntohl(odb->blockSize));
   if (blen != ntohl(odb->blockSize)) {
-    LOG_FILE_STRERROR(LOG_ERROR, "read", fn);
+    GE_LOG_STRERROR_FILE(ectx,
+                        GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, 
+                        "read",
+                        fn);
     FREE(fn);
     FREE(db);
-    closefile(fileHandle);
+    CLOSE(fileHandle);
     return SYSERR;
   }
-  closefile(fileHandle);
+  CLOSE(fileHandle);
   ret = fileBlockEncode(db,
                        ntohl(odb->blockSize) + sizeof(DBlock),
                        query,
@@ -487,12 +500,13 @@
   int fd;
 
   fn = getOnDemandFile(fileId);
-  fd = fileopen(fn,
-           O_RDONLY);
+  fd = disk_file_open(ectx,
+                     fn,
+                     O_RDONLY);
   FREE(fn);
   if(fd == -1)
     return NO;
-  closefile(fd);
+  CLOSE(fd);
   return YES;
 }
 
@@ -513,19 +527,21 @@
                    &comp[1],
                    ntohl(value->size) - sizeof(Datastore_Value))) ) {
 #if DEBUG_ONDEMAND
-    GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-       "`%s' found value that does not match (%u, %u).\n",
-       __FUNCTION__,
-       ntohl(comp->size),
-       ntohl(value->size));
+    GE_LOG(ectx, 
+          GE_DEBUG | GE_REQUEST | GE_USER,
+          "`%s' found value that does not match (%u, %u).\n",
+          __FUNCTION__,
+          ntohl(comp->size),
+          ntohl(value->size));
 #endif
     return OK;
   }
   *comp = *value; /* make copy! */
 #if DEBUG_ONDEMAND
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "`%s' found value that matches.\n",
-      __FUNCTION__);
+  GE_LOG(ectx, 
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "`%s' found value that matches.\n",
+        __FUNCTION__);
 #endif
   return SYSERR;
 }
@@ -557,21 +573,28 @@
 
   fn = getOnDemandFile(fileId);
 #if DEBUG_ONDEMAND
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "Removing on-demand encoded data stored in `%s'.\n",
-      fn);
+  GE_LOG(ectx, 
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "Removing on-demand encoded data stored in `%s'.\n",
+        fn);
 #endif
-  fd = fileopen(fn,
-           O_RDONLY | O_LARGEFILE,
-           S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); /* 644 */
+  fd = disk_file_open(ectx,
+                     fn,
+                     O_RDONLY | O_LARGEFILE,
+                     S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); /* 644 */
   if(fd == -1) {
-    LOG_FILE_STRERROR(LOG_ERROR, "open", fn);
+    GE_LOG_STRERROR_FILE(ectx,
+                        GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, 
+                        "open", 
+                        fn);
     FREE(fn);
     return SYSERR;
   }
   pos = 0;
-  if (OK != getFileSize(fn,
-                       &size)) {
+  if (OK != disk_file_size(ectx,
+                          fn,
+                          &size,
+                          YES)) {
     FREE(fn);
     return SYSERR;
   }
@@ -584,8 +607,11 @@
     if (delta != READ(fd,
                      &block[1],
                      delta)) {
-      LOG_FILE_STRERROR(LOG_ERROR, "read", fn);
-      closefile(fd);
+      GE_LOG_STRERROR_FILE(ectx,
+                          GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, 
+                          "read", 
+                          fn);
+      CLOSE(fd);
       FREE(fn);
       FREE(block);
       return SYSERR;
@@ -623,7 +649,7 @@
     pos += delta;
   }
   FREE(block);
-  closefile(fd);
+  CLOSE(fd);
   UNLINK(fn);
 
   /* Remove information about unavailability */
@@ -642,7 +668,8 @@
 
 int ONDEMAND_init(CoreAPIForApplication * capi) {
   char * tmp;
-  
+
+  coreAPI = capi;
   ectx = capi->ectx;
   tmp
     = getConfigurationString("FS",
@@ -656,9 +683,11 @@
                              strlen("/data/shared/") + 1);
     strcat(tmp, "/data/shared/");
   }
-  index_directory = expandFileName(tmp);
+  index_directory = string_expandFileName(ectx,
+                                         tmp);
   FREE(tmp);
-  mkdirp(index_directory); /* just in case */  
+  disk_directory_create(ectx,
+                       index_directory); /* just in case */  
   return OK;
 }
 

Modified: GNUnet/src/applications/fs/tools/gnunet-delete.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-delete.c    2006-08-08 15:35:12 UTC 
(rev 3216)
+++ GNUnet/src/applications/fs/tools/gnunet-delete.c    2006-08-08 19:56:16 UTC 
(rev 3217)
@@ -124,7 +124,7 @@
  */
 int main(int argc, char ** argv) {
   int beVerbose;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   int ok;
   char * filename;
 

Modified: GNUnet/src/applications/fs/tools/gnunet-directory.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-directory.c 2006-08-08 15:35:12 UTC 
(rev 3216)
+++ GNUnet/src/applications/fs/tools/gnunet-directory.c 2006-08-08 19:56:16 UTC 
(rev 3217)
@@ -85,7 +85,7 @@
   fd = fileopen(name,
                O_LARGEFILE | O_RDONLY);
   if (fd == -1) {
-    LOG_FILE_STRERROR(LOG_ERROR, "open", name);
+    GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "open", name);
     ret = -1;
   } else {
     data = MMAP(NULL,
@@ -95,7 +95,7 @@
                fd,
                0);
     if (data == MAP_FAILED) {
-      LOG_FILE_STRERROR(LOG_ERROR, "mmap", name);
+      GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "mmap", name);
       ret = -1;
     } else {
       ret = ECRS_listDirectory(data,

Modified: GNUnet/src/applications/gap/gaptest.c
===================================================================
--- GNUnet/src/applications/gap/gaptest.c       2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/gap/gaptest.c       2006-08-08 19:56:16 UTC (rev 
3217)
@@ -255,7 +255,7 @@
   pid_t daemon1;
   pid_t daemon2;
   int ret;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   int left;
   struct ECRS_URI * uri;
 

Modified: GNUnet/src/applications/session/sessiontest.c
===================================================================
--- GNUnet/src/applications/session/sessiontest.c       2006-08-08 15:35:12 UTC 
(rev 3216)
+++ GNUnet/src/applications/session/sessiontest.c       2006-08-08 19:56:16 UTC 
(rev 3217)
@@ -62,7 +62,7 @@
   pid_t daemon1;
   pid_t daemon2;
   int ret;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   int left;
 
   GE_ASSERT(ectx, OK ==

Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c       2006-08-08 15:35:12 UTC 
(rev 3216)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c       2006-08-08 19:56:16 UTC 
(rev 3217)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other 
contributing authors)
+     (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -134,27 +134,26 @@
  * a failure of the command 'cmd' with the message given
  * by strerror(errno).
  */
-#define DIE_MYSQL(cmd, dbh) do { errexit(_("`%s' failed at %s:%d with error: 
%s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); } while(0);
+#define DIE_MYSQL(cmd, dbh) do { GE_LOG(ectx, GE_FATAL | GE_ADMIN | 
GE_IMMEDIATE, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, 
__LINE__, mysql_error((dbh)->dbf)); abort(); } while(0);
 
 /**
  * Log an error message at log-level 'level' that indicates
  * a failure of the command 'cmd' on file 'filename'
  * with the message given by strerror(errno).
  */
-#define LOG_MYSQL(level, cmd, dbh) do { LOG(level, _("`%s' failed at %s:%d 
with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); } 
while(0);
+#define LOG_MYSQL(level, cmd, dbh) do { GE_LOG(ectx, level, _("`%s' failed at 
%s:%d with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); } 
while(0);
 
 static Stats_ServiceAPI * stats;
 static CoreAPIForApplication * coreAPI;
 static unsigned int stat_size;
 
+static struct GE_Context * ectx;
 
-
 /**
  * @brief mysql wrapper
  */
 typedef struct {
   MYSQL * dbf;
-  Mutex DATABASE_Lock_;
   int avgLength_ID;       /* which column contains the Avg_row_length
                             * in SHOW TABLE STATUS resultset */
   char * cnffile;
@@ -171,6 +170,7 @@
   MYSQL_BIND dbind[7];
   MYSQL_STMT * update;
   MYSQL_BIND ubind[3];
+  struct MUTEX * DATABASE_Lock_;
 } mysqlHandle;
 
 #define INSERT_SAMPLE "INSERT INTO gn070 
(size,type,prio,anonLevel,expire,hash,value) VALUES (?,?,?,?,?,?,?)"
@@ -228,7 +228,7 @@
               sizeof(HashCode512),
               sizeof(Datastore_Value));
       if (0 != mysql_query(dbhI->dbf, scratch))
-       LOG_MYSQL(LOG_ERROR, "mysql_query", dbhI);
+       LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbhI);
     } else {
       GE_BREAK(ectx, 0); /* should really never happen */
     }
@@ -286,7 +286,7 @@
                     0);
   FREE(dbname);
   if (mysql_error(dbhI->dbf)[0]) {
-    LOG_MYSQL(LOG_ERROR,
+    LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
              "mysql_real_connect",
              dbhI);
     dbhI->dbf = NULL;
@@ -307,7 +307,7 @@
                " INDEX (expire)"
                ") TYPE=InnoDB");
     if (mysql_error(dbhI->dbf)[0]) {
-      LOG_MYSQL(LOG_ERROR,
+      LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
                "mysql_query",
                dbhI);
       mysql_close(dbhI->dbf);
@@ -317,7 +317,7 @@
     mysql_query(dbhI->dbf,
                "SET AUTOCOMMIT = 1");
     if (mysql_error(dbhI->dbf)[0]) {
-      LOG_MYSQL(LOG_ERROR,
+      LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
                "mysql_query",
                dbhI);
       mysql_close(dbhI->dbf);
@@ -433,7 +433,7 @@
     dbhI->prepare = YES;
   } else
     dbhI->prepare = NO;
-  MUTEX_CREATE(&dbhI->DATABASE_Lock_);
+  dbhI->DATABASE_Lock_ = MUTEX_CREATE(NO);
   return OK;
 }
 
@@ -461,7 +461,7 @@
     mysql_stmt_close(dbhI->deleteh);
     mysql_stmt_close(dbhI->deleteg);
   }
-  MUTEX_DESTROY(&dbhI->DATABASE_Lock_);
+  MUTEX_DESTROY(dbhI->DATABASE_Lock_);
   mysql_close(dbhI->dbf);
   dbhI->dbf = NULL;
   return OK;
@@ -492,7 +492,7 @@
   if (OK != iopen(&dbhI, NO))
     return SYSERR;
 
-  MUTEX_LOCK(&dbhI.DATABASE_Lock_);
+  MUTEX_LOCK(dbhI.DATABASE_Lock_);
 
   mysql_query(dbhI.dbf,
              "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED");
@@ -517,14 +517,14 @@
              scratch);
   FREE(scratch);
   if (mysql_error(dbhI.dbf)[0]) {
-    LOG_MYSQL(LOG_ERROR, "mysql_query", &dbhI);
-    MUTEX_UNLOCK(&dbhI.DATABASE_Lock_);
+    LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", &dbhI);
+    MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
     iclose(&dbhI);
     return SYSERR;
   }
 
   if (!(sql_res=mysql_use_result(dbhI.dbf))) {
-    MUTEX_UNLOCK(&dbhI.DATABASE_Lock_);
+    MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
     iclose(&dbhI);
     return SYSERR;
   }
@@ -534,7 +534,7 @@
                          sql_row,
                          &dbhI);
     if (datum == NULL) {
-      MUTEX_UNLOCK(&dbhI.DATABASE_Lock_);
+      MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
       iclose(&dbhI);
       return count;
     }
@@ -549,14 +549,14 @@
     count++;
   }
   if (mysql_error(dbhI.dbf)[0]) {
-    LOG_MYSQL(LOG_ERROR, "mysql_query", &dbhI);
+    LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", &dbhI);
     mysql_free_result(sql_res);
-    MUTEX_UNLOCK(&dbhI.DATABASE_Lock_);
+    MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
     iclose(&dbhI);
     return SYSERR;
   }            
   mysql_free_result(sql_res);
-  MUTEX_UNLOCK(&dbhI.DATABASE_Lock_);
+  MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
   iclose(&dbhI);
   return count;
 }
@@ -589,7 +589,7 @@
   if (OK != iopen(&dbhI, NO))
     return SYSERR;
 
-  MUTEX_LOCK(&dbhI.DATABASE_Lock_);
+  MUTEX_LOCK(dbhI.DATABASE_Lock_);
 
   mysql_query(dbhI.dbf,
              "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED");
@@ -613,14 +613,14 @@
              scratch);
   FREE(scratch);
   if (mysql_error(dbhI.dbf)[0]) {
-    LOG_MYSQL(LOG_ERROR, "mysql_query", &dbhI);
-    MUTEX_UNLOCK(&dbhI.DATABASE_Lock_);
+    LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", &dbhI);
+    MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
     iclose(&dbhI);
     return SYSERR;
   }
 
   if (!(sql_res=mysql_use_result(dbhI.dbf))) {
-    MUTEX_UNLOCK(&dbhI.DATABASE_Lock_);
+    MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
     iclose(&dbhI);
     return SYSERR;
   }
@@ -630,7 +630,7 @@
                          sql_row,
                          &dbhI);
     if (datum == NULL) {
-      MUTEX_UNLOCK(&dbhI.DATABASE_Lock_);
+      MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
       iclose(&dbhI);
       return count;
     }
@@ -644,14 +644,14 @@
     count++;
   }            
   if (mysql_error(dbhI.dbf)[0]) {
-    LOG_MYSQL(LOG_ERROR, "mysql_query", &dbhI);
+    LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", &dbhI);
     mysql_free_result(sql_res);
-    MUTEX_UNLOCK(&dbhI.DATABASE_Lock_);
+    MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
     iclose(&dbhI);
     return SYSERR;
   }
   mysql_free_result(sql_res);
-  MUTEX_UNLOCK(&dbhI.DATABASE_Lock_);
+  MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
   iclose(&dbhI);
   return count;
 }
@@ -702,7 +702,7 @@
       &enc,
       type);
 #endif
-  MUTEX_LOCK(&dbh->DATABASE_Lock_);
+  MUTEX_LOCK(dbh->DATABASE_Lock_);
   if (type != 0) {
     if (iter == NULL)
       stmt = dbh->selectsc;
@@ -726,12 +726,12 @@
        "mysql_stmt_result_metadata",
        __FILE__, __LINE__,
        mysql_stmt_error(stmt));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;
   }
   if (7 != mysql_num_fields(sql_res)) {
     GE_BREAK(ectx, 0);
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;
   }
   if (mysql_stmt_bind_param(stmt,
@@ -741,7 +741,7 @@
        "mysql_stmt_bind_param",
        __FILE__, __LINE__,
        mysql_stmt_error(stmt));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;
   }
   if (mysql_stmt_execute(stmt)) {
@@ -750,7 +750,7 @@
        "mysql_stmt_execute",
        __FILE__, __LINE__,
        mysql_stmt_error(stmt));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;
   }
 
@@ -774,7 +774,7 @@
        "mysql_stmt_bind_result",
        __FILE__, __LINE__,
        mysql_stmt_error(stmt));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     FREE(datum);
     return SYSERR;
   }
@@ -784,7 +784,7 @@
        "mysql_stmt_store_result",
        __FILE__, __LINE__,
        mysql_stmt_error(stmt));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     FREE(datum);
     return SYSERR;
   }
@@ -805,10 +805,10 @@
               sizeof(HashCode512),
               sizeof(Datastore_Value));
       if (0 != mysql_query(dbh->dbf, scratch))
-       LOG_MYSQL(LOG_ERROR, "mysql_query", dbh);
+       LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbh);
       
       FREE(datum);
-      MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+      MUTEX_UNLOCK(dbh->DATABASE_Lock_);
       return count;
     }
     count++;
@@ -841,7 +841,7 @@
   }
   mysql_free_result(sql_res);
   FREE(datum);
-  MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+  MUTEX_UNLOCK(dbh->DATABASE_Lock_);
 
 #if DEBUG_MYSQL
   IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
@@ -886,7 +886,7 @@
     GE_BREAK(ectx, 0);
     return SYSERR;
   }
-  MUTEX_LOCK(&dbh->DATABASE_Lock_);
+  MUTEX_LOCK(dbh->DATABASE_Lock_);
 
   contentSize = ntohl(value->size)-sizeof(Datastore_Value);
   hashSize = sizeof(HashCode512);
@@ -923,7 +923,7 @@
        "mysql_stmt_bind_param",
        __FILE__, __LINE__,
        mysql_stmt_error(dbh->insert));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;
   }
 
@@ -933,10 +933,10 @@
        "mysql_stmt_execute",
        __FILE__, __LINE__,
        mysql_stmt_error(dbh->insert));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;
   }
-  MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+  MUTEX_UNLOCK(dbh->DATABASE_Lock_);
   return OK;
 }
 
@@ -970,7 +970,7 @@
       &enc,
       value == NULL ? 0 : ntohl(value->type));
 #endif
-  MUTEX_LOCK(&dbh->DATABASE_Lock_);
+  MUTEX_LOCK(dbh->DATABASE_Lock_);
 
   twenty = sizeof(HashCode512);
 
@@ -1005,7 +1005,7 @@
        "mysql_stmt_bind_param",
        __FILE__, __LINE__,
        mysql_stmt_error(stmt));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;
   }
   if (mysql_stmt_execute(stmt)) {
@@ -1014,11 +1014,11 @@
        "mysql_stmt_execute",
        __FILE__, __LINE__,
        mysql_stmt_error(stmt));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;
   }
   count = mysql_stmt_affected_rows(stmt);
-  MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+  MUTEX_UNLOCK(dbh->DATABASE_Lock_);
 #if DEBUG_MYSQL
   GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
       "MySQL DELETE operation affected %d rows.\n",
@@ -1039,7 +1039,7 @@
   unsigned long twenty;
 
   twenty = sizeof(HashCode512);
-  MUTEX_LOCK(&dbh->DATABASE_Lock_);
+  MUTEX_LOCK(dbh->DATABASE_Lock_);
   contentSize = ntohl(value->size)-sizeof(Datastore_Value);
   dbh->ubind[0].buffer = (char*) &delta;
   dbh->ubind[1].buffer = (char*) key;
@@ -1054,7 +1054,7 @@
        "mysql_stmt_bind_param",
        __FILE__, __LINE__,
        mysql_stmt_error(dbh->update));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;
   }
   /* NOTE: as the table entry for 'prio' is defined as unsigned,
@@ -1068,10 +1068,10 @@
        "mysql_stmt_execute",
        __FILE__, __LINE__,
        mysql_stmt_error(dbh->update));
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;
   }
-  MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+  MUTEX_UNLOCK(dbh->DATABASE_Lock_);
   return OK;
 }
 
@@ -1089,14 +1089,14 @@
   long long rowsInTable = 0;
   unsigned long long bytesUsed;
 
-  MUTEX_LOCK(&dbh->DATABASE_Lock_);
+  MUTEX_LOCK(dbh->DATABASE_Lock_);
 
   /* find out average row length in bytes */
   mysql_query(dbh->dbf,
              "SHOW TABLE STATUS LIKE 'gn070'");
   if (mysql_error(dbh->dbf)[0]) {
     DIE_MYSQL("mysql_query", dbh); /* this MUST not fail... */
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     return SYSERR;     /* shouldn't get here */
   }
   if ((sql_res=mysql_store_result(dbh->dbf))) {
@@ -1106,7 +1106,7 @@
       GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
          _("Query `%s' had no results.\n"),
          "SHOW TABLE STATUS LIKE 'gn070'");
-      MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+      MUTEX_UNLOCK(dbh->DATABASE_Lock_);
       GE_BREAK(ectx, 0);
       return 0;        /* shouldn't get here */
     }
@@ -1124,7 +1124,7 @@
   mysql_query(dbh->dbf,
              "SELECT COUNT(*) FROM gn070");
   if (!(sql_res=mysql_store_result(dbh->dbf))) {
-    MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+    MUTEX_UNLOCK(dbh->DATABASE_Lock_);
     DIE_MYSQL("mysql_store_result", dbh);
   }
 
@@ -1138,7 +1138,7 @@
   }
   mysql_free_result(sql_res);
 
-  MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
+  MUTEX_UNLOCK(dbh->DATABASE_Lock_);
 
   bytesUsed = rowsInTable * avgRowLen;
 
@@ -1171,6 +1171,7 @@
   size_t nX;
   char *home_dir;
 
+  ectx = capi->ectx;
   coreAPI = capi;
   stats = coreAPI->requestService("stats");
   if (stats)
@@ -1181,7 +1182,9 @@
 #ifndef WINDOWS
   pw = getpwuid(getuid());
   if(!pw)
-    DIE_STRERROR("getpwuid");
+    GE_DIE_STRERROR(ectx, 
+                   GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+                   "getpwuid");
   home_dir = pw->pw_dir;
 #else
   home_dir = (char *) MALLOC(_MAX_PATH + 1);
@@ -1194,7 +1197,7 @@
     cnffile = MALLOC(nX);
     SNPRINTF(cnffile, nX, "%s/.my.cnf", home_dir);
   } else {
-    char * ex = expandFileName(cnffile);
+    char * ex = string_expandFileName(ectx, cnffile);
     FREE(cnffile);
     cnffile = ex;
   }
@@ -1206,7 +1209,7 @@
       cnffile);
   fp = FOPEN(cnffile, "r");
   if (!fp) {
-    LOG_FILE_STRERROR(LOG_ERROR, "fopen", cnffile);
+    GE_LOG_STRERROR_FILE(ectx, GE_ERROR | GE_ADMIN | GE_BULK, "fopen", 
cnffile);
     FREE(cnffile);
     return NULL;
   } else {
@@ -1230,7 +1233,7 @@
   mysql_query(dbh->dbf,
              "SHOW TABLE STATUS LIKE 'gn070'");
   if (mysql_error(dbh->dbf)[0]) {
-    LOG_MYSQL(LOG_ERROR,
+    LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
              "mysql_query",
              dbh);
     iclose(dbh);
@@ -1309,6 +1312,7 @@
 
   if (stats != NULL)
     coreAPI->releaseService(stats);
+  ectx = NULL;
 }
 
 /* end of mysql.c */

Modified: GNUnet/src/applications/tbench/tbenchtest.c
===================================================================
--- GNUnet/src/applications/tbench/tbenchtest.c 2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/tbench/tbenchtest.c 2006-08-08 19:56:16 UTC (rev 
3217)
@@ -42,7 +42,7 @@
  */
 static PeerIdentity peer2;
 
-static int test(GNUNET_TCP_SOCKET * sock,
+static int test(struct ClientServerConnection * sock,
                unsigned int messageSize,
                unsigned int messageCnt,
                unsigned int messageIterations,
@@ -69,13 +69,13 @@
   msg.priority    = htonl(5);
   msg.receiverId  = peer2;
 
-  if (SYSERR == writeToSocket(sock,
+  if (SYSERR == connection_write(sock,
                              &msg.header))
     return -1;
   ret = 0;
 
   buffer = NULL;
-  if (OK == readFromSocket(sock, (CS_MESSAGE_HEADER**)&buffer)) {
+  if (OK == connection_read(sock, (CS_MESSAGE_HEADER**)&buffer)) {
     if ((float)buffer->mean_loss <= 0){
       messagesPercentLoss = 0.0;
     } else {
@@ -110,7 +110,7 @@
   return OK;
 }
 
-static int checkConnected(GNUNET_TCP_SOCKET * sock) {
+static int checkConnected(struct ClientServerConnection * sock) {
   int left;
   int ret;
 
@@ -143,7 +143,7 @@
   pid_t daemon2;
   int ret;
   int left;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   int i;
 
   GE_ASSERT(ectx, OK ==

Modified: GNUnet/src/applications/tbench/tbenchtest_udp.c
===================================================================
--- GNUnet/src/applications/tbench/tbenchtest_udp.c     2006-08-08 15:35:12 UTC 
(rev 3216)
+++ GNUnet/src/applications/tbench/tbenchtest_udp.c     2006-08-08 19:56:16 UTC 
(rev 3217)
@@ -42,7 +42,7 @@
  */
 static PeerIdentity peer2;
 
-static int test(GNUNET_TCP_SOCKET * sock,
+static int test(struct ClientServerConnection * sock,
                unsigned int messageSize,
                unsigned int messageCnt,
                unsigned int messageIterations,
@@ -69,13 +69,13 @@
   msg.priority    = htonl(5);
   msg.receiverId  = peer2;
 
-  if (SYSERR == writeToSocket(sock,
+  if (SYSERR == connection_write(sock,
                              &msg.header))
     return -1;
   ret = 0;
 
   buffer = NULL;
-  if (OK == readFromSocket(sock, (CS_MESSAGE_HEADER**)&buffer)) {
+  if (OK == connection_read(sock, (CS_MESSAGE_HEADER**)&buffer)) {
     if ((float)buffer->mean_loss <= 0){
       messagesPercentLoss = 0.0;
     } else {
@@ -110,7 +110,7 @@
   return OK;
 }
 
-static int checkConnected(GNUNET_TCP_SOCKET * sock) {
+static int checkConnected(struct ClientServerConnection * sock) {
   int left;
   int ret;
 
@@ -143,7 +143,7 @@
   pid_t daemon2;
   int ret;
   int left;
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   int i;
 
   GE_ASSERT(ectx, OK ==

Modified: GNUnet/src/applications/testbed/commands.c
===================================================================
--- GNUnet/src/applications/testbed/commands.c  2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/testbed/commands.c  2006-08-08 19:56:16 UTC (rev 
3217)
@@ -51,7 +51,7 @@
   /** string describing the peer address */
   char * ips;
   /** socket to communicate with the peer */
-  GNUNET_TCP_SOCKET sock;
+  struct ClientServerConnection sock;
   /** hello message identifying the peer in the network */
   P2P_hello_MESSAGE * helo;
   /** if we're using ssh, what is the PID of the
@@ -125,7 +125,7 @@
   memcpy(&((TESTBED_CS_MESSAGE_GENERIC*)msg)->data[0],
         arg,
         argSize);
-  msgsz = writeToSocket(&nodes[peer].sock,
+  msgsz = connection_write(&nodes[peer].sock,
                        &msg->header);
   FREE(msg);
   if (msgsz == SYSERR) {
@@ -144,7 +144,7 @@
  */
 static int readResult(int peer,
                      int * result) {
-  if (OK != readTCPResult(&nodes[peer].sock,
+  if (OK != connection_read_result(&nodes[peer].sock,
                          result)) {
     XPRINTF(" peer %s is not responding.\n",
           nodes[peer].ips);
@@ -220,7 +220,7 @@
   }
 
   hdr = NULL;
-  if (SYSERR == readFromSocket(&nodes[currindex].sock,
+  if (SYSERR == connection_read(&nodes[currindex].sock,
                               (CS_MESSAGE_HEADER**)&hdr)) {
     XPRINTF(" peer %s is not responding.\n",
           nodes[currindex].ips);
@@ -417,7 +417,7 @@
   }
 
   hdr = NULL;
-  if (SYSERR == readFromSocket(&nodes[currindex].sock,
+  if (SYSERR == connection_read(&nodes[currindex].sock,
                               (CS_MESSAGE_HEADER**)&hdr)) {
     XPRINTF(" peer %s is not responding.\n",
           nodes[currindex].ips);
@@ -970,7 +970,7 @@
       TESTBED_OUTPUT_REPLY_MESSAGE * reply;
 
       reply = NULL;
-      if (SYSERR == readFromSocket(&nodes[dst].sock,
+      if (SYSERR == connection_read(&nodes[dst].sock,
                                   (CS_MESSAGE_HEADER**)&reply)) {
        XPRINTF(" peer %s is not responding after %d of %d bytes.\n",
               nodes[dst].ips,
@@ -1257,7 +1257,7 @@
     = htonl(TESTBED_FILE_DELETE);
   memcpy(((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC*)msg)->buf, argv[2], flen);
 
-  if (SYSERR == writeToSocket(&nodes[peer].sock,
+  if (SYSERR == connection_write(&nodes[peer].sock,
                              &msg->header.header)) {
     fclose(infile);
     FREE(msg);
@@ -1266,7 +1266,7 @@
     return -1;
   }
   /* Read ack from the peer */
-  if (OK != readTCPResult(&nodes[peer].sock, &ack)) {
+  if (OK != connection_read_result(&nodes[peer].sock, &ack)) {
     fclose(infile);
     FREE(msg);
     XPRINTF("Peer is not responding\n");
@@ -1288,7 +1288,7 @@
       break;
     msg->header.header.size = htons(sizeof(TESTBED_UPLOAD_FILE_MESSAGE) +
                                    nbytes + flen);
-    if (SYSERR == writeToSocket(&nodes[peer].sock, &msg->header.header)) {
+    if (SYSERR == connection_write(&nodes[peer].sock, &msg->header.header)) {
       fclose(infile);
       FREE(msg);
       XPRINTF(" could not send file to node %s.\n",

Modified: GNUnet/src/applications/testbed/testbed.c
===================================================================
--- GNUnet/src/applications/testbed/testbed.c   2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/testbed/testbed.c   2006-08-08 19:56:16 UTC (rev 
3217)
@@ -534,7 +534,7 @@
     FREE(dir);
     execvp(pi->argv[0],
           &pi->argv[0]);
-    LOG_FILE_STRERROR(LOG_ERROR, "execvp", pi->argv[0]);
+    GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "execvp", pi->argv[0]);
     fprintf(stderr,
            _("`%s' %s failed: %s\n"),
            "execvp",
@@ -854,7 +854,7 @@
          end - ((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC*)msg)->buf);
   if (htonl(msg->type) == TESTBED_FILE_DELETE) {
     if (REMOVE(filename) && errno != ENOENT) {
-      LOG_FILE_STRERROR(LOG_WARNING, "remove", filename);
+      GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "remove", filename);
       ack = SYSERR;
     } else
       ack = OK;
@@ -873,7 +873,7 @@
   outfile = FOPEN(filename, "ab");
   if (outfile == NULL) {
     /* Send nack back to control point. */
-    LOG_FILE_STRERROR(LOG_ERROR, "fopen", filename);
+    GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "fopen", filename);
     sendAcknowledgement(client, SYSERR);
     FREE(filename);
     return;

Modified: GNUnet/src/applications/vpn/gnunet-vpn.c
===================================================================
--- GNUnet/src/applications/vpn/gnunet-vpn.c    2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/applications/vpn/gnunet-vpn.c    2006-08-08 19:56:16 UTC (rev 
3217)
@@ -122,14 +122,14 @@
   return OK;
 }
 
-static void * receiveThread(GNUNET_TCP_SOCKET * sock) {
+static void * receiveThread(struct ClientServerConnection * sock) {
   /* printf("Welcome to the VPN console: (Ctrl-D to exit)\n"); */
   /* CS_MESSAGE_HEADER *buffer; */
   char buffer[MAX_BUFFER_SIZE];
   CS_MESSAGE_HEADER* bufp = buf;
       
   /* buffer = MALLOC(MAX_BUFFER_SIZE); */
-  while (OK == readFromSocket(sock, &bufp)) {
+  while (OK == connection_read(sock, &bufp)) {
        switch (ntohs(buf->type)) {
                case CS_PROTO_VPN_DEBUGOFF:
                case CS_PROTO_VPN_DEBUGON:
@@ -181,7 +181,7 @@
  * @return return value from gnunet-template: 0: ok, -1: error
  */
 int main(int argc, char ** argv) {
-  GNUNET_TCP_SOCKET * sock;
+  struct ClientServerConnection * sock;
   PTHREAD_T messageReceiveThread;
   void * unused;
   char buffer[sizeof(CS_MESSAGE_HEADER) + 1024];
@@ -213,49 +213,49 @@
        if (strncmp(buffer, "debug0", 6) == 0) {
                ((CS_MESSAGE_HEADER*)&buffer)->type = 
htons(CS_PROTO_VPN_DEBUGOFF);
                ((CS_MESSAGE_HEADER*)&buffer)->size = 
htons(sizeof(CS_MESSAGE_HEADER));
-               if (SYSERR == writeToSocket(sock, (CS_MESSAGE_HEADER*)&buffer)) 
return -1;
+               if (SYSERR == connection_write(sock, 
(CS_MESSAGE_HEADER*)&buffer)) return -1;
                rancommand = 1;
                SEMAPHORE_DOWN(cmdAck);
        } else if (strncmp(buffer, "debug1", 6) == 0) {
                ((CS_MESSAGE_HEADER*)&buffer)->type = 
htons(CS_PROTO_VPN_DEBUGON);
                ((CS_MESSAGE_HEADER*)&buffer)->size = 
htons(sizeof(CS_MESSAGE_HEADER));
-               if (SYSERR == writeToSocket(sock, (CS_MESSAGE_HEADER*)&buffer)) 
return -1;
+               if (SYSERR == connection_write(sock, 
(CS_MESSAGE_HEADER*)&buffer)) return -1;
                rancommand = 1;
                SEMAPHORE_DOWN(cmdAck);
        } else if (strncmp(buffer, "tunnels", 7) == 0) {
                ((CS_MESSAGE_HEADER*)&buffer)->type = 
htons(CS_PROTO_VPN_TUNNELS);
                ((CS_MESSAGE_HEADER*)&buffer)->size = 
htons(sizeof(CS_MESSAGE_HEADER));
-               if (SYSERR == writeToSocket(sock, (CS_MESSAGE_HEADER*)&buffer)) 
return -1;
+               if (SYSERR == connection_write(sock, 
(CS_MESSAGE_HEADER*)&buffer)) return -1;
                rancommand = 1;
                SEMAPHORE_DOWN(cmdAck);
        } else if (strncmp(buffer, "route", 5) == 0) {
                ((CS_MESSAGE_HEADER*)&buffer)->type = 
htons(CS_PROTO_VPN_ROUTES);
                ((CS_MESSAGE_HEADER*)&buffer)->size = 
htons(sizeof(CS_MESSAGE_HEADER));
-               if (SYSERR == writeToSocket(sock, (CS_MESSAGE_HEADER*)&buffer)) 
return -1;
+               if (SYSERR == connection_write(sock, 
(CS_MESSAGE_HEADER*)&buffer)) return -1;
                rancommand = 1;
                SEMAPHORE_DOWN(cmdAck);
        } else if (strncmp(buffer, "realised", 8) == 0) {
                ((CS_MESSAGE_HEADER*)&buffer)->type = 
htons(CS_PROTO_VPN_REALISED);
                ((CS_MESSAGE_HEADER*)&buffer)->size = 
htons(sizeof(CS_MESSAGE_HEADER));
-               if (SYSERR == writeToSocket(sock, (CS_MESSAGE_HEADER*)&buffer)) 
return -1;
+               if (SYSERR == connection_write(sock, 
(CS_MESSAGE_HEADER*)&buffer)) return -1;
                rancommand = 1;
                SEMAPHORE_DOWN(cmdAck);
        } else if (strncmp(buffer, "reset", 5) == 0) {
                ((CS_MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_RESET);
                ((CS_MESSAGE_HEADER*)&buffer)->size = 
htons(sizeof(CS_MESSAGE_HEADER));
-               if (SYSERR == writeToSocket(sock, (CS_MESSAGE_HEADER*)&buffer)) 
return -1;
+               if (SYSERR == connection_write(sock, 
(CS_MESSAGE_HEADER*)&buffer)) return -1;
                rancommand = 1;
                SEMAPHORE_DOWN(cmdAck);
        } else if (strncmp(buffer, "realise", 7) == 0) {
                ((CS_MESSAGE_HEADER*)&buffer)->type = 
htons(CS_PROTO_VPN_REALISE);
                ((CS_MESSAGE_HEADER*)&buffer)->size = 
htons(sizeof(CS_MESSAGE_HEADER));
-               if (SYSERR == writeToSocket(sock, (CS_MESSAGE_HEADER*)&buffer)) 
return -1;
+               if (SYSERR == connection_write(sock, 
(CS_MESSAGE_HEADER*)&buffer)) return -1;
                rancommand = 1;
                SEMAPHORE_DOWN(cmdAck);
        } else if (strncmp(buffer, "trust", 5) == 0) {
                ((CS_MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_TRUST);
                ((CS_MESSAGE_HEADER*)&buffer)->size = 
htons(sizeof(CS_MESSAGE_HEADER));
-               if (SYSERR == writeToSocket(sock, (CS_MESSAGE_HEADER*)&buffer)) 
return -1;
+               if (SYSERR == connection_write(sock, 
(CS_MESSAGE_HEADER*)&buffer)) return -1;
                rancommand = 1;
                SEMAPHORE_DOWN(cmdAck);
        } else if (strncmp(buffer, "add ", 4) == 0) {
@@ -265,7 +265,7 @@
                if (strlen(&buffer[4]) > 1) {
                        ((CS_MESSAGE_HEADER*)&buffer)->type = 
htons(CS_PROTO_VPN_ADD);
                        ((CS_MESSAGE_HEADER*)&buffer)->size = 
htons(sizeof(CS_MESSAGE_HEADER) + strlen(&buffer[5]));
-                       if (SYSERR == writeToSocket(sock, 
(CS_MESSAGE_HEADER*)&buffer)) return -1;
+                       if (SYSERR == connection_write(sock, 
(CS_MESSAGE_HEADER*)&buffer)) return -1;
                        rancommand = 1;
                        SEMAPHORE_DOWN(cmdAck);
                } else {

Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h        2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/include/gnunet_ecrs_lib.h        2006-08-08 19:56:16 UTC (rev 
3217)
@@ -49,9 +49,10 @@
  * 3.1.x: with namespace meta-data
  * 3.2.x: with collections
  * 4.0.x: with expiration, variable meta-data, kblocks
+ * 4.1.x: with new error and configuration handling
  * 5.x.x: who knows? :-)
  */
-#define AFS_VERSION "4.0.2"
+#define AFS_VERSION "4.1.0"
 
 #define GNUNET_DIRECTORY_MIME  "application/gnunet-directory"
 #define GNUNET_DIRECTORY_MAGIC "\211GND\r\n\032\n"
@@ -183,7 +184,8 @@
  * @return SYSERR on error, otherwise the number
  *   of meta-data items obtained
  */
-int ECRS_extractMetaData(struct ECRS_MetaData * md,
+int ECRS_extractMetaData(struct GE_Context * ectx,
+                        struct ECRS_MetaData * md,
                         const char * filename,
                         EXTRACTOR_ExtractorList * extractors);
 
@@ -208,7 +210,8 @@
  *         SYSERR on error (typically: not enough
  *         space)
  */
-int ECRS_serializeMetaData(const struct ECRS_MetaData * md,
+int ECRS_serializeMetaData(struct GE_Context * ectx,
+                          const struct ECRS_MetaData * md,
                           char * target,
                           unsigned int size,
                           int part);
@@ -228,7 +231,8 @@
  *         bad format)
  */
 struct ECRS_MetaData *
-ECRS_deserializeMetaData(const char * input,
+ECRS_deserializeMetaData(struct GE_Context * ectx,
+                        const char * input,
                         unsigned int size);
 
 /**
@@ -244,7 +248,8 @@
  * Suggest a better filename for a file (and do the
  * renaming).
  */
-char * ECRS_suggestFilename(const char * filename);
+char * ECRS_suggestFilename(struct GE_Context * ectx,
+                           const char * filename);
 
 /* ******************** URI (uri.c) ************************ */
 
@@ -262,12 +267,14 @@
  * Convert a NULL-terminated array of keywords
  * to an ECRS URI.
  */
-struct ECRS_URI * ECRS_keywordsToUri(const char * keyword[]);
+struct ECRS_URI * ECRS_keywordsToUri(struct GE_Context * ectx,
+                                    const char * keyword[]);
 
 /**
  * Convert a UTF-8 String to a URI.
  */
-struct ECRS_URI * ECRS_stringToUri(const char * uri);
+struct ECRS_URI * ECRS_stringToUri(struct GE_Context * ectx,
+                                  const char * uri);
 
 /**
  * Free URI.
@@ -409,7 +416,8 @@
  * @return SYSERR if the upload failed (i.e. not enough space
  *  or gnunetd not running)
  */
-int ECRS_uploadFile(const char * filename,
+int ECRS_uploadFile(struct GE_Context * ectx,
+                   const char * filename,
                    int doIndex,
                    unsigned int anonymityLevel,
                    unsigned int priority,
@@ -429,7 +437,8 @@
  *  in either case, if SYSERR is returned the user should probably
  *  be notified that 'something is wrong')
  */
-int ECRS_isFileIndexed(const char * filename);
+int ECRS_isFileIndexed(struct GE_Context * ectx,
+                      const char * filename);
 
 /**
  * @return OK to continue iteration, SYSERR to abort
@@ -449,7 +458,8 @@
  *
  * @return number of files indexed, SYSERR if iterator aborted
  */
-int ECRS_iterateIndexedFiles(ECRS_FileIterator iterator,
+int ECRS_iterateIndexedFiles(struct GE_Context * ectx,
+                            ECRS_FileIterator iterator,
                             void * closure);
 
 /**
@@ -457,7 +467,8 @@
  *
  * @return SYSERR if the unindexing failed (i.e. not indexed)
  */
-int ECRS_unindexFile(const char * filename,
+int ECRS_unindexFile(struct GE_Context * ectx,
+                    const char * filename,
                     ECRS_UploadProgressCallback upcb,
                     void * upcbClosure,
                     ECRS_TestTerminate tt,
@@ -485,7 +496,8 @@
  * @return URI on success, NULL on error (namespace already exists)
  */
 struct ECRS_URI *
-ECRS_createNamespace(const char * name,
+ECRS_createNamespace(struct GE_Context * ectx,
+                    const char * name,
                     const struct ECRS_MetaData * meta,
                     unsigned int anonymityLevel,
                     unsigned int priority,
@@ -499,7 +511,8 @@
  *   hc of the public key
  * @return OK if the namespace exists, SYSERR if not
  */
-int ECRS_testNamespaceExists(const char * name,
+int ECRS_testNamespaceExists(struct GE_Context * ectx,
+                            const char * name,
                             const HashCode512 * hc);
 
 /**
@@ -509,7 +522,8 @@
  *
  * @return OK on success, SYSERR on error
  */
-int ECRS_deleteNamespace(const char * namespaceName); /* namespace.c */
+int ECRS_deleteNamespace(struct GE_Context * ectx,
+                        const char * namespaceName); /* namespace.c */
 
 /**
  * Callback with information about local (!) namespaces.
@@ -528,7 +542,8 @@
  * @param list where to store the names (is allocated, caller frees)
  * @return SYSERR on error, otherwise the number of pseudonyms in list
  */
-int ECRS_listNamespaces(ECRS_NamespaceInfoCallback cb,
+int ECRS_listNamespaces(struct GE_Context * ectx,
+                       ECRS_NamespaceInfoCallback cb,
                        void * cls); /* namespace.c */
 
 /**
@@ -542,7 +557,8 @@
  * @return URI on success, NULL on error
  */
 struct ECRS_URI *
-ECRS_addToNamespace(const char * name,
+ECRS_addToNamespace(struct GE_Context * ectx,
+                   const char * name,
                    unsigned int anonymityLevel,
                    unsigned int priority,
                    cron_t expirationTime,
@@ -562,7 +578,8 @@
  * @param md what meta-data should be associated with the
  *        entry?
  */
-int ECRS_addToKeyspace(const struct ECRS_URI * uri,
+int ECRS_addToKeyspace(struct GE_Context * ectx,
+                      const struct ECRS_URI * uri,
                       unsigned int anonymityLevel,
                       unsigned int priority,
                       cron_t expirationTime,
@@ -593,7 +610,8 @@
  * @param uri specifies the search parameters
  * @param uri set to the URI of the uploaded file
  */
-int ECRS_search(const struct ECRS_URI * uri,
+int ECRS_search(struct GE_Context * ectx,
+               const struct ECRS_URI * uri,
                unsigned int anonymityLevel,
                cron_t timeout,
                ECRS_SearchProgressCallback spcb,
@@ -630,7 +648,8 @@
  * @param uri the URI of the file (determines what to download)
  * @param filename where to store the file
  */
-int ECRS_downloadFile(const struct ECRS_URI * uri,
+int ECRS_downloadFile(struct GE_Context * ectx,
+                     const struct ECRS_URI * uri,
                      const char * filename,
                      unsigned int anonymityLevel,
                      ECRS_DownloadProgressCallback dpcb,
@@ -652,7 +671,8 @@
  * @return number of entries on success, SYSERR if the
  *         directory is malformed
  */
-int ECRS_listDirectory(const char * data,
+int ECRS_listDirectory(struct GE_Context * ectx,
+                      const char * data,
                       unsigned long long len,
                       struct ECRS_MetaData ** md,
                       ECRS_SearchProgressCallback spcb,
@@ -671,7 +691,8 @@
  *        is extended with the mime-type for a GNUnet directory.
  * @return OK on success, SYSERR on error
  */
-int ECRS_createDirectory(char ** data,
+int ECRS_createDirectory(struct GE_Context * ectx,
+                        char ** data,
                         unsigned long long * len,
                         unsigned int count,
                         const ECRS_FileInfo * fis,

Modified: GNUnet/src/include/gnunet_fs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fs_lib.h  2006-08-08 15:35:12 UTC (rev 3216)
+++ GNUnet/src/include/gnunet_fs_lib.h  2006-08-08 19:56:16 UTC (rev 3217)
@@ -32,6 +32,7 @@
 #define GNUNET_FS_LIB_H
 
 #include "gnunet_util.h"
+#include "gnunet_util_network_client.h"
 #include "gnunet_datastore_service.h"
 
 #ifdef __cplusplus
@@ -44,7 +45,9 @@
 
 struct FS_SEARCH_CONTEXT;
 
-struct FS_SEARCH_CONTEXT * FS_SEARCH_makeContext(Mutex * lock);
+struct FS_SEARCH_CONTEXT * FS_SEARCH_makeContext(struct GE_Context * ectx,
+                                                struct GC_Configuration * cfg,
+                                                struct MUTEX * lock);
 
 void FS_SEARCH_destroyContext(struct FS_SEARCH_CONTEXT * ctx);
 
@@ -80,7 +83,7 @@
  * What is the current average priority of entries
  * in the routing table like?  Returns -1 on error.
  */
-int FS_getAveragePriority(GNUNET_TCP_SOCKET * sock);
+int FS_getAveragePriority(struct ClientServerConnection * sock);
 
 /**
  * Insert a block.  Note that while the API is VERY similar to
@@ -91,14 +94,14 @@
  * @return OK on success, SYSERR on error
  * @see ecrs_core.h::fileBlockEncode
  */
-int FS_insert(GNUNET_TCP_SOCKET * sock,
+int FS_insert(struct ClientServerConnection * sock,
              const Datastore_Value * block);
 
 
 /**
  * Initialize to index a file.  Tries to do the symlinking.
  */
-int FS_initIndex(GNUNET_TCP_SOCKET * sock,
+int FS_initIndex(struct ClientServerConnection * sock,
                 const HashCode512 * fileHc,
                 const char * fn);
 
@@ -112,7 +115,7 @@
  * @param offset the offset of the block into the file
  * @return OK on success, SYSERR on error
  */
-int FS_index(GNUNET_TCP_SOCKET * sock,
+int FS_index(struct ClientServerConnection * sock,
             const HashCode512 * fileHc,        
             const Datastore_Value * block,
             unsigned long long offset);
@@ -125,7 +128,7 @@
  * @return number of items deleted on success,
  *    SYSERR on error
  */
-int FS_delete(GNUNET_TCP_SOCKET * sock,
+int FS_delete(struct ClientServerConnection * sock,
              const Datastore_Value * block);
 
 /**
@@ -134,7 +137,7 @@
  * @param hc the hash of the entire file
  * @return OK on success, SYSERR on error
  */
-int FS_unindex(GNUNET_TCP_SOCKET * sock,
+int FS_unindex(struct ClientServerConnection * sock,
               unsigned int blocksize,
               const HashCode512 * hc);
 
@@ -144,7 +147,7 @@
  * @param hc the hash of the entire file
  * @return YES if so, NO if not, SYSERR on error
  */
-int FS_testIndexed(GNUNET_TCP_SOCKET * sock,
+int FS_testIndexed(struct ClientServerConnection * sock,
                   const HashCode512 * hc);
 
 

Modified: GNUnet/src/include/gnunet_util_network_client.h
===================================================================
--- GNUnet/src/include/gnunet_util_network_client.h     2006-08-08 15:35:12 UTC 
(rev 3216)
+++ GNUnet/src/include/gnunet_util_network_client.h     2006-08-08 19:56:16 UTC 
(rev 3217)
@@ -54,7 +54,7 @@
  * Close a GNUnet TCP socket for now (use to temporarily close
  * a TCP connection that will probably not be used for a long
  * time; the socket will still be auto-reopened by the
- * readFromSocket/writeToSocket methods if it is a client-socket).
+ * connection_read/connection_write methods if it is a client-socket).
  *
  * Also, you must still call connection_destroy to free all
  * resources associated with the connection.

Modified: GNUnet/src/util/network_client/tcpio.c
===================================================================
--- GNUnet/src/util/network_client/tcpio.c      2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/util/network_client/tcpio.c      2006-08-08 19:56:16 UTC (rev 
3217)
@@ -249,7 +249,7 @@
 
 /**
  * Write to a GNUnet TCP socket.  Will also potentially complete the
- * sending of a previous non-blocking writeToSocket call.
+ * sending of a previous non-blocking connection_write call.
  *
  * @param sock the socket to write to
  * @param buffer the buffer to write

Modified: GNUnet/src/util/network_client/tcpiotest.c
===================================================================
--- GNUnet/src/util/network_client/tcpiotest.c  2006-08-08 15:35:12 UTC (rev 
3216)
+++ GNUnet/src/util/network_client/tcpiotest.c  2006-08-08 19:56:16 UTC (rev 
3217)
@@ -120,8 +120,8 @@
   return OK;
 }
 
-static int testTransmission(GNUNET_TCP_SOCKET * a,
-                           GNUNET_TCP_SOCKET * b) {
+static int testTransmission(struct ClientServerConnection * a,
+                           struct ClientServerConnection * b) {
   CS_MESSAGE_HEADER * hdr;
   CS_MESSAGE_HEADER * buf;
   int i;
@@ -134,12 +134,12 @@
       ((char*)&hdr[1])[j] = (char)i+j;
     hdr->size = htons(i+sizeof(CS_MESSAGE_HEADER));
     hdr->type = 0;
-    if (OK != writeToSocket(a, hdr)) {
+    if (OK != connection_write(a, hdr)) {
       FREE(hdr);
       return 1;
     }
     buf = NULL;
-    if (OK != readFromSocket(b, &buf)) {
+    if (OK != connection_read(b, &buf)) {
       FREE(hdr);
       return 2;
     }
@@ -154,8 +154,8 @@
   return 0;
 }
 
-static int testNonblocking(GNUNET_TCP_SOCKET * a,
-                          GNUNET_TCP_SOCKET * b) {
+static int testNonblocking(struct ClientServerConnection * a,
+                          struct ClientServerConnection * b) {
   CS_MESSAGE_HEADER * hdr;
   CS_MESSAGE_HEADER * buf;
   int i;
@@ -166,7 +166,7 @@
     ((char*)&hdr[1])[i] = (char)i;
   hdr->size = htons(64+sizeof(CS_MESSAGE_HEADER));
   hdr->type = 0;
-  while (OK == writeToSocketNonBlocking(a,
+  while (OK == connection_writeNonBlocking(a,
                                        hdr))
     hdr->type++;
   i = 0;
@@ -177,7 +177,7 @@
   for (i=0;i<cnt;i++) {
     hdr->type = i;
     buf = NULL;
-    if (OK != readFromSocket(b, &buf)) {
+    if (OK != connection_read(b, &buf)) {
       FREE(hdr);
       return 16;
     }
@@ -194,7 +194,7 @@
     if (i == cnt - 2) {
       /* printf("Blocking write to flush last non-blocking message.\n"); */
       hdr->type = cnt;
-      if (OK != writeToSocket(a,
+      if (OK != connection_write(a,
                              hdr)) {
        FREE(hdr);
        return 64;
@@ -203,7 +203,7 @@
   }
   hdr->type = i;
   buf = NULL;
-  if (OK != readFromSocket(b, &buf)) {
+  if (OK != connection_read(b, &buf)) {
     FREE(hdr);
     return 128;
   }
@@ -221,8 +221,8 @@
   int i;
   int ret;
   int serverSocket;
-  GNUNET_TCP_SOCKET * clientSocket;
-  GNUNET_TCP_SOCKET acceptSocket;
+  struct ClientServerConnection * clientSocket;
+  struct ClientServerConnection acceptSocket;
 
   ret = 0;
   initUtil(argc, argv, &parseCommandLine);

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-08-08 15:35:12 UTC (rev 3216)
+++ GNUnet/todo 2006-08-08 19:56:16 UTC (rev 3217)
@@ -26,7 +26,7 @@
   * applications:
     + fragmentation, identity,  pingpong, session, transport,
       stats, topology_default, state, getoption, advertising,
-      traffic, ecrs_core, template, tbench, tracekit compile
+      traffic, ecrs_core, template, tbench, tracekit, fs/fslib compile
     + bootstrap_http: maybe switch to libwww?
     + for fs: fs (18500), gap (2800)
     + rest: sqstore_mysql, dht, rpc, topology_f2f, vpn





reply via email to

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