aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/Makefile.am1
-rw-r--r--src/rps/rps-test_util.c56
-rw-r--r--src/rps/rps-test_util.h5
3 files changed, 11 insertions, 51 deletions
diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am
index a356d3dbc..b391eb8ae 100644
--- a/src/rps/Makefile.am
+++ b/src/rps/Makefile.am
@@ -60,7 +60,6 @@ gnunet_service_rps_SOURCES = \
60 gnunet-service-rps_sampler.h gnunet-service-rps_sampler.c \ 60 gnunet-service-rps_sampler.h gnunet-service-rps_sampler.c \
61 gnunet-service-rps_custommap.h gnunet-service-rps_custommap.c \ 61 gnunet-service-rps_custommap.h gnunet-service-rps_custommap.c \
62 gnunet-service-rps_view.h gnunet-service-rps_view.c \ 62 gnunet-service-rps_view.h gnunet-service-rps_view.c \
63 rps-test_util.h rps-test_util.c \
64 gnunet-service-rps.c 63 gnunet-service-rps.c
65 64
66 65
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 85829f247..077750329 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -414,44 +414,6 @@ auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key)
414 return name_buf; 414 return name_buf;
415} 415}
416 416
417
418
419char *
420create_file (const char *name)
421{
422 int size;
423 size_t name_buf_size;
424 char *name_buf;
425 char *prefix;
426 char *file_name;
427
428 prefix = "/tmp/rps/";
429 name_buf_size = (strlen (prefix) + strlen (name) + 2) * sizeof (char);
430 name_buf = GNUNET_malloc (name_buf_size);
431
432 size = GNUNET_snprintf (name_buf, name_buf_size, "%s%s", prefix, name);
433 if (0 > size)
434 LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n");
435
436 if (GNUNET_YES != GNUNET_DISK_directory_create (prefix))
437 {
438 LOG (GNUNET_ERROR_TYPE_WARNING,
439 "Could not create directory %s.\n",
440 prefix);
441 }
442
443 if (NULL == strstr (name, "sampler_el"))
444 {/* only append random string to sampler */
445 if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf)))
446 LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n");
447
448 GNUNET_free (name_buf);
449 return file_name;
450 }
451
452 return name_buf;
453}
454
455#endif /* TO_FILE */ 417#endif /* TO_FILE */
456 418
457 419
@@ -479,23 +441,23 @@ string_to_auth_key (const char *str)
479 * @return #GNUNET_YES on success 441 * @return #GNUNET_YES on success
480 * #GNUNET_SYSERR on failure 442 * #GNUNET_SYSERR on failure
481 */ 443 */
482static int ensure_folder_exist (void) 444static int
445ensure_folder_exist (void)
483{ 446{
484 if (GNUNET_NO == GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO)) 447 if (GNUNET_OK !=
485 { 448 GNUNET_DISK_directory_create ("/tmp/rps"))
486 GNUNET_DISK_directory_create ("/tmp/rps");
487 }
488 if (GNUNET_YES != GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO))
489 { 449 {
490 LOG (GNUNET_ERROR_TYPE_ERROR, "Could not create directory `/tmp/rps'\n"); 450 LOG (GNUNET_ERROR_TYPE_ERROR,
451 "Could not create directory `/tmp/rps'\n");
491 return GNUNET_SYSERR; 452 return GNUNET_SYSERR;
492 } 453 }
493 return GNUNET_YES; 454 return GNUNET_YES;
494} 455}
495 456
457
496char * 458char *
497store_prefix_file_name (const struct GNUNET_PeerIdentity *peer, 459store_prefix_file_name (const struct GNUNET_PeerIdentity *peer,
498 const char *prefix) 460 const char *prefix)
499{ 461{
500 int len_file_name; 462 int len_file_name;
501 int out_size; 463 int out_size;
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index 78d1e0a26..ace833034 100644
--- a/src/rps/rps-test_util.h
+++ b/src/rps/rps-test_util.h
@@ -37,8 +37,6 @@ auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key);
37struct GNUNET_CRYPTO_AuthKey 37struct GNUNET_CRYPTO_AuthKey
38string_to_auth_key (const char *str); 38string_to_auth_key (const char *str);
39 39
40char *
41create_file (const char *name);
42 40
43/** 41/**
44 * @brief Get file handle 42 * @brief Get file handle
@@ -64,9 +62,10 @@ close_all_files ();
64 * This function is used to facilitate writing important information to disk 62 * This function is used to facilitate writing important information to disk
65 */ 63 */
66#ifdef TO_FILE 64#ifdef TO_FILE
67#define to_file(file_name, ...) do { if (NULL == file_name) { GNUNET_break(0); return;} \ 65#define to_file(file_name, ...) do { \
68 char tmp_buf[512] = "";\ 66 char tmp_buf[512] = "";\
69 int size;\ 67 int size;\
68 if (NULL == file_name) return; \
70 size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\ 69 size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\
71 if (0 > size)\ 70 if (0 > size)\
72 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\ 71 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\