From b375439f2afd34fd4cb2a67d4cd70ab70d0fddbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega?= Date: Tue, 11 Jul 2017 19:18:45 +0200 Subject: [PATCH] Added documentation. --- .gitignore | 3 +++ include/connection.h | 4 ---- include/neocomm.h | 5 +++++ include/nodes.h | 18 ++++++++++++------ src/globals.h | 2 +- src/nodes.c | 11 ++++++----- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 789279b..e54565b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,8 @@ build/* !build/.keep +# Ignore documentation +doc/* + # Ignore Vim temprary files *.sw[a-z] diff --git a/include/connection.h b/include/connection.h index b4d0fc8..52d2811 100644 --- a/include/connection.h +++ b/include/connection.h @@ -18,7 +18,3 @@ */ #pragma once - -int NeoComm_connect_all_nodes(); - -int NeoComm_disconnect(); diff --git a/include/neocomm.h b/include/neocomm.h index b2cca1d..d7e635c 100644 --- a/include/neocomm.h +++ b/include/neocomm.h @@ -21,6 +21,11 @@ #include "nodes.h" +/** + * @file neocomm.h + * @brief Automated functions that manage the entire NeoComm framework. + */ + /** * @brief Initializes all modules of the NeoComm framework. * diff --git a/include/nodes.h b/include/nodes.h index fddf90e..fde3dde 100644 --- a/include/nodes.h +++ b/include/nodes.h @@ -19,10 +19,16 @@ #pragma once +/** + * @file nodes.h + * @brief Management of nodes. + * @details These functions are used to manage the global list of nodes. + */ + /** * @brief Simple address structure providing IP/DNS and port information. */ -struct address { +struct NeoComm_address { char *address; ///< IP/DNS string. unsigned short port; ///< Port of address. }; @@ -30,9 +36,9 @@ struct address { /** * @brief Structure used for NeoComm nodes. */ -struct node { +struct NeoComm_node { /// The address of the node. - struct address address; + struct NeoComm_address address; /// Whether or not it is a directory node/server. int directory; /// Number of connections a directory has. @@ -91,7 +97,7 @@ unsigned int NeoComm_get_node_count(); * @return If the list is full then it will return NULL, else it will return * a pointer to the new (or old, if already existing) node. */ -struct node *NeoComm_add_node(struct address addr); +struct NeoComm_node *NeoComm_add_node(struct NeoComm_address addr); /** * @brief Remove a node from the list. @@ -100,7 +106,7 @@ struct node *NeoComm_add_node(struct address addr); * * @return If the node was not found it returns 0, else it returns 1. */ -int NeoComm_remove_node(struct address addr); +int NeoComm_remove_node(struct NeoComm_address addr); /** * @brief Get a pointer to the node with a given address. @@ -109,4 +115,4 @@ int NeoComm_remove_node(struct address addr); * * @return A modifiable pointer to the node or NULL if not found. */ -struct node *NeoComm_get_node(struct address addr); +struct NeoComm_node *NeoComm_get_node(struct NeoComm_address addr); diff --git a/src/globals.h b/src/globals.h index d3d41e8..15f32c7 100644 --- a/src/globals.h +++ b/src/globals.h @@ -22,7 +22,7 @@ #include "nodes.h" // List of nodes -extern struct node *node_list; +extern struct NeoComm_node *node_list; // Maximum number of nodes extern unsigned int node_max; // Number of nodes in the list diff --git a/src/nodes.c b/src/nodes.c index faa614d..505bd33 100644 --- a/src/nodes.c +++ b/src/nodes.c @@ -28,7 +28,7 @@ int NeoComm_init_nodes(unsigned int max_nodes) { if(max_nodes == 0) return 1; - node_list = calloc(max_nodes, sizeof(struct node)); + node_list = calloc(max_nodes, sizeof(struct NeoComm_node)); if(!node_list) return 0; @@ -53,7 +53,8 @@ int NeoComm_resize_node_list(unsigned int new_max_nodes) { if(new_max_nodes <= node_max) return 0; - void* tmp_list = realloc(node_list, new_max_nodes * sizeof(struct node)); + void* tmp_list = + realloc(node_list, new_max_nodes * sizeof(struct NeoComm_node)); if(!tmp_list) return 0; @@ -70,7 +71,7 @@ unsigned int NeoComm_get_node_count() { return node_count; } -struct node *NeoComm_add_node(struct address addr) { +struct NeoComm_node *NeoComm_add_node(struct NeoComm_address addr) { assert(node_list); if(node_count >= node_max) return NULL; @@ -97,7 +98,7 @@ struct node *NeoComm_add_node(struct address addr) { return NULL; } -int NeoComm_remove_node(struct address addr) { +int NeoComm_remove_node(struct NeoComm_address addr) { assert(node_list); int removed = 0; for(unsigned int i = 0; i < node_max; ++i) @@ -117,7 +118,7 @@ int NeoComm_remove_node(struct address addr) { return 1; } -struct node *NeoComm_get_node(struct address addr) { +struct NeoComm_node *NeoComm_get_node(struct NeoComm_address addr) { assert(node_list); for(unsigned int i = 0; i < node_max; ++i) {