aboutsummaryrefslogtreecommitdiff
path: root/src/curl
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-09-16 21:26:06 +0200
committerChristian Grothoff <christian@grothoff.org>2019-09-16 21:26:06 +0200
commitc08131d6c72570825bfbedcc2c06175deff274c8 (patch)
tree899fc49fa762b6979867b742cf74ca4dc6fa7179 /src/curl
parentcd92f5e61376da2ee32c9f52eb4230857bd8a391 (diff)
downloadgnunet-c08131d6c72570825bfbedcc2c06175deff274c8.tar.gz
gnunet-c08131d6c72570825bfbedcc2c06175deff274c8.zip
reindentation
Diffstat (limited to 'src/curl')
-rw-r--r--src/curl/curl_reschedule.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/src/curl/curl_reschedule.c b/src/curl/curl_reschedule.c
index 0fdaa5e1f..9001f222d 100644
--- a/src/curl/curl_reschedule.c
+++ b/src/curl/curl_reschedule.c
@@ -28,14 +28,15 @@
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29 29
30extern void * 30extern void *
31GNUNET_CURL_download_get_result_(struct GNUNET_CURL_DownloadBuffer *db, 31GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db,
32 CURL *eh, 32 CURL *eh,
33 long *response_code); 33 long *response_code);
34 34
35/** 35/**
36 * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule(). 36 * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
37 */ 37 */
38struct GNUNET_CURL_RescheduleContext { 38struct GNUNET_CURL_RescheduleContext
39{
39 /** 40 /**
40 * Just the task. 41 * Just the task.
41 */ 42 */
@@ -65,13 +66,13 @@ struct GNUNET_CURL_RescheduleContext {
65 * @return closure for #GNUNET_CURL_gnunet_scheduler_reschedule(). 66 * @return closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
66 */ 67 */
67struct GNUNET_CURL_RescheduleContext * 68struct GNUNET_CURL_RescheduleContext *
68GNUNET_CURL_gnunet_rc_create_with_parser(struct GNUNET_CURL_Context *ctx, 69GNUNET_CURL_gnunet_rc_create_with_parser (struct GNUNET_CURL_Context *ctx,
69 GNUNET_CURL_RawParser rp, 70 GNUNET_CURL_RawParser rp,
70 GNUNET_CURL_ResponseCleaner rc) 71 GNUNET_CURL_ResponseCleaner rc)
71{ 72{
72 struct GNUNET_CURL_RescheduleContext *rctx; 73 struct GNUNET_CURL_RescheduleContext *rctx;
73 74
74 rctx = GNUNET_new(struct GNUNET_CURL_RescheduleContext); 75 rctx = GNUNET_new (struct GNUNET_CURL_RescheduleContext);
75 rctx->ctx = ctx; 76 rctx->ctx = ctx;
76 rctx->parser = rp; 77 rctx->parser = rp;
77 rctx->cleaner = rc; 78 rctx->cleaner = rc;
@@ -86,9 +87,9 @@ GNUNET_CURL_gnunet_rc_create_with_parser(struct GNUNET_CURL_Context *ctx,
86 * @param response the (JSON) response to clean. 87 * @param response the (JSON) response to clean.
87 */ 88 */
88static void 89static void
89clean_result(void *response) 90clean_result (void *response)
90{ 91{
91 json_decref(response); 92 json_decref (response);
92} 93}
93 94
94/** 95/**
@@ -98,11 +99,11 @@ clean_result(void *response)
98 * @return closure for #GNUNET_CURL_gnunet_scheduler_reschedule(). 99 * @return closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
99 */ 100 */
100struct GNUNET_CURL_RescheduleContext * 101struct GNUNET_CURL_RescheduleContext *
101GNUNET_CURL_gnunet_rc_create(struct GNUNET_CURL_Context *ctx) 102GNUNET_CURL_gnunet_rc_create (struct GNUNET_CURL_Context *ctx)
102{ 103{
103 struct GNUNET_CURL_RescheduleContext *rc; 104 struct GNUNET_CURL_RescheduleContext *rc;
104 105
105 rc = GNUNET_new(struct GNUNET_CURL_RescheduleContext); 106 rc = GNUNET_new (struct GNUNET_CURL_RescheduleContext);
106 rc->ctx = ctx; 107 rc->ctx = ctx;
107 rc->parser = &GNUNET_CURL_download_get_result_; 108 rc->parser = &GNUNET_CURL_download_get_result_;
108 rc->cleaner = &clean_result; 109 rc->cleaner = &clean_result;
@@ -116,11 +117,11 @@ GNUNET_CURL_gnunet_rc_create(struct GNUNET_CURL_Context *ctx)
116 * @param rc context to destroy 117 * @param rc context to destroy
117 */ 118 */
118void 119void
119GNUNET_CURL_gnunet_rc_destroy(struct GNUNET_CURL_RescheduleContext *rc) 120GNUNET_CURL_gnunet_rc_destroy (struct GNUNET_CURL_RescheduleContext *rc)
120{ 121{
121 if (NULL != rc->task) 122 if (NULL != rc->task)
122 GNUNET_SCHEDULER_cancel(rc->task); 123 GNUNET_SCHEDULER_cancel (rc->task);
123 GNUNET_free(rc); 124 GNUNET_free (rc);
124} 125}
125 126
126 127
@@ -130,7 +131,7 @@ GNUNET_CURL_gnunet_rc_destroy(struct GNUNET_CURL_RescheduleContext *rc)
130 * @param cls a `struct GNUNET_CURL_RescheduleContext *` 131 * @param cls a `struct GNUNET_CURL_RescheduleContext *`
131 */ 132 */
132static void 133static void
133context_task(void *cls) 134context_task (void *cls)
134{ 135{
135 struct GNUNET_CURL_RescheduleContext *rc = cls; 136 struct GNUNET_CURL_RescheduleContext *rc = cls;
136 long timeout; 137 long timeout;
@@ -144,36 +145,36 @@ context_task(void *cls)
144 145
145 rc->task = NULL; 146 rc->task = NULL;
146 147
147 GNUNET_CURL_perform2(rc->ctx, rc->parser, rc->cleaner); 148 GNUNET_CURL_perform2 (rc->ctx, rc->parser, rc->cleaner);
148 max_fd = -1; 149 max_fd = -1;
149 timeout = -1; 150 timeout = -1;
150 FD_ZERO(&read_fd_set); 151 FD_ZERO (&read_fd_set);
151 FD_ZERO(&write_fd_set); 152 FD_ZERO (&write_fd_set);
152 FD_ZERO(&except_fd_set); 153 FD_ZERO (&except_fd_set);
153 GNUNET_CURL_get_select_info(rc->ctx, 154 GNUNET_CURL_get_select_info (rc->ctx,
154 &read_fd_set, 155 &read_fd_set,
155 &write_fd_set, 156 &write_fd_set,
156 &except_fd_set, 157 &except_fd_set,
157 &max_fd, 158 &max_fd,
158 &timeout); 159 &timeout);
159 if (timeout >= 0) 160 if (timeout >= 0)
160 delay = 161 delay =
161 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, timeout); 162 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, timeout);
162 else 163 else
163 delay = GNUNET_TIME_UNIT_FOREVER_REL; 164 delay = GNUNET_TIME_UNIT_FOREVER_REL;
164 rs = GNUNET_NETWORK_fdset_create(); 165 rs = GNUNET_NETWORK_fdset_create ();
165 GNUNET_NETWORK_fdset_copy_native(rs, &read_fd_set, max_fd + 1); 166 GNUNET_NETWORK_fdset_copy_native (rs, &read_fd_set, max_fd + 1);
166 ws = GNUNET_NETWORK_fdset_create(); 167 ws = GNUNET_NETWORK_fdset_create ();
167 GNUNET_NETWORK_fdset_copy_native(ws, &write_fd_set, max_fd + 1); 168 GNUNET_NETWORK_fdset_copy_native (ws, &write_fd_set, max_fd + 1);
168 if (NULL == rc->task) 169 if (NULL == rc->task)
169 rc->task = GNUNET_SCHEDULER_add_select(GNUNET_SCHEDULER_PRIORITY_DEFAULT, 170 rc->task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
170 delay, 171 delay,
171 rs, 172 rs,
172 ws, 173 ws,
173 &context_task, 174 &context_task,
174 rc); 175 rc);
175 GNUNET_NETWORK_fdset_destroy(rs); 176 GNUNET_NETWORK_fdset_destroy (rs);
176 GNUNET_NETWORK_fdset_destroy(ws); 177 GNUNET_NETWORK_fdset_destroy (ws);
177} 178}
178 179
179 180
@@ -187,13 +188,13 @@ context_task(void *cls)
187 * (pointer to a pointer!) 188 * (pointer to a pointer!)
188 */ 189 */
189void 190void
190GNUNET_CURL_gnunet_scheduler_reschedule(void *cls) 191GNUNET_CURL_gnunet_scheduler_reschedule (void *cls)
191{ 192{
192 struct GNUNET_CURL_RescheduleContext *rc = *(void **)cls; 193 struct GNUNET_CURL_RescheduleContext *rc = *(void **) cls;
193 194
194 if (NULL != rc->task) 195 if (NULL != rc->task)
195 GNUNET_SCHEDULER_cancel(rc->task); 196 GNUNET_SCHEDULER_cancel (rc->task);
196 rc->task = GNUNET_SCHEDULER_add_now(&context_task, rc); 197 rc->task = GNUNET_SCHEDULER_add_now (&context_task, rc);
197} 198}
198 199
199/* end of curl_reschedule.c */ 200/* end of curl_reschedule.c */