1*418b791dSBob Badour /**
2*418b791dSBob Badour * Copyright (c) 2019, The Linux Foundation. All rights reserved.
3*418b791dSBob Badour *
4*418b791dSBob Badour * Redistribution and use in source and binary forms, with or without
5*418b791dSBob Badour * modification, are permitted provided that the following conditions are
6*418b791dSBob Badour * met:
7*418b791dSBob Badour * * Redistributions of source code must retain the above copyright
8*418b791dSBob Badour * notice, this list of conditions and the following disclaimer.
9*418b791dSBob Badour * * Redistributions in binary form must reproduce the above
10*418b791dSBob Badour * copyright notice, this list of conditions and the following
11*418b791dSBob Badour * disclaimer in the documentation and/or other materials provided
12*418b791dSBob Badour * with the distribution.
13*418b791dSBob Badour * * Neither the name of The Linux Foundation nor the names of its
14*418b791dSBob Badour * contributors may be used to endorse or promote products derived
15*418b791dSBob Badour * from this software without specific prior written permission.
16*418b791dSBob Badour *
17*418b791dSBob Badour * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18*418b791dSBob Badour * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19*418b791dSBob Badour * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20*418b791dSBob Badour * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21*418b791dSBob Badour * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22*418b791dSBob Badour * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23*418b791dSBob Badour * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24*418b791dSBob Badour * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25*418b791dSBob Badour * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26*418b791dSBob Badour * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27*418b791dSBob Badour * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*418b791dSBob Badour */
29*418b791dSBob Badour
30*418b791dSBob Badour #ifndef AEEBUFBOUND_H
31*418b791dSBob Badour #define AEEBUFBOUND_H
32*418b791dSBob Badour /*==============================================================================
33*418b791dSBob Badour
34*418b791dSBob Badour FILE: AEEBufBound.h
35*418b791dSBob Badour
36*418b791dSBob Badour SERVICES:
37*418b791dSBob Badour BufBound APIs
38*418b791dSBob Badour
39*418b791dSBob Badour GENERAL DESCRIPTION:
40*418b791dSBob Badour BufBound provides a "bounded buffer" API that facilitates
41*418b791dSBob Badour measuring strings or character output. It's design accomodates
42*418b791dSBob Badour the implementation of functions that can have the same exact logic
43*418b791dSBob Badour for measuring and outputting char buffer content.
44*418b791dSBob Badour
45*418b791dSBob Badour REVISION HISTORY:
46*418b791dSBob Badour Fri Aug 08 17:38:29 2003: Created
47*418b791dSBob Badour
48*418b791dSBob Badour ==============================================================================*/
49*418b791dSBob Badour
50*418b791dSBob Badour typedef struct BufBound
51*418b791dSBob Badour {
52*418b791dSBob Badour char* pcBuf; /* original buffer */
53*418b791dSBob Badour char* pcWrite; /* write pointer */
54*418b791dSBob Badour char* pcEnd; /* first illegal write pointer */
55*418b791dSBob Badour } BufBound;
56*418b791dSBob Badour
57*418b791dSBob Badour #ifdef __cplusplus
58*418b791dSBob Badour extern "C" {
59*418b791dSBob Badour #endif /* #ifdef __cplusplus */
60*418b791dSBob Badour
61*418b791dSBob Badour extern void BufBound_Init(BufBound *me, char *pBuf, int nLen);
62*418b791dSBob Badour extern void BufBound_Write(BufBound *me, const char *pc, int nLen);
63*418b791dSBob Badour extern void BufBound_Putc(BufBound *me, char c);
64*418b791dSBob Badour extern void BufBound_Putnc(BufBound *me, char c, int nCount);
65*418b791dSBob Badour extern void BufBound_ForceNullTerm(BufBound *me);
66*418b791dSBob Badour extern void BufBound_Puts(BufBound *me, const char* cpsz);
67*418b791dSBob Badour extern void BufBound_Advance(BufBound *me, int nLen);
68*418b791dSBob Badour extern void BufBound_WriteLE(BufBound* me,
69*418b791dSBob Badour const void *pvSrc, int nSrcSize,
70*418b791dSBob Badour const char *pszFields);
71*418b791dSBob Badour extern void BufBound_WriteBE(BufBound* me,
72*418b791dSBob Badour const void *pvSrc, int nSrcSize,
73*418b791dSBob Badour const char *pszFields);
74*418b791dSBob Badour extern int BufBound_BufSize(BufBound *me);
75*418b791dSBob Badour extern int BufBound_Left(BufBound* me);
76*418b791dSBob Badour extern int BufBound_ReallyWrote(BufBound* me);
77*418b791dSBob Badour extern int BufBound_Wrote(BufBound* me);
78*418b791dSBob Badour
BufBound_IsFull(BufBound * me)79*418b791dSBob Badour static __inline int BufBound_IsFull(BufBound* me)
80*418b791dSBob Badour {
81*418b791dSBob Badour return (BufBound_Left(me) <= 0);
82*418b791dSBob Badour }
83*418b791dSBob Badour
84*418b791dSBob Badour // Deprecated:
BufBound_IsCounter(BufBound * me)85*418b791dSBob Badour static __inline int BufBound_IsCounter(BufBound* me)
86*418b791dSBob Badour {
87*418b791dSBob Badour return BufBound_BufSize(me) == 0;
88*418b791dSBob Badour }
89*418b791dSBob Badour
90*418b791dSBob Badour #ifdef __cplusplus
91*418b791dSBob Badour }
92*418b791dSBob Badour #endif /* #ifdef __cplusplus */
93*418b791dSBob Badour
94*418b791dSBob Badour
95*418b791dSBob Badour /*=====================================================================
96*418b791dSBob Badour =======================================================================
97*418b791dSBob Badour DATA STRUCTURE DOCUMENTATION
98*418b791dSBob Badour =======================================================================
99*418b791dSBob Badour
100*418b791dSBob Badour BufBound
101*418b791dSBob Badour
102*418b791dSBob Badour Description:
103*418b791dSBob Badour An BufBound keeps track of whether appending to a bounded buffer
104*418b791dSBob Badour has overflowed.
105*418b791dSBob Badour
106*418b791dSBob Badour Definition:
107*418b791dSBob Badour typedef struct BufBound
108*418b791dSBob Badour {
109*418b791dSBob Badour char* pcBuf;
110*418b791dSBob Badour char* pcWrite;
111*418b791dSBob Badour char* pcEnd;
112*418b791dSBob Badour } BufBound;
113*418b791dSBob Badour
114*418b791dSBob Badour Members:
115*418b791dSBob Badour pcBuf: original start pointer
116*418b791dSBob Badour pcWrite: current write location
117*418b791dSBob Badour pcEnd: first illegal write position
118*418b791dSBob Badour
119*418b791dSBob Badour See Also:
120*418b791dSBob Badour BufBound Interface
121*418b791dSBob Badour
122*418b791dSBob Badour =======================================================================
123*418b791dSBob Badour INTERFACE DOCUMENTATION
124*418b791dSBob Badour =======================================================================
125*418b791dSBob Badour BufBound Interface
126*418b791dSBob Badour
127*418b791dSBob Badour BufBound is a statically-linked interface.
128*418b791dSBob Badour
129*418b791dSBob Badour BufBound provides functions for safely appending to a character buffer. On
130*418b791dSBob Badour initialization, the buffer start address and size are provided. Subsequent
131*418b791dSBob Badour write operations are checked against the buffer bounds.
132*418b791dSBob Badour
133*418b791dSBob Badour Once the buffer bounds are exceeded, no bytes will be written but the
134*418b791dSBob Badour BufBound will continue to increment its internal "write pointer" to reflect
135*418b791dSBob Badour the number of bytes that would have been written (had the bounds not been
136*418b791dSBob Badour exceeded).
137*418b791dSBob Badour
138*418b791dSBob Badour When initialized with a buffer size of zero, a BufBound simply counts the
139*418b791dSBob Badour number of bytes that would be required to contain the result. This design
140*418b791dSBob Badour accommodates implementations that use the same logic for generating output
141*418b791dSBob Badour and measuring the space required for generated output.
142*418b791dSBob Badour
143*418b791dSBob Badour BufBound protects clients from numerical overflow by limiting the write
144*418b791dSBob Badour pointer to a maximum offset of INT_MAX from the start of the buffer.
145*418b791dSBob Badour Functions that write data into the buffer safely ignore negative size inputs
146*418b791dSBob Badour (Write and Putnc).
147*418b791dSBob Badour
148*418b791dSBob Badour =======================================================================
149*418b791dSBob Badour BufBound_Init()
150*418b791dSBob Badour
151*418b791dSBob Badour Description:
152*418b791dSBob Badour initialize a BufBound for appending to a buffer
153*418b791dSBob Badour
154*418b791dSBob Badour Prototype:
155*418b791dSBob Badour
156*418b791dSBob Badour void BufBound_Init(BufBound *me, char *pBuf, int nLen);
157*418b791dSBob Badour
158*418b791dSBob Badour Parameters:
159*418b791dSBob Badour me: the BufBound
160*418b791dSBob Badour pBuf: the bounded buffer
161*418b791dSBob Badour nLen: size of pBuf, in bytes
162*418b791dSBob Badour
163*418b791dSBob Badour Return Value:
164*418b791dSBob Badour None
165*418b791dSBob Badour
166*418b791dSBob Badour Comments:
167*418b791dSBob Badour None
168*418b791dSBob Badour
169*418b791dSBob Badour Side Effects:
170*418b791dSBob Badour None
171*418b791dSBob Badour
172*418b791dSBob Badour See Also:
173*418b791dSBob Badour None
174*418b791dSBob Badour
175*418b791dSBob Badour =======================================================================
176*418b791dSBob Badour
177*418b791dSBob Badour BufBound_Write()
178*418b791dSBob Badour
179*418b791dSBob Badour Description:
180*418b791dSBob Badour Appends some number of bytes to a BufBound, if possible.
181*418b791dSBob Badour
182*418b791dSBob Badour When a negative size is passed, it is safely treated as zero.
183*418b791dSBob Badour
184*418b791dSBob Badour Prototype:
185*418b791dSBob Badour
186*418b791dSBob Badour void BufBound_Write(BufBound *me, const char *pc, int nLen);
187*418b791dSBob Badour
188*418b791dSBob Badour Parameters:
189*418b791dSBob Badour me: the BufBound
190*418b791dSBob Badour pc: pointer to bytes to append
191*418b791dSBob Badour int nLen: number of bytes to write
192*418b791dSBob Badour
193*418b791dSBob Badour Return Value:
194*418b791dSBob Badour None
195*418b791dSBob Badour
196*418b791dSBob Badour Comments:
197*418b791dSBob Badour If the BufBound has overflowed, no bytes are written, but pcWrite is
198*418b791dSBob Badour *always* advanced by nLen.
199*418b791dSBob Badour
200*418b791dSBob Badour Side Effects:
201*418b791dSBob Badour None
202*418b791dSBob Badour
203*418b791dSBob Badour See Also:
204*418b791dSBob Badour None
205*418b791dSBob Badour
206*418b791dSBob Badour =======================================================================
207*418b791dSBob Badour
208*418b791dSBob Badour BufBound_Advance()
209*418b791dSBob Badour
210*418b791dSBob Badour Description:
211*418b791dSBob Badour
212*418b791dSBob Badour Moves the write pointer. Advance is like a relative seek operation. It
213*418b791dSBob Badour does not change the contents of the buffer, so when using a forward seek
214*418b791dSBob Badour (positive advance) be careful of advancing over uninitialized data.
215*418b791dSBob Badour
216*418b791dSBob Badour Negative numbers will decrease the write pointer down to 0 (the start of
217*418b791dSBob Badour the buffer) and not below. Positive numbers will increase the write
218*418b791dSBob Badour pointer up to offset INT_MAX and not beyond.
219*418b791dSBob Badour
220*418b791dSBob Badour Prototype:
221*418b791dSBob Badour
222*418b791dSBob Badour void BufBound_Advance(BufBound *me, int nDelta);
223*418b791dSBob Badour
224*418b791dSBob Badour Parameters:
225*418b791dSBob Badour me: the BufBound
226*418b791dSBob Badour int nLen: number of bytes to advance
227*418b791dSBob Badour
228*418b791dSBob Badour Return Value:
229*418b791dSBob Badour None
230*418b791dSBob Badour
231*418b791dSBob Badour Comments:
232*418b791dSBob Badour None
233*418b791dSBob Badour
234*418b791dSBob Badour Side Effects:
235*418b791dSBob Badour None
236*418b791dSBob Badour
237*418b791dSBob Badour See Also:
238*418b791dSBob Badour None
239*418b791dSBob Badour
240*418b791dSBob Badour =======================================================================
241*418b791dSBob Badour
242*418b791dSBob Badour BufBound_Putc()
243*418b791dSBob Badour
244*418b791dSBob Badour Description:
245*418b791dSBob Badour Appends one byte to a BufBound, if possible.
246*418b791dSBob Badour
247*418b791dSBob Badour Prototype:
248*418b791dSBob Badour
249*418b791dSBob Badour void BufBound_Putc(BufBound *me, char c);
250*418b791dSBob Badour
251*418b791dSBob Badour Parameters:
252*418b791dSBob Badour me: the BufBound
253*418b791dSBob Badour c: the byte
254*418b791dSBob Badour
255*418b791dSBob Badour Return Value:
256*418b791dSBob Badour None
257*418b791dSBob Badour
258*418b791dSBob Badour Comments:
259*418b791dSBob Badour If the BufBound has overflowed, no byte is written, but pcWrite is
260*418b791dSBob Badour *always* advanced by 1.
261*418b791dSBob Badour
262*418b791dSBob Badour Side Effects:
263*418b791dSBob Badour None
264*418b791dSBob Badour
265*418b791dSBob Badour See Also:
266*418b791dSBob Badour None
267*418b791dSBob Badour
268*418b791dSBob Badour
269*418b791dSBob Badour =======================================================================
270*418b791dSBob Badour
271*418b791dSBob Badour BufBound_Putnc()
272*418b791dSBob Badour
273*418b791dSBob Badour Description:
274*418b791dSBob Badour Appends a byte to a BufBound repeatedly.
275*418b791dSBob Badour
276*418b791dSBob Badour When a negative size is passed, it is safely treated as zero.
277*418b791dSBob Badour
278*418b791dSBob Badour Prototype:
279*418b791dSBob Badour
280*418b791dSBob Badour void BufBound_Putnc(BufBound *me, char c, int nCount);
281*418b791dSBob Badour
282*418b791dSBob Badour Parameters:
283*418b791dSBob Badour me: the BufBound
284*418b791dSBob Badour c: the byte
285*418b791dSBob Badour nCount: number of times to append c
286*418b791dSBob Badour
287*418b791dSBob Badour Return Value:
288*418b791dSBob Badour None
289*418b791dSBob Badour
290*418b791dSBob Badour Comments:
291*418b791dSBob Badour If the BufBound has overflowed, no byte is written, but pcWrite is
292*418b791dSBob Badour *always* advanced by nCount.
293*418b791dSBob Badour
294*418b791dSBob Badour Side Effects:
295*418b791dSBob Badour None
296*418b791dSBob Badour
297*418b791dSBob Badour See Also:
298*418b791dSBob Badour None
299*418b791dSBob Badour
300*418b791dSBob Badour
301*418b791dSBob Badour =======================================================================
302*418b791dSBob Badour
303*418b791dSBob Badour BufBound_ForceNullTerm()
304*418b791dSBob Badour
305*418b791dSBob Badour Description:
306*418b791dSBob Badour Appends a null terminating character to a BufBound, if possible.
307*418b791dSBob Badour If the BufBound has overflowed, the last legal location is
308*418b791dSBob Badour set to '\0'.
309*418b791dSBob Badour
310*418b791dSBob Badour Prototype:
311*418b791dSBob Badour void BufBound_ForceNullTerm(BufBound *me);
312*418b791dSBob Badour
313*418b791dSBob Badour Parameters:
314*418b791dSBob Badour me: the BufBound
315*418b791dSBob Badour
316*418b791dSBob Badour Return Value:
317*418b791dSBob Badour None
318*418b791dSBob Badour
319*418b791dSBob Badour Comments:
320*418b791dSBob Badour pcWrite is *always* advanced by 1.
321*418b791dSBob Badour
322*418b791dSBob Badour Side Effects:
323*418b791dSBob Badour None
324*418b791dSBob Badour
325*418b791dSBob Badour See Also:
326*418b791dSBob Badour None
327*418b791dSBob Badour
328*418b791dSBob Badour
329*418b791dSBob Badour =======================================================================
330*418b791dSBob Badour
331*418b791dSBob Badour BufBound_Puts()
332*418b791dSBob Badour
333*418b791dSBob Badour Description:
334*418b791dSBob Badour Appends a null-terminated string to a BufBound, if possible
335*418b791dSBob Badour
336*418b791dSBob Badour Prototype:
337*418b791dSBob Badour
338*418b791dSBob Badour void BufBound_Puts(BufBound *me, const char* cpsz);
339*418b791dSBob Badour
340*418b791dSBob Badour Parameters:
341*418b791dSBob Badour me: the BufBound
342*418b791dSBob Badour cpsz: the string to append
343*418b791dSBob Badour
344*418b791dSBob Badour Return Value:
345*418b791dSBob Badour
346*418b791dSBob Badour Comments:
347*418b791dSBob Badour If the BufBound has overflowed, no bytes are written, but pcWrite is
348*418b791dSBob Badour *always* advanced by strlen(cpsz).
349*418b791dSBob Badour
350*418b791dSBob Badour Side Effects:
351*418b791dSBob Badour None
352*418b791dSBob Badour
353*418b791dSBob Badour See Also:
354*418b791dSBob Badour None
355*418b791dSBob Badour
356*418b791dSBob Badour
357*418b791dSBob Badour =======================================================================
358*418b791dSBob Badour
359*418b791dSBob Badour BufBound_BufSize()
360*418b791dSBob Badour
361*418b791dSBob Badour Description:
362*418b791dSBob Badour Returns the size of the buffer owned by the BufBound. This is
363*418b791dSBob Badour the same as the number passed to BufBound_Init (MAXed with zero).
364*418b791dSBob Badour
365*418b791dSBob Badour Prototype:
366*418b791dSBob Badour
367*418b791dSBob Badour int BufBound_IsCounter(BufBound* me);
368*418b791dSBob Badour
369*418b791dSBob Badour Parameters:
370*418b791dSBob Badour me: the BufBound
371*418b791dSBob Badour
372*418b791dSBob Badour Return Value:
373*418b791dSBob Badour 1 if the BufBound is a counter, 0 otherwise
374*418b791dSBob Badour
375*418b791dSBob Badour Comments:
376*418b791dSBob Badour None
377*418b791dSBob Badour
378*418b791dSBob Badour Side Effects:
379*418b791dSBob Badour None
380*418b791dSBob Badour
381*418b791dSBob Badour See Also:
382*418b791dSBob Badour None
383*418b791dSBob Badour
384*418b791dSBob Badour
385*418b791dSBob Badour =======================================================================
386*418b791dSBob Badour
387*418b791dSBob Badour BufBound_Left()
388*418b791dSBob Badour
389*418b791dSBob Badour Description:
390*418b791dSBob Badour Returns the number of bytes the BufBound can still accomodate,
391*418b791dSBob Badour without overflowing. If overflow has occurred, it will return
392*418b791dSBob Badour a negative number.
393*418b791dSBob Badour
394*418b791dSBob Badour Prototype:
395*418b791dSBob Badour
396*418b791dSBob Badour int BufBound_Left(BufBound* me);
397*418b791dSBob Badour
398*418b791dSBob Badour Parameters:
399*418b791dSBob Badour me: the BufBound
400*418b791dSBob Badour
401*418b791dSBob Badour Return Value:
402*418b791dSBob Badour The number of bytes the BufBound can still accomodate,
403*418b791dSBob Badour without overflowing.
404*418b791dSBob Badour
405*418b791dSBob Badour Comments:
406*418b791dSBob Badour The return value may be negative, if overflow has already occurred.
407*418b791dSBob Badour
408*418b791dSBob Badour Side Effects:
409*418b791dSBob Badour None
410*418b791dSBob Badour
411*418b791dSBob Badour See Also:
412*418b791dSBob Badour None
413*418b791dSBob Badour
414*418b791dSBob Badour
415*418b791dSBob Badour =======================================================================
416*418b791dSBob Badour
417*418b791dSBob Badour BufBound_ReallyWrote()
418*418b791dSBob Badour
419*418b791dSBob Badour Description:
420*418b791dSBob Badour Returns the number of bytes actually written to the BufBound,
421*418b791dSBob Badour not including any overflow.
422*418b791dSBob Badour
423*418b791dSBob Badour Prototype:
424*418b791dSBob Badour
425*418b791dSBob Badour int BufBound_ReallyWrote(BufBound* me);
426*418b791dSBob Badour
427*418b791dSBob Badour Parameters:
428*418b791dSBob Badour me: the BufBound
429*418b791dSBob Badour
430*418b791dSBob Badour Return Value:
431*418b791dSBob Badour The number of bytes actually written to the BufBound,
432*418b791dSBob Badour not including any overflow.
433*418b791dSBob Badour
434*418b791dSBob Badour Comments:
435*418b791dSBob Badour None
436*418b791dSBob Badour
437*418b791dSBob Badour Side Effects:
438*418b791dSBob Badour None
439*418b791dSBob Badour
440*418b791dSBob Badour See Also:
441*418b791dSBob Badour None
442*418b791dSBob Badour
443*418b791dSBob Badour
444*418b791dSBob Badour =======================================================================
445*418b791dSBob Badour
446*418b791dSBob Badour BufBound_Wrote()
447*418b791dSBob Badour
448*418b791dSBob Badour Description:
449*418b791dSBob Badour
450*418b791dSBob Badour Returns the number of bytes written to the BufBound, including any
451*418b791dSBob Badour overflow, up to INT_MAX.
452*418b791dSBob Badour
453*418b791dSBob Badour Prototype:
454*418b791dSBob Badour
455*418b791dSBob Badour int BufBound_Wrote(BufBound* me);
456*418b791dSBob Badour
457*418b791dSBob Badour Parameters:
458*418b791dSBob Badour me: the BufBound
459*418b791dSBob Badour
460*418b791dSBob Badour Return Value:
461*418b791dSBob Badour
462*418b791dSBob Badour The number of bytes written to the BufBound, including any overflow.
463*418b791dSBob Badour
464*418b791dSBob Badour Comments:
465*418b791dSBob Badour None
466*418b791dSBob Badour
467*418b791dSBob Badour Side Effects:
468*418b791dSBob Badour None
469*418b791dSBob Badour
470*418b791dSBob Badour See Also:
471*418b791dSBob Badour None
472*418b791dSBob Badour
473*418b791dSBob Badour
474*418b791dSBob Badour =======================================================================
475*418b791dSBob Badour
476*418b791dSBob Badour BufBound_IsFull()
477*418b791dSBob Badour
478*418b791dSBob Badour Description:
479*418b791dSBob Badour Tests whether an AEEBuffBound has overflowed.
480*418b791dSBob Badour
481*418b791dSBob Badour Prototype:
482*418b791dSBob Badour
483*418b791dSBob Badour int BufBound_IsFull(BufBound* me);
484*418b791dSBob Badour
485*418b791dSBob Badour Parameters:
486*418b791dSBob Badour me: the BufBound
487*418b791dSBob Badour
488*418b791dSBob Badour Return Value:
489*418b791dSBob Badour 1 if the BufBound has overflowed, 0 otherwise
490*418b791dSBob Badour
491*418b791dSBob Badour Comments:
492*418b791dSBob Badour None
493*418b791dSBob Badour
494*418b791dSBob Badour Side Effects:
495*418b791dSBob Badour None
496*418b791dSBob Badour
497*418b791dSBob Badour See Also:
498*418b791dSBob Badour None
499*418b791dSBob Badour
500*418b791dSBob Badour =======================================================================
501*418b791dSBob Badour
502*418b791dSBob Badour BufBound_WriteLE()
503*418b791dSBob Badour
504*418b791dSBob Badour Description:
505*418b791dSBob Badour
506*418b791dSBob Badour Writes data while translating numeric values between host byte ordering and
507*418b791dSBob Badour "little endian" byte ordering.
508*418b791dSBob Badour
509*418b791dSBob Badour The input buffer is treated as an array of structures. The 'abySizes'
510*418b791dSBob Badour parameter describes the sizes of fields in the structure.
511*418b791dSBob Badour
512*418b791dSBob Badour When the host byte ordering matches the target byte ordering (little
513*418b791dSBob Badour endian) this operation is equivalent to BufBound_Write().
514*418b791dSBob Badour
515*418b791dSBob Badour Prototype:
516*418b791dSBob Badour
517*418b791dSBob Badour void BufBound_WriteLE(BufBound* me,
518*418b791dSBob Badour const void *pvSrc, int nSrcSize,
519*418b791dSBob Badour const unsigned char *pszFields);
520*418b791dSBob Badour
521*418b791dSBob Badour Parameters:
522*418b791dSBob Badour me: the BufBound
523*418b791dSBob Badour pvSrc: the source buffer
524*418b791dSBob Badour nSrcSize: number of bytes to copy from the source buffer
525*418b791dSBob Badour pszFields: Description of the fields that comprise the source data,
526*418b791dSBob Badour as defined in std_CopyLE.
527*418b791dSBob Badour
528*418b791dSBob Badour Return Value:
529*418b791dSBob Badour None
530*418b791dSBob Badour
531*418b791dSBob Badour See Also:
532*418b791dSBob Badour BufBound_WriteBE, std_CopyLE
533*418b791dSBob Badour
534*418b791dSBob Badour =======================================================================
535*418b791dSBob Badour
536*418b791dSBob Badour BufBound_WriteBE()
537*418b791dSBob Badour
538*418b791dSBob Badour Description:
539*418b791dSBob Badour
540*418b791dSBob Badour BufBounf_WriteBE() has the same semantics as BufBound_WriteLE() except it
541*418b791dSBob Badour copies between host byte ordering and big-endian ("network") byte order.
542*418b791dSBob Badour
543*418b791dSBob Badour See BufBound_WriteLE() for more details.
544*418b791dSBob Badour
545*418b791dSBob Badour
546*418b791dSBob Badour Prototype:
547*418b791dSBob Badour
548*418b791dSBob Badour void BufBound_WriteBE(BufBound* me,
549*418b791dSBob Badour const void *pvSrc, int nSrcSize,
550*418b791dSBob Badour const unsigned char *pszFields);
551*418b791dSBob Badour
552*418b791dSBob Badour Parameters:
553*418b791dSBob Badour me: the BufBound
554*418b791dSBob Badour pvSrc: the source buffer
555*418b791dSBob Badour nSrcSize: number of bytes to copy from the source buffer
556*418b791dSBob Badour pszFields: Description of the fields that comprise the source data,
557*418b791dSBob Badour as defined in std_CopyLE.
558*418b791dSBob Badour
559*418b791dSBob Badour Return Value:
560*418b791dSBob Badour None
561*418b791dSBob Badour
562*418b791dSBob Badour See Also:
563*418b791dSBob Badour BufBound_WriteLE, std_CopyBE
564*418b791dSBob Badour
565*418b791dSBob Badour ======================================================================= */
566*418b791dSBob Badour #endif /* #ifndef AEEBUFBOUND_H */
567*418b791dSBob Badour
568