diff --git a/src/lib/scord/types.h b/src/lib/scord/types.h index 5d14e7dd427203adb517368ab1f0c5eff681b8bc..7bfbc11356f349547c86b9e8323d2654bf59c702 100644 --- a/src/lib/scord/types.h +++ b/src/lib/scord/types.h @@ -69,6 +69,7 @@ typedef struct adm_server* ADM_server_t; typedef enum { ADM_NODE_REGULAR, ADM_NODE_ADMINISTRATIVE, + ADM_NODE_INVALID } ADM_node_type_t; /** A node */ @@ -261,6 +262,24 @@ ADM_server_destroy(ADM_server_t server); ADM_node_t ADM_node_create(const char* hostname, ADM_node_type_t type); +/** + * Get the hostname of a node. + * + * @param[in] node A valid ADM_node_t + * @return The hostname of the node. + */ +const char* +ADM_node_get_hostname(ADM_node_t node); + +/** + * Get the type of a node. + * + * @param[in] node A valid ADM_node_t + * @return The type of the node. + */ +ADM_node_type_t +ADM_node_get_type(ADM_node_t node); + /** * Destroy a node created by ADM_node_create(). * diff --git a/src/lib/types.c b/src/lib/types.c index 97c9ae12adec1647a02c8dedbfc83255140dd4d1..fd2c7c7e6fc2d7a35dd0c20488c9770861de9dc0 100644 --- a/src/lib/types.c +++ b/src/lib/types.c @@ -86,6 +86,26 @@ ADM_node_create(const char* hostname, ADM_node_type_t type) { return adm_node; } +const char* +ADM_node_get_hostname(ADM_node_t node) { + if(!node) { + LOGGER_ERROR("Invalid ADM_node_t"); + return NULL; + } + + return node->n_hostname; +} + +ADM_node_type_t +ADM_node_get_type(ADM_node_t node) { + if(!node) { + LOGGER_ERROR("Invalid ADM_node_t"); + return ADM_NODE_INVALID; + } + + return node->n_type; +} + ADM_node_t ADM_node_copy(ADM_node_t dst, const ADM_node_t src) {