Loading...
Searching...
No Matches
cstring_fit.h File Reference

Copying text into a fixed buffer, and checking what a buffer holds before it is used. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

Go to the source code of this file.

Functions

static void cstring_fit (char *dst, const char *src, size_t size)
 Copy a string into a fixed buffer, keeping only what fits and always terminating it.
static bool cstring_fit_same (const char *current, const char *value, size_t size)
 Whether copying value into a buffer would leave it reading exactly as it does now.
void copy_bounded (char *dst, uint8_t cap, const uint8_t *src, uint8_t len)
 Copy bytes into a fixed buffer, taking what fits and terminating it.
bool cstring_is_clean (const char *s, uint16_t size)
 Whether a byte range holds a string worth keeping.
bool cstring_setting_is_clean (const char *s, uint16_t size, const char *default_str)
 Whether a saved text setting reads as one, where an empty setting can be the real value.

Detailed Description

Copying text into a fixed buffer, and checking what a buffer holds before it is used.