rps profiler: add correct make rule, util
authorJulius Bünger <buenger@mytum.de>
Thu, 7 Jun 2018 23:23:45 +0000 (01:23 +0200)
committerJulius Bünger <buenger@mytum.de>
Thu, 7 Jun 2018 23:29:23 +0000 (01:29 +0200)
src/rps/Makefile.am
src/rps/rps-test_util.c
src/rps/rps-test_util.h

index 33e03af76117955b7bee9f5aa34f467d42c6f0a9..d477ade929e3045fa2355b2670ce30146ef0d48e 100644 (file)
@@ -141,7 +141,12 @@ test_rps_seed_big_LDADD = $(ld_rps_test_lib)
 test_rps_churn_SOURCES = $(rps_test_src)
 test_rps_churn_LDADD = $(ld_rps_test_lib)
 
-gnunet_rps_profiler_SOURCES = $(rps_test_src)
+gnunet_rps_profiler_SOURCES = \
+ gnunet-service-rps_sampler_elem.h gnunet-service-rps_sampler_elem.c \
+ rps-test_util.h rps-test_util.c \
+ gnunet-rps-profiler.c
+
+
 gnunet_rps_profiler_LDADD = \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   libgnunetrps.la \
index 0c81cc2b42d51c5667088d1507b15c9e5e95973b..ea55deac55292bd095773b1befd93c7520a36719 100644 (file)
@@ -107,6 +107,53 @@ to_file_ (const char *file_name, char *line)
          "Unable to close file\n");
 }
 
+void
+to_file_raw (const char *file_name, void *buf, size_t size_buf)
+{
+  struct GNUNET_DISK_FileHandle *f;
+  size_t size2;
+
+
+  if (NULL == (f = GNUNET_DISK_file_open (file_name,
+                                          GNUNET_DISK_OPEN_APPEND |
+                                          GNUNET_DISK_OPEN_WRITE |
+                                          GNUNET_DISK_OPEN_CREATE,
+                                          GNUNET_DISK_PERM_USER_READ |
+                                          GNUNET_DISK_PERM_USER_WRITE |
+                                          GNUNET_DISK_PERM_GROUP_READ |
+                                          GNUNET_DISK_PERM_OTHER_READ)))
+  {
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "Not able to open file %s\n",
+         file_name);
+    return;
+  }
+
+  size2 = GNUNET_DISK_file_write (f, buf, size_buf);
+  if (size_buf != size2)
+  {
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "Unable to write to file! (Size: %u, size2: %u)\n",
+         size_buf,
+         size2);
+
+    if (GNUNET_YES != GNUNET_DISK_file_close (f))
+      LOG (GNUNET_ERROR_TYPE_WARNING,
+           "Unable to close file\n");
+
+    return;
+  }
+
+  //if (512 < size_buf)
+  //{
+  //  GNUNET_free (output_buffer_p);
+  //}
+
+  //if (GNUNET_YES != GNUNET_DISK_file_close (f))
+  //  LOG (GNUNET_ERROR_TYPE_WARNING,
+  //       "Unable to close file\n");
+}
+
 char *
 auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key)
 {
index 2213e50d8343b0a0b89b4fb7766b13c7e09ab2c7..d424227506d7573a1653e5133ae1e00205701eb4 100644 (file)
@@ -74,5 +74,8 @@ const char *
 store_prefix_file_name (const struct GNUNET_PeerIdentity *peer,
     const char *prefix);
 
+void
+to_file_raw (const char *file_name, void *buf, size_t size_buf);
+
 #endif /* RPS_TEST_UTIL_H */
 /* end of gnunet-service-rps.c */