Bibliotheques TP RT  1.0
Bibliotheque de support pour TP/RT
message.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 dimercur
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
26 #include "message.h"
27 
28 void set_msgToMon_header(MessageToMon *msg, char *header) {
29  memcpy(msg->header, header, sizeof (header));
30 }
31 
32 void set_msgToMon_data(MessageToMon *msg, void * data) {
33  if (msg->data != NULL) {
34  free(msg->data);
35  }
36  msg->data = malloc(sizeof (data));
37  memcpy(msg->data, data, sizeof (data));
38 }
39 
41  if (msg->data != NULL) {
42  free(msg->data);
43  }
44 }
45 
47  printf("header: %s\n", msg->header);
48  printf("data: %s\n", (char*)msg->data);
49 }
void * data
Definition: message.h:36
void set_msgToMon_header(MessageToMon *msg, char *header)
Definition: message.cpp:28
Functions for sending message to monitor.
void free_msgToMon_data(MessageToMon *msg)
Definition: message.cpp:40
void set_msgToMon_data(MessageToMon *msg, void *data)
Definition: message.cpp:32
void print_msgToMon(MessageToMon *msg)
Definition: message.cpp:46
char header[4]
Definition: message.h:35