aboutsummaryrefslogtreecommitdiff
path: root/src/rps/rps-test_util.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/rps/rps-test_util.h
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/rps/rps-test_util.h')
-rw-r--r--src/rps/rps-test_util.h87
1 files changed, 47 insertions, 40 deletions
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index f978059c3..2f11f0105 100644
--- a/src/rps/rps-test_util.h
+++ b/src/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,62 +56,69 @@ 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, \
87 sizeof( \
88 tmp_buf), \
89 __VA_ARGS__); \
87 if (0 > size) \ 90 if (0 > size) \
88 { \ 91 { \
89 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, \ 92 GNUNET_log ( \
90 "Failed to create tmp_buf\n"); \ 93 GNUNET_ERROR_TYPE_WARNING, \
91 break; \ 94 "Failed to create tmp_buf\n"); \
92 } \ 95 break; \
93 (void)strncat(tmp_buf, "\n", len); \ 96 } \
94 GNUNET_DISK_file_write(get_file_handle(file_name), \ 97 (void) strncat (tmp_buf, "\n", \
95 tmp_buf, \ 98 len); \
96 strnlen(tmp_buf, len)); \ 99 GNUNET_DISK_file_write ( \
97 } while (0); 100 get_file_handle (file_name), \
101 tmp_buf, \
102 strnlen ( \
103 tmp_buf, len)); \
104} while (0);
98#else /* TO_FILE */ 105#else /* TO_FILE */
99# define to_file(file_name, ...) 106# define to_file(file_name, ...)
100# define to_file_w_len(file_name, len, ...) 107# define to_file_w_len(file_name, len, ...)
101#endif /* TO_FILE */ 108#endif /* TO_FILE */
102 109
103char * 110char *
104store_prefix_file_name(const unsigned int index, 111store_prefix_file_name (const unsigned int index,
105 const char *prefix); 112 const char *prefix);
106 113
107void 114void
108to_file_raw(const char *file_name, const char *buf, size_t size_buf); 115to_file_raw (const char *file_name, const char *buf, size_t size_buf);
109 116
110void 117void
111to_file_raw_unaligned(const char *file_name, 118to_file_raw_unaligned (const char *file_name,
112 const char *buf, 119 const char *buf,
113 size_t size_buf, 120 size_t size_buf,
114 unsigned bits_needed); 121 unsigned bits_needed);
115 122
116 123
117/** 124/**
@@ -121,7 +128,7 @@ to_file_raw_unaligned(const char *file_name,
121 * 128 *
122 * @return Factorial of @a x 129 * @return Factorial of @a x
123 */ 130 */
124uint32_t fac(uint32_t x); 131uint32_t fac (uint32_t x);
125 132
126 133
127/** 134/**
@@ -132,7 +139,7 @@ uint32_t fac(uint32_t x);
132 * 139 *
133 * @return Binomial coefficient of @a n and @a k 140 * @return Binomial coefficient of @a n and @a k
134 */ 141 */
135uint32_t binom(uint32_t n, uint32_t k); 142uint32_t binom (uint32_t n, uint32_t k);
136 143
137#endif /* RPS_TEST_UTIL_H */ 144#endif /* RPS_TEST_UTIL_H */
138/* end of gnunet-service-rps.c */ 145/* end of gnunet-service-rps.c */