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/util/op.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/util/op.c')
-rw-r--r-- | src/util/op.c | 148 |
1 files changed, 75 insertions, 73 deletions
diff --git a/src/util/op.c b/src/util/op.c index 20a0d3b0d..647fedb53 100644 --- a/src/util/op.c +++ b/src/util/op.c | |||
@@ -30,9 +30,10 @@ | |||
30 | #include "platform.h" | 30 | #include "platform.h" |
31 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
32 | 32 | ||
33 | #define LOG(kind, ...) GNUNET_log_from(kind, "util-op", __VA_ARGS__) | 33 | #define LOG(kind, ...) GNUNET_log_from (kind, "util-op", __VA_ARGS__) |
34 | 34 | ||
35 | struct OperationListItem { | 35 | struct OperationListItem |
36 | { | ||
36 | struct OperationListItem *prev; | 37 | struct OperationListItem *prev; |
37 | struct OperationListItem *next; | 38 | struct OperationListItem *next; |
38 | 39 | ||
@@ -62,7 +63,8 @@ struct OperationListItem { | |||
62 | * Operations handle. | 63 | * Operations handle. |
63 | */ | 64 | */ |
64 | 65 | ||
65 | struct GNUNET_OP_Handle { | 66 | struct GNUNET_OP_Handle |
67 | { | ||
66 | /** | 68 | /** |
67 | * First operation in the linked list. | 69 | * First operation in the linked list. |
68 | */ | 70 | */ |
@@ -84,9 +86,9 @@ struct GNUNET_OP_Handle { | |||
84 | * Create new operations handle. | 86 | * Create new operations handle. |
85 | */ | 87 | */ |
86 | struct GNUNET_OP_Handle * | 88 | struct GNUNET_OP_Handle * |
87 | GNUNET_OP_create() | 89 | GNUNET_OP_create () |
88 | { | 90 | { |
89 | return GNUNET_new(struct GNUNET_OP_Handle); | 91 | return GNUNET_new (struct GNUNET_OP_Handle); |
90 | } | 92 | } |
91 | 93 | ||
92 | 94 | ||
@@ -94,9 +96,9 @@ GNUNET_OP_create() | |||
94 | * Destroy operations handle. | 96 | * Destroy operations handle. |
95 | */ | 97 | */ |
96 | void | 98 | void |
97 | GNUNET_OP_destroy(struct GNUNET_OP_Handle *h) | 99 | GNUNET_OP_destroy (struct GNUNET_OP_Handle *h) |
98 | { | 100 | { |
99 | GNUNET_free(h); | 101 | GNUNET_free (h); |
100 | } | 102 | } |
101 | 103 | ||
102 | 104 | ||
@@ -109,7 +111,7 @@ GNUNET_OP_destroy(struct GNUNET_OP_Handle *h) | |||
109 | * @return Operation ID to use. | 111 | * @return Operation ID to use. |
110 | */ | 112 | */ |
111 | uint64_t | 113 | uint64_t |
112 | GNUNET_OP_get_next_id(struct GNUNET_OP_Handle *h) | 114 | GNUNET_OP_get_next_id (struct GNUNET_OP_Handle *h) |
113 | { | 115 | { |
114 | return ++h->last_op_id; | 116 | return ++h->last_op_id; |
115 | } | 117 | } |
@@ -126,8 +128,8 @@ GNUNET_OP_get_next_id(struct GNUNET_OP_Handle *h) | |||
126 | * @return Operation, or NULL if not found. | 128 | * @return Operation, or NULL if not found. |
127 | */ | 129 | */ |
128 | static struct OperationListItem * | 130 | static struct OperationListItem * |
129 | op_find(struct GNUNET_OP_Handle *h, | 131 | op_find (struct GNUNET_OP_Handle *h, |
130 | uint64_t op_id) | 132 | uint64_t op_id) |
131 | { | 133 | { |
132 | struct OperationListItem *op; | 134 | struct OperationListItem *op; |
133 | 135 | ||
@@ -156,24 +158,24 @@ op_find(struct GNUNET_OP_Handle *h, | |||
156 | * #GNUNET_NO if not found. | 158 | * #GNUNET_NO if not found. |
157 | */ | 159 | */ |
158 | int | 160 | int |
159 | GNUNET_OP_get(struct GNUNET_OP_Handle *h, | 161 | GNUNET_OP_get (struct GNUNET_OP_Handle *h, |
160 | uint64_t op_id, | 162 | uint64_t op_id, |
161 | GNUNET_ResultCallback *result_cb, | 163 | GNUNET_ResultCallback *result_cb, |
162 | void **cls, | 164 | void **cls, |
163 | void **ctx) | 165 | void **ctx) |
164 | { | 166 | { |
165 | struct OperationListItem *op = op_find(h, op_id); | 167 | struct OperationListItem *op = op_find (h, op_id); |
166 | 168 | ||
167 | if (NULL != op) | 169 | if (NULL != op) |
168 | { | 170 | { |
169 | if (NULL != result_cb) | 171 | if (NULL != result_cb) |
170 | *result_cb = op->result_cb; | 172 | *result_cb = op->result_cb; |
171 | if (NULL != cls) | 173 | if (NULL != cls) |
172 | *cls = op->cls; | 174 | *cls = op->cls; |
173 | if (NULL != ctx) | 175 | if (NULL != ctx) |
174 | *ctx = op->ctx; | 176 | *ctx = op->ctx; |
175 | return GNUNET_YES; | 177 | return GNUNET_YES; |
176 | } | 178 | } |
177 | return GNUNET_NO; | 179 | return GNUNET_NO; |
178 | } | 180 | } |
179 | 181 | ||
@@ -193,24 +195,24 @@ GNUNET_OP_get(struct GNUNET_OP_Handle *h, | |||
193 | * @return ID of the new operation. | 195 | * @return ID of the new operation. |
194 | */ | 196 | */ |
195 | uint64_t | 197 | uint64_t |
196 | GNUNET_OP_add(struct GNUNET_OP_Handle *h, | 198 | GNUNET_OP_add (struct GNUNET_OP_Handle *h, |
197 | GNUNET_ResultCallback result_cb, | 199 | GNUNET_ResultCallback result_cb, |
198 | void *cls, | 200 | void *cls, |
199 | void *ctx) | 201 | void *ctx) |
200 | { | 202 | { |
201 | struct OperationListItem *op; | 203 | struct OperationListItem *op; |
202 | 204 | ||
203 | op = GNUNET_new(struct OperationListItem); | 205 | op = GNUNET_new (struct OperationListItem); |
204 | op->op_id = GNUNET_OP_get_next_id(h); | 206 | op->op_id = GNUNET_OP_get_next_id (h); |
205 | op->result_cb = result_cb; | 207 | op->result_cb = result_cb; |
206 | op->cls = cls; | 208 | op->cls = cls; |
207 | op->ctx = ctx; | 209 | op->ctx = ctx; |
208 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, | 210 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, |
209 | h->op_tail, | 211 | h->op_tail, |
210 | op); | 212 | op); |
211 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 213 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
212 | "%p Added operation #%" PRIu64 "\n", | 214 | "%p Added operation #%" PRIu64 "\n", |
213 | h, op->op_id); | 215 | h, op->op_id); |
214 | return op->op_id; | 216 | return op->op_id; |
215 | } | 217 | } |
216 | 218 | ||
@@ -240,38 +242,38 @@ GNUNET_OP_add(struct GNUNET_OP_Handle *h, | |||
240 | * #GNUNET_NO if the operation was not found. | 242 | * #GNUNET_NO if the operation was not found. |
241 | */ | 243 | */ |
242 | static int | 244 | static int |
243 | op_result(struct GNUNET_OP_Handle *h, | 245 | op_result (struct GNUNET_OP_Handle *h, |
244 | uint64_t op_id, | 246 | uint64_t op_id, |
245 | int64_t result_code, | 247 | int64_t result_code, |
246 | const void *data, | 248 | const void *data, |
247 | uint16_t data_size, | 249 | uint16_t data_size, |
248 | void **ctx, | 250 | void **ctx, |
249 | uint8_t cancel) | 251 | uint8_t cancel) |
250 | { | 252 | { |
251 | if (0 == op_id) | 253 | if (0 == op_id) |
252 | return GNUNET_NO; | 254 | return GNUNET_NO; |
253 | 255 | ||
254 | struct OperationListItem *op = op_find(h, op_id); | 256 | struct OperationListItem *op = op_find (h, op_id); |
255 | if (NULL == op) | 257 | if (NULL == op) |
256 | { | 258 | { |
257 | LOG(GNUNET_ERROR_TYPE_WARNING, | 259 | LOG (GNUNET_ERROR_TYPE_WARNING, |
258 | "Could not find operation #%" PRIu64 "\n", op_id); | 260 | "Could not find operation #%" PRIu64 "\n", op_id); |
259 | return GNUNET_NO; | 261 | return GNUNET_NO; |
260 | } | 262 | } |
261 | 263 | ||
262 | if (NULL != ctx) | 264 | if (NULL != ctx) |
263 | *ctx = op->ctx; | 265 | *ctx = op->ctx; |
264 | 266 | ||
265 | GNUNET_CONTAINER_DLL_remove(h->op_head, | 267 | GNUNET_CONTAINER_DLL_remove (h->op_head, |
266 | h->op_tail, | 268 | h->op_tail, |
267 | op); | 269 | op); |
268 | 270 | ||
269 | if ((GNUNET_YES != cancel) && | 271 | if ((GNUNET_YES != cancel) && |
270 | (NULL != op->result_cb)) | 272 | (NULL != op->result_cb)) |
271 | op->result_cb(op->cls, | 273 | op->result_cb (op->cls, |
272 | result_code, data, | 274 | result_code, data, |
273 | data_size); | 275 | data_size); |
274 | GNUNET_free(op); | 276 | GNUNET_free (op); |
275 | return GNUNET_YES; | 277 | return GNUNET_YES; |
276 | } | 278 | } |
277 | 279 | ||
@@ -296,17 +298,17 @@ op_result(struct GNUNET_OP_Handle *h, | |||
296 | * #GNUNET_NO if the operation was not found. | 298 | * #GNUNET_NO if the operation was not found. |
297 | */ | 299 | */ |
298 | int | 300 | int |
299 | GNUNET_OP_result(struct GNUNET_OP_Handle *h, | 301 | GNUNET_OP_result (struct GNUNET_OP_Handle *h, |
300 | uint64_t op_id, | 302 | uint64_t op_id, |
301 | int64_t result_code, | 303 | int64_t result_code, |
302 | const void *data, | 304 | const void *data, |
303 | uint16_t data_size, | 305 | uint16_t data_size, |
304 | void **ctx) | 306 | void **ctx) |
305 | { | 307 | { |
306 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 308 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
307 | "%p Received result for operation #%" PRIu64 ": %" PRId64 " (size: %u)\n", | 309 | "%p Received result for operation #%" PRIu64 ": %" PRId64 " (size: %u)\n", |
308 | h, op_id, result_code, data_size); | 310 | h, op_id, result_code, data_size); |
309 | return op_result(h, op_id, result_code, data, data_size, ctx, GNUNET_NO); | 311 | return op_result (h, op_id, result_code, data, data_size, ctx, GNUNET_NO); |
310 | } | 312 | } |
311 | 313 | ||
312 | 314 | ||
@@ -322,11 +324,11 @@ GNUNET_OP_result(struct GNUNET_OP_Handle *h, | |||
322 | * #GNUNET_NO if the operation was not found. | 324 | * #GNUNET_NO if the operation was not found. |
323 | */ | 325 | */ |
324 | int | 326 | int |
325 | GNUNET_OP_remove(struct GNUNET_OP_Handle *h, | 327 | GNUNET_OP_remove (struct GNUNET_OP_Handle *h, |
326 | uint64_t op_id) | 328 | uint64_t op_id) |
327 | { | 329 | { |
328 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 330 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
329 | "%p Cancelling operation #%" PRIu64 "\n", | 331 | "%p Cancelling operation #%" PRIu64 "\n", |
330 | h, op_id); | 332 | h, op_id); |
331 | return op_result(h, op_id, 0, NULL, 0, NULL, GNUNET_YES); | 333 | return op_result (h, op_id, 0, NULL, 0, NULL, GNUNET_YES); |
332 | } | 334 | } |