28#ifndef MUTT_MUTT_STRING2_H
29#define MUTT_MUTT_STRING2_H
35#define STR_COMMAND 8192
37#define NONULL(x) ((x) ? (x) : "")
46 while (*(ch) && isspace((unsigned char) *(ch))) \
49#define terminate_string(str, strlen, buflen) \
50 (str)[MIN((strlen), (buflen))] = '\0'
52#define terminate_buffer(str, strlen) \
53 terminate_string(str, strlen, sizeof(str) - 1)
57 __attribute__((__format__(__printf__, 2, 3)));
76size_t mutt_str_copy(
char *dest, const
char *src,
size_t dsize);
82char *
mutt_strn_copy(
char *dest, const
char *src,
size_t len,
size_t dsize);
89const
char *
mutt_istr_find(const
char *haystack, const
char *needle);
97const
char *
mutt_istrn_rfind(const
char *haystack,
size_t haystack_length, const
char *needle);
106 return (c ==
' ') || (c ==
'\t') || (c ==
'\r') || (c ==
'\n');
int mutt_str_inbox_cmp(const char *a, const char *b)
Do two folders share the same path and one is an inbox -.
const char * mutt_str_sysexit(int e)
Return a string matching an error code.
int mutt_str_cmp(const char *a, const char *b)
Compare two strings, safely.
int mutt_istrn_cmp(const char *a, const char *b, size_t num)
Compare two strings ignoring case (to a maximum), safely.
void mutt_str_remove_trailing_ws(char *s)
Trim trailing whitespace from a string.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
char * mutt_str_dup(const char *str)
Copy a string, safely.
int mutt_str_asprintf(char **strp, const char *fmt,...) __attribute__((__format__(__printf__
char * mutt_str_upper(char *str)
Convert all characters in the string to uppercase.
char * mutt_str_lower(char *str)
Convert all characters in the string to lowercase.
char * mutt_str_skip_email_wsp(const char *s)
Skip over whitespace as defined by RFC5322.
const char * mutt_istrn_rfind(const char *haystack, size_t haystack_length, const char *needle)
Find last instance of a substring, ignoring case.
size_t mutt_str_lws_len(const char *s, size_t n)
Measure the linear-white-space at the beginning of a string.
bool mutt_str_is_ascii(const char *str, size_t len)
Is a string ASCII (7-bit)?
int mutt_istr_cmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
char * mutt_strn_dup(const char *begin, size_t l)
Duplicate a sub-string.
int int mutt_str_coll(const char *a, const char *b)
Collate two strings (compare using locale), safely.
const char * mutt_str_find_word(const char *src)
Find the end of a word (non-space)
char * mutt_strn_copy(char *dest, const char *src, size_t len, size_t dsize)
Copy a sub-string into a buffer.
int mutt_istr_remall(char *str, const char *target)
Remove all occurrences of substring, ignoring case.
const char * mutt_str_getenv(const char *name)
Get an environment variable.
const char * mutt_istr_find(const char *haystack, const char *needle)
Find first occurrence of string (ignoring case)
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
void mutt_str_hyphenate(char *buf, size_t buflen, const char *str)
Hyphenate a snake-case string.
char * mutt_str_skip_whitespace(const char *p)
Find the first non-whitespace character in a string.
void mutt_str_adjust(char **ptr)
Shrink-to-fit a string.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
static bool mutt_str_is_email_wsp(char c)
Is this a whitespace character (for an email header)
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
bool mutt_istrn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings ignoring case (to a maximum), safely.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
char * mutt_str_sep(char **stringp, const char *delim)
Find first occurrence of any of delim characters in *stringp.