GNUnet MESSENGER service. More...
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_MessageEntry |
struct | GNUNET_MESSENGER_MessageLink |
struct | GNUNET_MESSENGER_MessageStore |
Functions | |
void | init_message_store (struct GNUNET_MESSENGER_MessageStore *store) |
Initializes a message store as fully empty. More... | |
void | clear_message_store (struct GNUNET_MESSENGER_MessageStore *store) |
Clears a message store, wipes its content and deallocates its memory. More... | |
void | load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory) |
Loads messages from a directory into a message store. More... | |
void | save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory) |
Saves messages from a message store into a directory. More... | |
int | contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) |
Checks if a message matching a given hash is stored in a message store. More... | |
const struct GNUNET_MESSENGER_Message * | get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) |
Returns the message from a message store matching a given hash. More... | |
const struct GNUNET_MESSENGER_MessageLink * | get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, int deleted_only) |
Returns the message link from a message store matching a given hash. More... | |
int | put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Message *message) |
Stores a message into the message store. More... | |
int | delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) |
Deletes a message in the message store. More... | |
GNUnet MESSENGER service.
Definition in file gnunet-service-messenger_message_store.h.
void init_message_store | ( | struct GNUNET_MESSENGER_MessageStore * | store | ) |
Initializes a message store as fully empty.
[out] | store | Message store |
Definition at line 31 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_MessageStore::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_NO, GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageStore::rewrite_entries, GNUNET_MESSENGER_MessageStore::storage_messages, and GNUNET_MESSENGER_MessageStore::write_links.
Referenced by create_srv_room().
void clear_message_store | ( | struct GNUNET_MESSENGER_MessageStore * | store | ) |
Clears a message store, wipes its content and deallocates its memory.
[in,out] | store | Message store |
Definition at line 82 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_MessageStore::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_file_close(), iterate_destroy_entries(), iterate_destroy_links(), iterate_destroy_messages(), GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageStore::messages, and GNUNET_MESSENGER_MessageStore::storage_messages.
Referenced by destroy_srv_room().
void load_message_store | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const char * | directory | ||
) |
Loads messages from a directory into a message store.
[out] | store | Message store |
[in] | directory | Path to a directory |
Definition at line 210 of file gnunet-service-messenger_message_store.c.
References filename, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_free, GNUNET_YES, load_message_store_entries(), load_message_store_links(), and GNUNET_MESSENGER_MessageStore::storage_messages.
Referenced by load_srv_room().
void save_message_store | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const char * | directory | ||
) |
Saves messages from a message store into a directory.
[in] | store | Message store |
[in] | directory | Path to a directory |
Definition at line 323 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_MessageStore::entries, filename, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_seek(), GNUNET_DISK_file_sync(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_DISK_SEEK_END, GNUNET_DISK_SEEK_SET, GNUNET_free, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, iterate_save_entries(), iterate_save_links(), iterate_save_messages(), GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageStore::rewrite_entries, save(), GNUNET_MESSENGER_MessageStore::storage_messages, GNUNET_MESSENGER_ClosureMessageSave::store, and GNUNET_MESSENGER_MessageStore::write_links.
Referenced by save_srv_room().
int contains_store_message | ( | const struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_HashCode * | hash | ||
) |
Checks if a message matching a given hash is stored in a message store.
The function returns GNUNET_YES if a match is found, GNUNET_NO otherwise.
The message has not to be loaded from disk into memory for this check!
[in] | store | Message store |
[in] | hash | Hash of message |
Definition at line 401 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_MessageStore::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_YES, GNUNET_MESSENGER_MessageStore::messages, and GNUNET_MESSENGER_ClosureMessageSave::store.
const struct GNUNET_MESSENGER_Message* get_store_message | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_HashCode * | hash | ||
) |
Returns the message from a message store matching a given hash.
If no matching message is found, NULL gets returned.
This function requires the message to be loaded into memory!
[in,out] | store | Message store |
[in] | hash | Hash of message |
Definition at line 413 of file gnunet-service-messenger_message_store.c.
References create_message(), decode_message(), destroy_message(), GNUNET_MESSENGER_MessageStore::entries, get_message_kind_size(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash_cmp(), GNUNET_DISK_file_read(), GNUNET_DISK_file_seek(), GNUNET_DISK_SEEK_SET, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_malloc, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_OK, GNUNET_YES, hash_message(), GNUNET_MESSENGER_MessageEntry::length, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageEntry::offset, GNUNET_MESSENGER_MessageStore::rewrite_entries, and GNUNET_MESSENGER_MessageStore::storage_messages.
Referenced by callback_verify_room_message(), check_srv_room_peer_status(), delete_srv_room_message(), forward_about_members(), get_store_message_link(), handle_room_messages(), notify_about_members(), request_room_message_step(), update_room_message(), and update_tunnel_last_message().
const struct GNUNET_MESSENGER_MessageLink* get_store_message_link | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_HashCode * | hash, | ||
int | deleted_only | ||
) |
Returns the message link from a message store matching a given hash.
If the flag is set to GNUNET_YES, only links from deleted messages will be returned or NULL.
Otherwise message links will also returned for messages found in the store under the given hash. The link which will be returned copies link information from the message for temporary usage.
[in,out] | store | Message store |
[in] | hash | Hash of message |
[in] | deleted_only | Flag |
Definition at line 475 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageLink::first, get_store_message(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_MERGE, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageLink::multiple, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageMerge::previous, and GNUNET_MESSENGER_MessageLink::second.
Referenced by check_member_session_completion(), and request_room_message_step().
int put_store_message | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_HashCode * | hash, | ||
struct GNUNET_MESSENGER_Message * | message | ||
) |
Stores a message into the message store.
The result indicates if the operation was successful.
[in,out] | store | Message store |
[in] | hash | Hash of message |
[in,out] | message | Message |
Definition at line 505 of file gnunet-service-messenger_message_store.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, and GNUNET_MESSENGER_MessageStore::messages.
Referenced by update_room_message().
int delete_store_message | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_HashCode * | hash | ||
) |
Deletes a message in the message store.
It will be removed from disk space and memory. The result indicates if the operation was successful.
[in,out] | store | Message store |
[in] | hash | Hash of message |
Definition at line 537 of file gnunet-service-messenger_message_store.c.
Referenced by callback_room_deletion().