diff options
-rw-r--r-- | src/rps/Makefile.am | 1 | ||||
-rw-r--r-- | src/rps/rps-test_util.c | 56 | ||||
-rw-r--r-- | src/rps/rps-test_util.h | 5 | ||||
-rw-r--r-- | src/util/disk.c | 18 |
4 files changed, 25 insertions, 55 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 | |||
419 | char * | ||
420 | create_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 | */ |
482 | static int ensure_folder_exist (void) | 444 | static int |
445 | ensure_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 | |||
496 | char * | 458 | char * |
497 | store_prefix_file_name (const struct GNUNET_PeerIdentity *peer, | 459 | store_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); | |||
37 | struct GNUNET_CRYPTO_AuthKey | 37 | struct GNUNET_CRYPTO_AuthKey |
38 | string_to_auth_key (const char *str); | 38 | string_to_auth_key (const char *str); |
39 | 39 | ||
40 | char * | ||
41 | create_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,\ |
diff --git a/src/util/disk.c b/src/util/disk.c index de37cba0a..4f78c7747 100644 --- a/src/util/disk.c +++ b/src/util/disk.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 | ||
@@ -625,7 +625,8 @@ GNUNET_DISK_mktemp (const char *t) | |||
625 | * does not exist or stat'ed | 625 | * does not exist or stat'ed |
626 | */ | 626 | */ |
627 | int | 627 | int |
628 | GNUNET_DISK_directory_test (const char *fil, int is_readable) | 628 | GNUNET_DISK_directory_test (const char *fil, |
629 | int is_readable) | ||
629 | { | 630 | { |
630 | struct stat filestat; | 631 | struct stat filestat; |
631 | int ret; | 632 | int ret; |
@@ -639,7 +640,7 @@ GNUNET_DISK_directory_test (const char *fil, int is_readable) | |||
639 | } | 640 | } |
640 | if (!S_ISDIR (filestat.st_mode)) | 641 | if (!S_ISDIR (filestat.st_mode)) |
641 | { | 642 | { |
642 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 643 | LOG (GNUNET_ERROR_TYPE_INFO, |
643 | "A file already exits with the same name %s\n", fil); | 644 | "A file already exits with the same name %s\n", fil); |
644 | return GNUNET_NO; | 645 | return GNUNET_NO; |
645 | } | 646 | } |
@@ -720,7 +721,10 @@ GNUNET_DISK_directory_create (const char *dir) | |||
720 | 721 | ||
721 | rdir = GNUNET_STRINGS_filename_expand (dir); | 722 | rdir = GNUNET_STRINGS_filename_expand (dir); |
722 | if (rdir == NULL) | 723 | if (rdir == NULL) |
724 | { | ||
725 | GNUNET_break (0); | ||
723 | return GNUNET_SYSERR; | 726 | return GNUNET_SYSERR; |
727 | } | ||
724 | 728 | ||
725 | len = strlen (rdir); | 729 | len = strlen (rdir); |
726 | #ifndef MINGW | 730 | #ifndef MINGW |
@@ -756,6 +760,9 @@ GNUNET_DISK_directory_create (const char *dir) | |||
756 | ret = GNUNET_DISK_directory_test (rdir, GNUNET_NO); | 760 | ret = GNUNET_DISK_directory_test (rdir, GNUNET_NO); |
757 | if (GNUNET_NO == ret) | 761 | if (GNUNET_NO == ret) |
758 | { | 762 | { |
763 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
764 | "Creating directory `%s' failed", | ||
765 | rdir); | ||
759 | GNUNET_free (rdir); | 766 | GNUNET_free (rdir); |
760 | return GNUNET_SYSERR; | 767 | return GNUNET_SYSERR; |
761 | } | 768 | } |
@@ -780,6 +787,9 @@ GNUNET_DISK_directory_create (const char *dir) | |||
780 | ret = GNUNET_DISK_directory_test (rdir, GNUNET_NO); | 787 | ret = GNUNET_DISK_directory_test (rdir, GNUNET_NO); |
781 | if (GNUNET_NO == ret) | 788 | if (GNUNET_NO == ret) |
782 | { | 789 | { |
790 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
791 | "Creating directory `%s' failed", | ||
792 | rdir); | ||
783 | GNUNET_free (rdir); | 793 | GNUNET_free (rdir); |
784 | return GNUNET_SYSERR; | 794 | return GNUNET_SYSERR; |
785 | } | 795 | } |
@@ -2684,7 +2694,7 @@ purge_cfg_dir (void *cls, | |||
2684 | { | 2694 | { |
2685 | const char *option = cls; | 2695 | const char *option = cls; |
2686 | char *tmpname; | 2696 | char *tmpname; |
2687 | 2697 | ||
2688 | if (GNUNET_OK != | 2698 | if (GNUNET_OK != |
2689 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 2699 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
2690 | "PATHS", | 2700 | "PATHS", |