ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
string.c File Reference

String utility functions for WASM/Emscripten. More...

Go to the source code of this file.

Functions

size_t platform_strlcpy (char *dst, const char *src, size_t size)
 Safe string copy with size tracking (strlcpy)
 
size_t platform_strlcat (char *dst, const char *src, size_t size)
 
int platform_strcasecmp (const char *s1, const char *s2)
 Case-insensitive string comparison.
 
int platform_asprintf (char **strp, const char *fmt,...)
 Allocate formatted string (asprintf replacement)
 
char * platform_strdup (const char *s)
 Duplicate string (strdup replacement)
 
asciichat_error_t platform_memcpy (void *dest, size_t dest_size, const void *src, size_t count)
 Platform-safe memcpy wrapper.
 
asciichat_error_t platform_memset (void *dest, size_t dest_size, int ch, size_t count)
 Platform-safe memset wrapper.
 
int platform_vsnprintf (char *str, size_t size, const char *format, va_list ap)
 Safe variable-argument string formatting.
 
int platform_strncasecmp (const char *s1, const char *s2, size_t n)
 Case-insensitive string comparison with length limit.
 
asciichat_error_t platform_strcpy (char *dest, size_t dest_size, const char *src)
 Platform-safe strcpy wrapper.
 

Detailed Description

String utility functions for WASM/Emscripten.

Definition in file platform/wasm/string.c.

Function Documentation

◆ platform_strlcat()

size_t platform_strlcat ( char *  dst,
const char *  src,
size_t  size 
)

Definition at line 27 of file platform/wasm/string.c.

27 {
28 size_t dst_len = strlen(dst);
29 size_t src_len = strlen(src);
30
31 if (dst_len >= size) {
32 return dst_len + src_len;
33 }
34
35 size_t remaining = size - dst_len;
36 size_t copy_len = (src_len >= remaining) ? remaining - 1 : src_len;
37 memcpy(dst + dst_len, src, copy_len);
38 dst[dst_len + copy_len] = '\0';
39
40 return dst_len + src_len;
41}