#ifndef SENTRY_STRING_H_INCLUDED
#define SENTRY_STRING_H_INCLUDED
#include "sentry_boot.h"
#include <ctype.h>
#include <stdio.h>
#include <string.h>
typedef struct sentry_stringbuilder_s {
char *buf;
size_t allocated;
size_t len;
} sentry_stringbuilder_t;
void sentry__stringbuilder_init(sentry_stringbuilder_t *sb);
int sentry__stringbuilder_append(sentry_stringbuilder_t *sb, const char *s);
int sentry__stringbuilder_append_buf(
sentry_stringbuilder_t *sb, const char *s, size_t len);
int sentry__stringbuilder_append_char(sentry_stringbuilder_t *sb, char c);
int sentry__stringbuilder_append_char32(sentry_stringbuilder_t *sb, uint32_t c);
static inline int
sentry__stringbuilder_append_int64(sentry_stringbuilder_t *sb, int64_t val)
{
char buf[24];
snprintf(buf, sizeof(buf), "%" PRId64, val);
return sentry__stringbuilder_append(sb, buf);
}
char *sentry__stringbuilder_into_string(sentry_stringbuilder_t *sb);
char *sentry_stringbuilder_take_string(sentry_stringbuilder_t *sb);
void sentry__stringbuilder_cleanup(sentry_stringbuilder_t *sb);
size_t sentry__stringbuilder_len(const sentry_stringbuilder_t *sb);
char *sentry__string_clone(const char *str);
char *sentry__string_clonen(const char *str, size_t n);
static inline void
sentry__string_ascii_lower(char *s)
{
for (; *s; s++) {
*s = (char)tolower((char)*s);
}
}
static inline bool
sentry__string_eq(const char *a, const char *b)
{
return strcmp(a, b) == 0;
}
static inline char *
sentry__int64_to_string(int64_t val)
{
char buf[24];
snprintf(buf, sizeof(buf), "%" PRId64, val);
return sentry__string_clone(buf);
}
#ifdef SENTRY_PLATFORM_WINDOWS
char *sentry__string_from_wstr(const wchar_t *s);
wchar_t *sentry__string_to_wstr(const char *s);
#endif
size_t sentry__unichar_to_utf8(uint32_t c, char *buf);
#define sentry__is_lead_surrogate(c) ((c) >= 0xd800 && (c) < 0xdc00)
#define sentry__is_trail_surrogate(c) ((c) >= 0xdc00 && (c) < 0xe000)
#define sentry__surrogate_value(lead, trail) \
(((((lead)-0xd800) << 10) | ((trail)-0xdc00)) + 0x10000)
#endif