diff options
Diffstat (limited to 'src/messenger/gnunet-service-messenger_message_store.c')
-rw-r--r-- | src/messenger/gnunet-service-messenger_message_store.c | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/src/messenger/gnunet-service-messenger_message_store.c b/src/messenger/gnunet-service-messenger_message_store.c index 1984eba21..56448997a 100644 --- a/src/messenger/gnunet-service-messenger_message_store.c +++ b/src/messenger/gnunet-service-messenger_message_store.c | |||
@@ -42,7 +42,9 @@ init_message_store (struct GNUNET_MESSENGER_MessageStore *store) | |||
42 | } | 42 | } |
43 | 43 | ||
44 | static int | 44 | static int |
45 | iterate_destroy_entries (void *cls, const struct GNUNET_HashCode *key, void *value) | 45 | iterate_destroy_entries (void *cls, |
46 | const struct GNUNET_HashCode *key, | ||
47 | void *value) | ||
46 | { | 48 | { |
47 | struct GNUNET_MESSENGER_MessageEntry *entry = value; | 49 | struct GNUNET_MESSENGER_MessageEntry *entry = value; |
48 | 50 | ||
@@ -52,7 +54,9 @@ iterate_destroy_entries (void *cls, const struct GNUNET_HashCode *key, void *val | |||
52 | } | 54 | } |
53 | 55 | ||
54 | static int | 56 | static int |
55 | iterate_destroy_messages (void *cls, const struct GNUNET_HashCode *key, void *value) | 57 | iterate_destroy_messages (void *cls, |
58 | const struct GNUNET_HashCode *key, | ||
59 | void *value) | ||
56 | { | 60 | { |
57 | struct GNUNET_MESSENGER_Message *message = value; | 61 | struct GNUNET_MESSENGER_Message *message = value; |
58 | 62 | ||
@@ -62,7 +66,9 @@ iterate_destroy_messages (void *cls, const struct GNUNET_HashCode *key, void *va | |||
62 | } | 66 | } |
63 | 67 | ||
64 | static int | 68 | static int |
65 | iterate_destroy_links (void *cls, const struct GNUNET_HashCode *key, void *value) | 69 | iterate_destroy_links (void *cls, |
70 | const struct GNUNET_HashCode *key, | ||
71 | void *value) | ||
66 | { | 72 | { |
67 | struct GNUNET_HashCode *previous = value; | 73 | struct GNUNET_HashCode *previous = value; |
68 | 74 | ||
@@ -99,7 +105,8 @@ struct GNUNET_MESSENGER_MessageEntryStorage | |||
99 | }; | 105 | }; |
100 | 106 | ||
101 | static void | 107 | static void |
102 | load_message_store_entries (struct GNUNET_MESSENGER_MessageStore *store, const char *filename) | 108 | load_message_store_entries (struct GNUNET_MESSENGER_MessageStore *store, |
109 | const char *filename) | ||
103 | { | 110 | { |
104 | enum GNUNET_DISK_AccessPermissions permission = (GNUNET_DISK_PERM_USER_READ); | 111 | enum GNUNET_DISK_AccessPermissions permission = (GNUNET_DISK_PERM_USER_READ); |
105 | 112 | ||
@@ -146,7 +153,8 @@ struct GNUNET_MESSENGER_MessageLinkStorage | |||
146 | }; | 153 | }; |
147 | 154 | ||
148 | static void | 155 | static void |
149 | load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, const char *filename) | 156 | load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, |
157 | const char *filename) | ||
150 | { | 158 | { |
151 | enum GNUNET_DISK_AccessPermissions permission = (GNUNET_DISK_PERM_USER_READ); | 159 | enum GNUNET_DISK_AccessPermissions permission = (GNUNET_DISK_PERM_USER_READ); |
152 | 160 | ||
@@ -187,7 +195,8 @@ load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, const cha | |||
187 | } | 195 | } |
188 | 196 | ||
189 | void | 197 | void |
190 | load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory) | 198 | load_message_store (struct GNUNET_MESSENGER_MessageStore *store, |
199 | const char *directory) | ||
191 | { | 200 | { |
192 | GNUNET_assert((store) && (directory)); | 201 | GNUNET_assert((store) && (directory)); |
193 | 202 | ||
@@ -232,7 +241,9 @@ struct GNUNET_MESSENGER_ClosureMessageSave | |||
232 | }; | 241 | }; |
233 | 242 | ||
234 | static int | 243 | static int |
235 | iterate_save_entries (void *cls, const struct GNUNET_HashCode *key, void *value) | 244 | iterate_save_entries (void *cls, |
245 | const struct GNUNET_HashCode *key, | ||
246 | void *value) | ||
236 | { | 247 | { |
237 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; | 248 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; |
238 | struct GNUNET_MESSENGER_MessageEntry *entry = value; | 249 | struct GNUNET_MESSENGER_MessageEntry *entry = value; |
@@ -248,7 +259,9 @@ iterate_save_entries (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
248 | } | 259 | } |
249 | 260 | ||
250 | static int | 261 | static int |
251 | iterate_save_messages (void *cls, const struct GNUNET_HashCode *key, void *value) | 262 | iterate_save_messages (void *cls, |
263 | const struct GNUNET_HashCode *key, | ||
264 | void *value) | ||
252 | { | 265 | { |
253 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; | 266 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; |
254 | 267 | ||
@@ -279,7 +292,9 @@ iterate_save_messages (void *cls, const struct GNUNET_HashCode *key, void *value | |||
279 | } | 292 | } |
280 | 293 | ||
281 | static int | 294 | static int |
282 | iterate_save_links (void *cls, const struct GNUNET_HashCode *key, void *value) | 295 | iterate_save_links (void *cls, |
296 | const struct GNUNET_HashCode *key, | ||
297 | void *value) | ||
283 | { | 298 | { |
284 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; | 299 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; |
285 | struct GNUNET_MESSENGER_MessageLink *link = value; | 300 | struct GNUNET_MESSENGER_MessageLink *link = value; |
@@ -295,7 +310,8 @@ iterate_save_links (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
295 | } | 310 | } |
296 | 311 | ||
297 | void | 312 | void |
298 | save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory) | 313 | save_message_store (struct GNUNET_MESSENGER_MessageStore *store, |
314 | const char *directory) | ||
299 | { | 315 | { |
300 | GNUNET_assert((store) && (directory)); | 316 | GNUNET_assert((store) && (directory)); |
301 | 317 | ||
@@ -372,7 +388,8 @@ close_entries: | |||
372 | } | 388 | } |
373 | 389 | ||
374 | int | 390 | int |
375 | contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) | 391 | contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, |
392 | const struct GNUNET_HashCode *hash) | ||
376 | { | 393 | { |
377 | GNUNET_assert((store) && (hash)); | 394 | GNUNET_assert((store) && (hash)); |
378 | 395 | ||
@@ -383,7 +400,8 @@ contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const | |||
383 | } | 400 | } |
384 | 401 | ||
385 | const struct GNUNET_MESSENGER_Message* | 402 | const struct GNUNET_MESSENGER_Message* |
386 | get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) | 403 | get_store_message (struct GNUNET_MESSENGER_MessageStore *store, |
404 | const struct GNUNET_HashCode *hash) | ||
387 | { | 405 | { |
388 | GNUNET_assert((store) && (hash)); | 406 | GNUNET_assert((store) && (hash)); |
389 | 407 | ||
@@ -444,7 +462,8 @@ free_buffer: | |||
444 | } | 462 | } |
445 | 463 | ||
446 | const struct GNUNET_MESSENGER_MessageLink* | 464 | const struct GNUNET_MESSENGER_MessageLink* |
447 | get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, | 465 | get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, |
466 | const struct GNUNET_HashCode *hash, | ||
448 | int deleted_only) | 467 | int deleted_only) |
449 | { | 468 | { |
450 | if (deleted_only) | 469 | if (deleted_only) |
@@ -473,7 +492,8 @@ get_link: | |||
473 | } | 492 | } |
474 | 493 | ||
475 | int | 494 | int |
476 | put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, | 495 | put_store_message (struct GNUNET_MESSENGER_MessageStore *store, |
496 | const struct GNUNET_HashCode *hash, | ||
477 | struct GNUNET_MESSENGER_Message *message) | 497 | struct GNUNET_MESSENGER_Message *message) |
478 | { | 498 | { |
479 | GNUNET_assert((store) && (hash) && (message)); | 499 | GNUNET_assert((store) && (hash) && (message)); |
@@ -483,7 +503,8 @@ put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNU | |||
483 | } | 503 | } |
484 | 504 | ||
485 | static void | 505 | static void |
486 | add_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, | 506 | add_link (struct GNUNET_MESSENGER_MessageStore *store, |
507 | const struct GNUNET_HashCode *hash, | ||
487 | const struct GNUNET_MESSENGER_Message *message) | 508 | const struct GNUNET_MESSENGER_Message *message) |
488 | { | 509 | { |
489 | struct GNUNET_MESSENGER_MessageLink *link = GNUNET_new(struct GNUNET_MESSENGER_MessageLink); | 510 | struct GNUNET_MESSENGER_MessageLink *link = GNUNET_new(struct GNUNET_MESSENGER_MessageLink); |
@@ -503,7 +524,8 @@ add_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashC | |||
503 | } | 524 | } |
504 | 525 | ||
505 | int | 526 | int |
506 | delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) | 527 | delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, |
528 | const struct GNUNET_HashCode *hash) | ||
507 | { | 529 | { |
508 | GNUNET_assert((store) && (hash)); | 530 | GNUNET_assert((store) && (hash)); |
509 | 531 | ||