Mistake on this page?
Report an issue in GitHub or email us
useful_buf.h
Go to the documentation of this file.
1 /*
2  * useful_buf.h
3  *
4  * Copyright 2019, Laurence Lundblade
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * See BSD-3-Clause license in README.mdE.
9  */
10 
11 
12 #ifndef __USEFUL_BUF_H__
13 #define __USEFUL_BUF_H__
14 
15 #include "UsefulBuf.h"
16 
17 
18 /**
19  * \file useful_buf.h
20  *
21  * \brief This is a TF-M coding style version of UsefulBuf.
22  * See UsefulBuf for documentation of these functions.
23  */
24 
25 
26 #define NULL_USEFUL_BUF_C NULLUsefulBufC
27 
28 #define NULL_USEFUL_BUF NULLUsefulBuf
29 
30 
31 static inline int useful_buf_c_is_null(struct useful_buf_c in)
32 {
33  return UsefulBuf_IsNULLC(in);
34 }
35 
36 
37 static inline int useful_buf_is_null(struct useful_buf in)
38 {
39  return UsefulBuf_IsNULL(in);
40 }
41 
42 
43 static inline int useful_buf_c_is_empty(struct useful_buf_c in)
44 {
45  return UsefulBuf_IsEmptyC(in);
46 }
47 
48 static inline int useful_buf_is_empty(struct useful_buf in)
49 {
50  return UsefulBuf_IsEmpty(in);
51 }
52 
53 
54 static inline int useful_buf_is_null_or_empty(struct useful_buf in)
55 {
56  return UsefulBuf_IsNULLOrEmpty(in);
57 }
58 
59 
60 static inline int useful_buf_c_is_null_or_empty(struct useful_buf_c in)
61 {
62  return UsefulBuf_IsNULLOrEmptyC(in);
63 }
64 
65 
66 static inline struct useful_buf useful_buf_unconst(struct useful_buf_c in)
67 {
68  return UsefulBuf_Unconst(in);
69 }
70 
71 #define USEFUL_BUF_FROM_SZ_LITERAL UsefulBuf_FROM_SZ_LITERAL
72 
73 #define USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL UsefulBuf_FROM_BYTE_ARRAY_LITERAL
74 
75 #define USEFUL_BUF_MAKE_STACK_UB UsefulBuf_MAKE_STACK_UB
76 
77 #define USEFUL_BUF_FROM_BYTE_ARRAY UsefulBuf_FROM_BYTE_ARRAY
78 
79 
80 static inline struct useful_buf_c useful_buf_from_sz(const char *string)
81 {
82  return UsefulBuf_FromSZ(string);
83 }
84 
85 static inline struct
86 useful_buf_c useful_buf_copy_offset(struct useful_buf dest,
87  size_t offset,
88  struct useful_buf_c src)
89 {
90  return UsefulBuf_CopyOffset(dest, offset, src);
91 }
92 
93 
94 
95 static inline struct useful_buf_c useful_buf_copy(struct useful_buf dest,
96  struct useful_buf_c src)
97 {
98  return UsefulBuf_Copy(dest, src);
99 }
100 
101 
102 static inline struct useful_buf_c useful_buf_set(struct useful_buf dest,
103  uint8_t value)
104 {
105  return UsefulBuf_Set(dest, value);
106 }
107 
108 
109 static inline struct useful_buf_c useful_buf_copy_ptr(struct useful_buf dest,
110  const void *ptr,
111  size_t len)
112 {
113  return UsefulBuf_CopyPtr(dest, ptr, len);
114 }
115 
116 
117 static inline struct useful_buf_c useful_buf_head(struct useful_buf_c buf,
118  size_t amount)
119 {
120  return UsefulBuf_Head(buf, amount);
121 }
122 
123 static inline struct useful_buf_c useful_buf_tail(struct useful_buf_c buf,
124  size_t amount)
125 {
126  return UsefulBuf_Tail(buf, amount);
127 }
128 
129 static inline int useful_buf_compare(const struct useful_buf_c buf1,
130  const struct useful_buf_c buf2)
131 {
132  return UsefulBuf_Compare(buf1, buf2);
133 }
134 
135 static inline size_t
136 useful_buf_find_bytes(const struct useful_buf_c bytes_to_search,
137  const struct useful_buf_c bytes_to_find)
138 {
139  return UsefulBuf_FindBytes(bytes_to_search, bytes_to_find);
140 }
141 
142 
143 #endif /* __USEFUL_BUF_H__ */
int UsefulBuf_Compare(const UsefulBufC UB1, const UsefulBufC UB2)
Compare two UsefulBufCs.
static UsefulBufC UsefulBuf_Copy(UsefulBuf Dest, const UsefulBufC Src)
Copy one UsefulBuf into another.
Definition: UsefulBuf.h:386
static int UsefulBuf_IsEmpty(UsefulBuf UB)
Check if a UsefulBuf is empty or not.
Definition: UsefulBuf.h:220
static UsefulBufC UsefulBuf_Set(UsefulBuf pDest, uint8_t value)
Set all bytes in a UsefulBuf to a value, for example 0.
Definition: UsefulBuf.h:401
size_t UsefulBuf_FindBytes(UsefulBufC BytesToSearch, UsefulBufC BytesToFind)
Find one UsefulBuf in another.
The non-const UsefulBuf typically used for some allocated memory that is to be filled in...
Definition: UsefulBuf.h:160
static UsefulBuf UsefulBuf_Unconst(const UsefulBufC UBC)
Convert a const UsefulBufC to a non-const UsefulBuf.
Definition: UsefulBuf.h:282
static int UsefulBuf_IsNULLOrEmpty(UsefulBuf UB)
Check if a UsefulBuf is NULL or empty.
Definition: UsefulBuf.h:244
UsefulBufC and UsefulBuf are simple data structures to hold a pointer and length for a binary data...
Definition: UsefulBuf.h:149
static int UsefulBuf_IsNULLOrEmptyC(UsefulBufC UB)
Check if a UsefulBufC is NULL or empty.
Definition: UsefulBuf.h:256
The goal of this code is to make buffer and pointer manipulation easier and safer when working with b...
static int UsefulBuf_IsEmptyC(UsefulBufC UB)
Check if a UsefulBufC is empty or not.
Definition: UsefulBuf.h:232
static UsefulBufC UsefulBuf_FromSZ(const char *szString)
Convert a NULL terminated string to a UsefulBufC.
Definition: UsefulBuf.h:342
static UsefulBufC UsefulBuf_Head(UsefulBufC UB, size_t uAmount)
Returns a truncation of a UsefulBufC.
Definition: UsefulBuf.h:440
static int UsefulBuf_IsNULLC(UsefulBufC UB)
Check if a UsefulBufC is NULL or not.
Definition: UsefulBuf.h:198
static UsefulBufC UsefulBuf_CopyPtr(UsefulBuf Dest, const void *ptr, size_t len)
Copy a pointer into a UsefulBuf.
Definition: UsefulBuf.h:425
static UsefulBufC UsefulBuf_Tail(UsefulBufC UB, size_t uAmount)
Returns bytes from the end of a UsefulBufC.
Definition: UsefulBuf.h:462
static int UsefulBuf_IsNULL(UsefulBuf UB)
Check if a UsefulBuf is NULL or not.
Definition: UsefulBuf.h:186
UsefulBufC UsefulBuf_CopyOffset(UsefulBuf Dest, size_t uOffset, const UsefulBufC Src)
Copy one UsefulBuf into another at an offset.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.