From e6be2716f4bfcac9c82a530cf05de8aa578db103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Mon, 20 Nov 2017 13:59:48 +0100 Subject: [PATCH] Renaming structs to evade conflicts with already existing code. --- demo/main.c | 2 +- include/neocomm.h | 14 +++++++------- src/message.cpp | 6 +++--- src/node.cpp | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/demo/main.c b/demo/main.c index ac146b7..f9ca6ae 100644 --- a/demo/main.c +++ b/demo/main.c @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) { else if(strcmp(in, "/stats") == 0) { // get statistics - struct stats statistics = NeoComm_get_node_stats(); + struct NeoComm_stats statistics = NeoComm_get_node_stats(); printf("Good: %u\nDubious: %u\nCached: %u\nIncoming: %u\nTotal: %u\n", statistics.good, statistics.dubious, diff --git a/include/neocomm.h b/include/neocomm.h index b30348b..15e42ca 100644 --- a/include/neocomm.h +++ b/include/neocomm.h @@ -35,7 +35,7 @@ extern "C" { /** * @brief A structure with necessary variables for other users. */ -struct user { +struct NeoComm_user { const char *nick; ///< The alias used by the user. const char *hash; ///< The unique hash of the user. }; @@ -43,16 +43,16 @@ struct user { /** * @brief Structure with relevant message information. */ -struct message { +struct NeoComm_message { const char *msg; ///< The text message. time_t sent; ///< The time it was sent. - struct user from; ///< Info on the peer who sent the message. + struct NeoComm_user from; ///< Info on the peer who sent the message. }; /** * @brief Structure with information on the status of the node's connection. */ -struct stats { +struct NeoComm_stats { unsigned int good, dubious, cached, @@ -121,7 +121,7 @@ int NeoComm_export_nodes(const char *node_file); * * @return A text description of the local node's status. */ -struct stats NeoComm_get_node_stats(); +struct NeoComm_stats NeoComm_get_node_stats(); /** * @brief Join a channel. @@ -169,14 +169,14 @@ unsigned int NeoComm_get_num_channels(); * @warning This command will remove the message from the internal list. * @warning The message must be freed from memory using NeoComm_free_message. */ -struct message *NeoComm_get_next_message(const char *channel_name); +struct NeoComm_message *NeoComm_get_next_message(const char *channel_name); /** * @brief Free the memory for a message. * * @param msg The message to free from memory. */ -static inline void NeoComm_free_message(struct message *msg) { +static inline void NeoComm_free_message(struct NeoComm_message *msg) { free(msg); } diff --git a/src/message.cpp b/src/message.cpp index c7364d4..5d626b5 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -28,13 +28,13 @@ static std::uniform_int_distribution rand_id; static std::map sent_messages; -struct message *NeoComm_get_next_message(const char *channel_name) { +struct NeoComm_message *NeoComm_get_next_message(const char *channel_name) { const std::string s_chan_name(channel_name); if(channels[s_chan_name].msgs.empty()) return NULL; const dht::ImMessage *new_msg = &channels[s_chan_name].msgs.front(); - struct message *msg = - static_cast(malloc(sizeof(struct message))); + struct NeoComm_message *msg = + static_cast(malloc(sizeof(struct NeoComm_message))); *msg = { /*.msg =*/ new_msg->msg.c_str(), diff --git a/src/node.cpp b/src/node.cpp index 77143cd..31151ce 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -113,8 +113,8 @@ int NeoComm_export_nodes(const char *node_file) { return 1; } -struct stats NeoComm_get_node_stats() { - struct stats statistics; +struct NeoComm_stats NeoComm_get_node_stats() { + struct NeoComm_stats statistics; statistics.total = node.getNodesStats( AF_UNSPEC, &statistics.good,