#include <stdint.h>
#include "externs.h"
#include "ziti_log.h"
#include <unistd.h>
Go to the source code of this file.
|
typedef struct string_buf_s | string_buf_t |
| Growing string buffer.
|
|
◆ string_buf_t
Growing string buffer.
string_buf allocates memory internally as needed unless it was created with [new_fixed_string_buf()]
◆ delete_string_buf()
Deallocate all memory associated with the given string buffer.
The passed in pointer is not valid after the function invocation.
- Parameters
-
◆ new_fixed_string_buf()
string_buf_t * new_fixed_string_buf |
( |
char * |
outbuf, |
|
|
size_t |
max |
|
) |
| |
Create buffer using passed in memory for output.
No new memory will be allocated.
- Parameters
-
- Returns
- new buffer instance
◆ new_string_buf()
Create new string buffer.
- Returns
- new buffer instance
◆ string_buf_append()
int string_buf_append |
( |
string_buf_t * |
wb, |
|
|
const char * |
str |
|
) |
| |
Append \0
terminated string to the buffer.
- Parameters
-
wb | string buffer |
str | string |
- Returns
- 0 on success, -1 if
wb
is a fixed buffer and appending would go over its limit.
◆ string_buf_append_byte()
Append one byte to the string buffer.
- Parameters
-
wb | string buffer |
c | byte to append |
- Returns
- 0 on success, -1 if
wb
is a fixed buffer and appending would go over its limit.
◆ string_buf_append_urlsafe()
int string_buf_append_urlsafe |
( |
string_buf_t * |
wb, |
|
|
const char * |
str |
|
) |
| |
Appends [str] to [wb] converting to urlsafe encoding.
◆ string_buf_appendn()
int string_buf_appendn |
( |
string_buf_t * |
wb, |
|
|
const char * |
str, |
|
|
size_t |
len |
|
) |
| |
Append len
bytes from str
to the string buffer.
- Parameters
-
wb | string buffer |
str | string |
len | number of bytes to append |
- Returns
- 0 on success, -1 if
wb
is a fixed buffer and appending would go over its limit.
◆ string_buf_fmt()
int string_buf_fmt |
( |
string_buf_t * |
wb, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
printf style append operation.
- Parameters
-
wb | string buffer |
fmt | printf-style format string |
... | arguments to the fmt argument |
- Returns
- 0 on success, -1 if
wb
is a fixed buffer and appending would go over its limit.
◆ string_buf_size()
number of bytes written to the string buffer so far
- Parameters
-
- Returns
- number of bytes in the buffer
◆ string_buf_to_string()
char * string_buf_to_string |
( |
string_buf_t * |
wb, |
|
|
size_t * |
outlen |
|
) |
| |
Allocate string big enough to hold the contents of the buffer with '\0at the end and copy contents into the result.
String buffer is cleared after operation is complete. @param wb string buffer @param outlen size of the output not including final\0' terminator
- Returns
- allocated string filled with buffer content