GNUnet 0.22.2
gnunet-service-messenger_list_handles.h File Reference
#include "gnunet_common.h"
Include dependency graph for gnunet-service-messenger_list_handles.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_ListHandle
 
struct  GNUNET_MESSENGER_ListHandles
 

Functions

void init_list_handles (struct GNUNET_MESSENGER_ListHandles *handles)
 Initializes list of handles as empty list. More...
 
void clear_list_handles (struct GNUNET_MESSENGER_ListHandles *handles)
 Destroys remaining handles and clears the list. More...
 
void add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle)
 Adds a specific handle to the end of the list. More...
 
enum GNUNET_GenericReturnValue remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle)
 Removes the first entry matching with a specific handle from the list of handles and returns GNUNET_YES on success or GNUNET_NO on failure. More...
 
struct GNUNET_MESSENGER_SrvHandlefind_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles, const struct GNUNET_HashCode *key)
 Searches linearly through the list of handles for members of a specific room which is identified by a given key. More...
 

Function Documentation

◆ init_list_handles()

void init_list_handles ( struct GNUNET_MESSENGER_ListHandles handles)

Initializes list of handles as empty list.

Parameters
[out]handlesList of handles

Definition at line 31 of file gnunet-service-messenger_list_handles.c.

32{
33 GNUNET_assert (handles);
34
35 handles->head = NULL;
36 handles->tail = NULL;
37}
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MESSENGER_ListHandle * tail
struct GNUNET_MESSENGER_ListHandle * head

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

Referenced by create_service().

Here is the caller graph for this function:

◆ clear_list_handles()

void clear_list_handles ( struct GNUNET_MESSENGER_ListHandles handles)

Destroys remaining handles and clears the list.

Parameters
[in,out]handlesList of handles

Definition at line 41 of file gnunet-service-messenger_list_handles.c.

42{
43 GNUNET_assert (handles);
44
45 while (handles->head)
46 {
47 struct GNUNET_MESSENGER_ListHandle *element = handles->head;
48
49 GNUNET_CONTAINER_DLL_remove (handles->head, handles->tail, element);
50 destroy_srv_handle (element->handle);
51 GNUNET_free (element);
52 }
53
54 handles->head = NULL;
55 handles->tail = NULL;
56}
void destroy_srv_handle(struct GNUNET_MESSENGER_SrvHandle *handle)
Destroys a handle and frees its memory fully.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MESSENGER_SrvHandle * handle

References destroy_srv_handle(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MESSENGER_ListHandle::handle, GNUNET_MESSENGER_ListHandles::head, and GNUNET_MESSENGER_ListHandles::tail.

Referenced by destroy_service().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_list_handle()

void add_list_handle ( struct GNUNET_MESSENGER_ListHandles handles,
struct GNUNET_MESSENGER_SrvHandle handle 
)

Adds a specific handle to the end of the list.

Parameters
[in,out]handlesList of handles
[in,out]handleHandle

Definition at line 60 of file gnunet-service-messenger_list_handles.c.

62{
63 struct GNUNET_MESSENGER_ListHandle *element;
64
65 GNUNET_assert ((handles) && (handle));
66
67 element = GNUNET_new (struct GNUNET_MESSENGER_ListHandle);
68 element->handle = handle;
69
70 GNUNET_CONTAINER_DLL_insert_tail (handles->head, handles->tail, element);
71}
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.

References GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_new, handle, GNUNET_MESSENGER_ListHandle::handle, GNUNET_MESSENGER_ListHandles::head, and GNUNET_MESSENGER_ListHandles::tail.

Referenced by add_service_handle().

Here is the caller graph for this function:

◆ remove_list_handle()

enum GNUNET_GenericReturnValue remove_list_handle ( struct GNUNET_MESSENGER_ListHandles handles,
struct GNUNET_MESSENGER_SrvHandle handle 
)

Removes the first entry matching with a specific handle from the list of handles and returns GNUNET_YES on success or GNUNET_NO on failure.

Parameters
[in,out]handlesList of handles
[in,out]handleHandle
Returns
GNUNET_YES on success, otherwise GNUNET_NO

Definition at line 75 of file gnunet-service-messenger_list_handles.c.

77{
78 struct GNUNET_MESSENGER_ListHandle *element;
79
80 GNUNET_assert ((handles) && (handle));
81
82 for (element = handles->head; element; element = element->next)
83 if (element->handle == handle)
84 break;
85
86 if (! element)
87 return GNUNET_NO;
88
89 GNUNET_CONTAINER_DLL_remove (handles->head, handles->tail, element);
90 GNUNET_free (element);
91
92 return GNUNET_YES;
93}
@ GNUNET_YES
@ GNUNET_NO
struct GNUNET_MESSENGER_ListHandle * next

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_YES, handle, GNUNET_MESSENGER_ListHandle::handle, GNUNET_MESSENGER_ListHandles::head, GNUNET_MESSENGER_ListHandle::next, and GNUNET_MESSENGER_ListHandles::tail.

Referenced by remove_service_handle().

Here is the caller graph for this function:

◆ find_list_handle_by_member()

struct GNUNET_MESSENGER_SrvHandle * find_list_handle_by_member ( const struct GNUNET_MESSENGER_ListHandles handles,
const struct GNUNET_HashCode key 
)

Searches linearly through the list of handles for members of a specific room which is identified by a given key.

The handle returned will be one that has enabled routing for the room if possible.

If no handle is found which is a current member, NULL gets returned.

Parameters
[in]handlesList of handles
[in]keyCommon key of a room
Returns
A handle which is a current member

Definition at line 97 of file gnunet-service-messenger_list_handles.c.

99{
100 struct GNUNET_MESSENGER_ListHandle *element;
102
103 GNUNET_assert ((handles) && (key));
104
105 handle = NULL;
106
107 for (element = handles->head; element; element = element->next)
108 {
109 if (get_srv_handle_member_id ((struct
111 key))
112 handle = (struct GNUNET_MESSENGER_SrvHandle *) element->handle;
113
115 break;
116 }
117
118 return handle;
119}
struct GNUNET_HashCode key
The key used in the DHT.
const struct GNUNET_ShortHashCode * get_srv_handle_member_id(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Returns the member id of a given handle in a specific room.
enum GNUNET_GenericReturnValue is_srv_handle_routing(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Returns whether a given handle has enabled routing for a room using a specific key by opening that ro...

References get_srv_handle_member_id(), GNUNET_assert, GNUNET_YES, handle, GNUNET_MESSENGER_ListHandle::handle, GNUNET_MESSENGER_ListHandles::head, is_srv_handle_routing(), key, and GNUNET_MESSENGER_ListHandle::next.

Referenced by close_service_room().

Here is the call graph for this function:
Here is the caller graph for this function: