GNUnet  0.11.x
Data Structures | Functions
gnunet-service-messenger_list_messages.h File Reference

GNUnet MESSENGER service. More...

#include "platform.h"
#include "gnunet_crypto_lib.h"
#include "gnunet_container_lib.h"
Include dependency graph for gnunet-service-messenger_list_messages.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_ListMessage
 
struct  GNUNET_MESSENGER_ListMessages
 

Functions

void init_list_messages (struct GNUNET_MESSENGER_ListMessages *messages)
 Initializes list of message hashes as empty list. More...
 
void clear_list_messages (struct GNUNET_MESSENGER_ListMessages *messages)
 Clears the list of message hashes. More...
 
void add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
 Adds a specific hash from a message to the end of the list. More...
 
void remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
 Removes the first entry with a matching hash from the list. More...
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger_list_messages.h.

Function Documentation

◆ init_list_messages()

void init_list_messages ( struct GNUNET_MESSENGER_ListMessages messages)

Initializes list of message hashes as empty list.

Parameters
messagesList of hashes

Definition at line 29 of file gnunet-service-messenger_list_messages.c.

References GNUNET_assert, GNUNET_MESSENGER_ListMessages::head, and GNUNET_MESSENGER_ListMessages::tail.

Referenced by create_room(), handle_message_join(), and join_room().

30 {
31  GNUNET_assert(messages);
32 
33  messages->head = NULL;
34  messages->tail = NULL;
35 }
struct GNUNET_MESSENGER_ListMessage * head
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MESSENGER_ListMessage * tail
Here is the caller graph for this function:

◆ clear_list_messages()

void clear_list_messages ( struct GNUNET_MESSENGER_ListMessages messages)

Clears the list of message hashes.

Parameters
messagesList of hashes

Definition at line 38 of file gnunet-service-messenger_list_messages.c.

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MESSENGER_ListMessages::head, and GNUNET_MESSENGER_ListMessages::tail.

Referenced by destroy_room(), handle_message_join(), handle_message_leave(), and iterate_destroy_member_infos().

39 {
40  GNUNET_assert(messages);
41 
42  while (messages->head)
43  {
44  struct GNUNET_MESSENGER_ListMessage *element = messages->head;
45 
46  GNUNET_CONTAINER_DLL_remove(messages->head, messages->tail, element);
47  GNUNET_free(element);
48  }
49 
50  messages->head = NULL;
51  messages->tail = NULL;
52 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_MESSENGER_ListMessage * head
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MESSENGER_ListMessage * tail
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ add_to_list_messages()

void add_to_list_messages ( struct GNUNET_MESSENGER_ListMessages messages,
const struct GNUNET_HashCode hash 
)

Adds a specific hash from a message to the end of the list.

Parameters
messagesList of hashes
hashHash of message

Definition at line 55 of file gnunet-service-messenger_list_messages.c.

References GNUNET_CONTAINER_DLL_insert_tail, GNUNET_memcpy, GNUNET_new, GNUNET_MESSENGER_ListMessage::hash, GNUNET_MESSENGER_ListMessages::head, and GNUNET_MESSENGER_ListMessages::tail.

Referenced by callback_room_recv(), callback_room_sent(), handle_message_id(), handle_message_join(), handle_message_key(), handle_message_name(), join_room(), switch_room_member_id(), and update_room_last_messages().

56 {
58 
59  GNUNET_memcpy(&(element->hash), hash, sizeof(struct GNUNET_HashCode));
60 
61  GNUNET_CONTAINER_DLL_insert_tail(messages->head, messages->tail, element);
62 }
struct GNUNET_MESSENGER_ListMessage * head
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
A 512-bit hashcode.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_MESSENGER_ListMessage * tail
Here is the caller graph for this function:

◆ remove_from_list_messages()

void remove_from_list_messages ( struct GNUNET_MESSENGER_ListMessages messages,
const struct GNUNET_HashCode hash 
)

Removes the first entry with a matching hash from the list.

Parameters
messagesList of hashes
hashHash of message

Definition at line 65 of file gnunet-service-messenger_list_messages.c.

References GNUNET_CONTAINER_DLL_remove, GNUNET_CRYPTO_hash_cmp(), GNUNET_free, GNUNET_MESSENGER_ListMessage::hash, GNUNET_MESSENGER_ListMessages::head, GNUNET_MESSENGER_ListMessage::next, and GNUNET_MESSENGER_ListMessages::tail.

66 {
67  struct GNUNET_MESSENGER_ListMessage *element;
68 
69  for (element = messages->head; element; element = element->next)
70  if (0 == GNUNET_CRYPTO_hash_cmp (&(element->hash), hash))
71  {
72  GNUNET_CONTAINER_DLL_remove(messages->head, messages->tail, element);
73  GNUNET_free(element);
74  break;
75  }
76 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_MESSENGER_ListMessage * next
struct GNUNET_MESSENGER_ListMessage * head
struct GNUNET_MESSENGER_ListMessage * tail
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:311
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function: