2 This file is part of GNUnet.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file rps/rps-test_util.h
23 * @brief Some utils faciliating the view into the internals for the sampler
24 * needed for evaluation
25 * @author Julius Bünger
28 #ifndef RPS_TEST_UTIL_H
29 #define RPS_TEST_UTIL_H
35 auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key);
37 struct GNUNET_CRYPTO_AuthKey
38 string_to_auth_key (const char *str);
42 * @brief Get file handle
44 * If necessary, create file handle and store it with the other file handles.
46 * @param name Name of the file
50 struct GNUNET_DISK_FileHandle *
51 get_file_handle (const char *name);
54 * @brief Close all files that were opened with #get_file_handle
56 * @return Success of iterating over files
62 * This function is used to facilitate writing important information to disk
65 #define to_file(file_name, ...) do { \
66 char tmp_buf[512] = ""; \
68 if (NULL == file_name) break; \
69 size = GNUNET_snprintf (tmp_buf, sizeof(tmp_buf), __VA_ARGS__); \
72 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \
73 "Failed to create tmp_buf\n"); \
76 (void) strncat (tmp_buf, "\n", 512); \
77 GNUNET_DISK_file_write (get_file_handle (file_name), \
79 strnlen (tmp_buf, 512)); \
83 #define to_file_w_len(file_name, len, ...) do { char tmp_buf [len]; \
85 memset (tmp_buf, 0, len); \
86 size = GNUNET_snprintf (tmp_buf, \
93 GNUNET_ERROR_TYPE_WARNING, \
94 "Failed to create tmp_buf\n"); \
97 (void) strncat (tmp_buf, "\n", \
99 GNUNET_DISK_file_write ( \
100 get_file_handle (file_name), \
106 # define to_file(file_name, ...)
107 # define to_file_w_len(file_name, len, ...)
111 store_prefix_file_name (const unsigned int index,
115 to_file_raw (const char *file_name, const char *buf, size_t size_buf);
118 to_file_raw_unaligned (const char *file_name,
121 unsigned bits_needed);
127 * @param x Number of which to compute the factorial
129 * @return Factorial of @a x
131 uint32_t fac (uint32_t x);
135 * @brief Binomial coefficient (n choose k)
140 * @return Binomial coefficient of @a n and @a k
142 uint32_t binom (uint32_t n, uint32_t k);
144 #endif /* RPS_TEST_UTIL_H */
145 /* end of gnunet-service-rps.c */