Renaming structs to evade conflicts with already existing code.

This commit is contained in:
Nicolás Ortega Froysa 2017-11-20 13:59:48 +01:00
parent 5b5660e5c4
commit e6be2716f4
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF
4 changed files with 13 additions and 13 deletions

View File

@ -66,7 +66,7 @@ int main(int argc, char *argv[]) {
else if(strcmp(in, "/stats") == 0) else if(strcmp(in, "/stats") == 0)
{ {
// get statistics // 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", printf("Good: %u\nDubious: %u\nCached: %u\nIncoming: %u\nTotal: %u\n",
statistics.good, statistics.good,
statistics.dubious, statistics.dubious,

View File

@ -35,7 +35,7 @@ extern "C" {
/** /**
* @brief A structure with necessary variables for other users. * @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 *nick; ///< The alias used by the user.
const char *hash; ///< The unique hash of the user. const char *hash; ///< The unique hash of the user.
}; };
@ -43,16 +43,16 @@ struct user {
/** /**
* @brief Structure with relevant message information. * @brief Structure with relevant message information.
*/ */
struct message { struct NeoComm_message {
const char *msg; ///< The text message. const char *msg; ///< The text message.
time_t sent; ///< The time it was sent. 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. * @brief Structure with information on the status of the node's connection.
*/ */
struct stats { struct NeoComm_stats {
unsigned int good, unsigned int good,
dubious, dubious,
cached, cached,
@ -121,7 +121,7 @@ int NeoComm_export_nodes(const char *node_file);
* *
* @return A text description of the local node's status. * @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. * @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 This command will remove the message from the internal list.
* @warning The message must be freed from memory using NeoComm_free_message. * @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. * @brief Free the memory for a message.
* *
* @param msg The message to free from memory. * @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); free(msg);
} }

View File

@ -28,13 +28,13 @@ static std::uniform_int_distribution<dht::Value::Id> rand_id;
static std::map<time_t, int> sent_messages; static std::map<time_t, int> 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); const std::string s_chan_name(channel_name);
if(channels[s_chan_name].msgs.empty()) if(channels[s_chan_name].msgs.empty())
return NULL; return NULL;
const dht::ImMessage *new_msg = &channels[s_chan_name].msgs.front(); const dht::ImMessage *new_msg = &channels[s_chan_name].msgs.front();
struct message *msg = struct NeoComm_message *msg =
static_cast<struct message*>(malloc(sizeof(struct message))); static_cast<struct NeoComm_message*>(malloc(sizeof(struct NeoComm_message)));
*msg = { *msg = {
/*.msg =*/ new_msg->msg.c_str(), /*.msg =*/ new_msg->msg.c_str(),

View File

@ -113,8 +113,8 @@ int NeoComm_export_nodes(const char *node_file) {
return 1; return 1;
} }
struct stats NeoComm_get_node_stats() { struct NeoComm_stats NeoComm_get_node_stats() {
struct stats statistics; struct NeoComm_stats statistics;
statistics.total = node.getNodesStats( statistics.total = node.getNodesStats(
AF_UNSPEC, AF_UNSPEC,
&statistics.good, &statistics.good,