aboutsummaryrefslogtreecommitdiff
path: root/src/rps/rps-test_util.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-02-26 09:08:21 +0100
committerChristian Grothoff <christian@grothoff.org>2019-02-26 09:08:21 +0100
commit3495689e26efb8f9690945d3c7f4cd68eaeaaf86 (patch)
treed038a81b8082842895e3c826ef213d7d12e9b6bc /src/rps/rps-test_util.c
parent0e3f1038f95d67ffc029debfce7e60e6de05a135 (diff)
downloadgnunet-3495689e26efb8f9690945d3c7f4cd68eaeaaf86.tar.gz
gnunet-3495689e26efb8f9690945d3c7f4cd68eaeaaf86.zip
fix /tmp/rps directory creation, fix linkage, DCE
Diffstat (limited to 'src/rps/rps-test_util.c')
-rw-r--r--src/rps/rps-test_util.c56
1 files changed, 9 insertions, 47 deletions
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;