Added documentation.

This commit is contained in:
Nicolás A. Ortega 2017-07-11 19:18:45 +02:00
parent 6f98136102
commit b375439f2a
No known key found for this signature in database
GPG Key ID: 3D786FB3123FF1DD
6 changed files with 27 additions and 16 deletions

3
.gitignore vendored
View File

@ -2,5 +2,8 @@
build/*
!build/.keep
# Ignore documentation
doc/*
# Ignore Vim temprary files
*.sw[a-z]

View File

@ -18,7 +18,3 @@
*/
#pragma once
int NeoComm_connect_all_nodes();
int NeoComm_disconnect();

View File

@ -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.
*

View File

@ -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);

View File

@ -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

View File

@ -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)
{