summaryrefslogtreecommitdiff
path: root/src/fs/fs_publish_ksk.c
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/fs/fs_publish_ksk.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/fs/fs_publish_ksk.c')
-rw-r--r--src/fs/fs_publish_ksk.c143
1 files changed, 72 insertions, 71 deletions
diff --git a/src/fs/fs_publish_ksk.c b/src/fs/fs_publish_ksk.c
index 151b8256c..372ac705d 100644
--- a/src/fs/fs_publish_ksk.c
+++ b/src/fs/fs_publish_ksk.c
@@ -38,7 +38,8 @@
38/** 38/**
39 * Context for the KSK publication. 39 * Context for the KSK publication.
40 */ 40 */
41struct GNUNET_FS_PublishKskContext { 41struct GNUNET_FS_PublishKskContext
42{
42 /** 43 /**
43 * Keywords to use. 44 * Keywords to use.
44 */ 45 */
@@ -72,7 +73,7 @@ struct GNUNET_FS_PublishKskContext {
72 /** 73 /**
73 * Current task. 74 * Current task.
74 */ 75 */
75 struct GNUNET_SCHEDULER_Task * ksk_task; 76 struct GNUNET_SCHEDULER_Task *ksk_task;
76 77
77 /** 78 /**
78 * Function to call once we're done. 79 * Function to call once we're done.
@@ -109,7 +110,7 @@ struct GNUNET_FS_PublishKskContext {
109 * @param cls closure of type `struct PublishKskContext *` 110 * @param cls closure of type `struct PublishKskContext *`
110 */ 111 */
111static void 112static void
112publish_ksk_cont(void *cls); 113publish_ksk_cont (void *cls);
113 114
114 115
115/** 116/**
@@ -120,21 +121,21 @@ publish_ksk_cont(void *cls);
120 * @param msg error message (or NULL) 121 * @param msg error message (or NULL)
121 */ 122 */
122static void 123static void
123kb_put_cont(void *cls, 124kb_put_cont (void *cls,
124 const char *msg) 125 const char *msg)
125{ 126{
126 struct GNUNET_FS_PublishKskContext *pkc = cls; 127 struct GNUNET_FS_PublishKskContext *pkc = cls;
127 128
128 pkc->uc = NULL; 129 pkc->uc = NULL;
129 if (NULL != msg) 130 if (NULL != msg)
130 { 131 {
131 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
132 "KBlock PUT operation failed: %s\n", msg); 133 "KBlock PUT operation failed: %s\n", msg);
133 pkc->cont(pkc->cont_cls, NULL, msg); 134 pkc->cont (pkc->cont_cls, NULL, msg);
134 GNUNET_FS_publish_ksk_cancel(pkc); 135 GNUNET_FS_publish_ksk_cancel (pkc);
135 return; 136 return;
136 } 137 }
137 pkc->ksk_task = GNUNET_SCHEDULER_add_now(&publish_ksk_cont, pkc); 138 pkc->ksk_task = GNUNET_SCHEDULER_add_now (&publish_ksk_cont, pkc);
138} 139}
139 140
140 141
@@ -145,7 +146,7 @@ kb_put_cont(void *cls,
145 * @param cls closure of type `struct GNUNET_FS_PublishKskContext *` 146 * @param cls closure of type `struct GNUNET_FS_PublishKskContext *`
146 */ 147 */
147static void 148static void
148publish_ksk_cont(void *cls) 149publish_ksk_cont (void *cls)
149{ 150{
150 struct GNUNET_FS_PublishKskContext *pkc = cls; 151 struct GNUNET_FS_PublishKskContext *pkc = cls;
151 const char *keyword; 152 const char *keyword;
@@ -153,25 +154,25 @@ publish_ksk_cont(void *cls)
153 pkc->ksk_task = NULL; 154 pkc->ksk_task = NULL;
154 if ((pkc->i == pkc->ksk_uri->data.ksk.keywordCount) || 155 if ((pkc->i == pkc->ksk_uri->data.ksk.keywordCount) ||
155 (NULL == pkc->dsh)) 156 (NULL == pkc->dsh))
156 { 157 {
157 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
158 "KSK PUT operation complete\n"); 159 "KSK PUT operation complete\n");
159 pkc->cont(pkc->cont_cls, pkc->ksk_uri, 160 pkc->cont (pkc->cont_cls, pkc->ksk_uri,
160 NULL); 161 NULL);
161 GNUNET_FS_publish_ksk_cancel(pkc); 162 GNUNET_FS_publish_ksk_cancel (pkc);
162 return; 163 return;
163 } 164 }
164 keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++]; 165 keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++];
165 pkc->uc = GNUNET_FS_publish_ublock_(pkc->h, 166 pkc->uc = GNUNET_FS_publish_ublock_ (pkc->h,
166 pkc->dsh, 167 pkc->dsh,
167 keyword + 1 /* skip '+' */, 168 keyword + 1 /* skip '+' */,
168 NULL, 169 NULL,
169 GNUNET_CRYPTO_ecdsa_key_get_anonymous(), 170 GNUNET_CRYPTO_ecdsa_key_get_anonymous (),
170 pkc->meta, 171 pkc->meta,
171 pkc->uri, 172 pkc->uri,
172 &pkc->bo, 173 &pkc->bo,
173 pkc->options, 174 pkc->options,
174 &kb_put_cont, pkc); 175 &kb_put_cont, pkc);
175} 176}
176 177
177 178
@@ -189,39 +190,39 @@ publish_ksk_cont(void *cls)
189 * @return NULL on error ('cont' will still be called) 190 * @return NULL on error ('cont' will still be called)
190 */ 191 */
191struct GNUNET_FS_PublishKskContext * 192struct GNUNET_FS_PublishKskContext *
192GNUNET_FS_publish_ksk(struct GNUNET_FS_Handle *h, 193GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
193 const struct GNUNET_FS_Uri *ksk_uri, 194 const struct GNUNET_FS_Uri *ksk_uri,
194 const struct GNUNET_CONTAINER_MetaData *meta, 195 const struct GNUNET_CONTAINER_MetaData *meta,
195 const struct GNUNET_FS_Uri *uri, 196 const struct GNUNET_FS_Uri *uri,
196 const struct GNUNET_FS_BlockOptions *bo, 197 const struct GNUNET_FS_BlockOptions *bo,
197 enum GNUNET_FS_PublishOptions options, 198 enum GNUNET_FS_PublishOptions options,
198 GNUNET_FS_PublishContinuation cont, void *cont_cls) 199 GNUNET_FS_PublishContinuation cont, void *cont_cls)
199{ 200{
200 struct GNUNET_FS_PublishKskContext *pkc; 201 struct GNUNET_FS_PublishKskContext *pkc;
201 202
202 GNUNET_assert(NULL != uri); 203 GNUNET_assert (NULL != uri);
203 pkc = GNUNET_new(struct GNUNET_FS_PublishKskContext); 204 pkc = GNUNET_new (struct GNUNET_FS_PublishKskContext);
204 pkc->h = h; 205 pkc->h = h;
205 pkc->bo = *bo; 206 pkc->bo = *bo;
206 pkc->options = options; 207 pkc->options = options;
207 pkc->cont = cont; 208 pkc->cont = cont;
208 pkc->cont_cls = cont_cls; 209 pkc->cont_cls = cont_cls;
209 pkc->meta = GNUNET_CONTAINER_meta_data_duplicate(meta); 210 pkc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
210 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) 211 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
212 {
213 pkc->dsh = GNUNET_DATASTORE_connect (h->cfg);
214 if (NULL == pkc->dsh)
211 { 215 {
212 pkc->dsh = GNUNET_DATASTORE_connect(h->cfg); 216 cont (cont_cls,
213 if (NULL == pkc->dsh) 217 NULL,
214 { 218 _ ("Could not connect to datastore."));
215 cont(cont_cls, 219 GNUNET_free (pkc);
216 NULL, 220 return NULL;
217 _("Could not connect to datastore."));
218 GNUNET_free(pkc);
219 return NULL;
220 }
221 } 221 }
222 pkc->uri = GNUNET_FS_uri_dup(uri); 222 }
223 pkc->ksk_uri = GNUNET_FS_uri_dup(ksk_uri); 223 pkc->uri = GNUNET_FS_uri_dup (uri);
224 pkc->ksk_task = GNUNET_SCHEDULER_add_now(&publish_ksk_cont, pkc); 224 pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
225 pkc->ksk_task = GNUNET_SCHEDULER_add_now (&publish_ksk_cont, pkc);
225 return pkc; 226 return pkc;
226} 227}
227 228
@@ -232,27 +233,27 @@ GNUNET_FS_publish_ksk(struct GNUNET_FS_Handle *h,
232 * @param pkc context of the operation to abort. 233 * @param pkc context of the operation to abort.
233 */ 234 */
234void 235void
235GNUNET_FS_publish_ksk_cancel(struct GNUNET_FS_PublishKskContext *pkc) 236GNUNET_FS_publish_ksk_cancel (struct GNUNET_FS_PublishKskContext *pkc)
236{ 237{
237 if (NULL != pkc->ksk_task) 238 if (NULL != pkc->ksk_task)
238 { 239 {
239 GNUNET_SCHEDULER_cancel(pkc->ksk_task); 240 GNUNET_SCHEDULER_cancel (pkc->ksk_task);
240 pkc->ksk_task = NULL; 241 pkc->ksk_task = NULL;
241 } 242 }
242 if (NULL != pkc->uc) 243 if (NULL != pkc->uc)
243 { 244 {
244 GNUNET_FS_publish_ublock_cancel_(pkc->uc); 245 GNUNET_FS_publish_ublock_cancel_ (pkc->uc);
245 pkc->uc = NULL; 246 pkc->uc = NULL;
246 } 247 }
247 if (NULL != pkc->dsh) 248 if (NULL != pkc->dsh)
248 { 249 {
249 GNUNET_DATASTORE_disconnect(pkc->dsh, GNUNET_NO); 250 GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
250 pkc->dsh = NULL; 251 pkc->dsh = NULL;
251 } 252 }
252 GNUNET_CONTAINER_meta_data_destroy(pkc->meta); 253 GNUNET_CONTAINER_meta_data_destroy (pkc->meta);
253 GNUNET_FS_uri_destroy(pkc->ksk_uri); 254 GNUNET_FS_uri_destroy (pkc->ksk_uri);
254 GNUNET_FS_uri_destroy(pkc->uri); 255 GNUNET_FS_uri_destroy (pkc->uri);
255 GNUNET_free(pkc); 256 GNUNET_free (pkc);
256} 257}
257 258
258 259