message.cpp
Go to the documentation of this file.
/*
* Copyright (C) 2018 dimercur
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "message.h"
void set_msgToMon_header(MessageToMon *msg, char *header) {
memcpy(msg->header, header, sizeof (header));
}
void set_msgToMon_data(MessageToMon *msg, void * data) {
if (msg->data != NULL) {
free(msg->data);
}
msg->data = malloc(sizeof (data));
memcpy(msg->data, data, sizeof (data));
}
void free_msgToMon_data(MessageToMon *msg) {
if (msg->data != NULL) {
free(msg->data);
}
}
void print_msgToMon(MessageToMon *msg) {
printf("header: %s\n", msg->header);
printf("data: %s\n", (char*)msg->data);
}
MessageToMon::data
void * data
Definition: message.h:36
set_msgToMon_header
void set_msgToMon_header(MessageToMon *msg, char *header)
Definition: message.cpp:28
MessageToMon
Definition: message.h:34
message.h
Functions for sending message to monitor.
free_msgToMon_data
void free_msgToMon_data(MessageToMon *msg)
Definition: message.cpp:40
set_msgToMon_data
void set_msgToMon_data(MessageToMon *msg, void *data)
Definition: message.cpp:32
print_msgToMon
void print_msgToMon(MessageToMon *msg)
Definition: message.cpp:46
MessageToMon::header
char header[4]
Definition: message.h:35