diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/rps/rps-test_util.h | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-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.h | 87 |
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 | ||
34 | char * | 34 | char * |
35 | auth_key_to_string(struct GNUNET_CRYPTO_AuthKey auth_key); | 35 | auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key); |
36 | 36 | ||
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 | 40 | ||
41 | /** | 41 | /** |
@@ -48,7 +48,7 @@ string_to_auth_key(const char *str); | |||
48 | * @return File handle | 48 | * @return File handle |
49 | */ | 49 | */ |
50 | struct GNUNET_DISK_FileHandle * | 50 | struct GNUNET_DISK_FileHandle * |
51 | get_file_handle(const char *name); | 51 | get_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 | */ |
58 | int | 58 | int |
59 | close_all_files(); | 59 | close_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 | ||
103 | char * | 110 | char * |
104 | store_prefix_file_name(const unsigned int index, | 111 | store_prefix_file_name (const unsigned int index, |
105 | const char *prefix); | 112 | const char *prefix); |
106 | 113 | ||
107 | void | 114 | void |
108 | to_file_raw(const char *file_name, const char *buf, size_t size_buf); | 115 | to_file_raw (const char *file_name, const char *buf, size_t size_buf); |
109 | 116 | ||
110 | void | 117 | void |
111 | to_file_raw_unaligned(const char *file_name, | 118 | to_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 | */ |
124 | uint32_t fac(uint32_t x); | 131 | uint32_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 | */ |
135 | uint32_t binom(uint32_t n, uint32_t k); | 142 | uint32_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 */ |