Subversion Repositories QNX 8.QNX8 IFS tool

Rev

Rev 16 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16 Rev 38
Line 19... Line 19...
19
   size_t size; // buffer size in bytes (i.e byte length of data)
19
   size_t size; // buffer size in bytes (i.e byte length of data)
20
} buffer_t;
20
} buffer_t;
21
 
21
 
22
 
22
 
23
// function prototypes
23
// function prototypes
24
#define Buffer_Initialize(buffer) (memset ((buffer), 0, sizeof (buffer_t)), 1)
24
#define Buffer_Initialize(buffer) (memset ((buffer), 0, sizeof (buffer_t)) != NULL)
25
#define Buffer_InitWithSize(buffer,size) (Buffer_Initialize ((buffer)), Buffer_Append ((buffer), NULL, (size)))
25
#define Buffer_InitWithSize(buffer,size) (Buffer_Initialize ((buffer)) && Buffer_Append ((buffer), NULL, (size)))
26
#define Buffer_InitWithCString(buffer,data_string) (Buffer_Initialize ((buffer)), Buffer_Append ((buffer), (data_string), strlen ((data_string))))
26
#define Buffer_InitWithCString(buffer,data_string) (Buffer_Initialize ((buffer)) && Buffer_Append ((buffer), (data_string), strlen ((data_string))))
27
#define Buffer_InitWithFormattedCString(buffer,fmt_string,...) (Buffer_Initialize ((buffer)), Buffer_AppendFormattedCString ((buffer), (fmt_string), __VA_ARGS__))
27
#define Buffer_InitWithFormattedCString(buffer,fmt_string,...) (Buffer_Initialize ((buffer)) && Buffer_AppendFormattedCString ((buffer), (fmt_string), __VA_ARGS__))
28
#define Buffer_InitWithByteArray(buffer,data_array) (Buffer_Initialize ((buffer)), Buffer_Append ((buffer), (data_array), sizeof ((data_array)) - 1)) // WARNING: DO NOT USE WITH TERNARY OPERATORS!
28
#define Buffer_InitWithByteArray(buffer,data_array) (Buffer_Initialize ((buffer)) && Buffer_Append ((buffer), (data_array), sizeof ((data_array)) - 1)) // WARNING: DO NOT USE WITH TERNARY OPERATORS!
29
#define Buffer_InitWithData(buffer,data,data_size) (Buffer_Initialize ((buffer)), Buffer_Append ((buffer), (data), (data_size)))
29
#define Buffer_InitWithData(buffer,data,data_size) (Buffer_Initialize ((buffer)) && Buffer_Append ((buffer), (data), (data_size)))
30
#define Buffer_InitWithBuffer(buffer,data_buffer) (Buffer_Initialize ((buffer)), Buffer_Append ((buffer), (data_buffer)->bytes, (data_buffer)->size))
30
#define Buffer_InitWithBuffer(buffer,data_buffer) (Buffer_Initialize ((buffer)) && Buffer_Append ((buffer), (data_buffer)->bytes, (data_buffer)->size))
31
void Buffer_Forget (buffer_t *buffer);
31
void Buffer_Forget (buffer_t *buffer);
32
int Buffer_Reset (buffer_t *buffer);
32
int Buffer_Reset (buffer_t *buffer);
33
#define Buffer_ResetWithData(buffer,data,data_size) (Buffer_Reset ((buffer)), Buffer_Append ((buffer), (data), (data_size)))
33
#define Buffer_ResetWithData(buffer,data,data_size) (Buffer_Reset ((buffer)) && Buffer_Append ((buffer), (data), (data_size)))
34
#define Buffer_ResetWithCString(buffer,data_string) (Buffer_Reset ((buffer)), Buffer_Append ((buffer), (data_string), strlen ((data_string))))
34
#define Buffer_ResetWithCString(buffer,data_string) (Buffer_Reset ((buffer)) && Buffer_Append ((buffer), (data_string), strlen ((data_string))))
35
#define Buffer_ResetWithFormattedCString(buffer,fmt_string,...) (Buffer_Reset ((buffer)), Buffer_AppendFormattedCString ((buffer), (fmt_string), __VA_ARGS__))
35
#define Buffer_ResetWithFormattedCString(buffer,fmt_string,...) (Buffer_Reset ((buffer)) && Buffer_AppendFormattedCString ((buffer), (fmt_string), __VA_ARGS__))
36
#define Buffer_ResetWithByteArray(buffer,data_array) (Buffer_Reset ((buffer)), Buffer_Append ((buffer), (data_array), sizeof ((data_array)) - 1)) // WARNING: DO NOT USE WITH TERNARY OPERATORS!
36
#define Buffer_ResetWithByteArray(buffer,data_array) (Buffer_Reset ((buffer)) && Buffer_Append ((buffer), (data_array), sizeof ((data_array)) - 1)) // WARNING: DO NOT USE WITH TERNARY OPERATORS!
37
#define Buffer_ResetWithBuffer(buffer,data_buffer) (Buffer_Reset ((buffer)), Buffer_Append ((buffer), (data_buffer)->bytes, (data_buffer)->size))
37
#define Buffer_ResetWithBuffer(buffer,data_buffer) (Buffer_Reset ((buffer)) && Buffer_Append ((buffer), (data_buffer)->bytes, (data_buffer)->size))
38
int Buffer_Append (buffer_t *buffer, const void *data, const size_t data_size);
38
int Buffer_Append (buffer_t *buffer, const void *data, const size_t data_size);
39
#define Buffer_AppendCString(buffer,data_string) Buffer_Append ((buffer), (data_string), strlen ((data_string)))
39
#define Buffer_AppendCString(buffer,data_string) Buffer_Append ((buffer), (data_string), strlen ((data_string)))
40
#define Buffer_AppendByteArray(buffer,data_array) Buffer_Append ((buffer), (data_array), sizeof ((data_array)) - 1) // WARNING: DO NOT USE WITH TERNARY OPERATORS!
40
#define Buffer_AppendByteArray(buffer,data_array) Buffer_Append ((buffer), (data_array), sizeof ((data_array)) - 1) // WARNING: DO NOT USE WITH TERNARY OPERATORS!
41
#define Buffer_AppendBuffer(buffer,data_buffer) Buffer_Append ((buffer), (data_buffer)->bytes, (data_buffer)->size)
41
#define Buffer_AppendBuffer(buffer,data_buffer) Buffer_Append ((buffer), (data_buffer)->bytes, (data_buffer)->size)
42
int Buffer_AppendFormattedCString (buffer_t *buffer, const char *fmt_string, ...);
42
int Buffer_AppendFormattedCString (buffer_t *buffer, const char *fmt_string, ...);