strfuncs.c revision 9464dc83df5da54457ff0b629d02e543e43d53bf
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březina/* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březina/* @UNSAFE: whole file */
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březinaconst unsigned char *uchar_empty_ptr = { 0 };
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březinaint i_snprintf(char *dest, size_t max_chars, const char *format, ...)
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březina ret = vsnprintf(dest, max_chars, printf_format_fix_unsafe(format),
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březina return (unsigned int)ret < max_chars ? 0 : -1;
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březinavoid *p_memdup(pool_t pool, const void *data, size_t size)
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březinachar *p_strdup_empty(pool_t pool, const char *str)
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březinachar *p_strdup_until(pool_t pool, const void *start, const void *end)
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březina i_assert((const char *) start <= (const char *) end);
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březina size = (size_t) ((const char *) end - (const char *) start);
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březinachar *p_strndup(pool_t pool, const void *str, size_t max_chars)
f8c829e72968b574e1c9bda96f4d5f206622358fPavel Březina while (len < max_chars && ((const char *) str)[len] != '\0')
char *ret;
return ret;
unsigned int *size_r)
char *tmp;
int ret;
#ifdef DEBUG
#ifdef DEBUG
return tmp;
unsigned int size;
return tmp;
return buf;
const char *str;
char *temp;
*ret_len = i;
return temp;
return ret;
const char *ret;
return ret;
const char *ret;
return ret;
if (*p == cutchar)
return str;
char *out;
return str;
for (i = 0; i < len; i++) {
return out;
if (dstsize == 0)
dstsize--;
*p = i_toupper(*p);
return str;
*p = i_tolower(*p);
return str;
p = str;
if (p == pend)
begin = p;
p = pend;
if (p == begin)
end = p;
return begin;
int ret;
while (size > 0) {
if (ret != 0)
return ret;
size_t i;
int ret = 0;
for (i = 0; i < size; i++)
return ret == 0;
char **array;
char *str;
if (spaces) {
data++;
sizeof(char *) * alloc_count,
if (spaces) {
str++;
str++;
return array;
const char *separators)
unsigned int count;
count++;
return count;
const char *separator)
char *str;
pos = 0;
for (i = 0; i < arr_len; i++) {
return str;
const char **dest;
return TRUE;
return FALSE;
return TRUE;
return FALSE;
return TRUE;
return FALSE;
const char **ret;
ret[i] = p;
p += len;
return ret;
char *buffer;
int pos;
const char *separator)