libgnunetchat

library for GNUnet Messenger
Log | Files | Refs | README | LICENSE

commit eb314fb342dcdc6fd12438ef1ce98050f74a45ac
parent 4d3a143438e87fb7ec5a6f2e35455270360db6cc
Author: Jacki <jacki@thejackimonster.de>
Date:   Wed, 17 Apr 2024 19:08:17 +0200

Add function to return type of uri

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Minclude/gnunet/gnunet_chat_lib.h | 30++++++++++++++++++++++++++++++
Msrc/gnunet_chat_lib.c | 12++++++++++++
Msrc/gnunet_chat_uri.h | 8--------
3 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/include/gnunet/gnunet_chat_lib.h b/include/gnunet/gnunet_chat_lib.h @@ -52,6 +52,27 @@ #define GNUNET_CHAT_URI_PREFIX "gnunet://chat/" /** + * Enum for the different types of supported URIs. + */ +enum GNUNET_CHAT_UriType +{ + /** + * The type to share and join a lobby or chat. + */ + GNUNET_CHAT_URI_TYPE_CHAT = 1, /**< GNUNET_CHAT_URI_TYPE_CHAT */ + + /** + * The type to download and query files vis FS service from GNUnet. + */ + GNUNET_CHAT_URI_TYPE_FS = 2, /**< GNUNET_CHAT_URI_TYPE_FS */ + + /** + * An unknown type of uri. + */ + GNUNET_CHAT_URI_TYPE_UNKNOWN = 0 /**< GNUNET_CHAT_URI_TYPE_UNKNOWN */ +}; + +/** * Enum for the different kinds of messages. */ enum GNUNET_CHAT_MessageKind @@ -614,6 +635,15 @@ char* GNUNET_CHAT_uri_to_string (const struct GNUNET_CHAT_Uri *uri); /** + * Returns the type of a given chat URI. + * + * @param[in] uri Chat URI + * @return The type of URI + */ +enum GNUNET_CHAT_UriType +GNUNET_CHAT_uri_get_type (const struct GNUNET_CHAT_Uri *uri); + +/** * Free an allocated chat URI. * * @param[in,out] uri Chat URI diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c @@ -642,6 +642,18 @@ GNUNET_CHAT_uri_to_string (const struct GNUNET_CHAT_Uri *uri) } +enum GNUNET_CHAT_UriType +GNUNET_CHAT_uri_get_type (const struct GNUNET_CHAT_Uri *uri) +{ + GNUNET_CHAT_VERSION_ASSERT(); + + if (!uri) + return GNUNET_CHAT_URI_TYPE_UNKNOWN; + + return uri->type; +} + + void GNUNET_CHAT_uri_destroy (struct GNUNET_CHAT_Uri *uri) { diff --git a/src/gnunet_chat_uri.h b/src/gnunet_chat_uri.h @@ -30,14 +30,6 @@ #include "gnunet_chat_util.h" -enum GNUNET_CHAT_UriType -{ - GNUNET_CHAT_URI_TYPE_CHAT = 1, - GNUNET_CHAT_URI_TYPE_FS = 2, - - GNUNET_CHAT_URI_TYPE_UNKNOWN = 0 -}; - struct GNUNET_CHAT_UriChat { struct GNUNET_CRYPTO_PublicKey zone;