SELKIELogger  1.0.0
MQTTTypes.c
1 /*
2  * Copyright (C) 2023 Swansea University
3  *
4  * This file is part of the SELKIELogger suite of tools.
5  *
6  * SELKIELogger is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation, either version 3 of the License, or (at your option)
9  * any later version.
10  *
11  * SELKIELogger is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this SELKIELogger product.
18  * If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include <stdlib.h>
24 
25 #include "MQTTTypes.h"
26 
34  queue_init(&qm->q);
35  qm->numtopics = 0;
36  for (int i = 0; i < 120; i++) {
37  qm->tc[i].topic = NULL;
38  qm->tc[i].name = NULL;
39  }
40  return true;
41 }
42 
49  queue_destroy(&qm->q);
50  for (int i = 0; i < 120; i++) {
51  if (qm->tc[i].topic) {
52  free(qm->tc[i].topic);
53  qm->tc[i].topic = NULL;
54  }
55  if (qm->tc[i].name) {
56  free(qm->tc[i].name);
57  qm->tc[i].name = NULL;
58  }
59  }
60 }
bool mqtt_init_queue_map(mqtt_queue_map *qm)
Initialise mqtt_queue_map to sensible defaults.
Definition: MQTTTypes.c:33
void mqtt_destroy_queue_map(mqtt_queue_map *qm)
Release resources used by mqtt_queue_map instance.
Definition: MQTTTypes.c:48
void queue_destroy(msgqueue *queue)
Invalidate queue and destroy all contents.
Definition: queue.c:64
bool queue_init(msgqueue *queue)
Ensure queue structure is set to known good values and marked valid.
Definition: queue.c:35
int numtopics
Number of topics registered.
Definition: MQTTTypes.h:59
mqtt_topic_config tc[120]
Individual topic configuration.
Definition: MQTTTypes.h:60
msgqueue q
Internal message queue.
Definition: MQTTTypes.h:57
char * name
Channel name.
Definition: MQTTTypes.h:45
char * topic
MQTT topic to subscribe/match against.
Definition: MQTTTypes.h:44