gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1919 - in GNUnet/src: applications/identity applications/s


From: grothoff
Subject: [GNUnet-SVN] r1919 - in GNUnet/src: applications/identity applications/session include server util
Date: Thu, 25 Aug 2005 22:14:22 -0700 (PDT)

Author: grothoff
Date: 2005-08-25 22:14:19 -0700 (Thu, 25 Aug 2005)
New Revision: 1919

Modified:
   GNUnet/src/applications/identity/identity.c
   GNUnet/src/applications/session/connect.c
   GNUnet/src/include/gnunet_util.h
   GNUnet/src/server/connection.c
   GNUnet/src/util/storage.c
Log:
fancy

Modified: GNUnet/src/applications/identity/identity.c
===================================================================
--- GNUnet/src/applications/identity/identity.c 2005-08-26 04:55:24 UTC (rev 
1918)
+++ GNUnet/src/applications/identity/identity.c 2005-08-26 05:14:19 UTC (rev 
1919)
@@ -255,9 +255,14 @@
   MUTEX_LOCK(&lock_);
   host = findHost(hostId);
   if (host == NULL) {
-    BREAK();
-    MUTEX_UNLOCK(&lock_);
-    return 0;
+    addHostToKnown(hostId,
+                  NAT_PROTOCOL_NUMBER);
+    host = findHost(hostId);
+    if (host == NULL) {
+      BREAK();
+      MUTEX_UNLOCK(&lock_);
+      return 0;
+    }
   }
   if ( ((int) (host->trust & TRUST_ACTUAL_MASK)) + value < 0) {
     value = - (host->trust & TRUST_ACTUAL_MASK);

Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c   2005-08-26 04:55:24 UTC (rev 
1918)
+++ GNUnet/src/applications/session/connect.c   2005-08-26 05:14:19 UTC (rev 
1919)
@@ -591,7 +591,7 @@
        pong = hdr;
       else
        LOG(LOG_WARNING,
-           "Unknown type in embedded message: %u (size: %u)\n",
+           _("Unknown type in embedded message: %u (size: %u)\n"),
            htons(hdr->type),
            htons(hdr->size));
       pos += ntohs(hdr->size);

Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h    2005-08-26 04:55:24 UTC (rev 1918)
+++ GNUnet/src/include/gnunet_util.h    2005-08-26 05:14:19 UTC (rev 1919)
@@ -1236,6 +1236,11 @@
 char * timeIntervalToFancyString(cron_t delta);
 
 /**
+ * Convert a given filesize into a fancy human-readable format.
+ */
+char * fileSizeToFancyString(unsigned long long size);
+
+/**
  * Create a new Session key.
  */
 void makeSessionkey(SESSIONKEY * key);

Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c      2005-08-26 04:55:24 UTC (rev 1918)
+++ GNUnet/src/server/connection.c      2005-08-26 05:14:19 UTC (rev 1919)
@@ -2392,7 +2392,7 @@
     if (forSending == YES) {
       be->skey_local = *key;
       be->skey_local_created = age;
-      be->status |= STAT_SKEY_SENT;
+      be->status = STAT_SKEY_SENT | (be->status & STAT_SKEY_RECEIVED);
     } else { /* for receiving */
       if ( ((be->status & STAT_SKEY_RECEIVED) == 0) ||
           (be->skey_remote_created < age) ) {

Modified: GNUnet/src/util/storage.c
===================================================================
--- GNUnet/src/util/storage.c   2005-08-26 04:55:24 UTC (rev 1918)
+++ GNUnet/src/util/storage.c   2005-08-26 05:14:19 UTC (rev 1919)
@@ -647,6 +647,36 @@
   }
 }
 
+char * fileSizeToFancyString(unsigned long long size) {
+  const char * unit = _(/* size unit */ "b");
+  char * ret;
+
+  if (delta > 5 * 1024) {
+    delta = delta / 1024;
+    unit = _(/* size unit */ "k");
+    if (delta > 5 * 1024) {
+      delta = delta / 1024;
+      unit = _(/* size unit */ "m");
+      if (delta > 5 * 1024) {
+       delta = delta / 1024;
+       unit = _(/* size unit */ "g");
+       if (delta > 5 * 1024) {
+         delta = delta / 1024;
+         unit = _(/* size unit */ "t");              
+       }           
+      }                
+    }  
+  }    
+  ret = MALLOC(32);
+  SNPRINTF(ret, 
+          32, 
+          "%llu%s",
+          delta, 
+          unit);
+  return ret;
+}
+
+
 #define COPY_BLK_SIZE 65536
 
 /**





reply via email to

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