MGE General C Library - API Documentation  v1.3.5
Library of general C functions.
mgebuffer.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 commenting. *
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 Improve offset field name to proc_next. *
27  * Improve index field name to next_free. *
28  * Convert proc_next and next_free to *
29  * size_t. *
30  * 06/09/2018 MG 1.0.6 Add an mgebuffer initialisation macro. *
31  * 09/09/2018 MG 1.0.7 Move default buffer size macro to *
32  * internal header file as it should not *
33  * be part of the API. *
34  * 25/05/2019 MG 1.0.8 Correct source buffer offset type to *
35  * unsigned. *
36  * 08/06/2019 MG 1.0.9 clang-format coding style changes. *
37  * 15/04/2021 MG 1.0.10 Add print_def_buf_values() prototype. *
38  * *
39  ************************************************************************
40  */
41 
42 #ifndef MGEBUFFER_H
43 #define MGEBUFFER_H
44 
45 #include <portability.h>
46 #include <sys/types.h>
47 
49 
53 struct mgebuffer {
54  char *buffer;
55  size_t size;
56  size_t proc_next;
57  size_t next_free;
58 };
59 
63 #define MGEBUFFER_INIT \
64  { \
65  .buffer = NULL, .size = 0, .proc_next = 0, .next_free = 0 \
66  }
67 
68 struct mgebuffer *concat_buf(const char *s_buf, const size_t s_buf_os,
69  struct mgebuffer *m_buf);
70 
71 struct mgebuffer *trim_buf(struct mgebuffer *msg_buf);
72 
73 void print_buf(struct mgebuffer *m_buf);
74 
75 void print_def_buf_values(void);
76 
78 
79 #endif /* ndef MGEBUFFER_H */
80 
A buffer object.
Definition: mgebuffer.h:53
Header file to ease portability.
size_t size
Size of the buffer storage area.
Definition: mgebuffer.h:55
void print_buf(struct mgebuffer *m_buf)
Print a buffer object to stdout, (for debugging).
Definition: buffer.c:151
void print_def_buf_values(void)
Print the key default values to stdout, (for debugging).
Definition: buffer.c:164
#define END_C_DECLS
Use END_C_DECLS at the end of C declarations.
Definition: portability.h:50
struct mgebuffer * trim_buf(struct mgebuffer *msg_buf)
Remove processed data from a buffer object if deemed necessary.
Definition: buffer.c:110
#define BEGIN_C_DECLS
BEGIN_C_DECLS should be used at the beginning of declarations so that C++ compilers don&#39;t mangle thei...
Definition: portability.h:46
size_t proc_next
Next buffer location for processing.
Definition: mgebuffer.h:56
size_t next_free
Next free buffer location.
Definition: mgebuffer.h:57
char * buffer
Buffer storage.
Definition: mgebuffer.h:54
struct mgebuffer * concat_buf(const char *s_buf, const size_t s_buf_os, struct mgebuffer *m_buf)
Concatenate the used portion of a flat buffer into a buffer object.
Definition: buffer.c:71