From 82ca959ff701832e96c869161adc5e179c2201dd Mon Sep 17 00:00:00 2001 From: latex Date: Sat, 11 Feb 2023 02:01:21 +0100 Subject: restructure include and fix makefiles * restructed include/ to have a umumble folder * fix the makefile to use the new include structure * tests makefile now builds inside root build folder * added TODO list for shit I gotta do * laid groundwork for packet parsing/packing: mumble_packet_gen_header --- include/libumumble.h | 55 -------------------------------- include/umumble/constants.h | 78 +++++++++++++++++++++++++++++++++++++++++++++ include/umumble/umumble.h | 49 ++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 55 deletions(-) delete mode 100644 include/libumumble.h create mode 100644 include/umumble/constants.h create mode 100644 include/umumble/umumble.h (limited to 'include') diff --git a/include/libumumble.h b/include/libumumble.h deleted file mode 100644 index 43ba3ec..0000000 --- a/include/libumumble.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef LIBUMUMBLE_H -#define LIBUMUMBLE_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include -#include - -enum mumble_ctx_status { - UNINITIALIZED = 0, - READY, - CONNECTING, - CONNECTED, - DISCONNECTED -}; - -typedef struct mumble_ctx { - enum mumble_ctx_status status; - int error; - uv_loop_t uv_loop; - uv_getaddrinfo_t uv_resolver; - uv_connect_t uv_connect_req; - tlsuv_stream_t tls_stream; - uv_tcp_t uv_tcp_socket; -} mumble_ctx_t; - -/* Initializes a mumble context object. - * This function will allocate initial memory needed for storing e.g. the channel layout. - * Make sure to call mumble_ctx_close() when you're done! - * - * \param ctx pointer to the context object to initialize - * \return int indicating success - * \retval 1 error - */ -int mumble_ctx_init(mumble_ctx_t *ctx); - -/* Closes a mumble context, deallocating internal objects used by the context. - * This function does not free the memory possibly used to allocate the ctx object. - * If you stored ctx in dynamic memory, make sure to call free(ctx) after calling this function. - * - * \param ctx pointer to the context object to close -*/ -void mumble_ctx_close(mumble_ctx_t *ctx); - -int mumble_connect(mumble_ctx_t *ctx, const char *host, int port); - -int mumble_run(mumble_ctx_t *ctx); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* LIBUMUMBLE_H */ diff --git a/include/umumble/constants.h b/include/umumble/constants.h new file mode 100644 index 0000000..5dfded4 --- /dev/null +++ b/include/umumble/constants.h @@ -0,0 +1,78 @@ +#ifndef UMUMBLE_CONSTANTS_H +#define UMUMBLE_CONSTANTS_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +enum mumble_tcp_packet_type { + MUMBLE_TCP_PACKET_Version, + MUMBLE_TCP_PACKET_UDPTunnel, + MUMBLE_TCP_PACKET_Authenticate, + MUMBLE_TCP_PACKET_Ping, + MUMBLE_TCP_PACKET_Reject, + MUMBLE_TCP_PACKET_ServerSync, + MUMBLE_TCP_PACKET_ChannelRemove, + MUMBLE_TCP_PACKET_ChannelState, + MUMBLE_TCP_PACKET_UserRemove, + MUMBLE_TCP_PACKET_UserState, + MUMBLE_TCP_PACKET_BanList, + MUMBLE_TCP_PACKET_TextMessage, + MUMBLE_TCP_PACKET_PermissionDenied, + MUMBLE_TCP_PACKET_ACL, + MUMBLE_TCP_PACKET_QueryUsers, + MUMBLE_TCP_PACKET_CryptSetup, + MUMBLE_TCP_PACKET_ContextActionModify, + MUMBLE_TCP_PACKET_ContextAction, + MUMBLE_TCP_PACKET_UserList, + MUMBLE_TCP_PACKET_VoiceTarget, + MUMBLE_TCP_PACKET_PermissionQuery, + MUMBLE_TCP_PACKET_CodecVersion, + MUMBLE_TCP_PACKET_UserStats, + MUMBLE_TCP_PACKET_RequestBlob, + MUMBLE_TCP_PACKET_ServerConfig, + MUMBLE_TCP_PACKET_SuggestConfig, + MUMBLE_TCP_PACKET_PluginDataTransmission, +}; + +enum mumble_udp_packet_type { + MUMBLE_UDP_PACKET_Audio, + MUMBLE_UDP_PACKET_Ping +}; + +enum mumble_acl { + MUMBLE_ACL_None = 0, + MUMBLE_ACL_Write = 1, + MUMBLE_ACL_Traverse = 1 << 1, + MUMBLE_ACL_Enter = 1 << 2, + MUMBLE_ACL_Speak = 1 << 3, + MUMBLE_ACL_MuteDeafen = 1 << 4, + MUMBLE_ACL_Move = 1 << 5, + MUMBLE_ACL_MakeChannel = 1 << 6, + MUMBLE_ACL_LinkChannel = 1 << 7, + MUMBLE_ACL_Whisper = 1 << 8, + MUMBLE_ACL_TextMessage = 1 << 9, + MUMBLE_ACL_MakeTempChannel = 1 << 10, + MUMBLE_ACL_Listen = 1 << 11, + + // Root channel only + MUMBLE_ACL_Kick = 1 << 16, + MUMBLE_ACL_Ban = 1 << 17, + MUMBLE_ACL_Register = 1 << 18, + MUMBLE_ACL_SelfRegister = 1 << 19, + MUMBLE_ACL_ResetUserContent = 1 << 20 +}; + +enum mumble_ctx_status { + MUMBLE_STATUS_UNINITIALIZED = 0, + MUMBLE_STATUS_READY, + MUMBLE_STATUS_CONNECTING, + MUMBLE_STATUS_CONNECTED, + MUMBLE_STATUS_DISCONNECTED +}; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* UMUMBLE_CONSTANTS_H */ diff --git a/include/umumble/umumble.h b/include/umumble/umumble.h new file mode 100644 index 0000000..755be59 --- /dev/null +++ b/include/umumble/umumble.h @@ -0,0 +1,49 @@ +#ifndef UMUMBLE_UMUMBLE_H +#define UMUMBLE_UMUMBLE_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "constants.h" + +#include +#include + +typedef struct mumble_ctx_s { + int status; + int error; + uv_loop_t uv_loop; + uv_getaddrinfo_t uv_resolver; + uv_connect_t uv_connect_req; + tlsuv_stream_t tls_stream; + uv_tcp_t uv_tcp_socket; +} mumble_ctx_t; + +/* Initializes a mumble context object. + * This function will allocate initial memory needed for storing e.g. the channel layout. + * Make sure to call mumble_ctx_close() when you're done! + * + * \param ctx pointer to the context object to initialize + * \return int indicating success + * \retval 1 error + */ +int mumble_ctx_init(mumble_ctx_t *ctx); + +/* Closes a mumble context, deallocating internal objects used by the context. + * This function does not free the memory possibly used to allocate the ctx object. + * If you stored ctx in dynamic memory, make sure to call free(ctx) after calling this function. + * + * \param ctx pointer to the context object to close +*/ +void mumble_ctx_close(mumble_ctx_t *ctx); + +int mumble_connect(mumble_ctx_t *ctx, const char *host, int port); + +int mumble_run(mumble_ctx_t *ctx); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* UMUMBLE_UMUMBLE_H */ -- cgit 1.4.1-2-gfad0