diff options
author | Julius Bünger <buenger@mytum.de> | 2015-07-23 18:21:49 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-07-23 18:21:49 +0000 |
commit | ff073fe2f2c6a0fe0532061533c570acfba60e7d (patch) | |
tree | 43bd8220c5414f04ba20ec8362e1cc2cd15057a4 /src/rps/rps-test_util.c | |
parent | 66fa52570d0d9f29d8b6bf8bd4667c18931b3806 (diff) | |
download | gnunet-ff073fe2f2c6a0fe0532061533c570acfba60e7d.tar.gz gnunet-ff073fe2f2c6a0fe0532061533c570acfba60e7d.zip |
get perfect sample of each sampler element
Diffstat (limited to 'src/rps/rps-test_util.c')
-rw-r--r-- | src/rps/rps-test_util.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c index 7af2071b5..882f945c9 100644 --- a/src/rps/rps-test_util.c +++ b/src/rps/rps-test_util.c | |||
@@ -128,7 +128,7 @@ auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key) | |||
128 | *end = '\0'; | 128 | *end = '\0'; |
129 | } | 129 | } |
130 | 130 | ||
131 | size = GNUNET_snprintf (name_buf, name_buf_size, "sampler_el-%s-", buf); | 131 | size = GNUNET_snprintf (name_buf, name_buf_size, "sampler_el-%s", buf); |
132 | if (0 > size) | 132 | if (0 > size) |
133 | LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n"); | 133 | LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n"); |
134 | 134 | ||
@@ -137,6 +137,25 @@ auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key) | |||
137 | return name_buf; | 137 | return name_buf; |
138 | } | 138 | } |
139 | 139 | ||
140 | |||
141 | struct GNUNET_CRYPTO_AuthKey | ||
142 | string_to_auth_key (const char *str) | ||
143 | { | ||
144 | struct GNUNET_CRYPTO_AuthKey auth_key; | ||
145 | |||
146 | if (GNUNET_OK != | ||
147 | GNUNET_STRINGS_string_to_data (str, | ||
148 | strlen (str), | ||
149 | &auth_key.key, | ||
150 | sizeof (struct GNUNET_CRYPTO_AuthKey))) | ||
151 | { | ||
152 | LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to convert string to data\n"); | ||
153 | } | ||
154 | |||
155 | return auth_key; | ||
156 | } | ||
157 | |||
158 | |||
140 | char * | 159 | char * |
141 | create_file (const char *name) | 160 | create_file (const char *name) |
142 | { | 161 | { |
@@ -150,7 +169,7 @@ create_file (const char *name) | |||
150 | name_buf_size = (strlen (prefix) + strlen (name) + 2) * sizeof (char); | 169 | name_buf_size = (strlen (prefix) + strlen (name) + 2) * sizeof (char); |
151 | name_buf = GNUNET_malloc (name_buf_size); | 170 | name_buf = GNUNET_malloc (name_buf_size); |
152 | 171 | ||
153 | size = GNUNET_snprintf (name_buf, name_buf_size, "%s%s-", prefix, name); | 172 | size = GNUNET_snprintf (name_buf, name_buf_size, "%s%s", prefix, name); |
154 | if (0 > size) | 173 | if (0 > size) |
155 | LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n"); | 174 | LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n"); |
156 | 175 | ||
@@ -161,12 +180,16 @@ create_file (const char *name) | |||
161 | prefix); | 180 | prefix); |
162 | } | 181 | } |
163 | 182 | ||
164 | if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf))) | 183 | if (NULL == strstr (name, "sampler_el")) |
165 | LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n"); | 184 | {/* only append random string to sampler */ |
185 | if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf))) | ||
186 | LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n"); | ||
166 | 187 | ||
167 | GNUNET_free (name_buf); | 188 | GNUNET_free (name_buf); |
168 | |||
169 | return file_name; | 189 | return file_name; |
190 | } | ||
191 | |||
192 | return name_buf; | ||
170 | } | 193 | } |
171 | 194 | ||
172 | #endif /* TO_FILE */ | 195 | #endif /* TO_FILE */ |