summaryrefslogtreecommitdiff
path: root/src/rps/rps-test_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/rps-test_util.h')
-rw-r--r--src/rps/rps-test_util.h84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index 5aa0688d5..f978059c3 100644
--- a/src/rps/rps-test_util.h
+++ b/src/rps/rps-test_util.h
@@ -16,7 +16,7 @@
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
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file rps/rps-test_util.h 22 * @file rps/rps-test_util.h
@@ -32,10 +32,10 @@
32 32
33 33
34char * 34char *
35auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key); 35auth_key_to_string(struct GNUNET_CRYPTO_AuthKey auth_key);
36 36
37struct GNUNET_CRYPTO_AuthKey 37struct GNUNET_CRYPTO_AuthKey
38string_to_auth_key (const char *str); 38string_to_auth_key(const char *str);
39 39
40 40
41/** 41/**
@@ -48,7 +48,7 @@ string_to_auth_key (const char *str);
48 * @return File handle 48 * @return File handle
49 */ 49 */
50struct GNUNET_DISK_FileHandle * 50struct GNUNET_DISK_FileHandle *
51get_file_handle (const char *name); 51get_file_handle(const char *name);
52 52
53/** 53/**
54 * @brief Close all files that were opened with #get_file_handle 54 * @brief Close all files that were opened with #get_file_handle
@@ -56,44 +56,44 @@ get_file_handle (const char *name);
56 * @return Success of iterating over files 56 * @return Success of iterating over files
57 */ 57 */
58int 58int
59close_all_files (); 59close_all_files();
60 60
61/** 61/**
62 * This function is used to facilitate writing important information to disk 62 * This function is used to facilitate writing important information to disk
63 */ 63 */
64#ifdef TO_FILE 64#ifdef TO_FILE
65#define to_file(file_name, ...) do { \ 65#define to_file(file_name, ...) do { \
66 char tmp_buf[512] = "";\ 66 char tmp_buf[512] = ""; \
67 int size;\ 67 int size; \
68 if (NULL == file_name) break; \ 68 if (NULL == file_name) break; \
69 size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\ 69 size = GNUNET_snprintf (tmp_buf, sizeof(tmp_buf), __VA_ARGS__); \
70 if (0 > size)\ 70 if (0 > size) \
71 {\ 71 { \
72 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\ 72 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, \
73 "Failed to create tmp_buf\n");\ 73 "Failed to create tmp_buf\n"); \
74 break;\ 74 break; \
75 }\ 75 } \
76 (void) strncat(tmp_buf,"\n",512);\ 76 (void)strncat(tmp_buf, "\n", 512); \
77 GNUNET_DISK_file_write (get_file_handle (file_name),\ 77 GNUNET_DISK_file_write(get_file_handle(file_name), \
78 tmp_buf,\ 78 tmp_buf, \
79 strnlen (tmp_buf, 512));\ 79 strnlen(tmp_buf, 512)); \
80 } while (0); 80 } while (0);
81 81
82 82
83#define to_file_w_len(file_name, len, ...) do {char tmp_buf[len];\ 83#define to_file_w_len(file_name, len, ...) do { char tmp_buf [len]; \
84 int size;\ 84 int size; \
85 memset (tmp_buf, 0, len);\ 85 memset(tmp_buf, 0, len); \
86 size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\ 86 size = GNUNET_snprintf(tmp_buf, sizeof(tmp_buf), __VA_ARGS__); \
87 if (0 > size)\ 87 if (0 > size) \
88 {\ 88 { \
89 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\ 89 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, \
90 "Failed to create tmp_buf\n");\ 90 "Failed to create tmp_buf\n"); \
91 break;\ 91 break; \
92 }\ 92 } \
93 (void) strncat(tmp_buf,"\n",len);\ 93 (void)strncat(tmp_buf, "\n", len); \
94 GNUNET_DISK_file_write (get_file_handle (file_name),\ 94 GNUNET_DISK_file_write(get_file_handle(file_name), \
95 tmp_buf,\ 95 tmp_buf, \
96 strnlen (tmp_buf, len));\ 96 strnlen(tmp_buf, len)); \
97 } while (0); 97 } while (0);
98#else /* TO_FILE */ 98#else /* TO_FILE */
99# define to_file(file_name, ...) 99# define to_file(file_name, ...)
@@ -101,17 +101,17 @@ close_all_files ();
101#endif /* TO_FILE */ 101#endif /* TO_FILE */
102 102
103char * 103char *
104store_prefix_file_name (const unsigned int index, 104store_prefix_file_name(const unsigned int index,
105 const char *prefix); 105 const char *prefix);
106 106
107void 107void
108to_file_raw (const char *file_name, const char *buf, size_t size_buf); 108to_file_raw(const char *file_name, const char *buf, size_t size_buf);
109 109
110void 110void
111to_file_raw_unaligned (const char *file_name, 111to_file_raw_unaligned(const char *file_name,
112 const char *buf, 112 const char *buf,
113 size_t size_buf, 113 size_t size_buf,
114 unsigned bits_needed); 114 unsigned bits_needed);
115 115
116 116
117/** 117/**
@@ -121,7 +121,7 @@ to_file_raw_unaligned (const char *file_name,
121 * 121 *
122 * @return Factorial of @a x 122 * @return Factorial of @a x
123 */ 123 */
124uint32_t fac (uint32_t x); 124uint32_t fac(uint32_t x);
125 125
126 126
127/** 127/**
@@ -132,7 +132,7 @@ uint32_t fac (uint32_t x);
132 * 132 *
133 * @return Binomial coefficient of @a n and @a k 133 * @return Binomial coefficient of @a n and @a k
134 */ 134 */
135uint32_t binom (uint32_t n, uint32_t k); 135uint32_t binom(uint32_t n, uint32_t k);
136 136
137#endif /* RPS_TEST_UTIL_H */ 137#endif /* RPS_TEST_UTIL_H */
138/* end of gnunet-service-rps.c */ 138/* end of gnunet-service-rps.c */