MGE General C Library - API Documentation v1.6.7
Library of general C functions.
Loading...
Searching...
No Matches
mgemessage.h
Go to the documentation of this file.
1
16/* **********************************************************************
17 * *
18 * Changelog *
19 * *
20 * Date Author Version Description *
21 * *
22 * 24/10/2017 MG 1.0.1 This ChangeLog introduced. *
23 * 04/11/2017 MG 1.0.2 Add Doxygen comments. *
24 * 09/11/2017 MG 1.0.3 Add SPDX license tag. *
25 * 02/01/2018 MG 1.0.4 Move to new source directory structure. *
26 * 04/08/2018 MG 1.0.5 Change mgemessage.offset to next_free *
27 * and make it size_t. *
28 * Change mgemessage.complete to bool. *
29 * 06/09/2018 MG 1.0.6 Add mgemessage struct initialiser. *
30 * 09/09/2018 MG 1.0.7 Move default message size macro to *
31 * internal header file as it should not *
32 * be part of the API. *
33 * 31/05/2019 MG 1.0.8 Use standard GNU ifdeffery around use *
34 * of AC_HEADER_STDBOOL. *
35 * 08/06/2019 MG 1.0.9 clang-format coding style changes. *
36 * 19/07/2020 MG 1.0.10 Remove get_msg() declaration, remove it *
37 * from API. *
38 * Remove deconstruct_msg() declaration, *
39 * remove it from API. *
40 * 16/04/2021 MG 1.0.11 Add print_def_msg_values() prototype. *
41 * 03/12/2021 MG 1.0.12 Tighten SPDX tag. *
42 * *
43 ************************************************************************
44 */
45
46#ifndef MGEMESSAGE_H
47#define MGEMESSAGE_H
48
49#include <portability.h>
50#include <sys/types.h>
51
52/* Standard GNU AC_HEADER_STDBOOL ifdeffery. */
53#ifdef HAVE_STDBOOL_H
54 #include <stdbool.h>
55#else
56 #ifndef HAVE__BOOL
57 #ifdef __cplusplus /* clang-format off */
58 typedef bool _Bool; /* clang-format on */
59 #else
60 #define _Bool signed char
61 #endif
62 #endif
63 #define bool _Bool
64 #define false 0
65 #define true 1
66 #define __bool_true_false_are_defined 1
67#endif
68
69#include <mgebuffer.h>
70
72
76struct mgemessage {
77 char *message;
78 size_t size;
79 size_t next_free;
80 bool complete;
82 char separator;
83 int argc;
84 char **argv;
85};
86
90#define MGEMESSAGE_INIT(a, b) \
91 { \
92 .message = NULL, .size = 0, .next_free = 0, .complete = false, \
93 .terminator = a, .separator = b, .argc = 0, .argv = NULL \
94 }
95
96struct mgemessage *pull_msg(struct mgebuffer *buf, struct mgemessage *msg);
97
98void clear_msg(struct mgemessage *msg, const char terminator,
99 const char separator);
100
101void print_msg(struct mgemessage *msg);
102
103void print_def_msg_values(void);
104
106
107#endif /* ndef MGEMESSAGE_H */
108
Header file for buffer processing.
void clear_msg(struct mgemessage *msg, const char terminator, const char separator)
Clear message struct.
Definition: message.c:267
struct mgemessage * pull_msg(struct mgebuffer *buf, struct mgemessage *msg)
Pull a message from a buffer object.
Definition: message.c:114
void print_def_msg_values(void)
Print default values to stdout, for debugging.
Definition: message.c:304
void print_msg(struct mgemessage *msg)
Print a message struct.
Definition: message.c:285
#define _Bool
Definition: mgemessage.h:60
Header file to ease portability.
#define BEGIN_C_DECLS
BEGIN_C_DECLS should be used at the beginning of declarations so that C++ compilers don't mangle thei...
Definition: portability.h:47
#define END_C_DECLS
Use END_C_DECLS at the end of C declarations.
Definition: portability.h:51
A buffer object.
Definition: mgebuffer.h:54
Message object.
Definition: mgemessage.h:76
size_t next_free
Next free message location.
Definition: mgemessage.h:79
char * message
The message buffer.
Definition: mgemessage.h:77
char terminator
Message delimmitter.
Definition: mgemessage.h:81
char separator
Message element delimitter.
Definition: mgemessage.h:82
size_t size
Size of message buffer.
Definition: mgemessage.h:78
int argc
Number of arguments to the message.
Definition: mgemessage.h:83
char ** argv
Message arguments.
Definition: mgemessage.h:84
bool complete
Is message a complete message.
Definition: mgemessage.h:80