handling replies continuously from server
[oweals/gnunet.git] / src / util / common_logging.c
index 59de9622664fea9b37de07247797a4d81c093a7c..2c0fd57a817845ca4313d650f36544cc5fc9798e 100644 (file)
@@ -530,6 +530,8 @@ parse_all_definitions ()
   gnunet_force_log_parsed = GNUNET_YES;
 }
 #endif
+
+
 /**
  * Setup logging.
  *
@@ -569,30 +571,29 @@ GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile)
   if (NULL == fn)
     return GNUNET_SYSERR;
   dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn));
-  altlog_fd = OPEN (fn, O_APPEND |
 #if WINDOWS
+  altlog_fd = OPEN (fn, O_APPEND |
                         O_BINARY |
-#endif
                         O_WRONLY | O_CREAT,
-#if WINDOWS
-                        _S_IREAD | _S_IWRITE
+                        _S_IREAD | _S_IWRITE);
 #else
-                        S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
+  altlog_fd = OPEN (fn, O_APPEND |
+                        O_WRONLY | O_CREAT,
+                        S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 #endif
-                   );
   if (altlog_fd != -1)
   {
     int dup_return;
     if (GNUNET_stderr != NULL)
       fclose (GNUNET_stderr);
     dup_return = dup2 (altlog_fd, 2);
-    close (altlog_fd);
+    (void) close (altlog_fd);
     if (dup_return != -1)
     {
       altlog = fdopen (2, "ab");
       if (altlog == NULL)
       {
-        close (2);
+        (void) close (2);
         altlog_fd = -1;
       }
     }
@@ -948,6 +949,23 @@ GNUNET_i2s (const struct GNUNET_PeerIdentity *pid)
   return (const char *) ret.encoding;
 }
 
+/**
+ * Convert a peer identity to a string (for printing debug messages).
+ * This is one of the very few calls in the entire API that is
+ * NOT reentrant!
+ *
+ * @param pid the peer identity
+ * @return string form of the pid; will be overwritten by next
+ *         call to GNUNET_i2s.
+ */
+const char *
+GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid)
+{
+  static struct GNUNET_CRYPTO_HashAsciiEncoded ret;
+
+  GNUNET_CRYPTO_hash_to_enc (&pid->hashPubKey, &ret);
+  return (const char *) ret.encoding;
+}
 
 
 /**