This file declares a simple string object that can be appended to.
More...
Go to the source code of this file.
|
| struct | sc_string |
| | This is a simple type for growing a string by printf-like commands. More...
|
| |
|
|
#define | SC_STRING_SIZE 4088 |
| | This defines the maximum string storage including the trailing '\0'.
|
| |
|
| typedef struct sc_string | sc_string_t |
| | This is a simple type for growing a string by printf-like commands.
|
| |
This file declares a simple string object that can be appended to.
◆ sc_string_t
This is a simple type for growing a string by printf-like commands.
It is public so it can be declared on the stack to avoid malloc and free. This means that the length of the string is limited to SC_STRING_SIZE - 1. The current string can be accessed by sc_string_get_content. This is really an opaque object: its members shall not be accessed directly.
◆ sc_string_get_content()
| const char * sc_string_get_content |
( |
sc_string_t * |
scs, |
|
|
int * |
length |
|
) |
| |
Access content of the string buffer.
- Parameters
-
| [in] | scs | Valid sc_string object. |
| [in] | length | If not NULL, assign length without trailing '\0'. |
- Returns
- Pointer to an internally allocated string, may not be used after scs goes out of scope.
◆ sc_string_init()
Initialize to an empty string.
This function can be used to reset a non-empty string to be empty again.
- Parameters
-
| [out] | scs | After returning, a valid object containing the empty string. |
◆ sc_string_putc()
Append a single character to the string buffer object.
- Parameters
-
| [in,out] | scs | A valid string buffer object. |
| [in] | c | Converted to an unsigned char and appended. |
- Returns
- Zero if the character has been appended and a negative value when the input was truncated.
◆ sc_string_putf()
| int sc_string_putf |
( |
sc_string_t * |
scs, |
|
|
SC_PRINTF_FMT const char * |
fmt, |
|
|
|
... |
|
) |
| |
Append to the string object using a format string and arguments.
The maximum length will not be exceeded. The string object will remain valid even on truncated input.
- Parameters
-
| [in,out] | scs | Valid string object that is appended to. |
| [in] | fmt | Format string as used with printf and friends. |
- Returns
- Zero if everything has been appended and a negative value when the input was truncated.
◆ sc_string_puts()
| int sc_string_puts |
( |
sc_string_t * |
scs, |
|
|
const char * |
s |
|
) |
| |
Append a string to the string buffer object.
- Parameters
-
| [in,out] | scs | A valid string buffer object. |
| [in] | s | This string is appended to the string buffer. |
- Returns
- Zero if the string has been appended and a negative value when the input was truncated.
◆ sc_string_putv()
| int int sc_string_putv |
( |
sc_string_t * |
scs, |
|
|
const char * |
fmt, |
|
|
va_list |
ap |
|
) |
| |
Append to the string object using a format string and a vararg pointer.
The maximum length will not be exceeded. The string object will remain valid even on truncated input.
- Parameters
-
| [in,out] | scs | Valid string object that is appended to. |
| [in] | fmt | Format string as used with printf and friends. |
| [in,out] | ap | Argument list pointer as defined in stdarg.h. |
- Returns
- Zero if everything has been appended and a negative value when the input was truncated.