NeoMutt  2020-06-26-250-g349c94
Teaching an old dog new tricks
DOXYGEN
string.c
Go to the documentation of this file.
1 
30 #include "config.h"
31 #include <ctype.h>
32 #include <errno.h>
33 #include <limits.h>
34 #include <stdarg.h>
35 #include <stdbool.h>
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <strings.h>
40 #include "exit.h"
41 #include "logging.h"
42 #include "memory.h"
43 #include "message.h"
44 #include "string2.h"
45 #ifdef HAVE_SYSEXITS_H
46 #include <sysexits.h>
47 #endif
48 
52 typedef bool (*char_cmp)(char, char);
53 
57 struct SysExits
58 {
59  int err_num;
60  const char *err_str;
61 };
62 
63 static const struct SysExits sysexits[] = {
64 #ifdef EX_USAGE
65  { 0xff & EX_USAGE, "Bad usage." },
66 #endif
67 #ifdef EX_DATAERR
68  { 0xff & EX_DATAERR, "Data format error." },
69 #endif
70 #ifdef EX_NOINPUT
71  { 0xff & EX_NOINPUT, "Can't open input." },
72 #endif
73 #ifdef EX_NOUSER
74  { 0xff & EX_NOUSER, "User unknown." },
75 #endif
76 #ifdef EX_NOHOST
77  { 0xff & EX_NOHOST, "Host unknown." },
78 #endif
79 #ifdef EX_UNAVAILABLE
80  { 0xff & EX_UNAVAILABLE, "Service unavailable." },
81 #endif
82 #ifdef EX_SOFTWARE
83  { 0xff & EX_SOFTWARE, "Internal error." },
84 #endif
85 #ifdef EX_OSERR
86  { 0xff & EX_OSERR, "Operating system error." },
87 #endif
88 #ifdef EX_OSFILE
89  { 0xff & EX_OSFILE, "System file missing." },
90 #endif
91 #ifdef EX_CANTCREAT
92  { 0xff & EX_CANTCREAT, "Can't create output." },
93 #endif
94 #ifdef EX_IOERR
95  { 0xff & EX_IOERR, "I/O error." },
96 #endif
97 #ifdef EX_TEMPFAIL
98  { 0xff & EX_TEMPFAIL, "Deferred." },
99 #endif
100 #ifdef EX_PROTOCOL
101  { 0xff & EX_PROTOCOL, "Remote protocol error." },
102 #endif
103 #ifdef EX_NOPERM
104  { 0xff & EX_NOPERM, "Insufficient permission." },
105 #endif
106 #ifdef EX_CONFIG
107  { 0xff & EX_NOPERM, "Local configuration error." },
108 #endif
109  { S_ERR, "Exec error." },
110 };
111 
117 const char *mutt_str_sysexit(int err_num)
118 {
119  for (size_t i = 0; i < mutt_array_size(sysexits); i++)
120  {
121  if (err_num == sysexits[i].err_num)
122  return sysexits[i].err_str;
123  }
124 
125  return NULL;
126 }
127 
136 static size_t startswith(const char *str, const char *prefix, bool match_case)
137 {
138  if (!str || (str[0] == '\0') || !prefix || (prefix[0] == '\0'))
139  {
140  return 0;
141  }
142 
143  const char *saved_prefix = prefix;
144  for (; *str && *prefix; str++, prefix++)
145  {
146  if (*str == *prefix)
147  continue;
148 
149  if (!match_case && tolower(*str) == tolower(*prefix))
150  continue;
151 
152  return 0;
153  }
154 
155  return (*prefix == '\0') ? (prefix - saved_prefix) : 0;
156 }
157 
165 size_t mutt_str_startswith(const char *str, const char *prefix)
166 {
167  return startswith(str, prefix, true);
168 }
169 
177 size_t mutt_istr_startswith(const char *str, const char *prefix)
178 {
179  return startswith(str, prefix, false);
180 }
181 
193 int mutt_str_atol(const char *str, long *dst)
194 {
195  if (dst)
196  *dst = 0;
197 
198  if (!str || (*str == '\0')) /* no input: 0 */
199  return 0;
200 
201  char *e = NULL;
202  errno = 0;
203 
204  long res = strtol(str, &e, 10);
205  if (dst)
206  *dst = res;
207  if (((res == LONG_MIN) || (res == LONG_MAX)) && (errno == ERANGE))
208  return -2;
209  if (e && (*e != '\0'))
210  return -1;
211  return 0;
212 }
213 
227 int mutt_str_atos(const char *str, short *dst)
228 {
229  if (dst)
230  *dst = 0;
231 
232  long res = 0;
233  int rc = mutt_str_atol(str, &res);
234  if (rc < 0)
235  return rc;
236  if ((res < SHRT_MIN) || (res > SHRT_MAX))
237  return -2;
238 
239  if (dst)
240  *dst = (short) res;
241 
242  return 0;
243 }
244 
257 int mutt_str_atoi(const char *str, int *dst)
258 {
259  if (dst)
260  *dst = 0;
261 
262  long res = 0;
263  int rc = mutt_str_atol(str, &res);
264  if (rc < 0)
265  return rc;
266  if ((res < INT_MIN) || (res > INT_MAX))
267  return -2;
268 
269  if (dst)
270  *dst = (int) res;
271 
272  return 0;
273 }
274 
287 int mutt_str_atoui(const char *str, unsigned int *dst)
288 {
289  if (dst)
290  *dst = 0;
291 
292  unsigned long res = 0;
293  int rc = mutt_str_atoul(str, &res);
294  if (rc < 0)
295  return rc;
296  if (res > UINT_MAX)
297  return -2;
298 
299  if (dst)
300  *dst = (unsigned int) res;
301 
302  return rc;
303 }
304 
316 int mutt_str_atoul(const char *str, unsigned long *dst)
317 {
318  if (dst)
319  *dst = 0;
320 
321  if (!str || (*str == '\0')) /* no input: 0 */
322  return 0;
323 
324  char *e = NULL;
325  errno = 0;
326 
327  unsigned long res = strtoul(str, &e, 10);
328  if (dst)
329  *dst = res;
330  if ((res == ULONG_MAX) && (errno == ERANGE))
331  return -1;
332  if (e && (*e != '\0'))
333  return 1;
334  return 0;
335 }
336 
348 int mutt_str_atoull(const char *str, unsigned long long *dst)
349 {
350  if (dst)
351  *dst = 0;
352 
353  if (!str || (*str == '\0')) /* no input: 0 */
354  return 0;
355 
356  char *e = NULL;
357  errno = 0;
358 
359  unsigned long long res = strtoull(str, &e, 10);
360  if (dst)
361  *dst = res;
362  if ((res == ULLONG_MAX) && (errno == ERANGE))
363  return -1;
364  if (e && (*e != '\0'))
365  return 1;
366  return 0;
367 }
368 
375 char *mutt_str_dup(const char *str)
376 {
377  if (!str || (*str == '\0'))
378  return NULL;
379 
380  return strdup(str);
381 }
382 
390 char *mutt_str_cat(char *buf, size_t buflen, const char *s)
391 {
392  if (!buf || (buflen == 0) || !s)
393  return buf;
394 
395  char *p = buf;
396 
397  buflen--; /* Space for the trailing '\0'. */
398 
399  for (; (*buf != '\0') && buflen; buflen--)
400  buf++;
401  for (; *s && buflen; buflen--)
402  *buf++ = *s++;
403 
404  *buf = '\0';
405 
406  return p;
407 }
408 
419 char *mutt_strn_cat(char *d, size_t l, const char *s, size_t sl)
420 {
421  if (!d || (l == 0) || !s)
422  return d;
423 
424  char *p = d;
425 
426  l--; /* Space for the trailing '\0'. */
427 
428  for (; *d && l; l--)
429  d++;
430  for (; *s && l && sl; l--, sl--)
431  *d++ = *s++;
432 
433  *d = '\0';
434 
435  return p;
436 }
437 
451 char *mutt_str_replace(char **p, const char *s)
452 {
453  if (!p)
454  return NULL;
455  const char *tmp = *p;
456  *p = mutt_str_dup(s);
457  FREE(&tmp);
458  return *p;
459 }
460 
471 void mutt_str_append_item(char **str, const char *item, char sep)
472 {
473  if (!str || !item)
474  return;
475 
476  size_t sz = mutt_str_len(item);
477  size_t ssz = mutt_str_len(*str);
478 
479  mutt_mem_realloc(str, ssz + (((ssz > 0) && (sep != '\0')) ? 1 : 0) + sz + 1);
480  char *p = *str + ssz;
481  if ((ssz > 0) && (sep != '\0'))
482  *p++ = sep;
483  memcpy(p, item, sz + 1);
484 }
485 
495 void mutt_str_adjust(char **p)
496 {
497  if (!p || !*p)
498  return;
499  mutt_mem_realloc(p, strlen(*p) + 1);
500 }
501 
509 char *mutt_str_lower(char *s)
510 {
511  if (!s)
512  return NULL;
513 
514  char *p = s;
515 
516  while (*p)
517  {
518  *p = tolower((unsigned char) *p);
519  p++;
520  }
521 
522  return s;
523 }
524 
533 char *mutt_strn_copy(char *dest, const char *src, size_t len, size_t dsize)
534 {
535  if (!src || !dest || (len == 0) || (dsize == 0))
536  return dest;
537 
538  if (len > (dsize - 1))
539  len = dsize - 1;
540  memcpy(dest, src, len);
541  dest[len] = '\0';
542  return dest;
543 }
544 
553 char *mutt_strn_dup(const char *begin, size_t len)
554 {
555  if (!begin)
556  return NULL;
557 
558  char *p = mutt_mem_malloc(len + 1);
559  memcpy(p, begin, len);
560  p[len] = '\0';
561  return p;
562 }
563 
572 int mutt_str_cmp(const char *a, const char *b)
573 {
574  return strcmp(NONULL(a), NONULL(b));
575 }
576 
585 int mutt_istr_cmp(const char *a, const char *b)
586 {
587  return strcasecmp(NONULL(a), NONULL(b));
588 }
589 
598 bool mutt_strn_equal(const char *a, const char *b, size_t l)
599 {
600  return strncmp(NONULL(a), NONULL(b), l) == 0;
601 }
602 
612 int mutt_istrn_cmp(const char *a, const char *b, size_t l)
613 {
614  return strncasecmp(NONULL(a), NONULL(b), l);
615 }
616 
626 bool mutt_istrn_equal(const char *a, const char *b, size_t l)
627 {
628  return strncasecmp(NONULL(a), NONULL(b), l) == 0;
629 }
630 
636 size_t mutt_str_len(const char *a)
637 {
638  return a ? strlen(a) : 0;
639 }
640 
649 int mutt_str_coll(const char *a, const char *b)
650 {
651  return strcoll(NONULL(a), NONULL(b));
652 }
653 
661 const char *mutt_istr_find(const char *haystack, const char *needle)
662 {
663  if (!haystack)
664  return NULL;
665  if (!needle)
666  return haystack;
667 
668  const char *p = NULL, *q = NULL;
669 
670  while (*(p = haystack))
671  {
672  for (q = needle;
673  *p && *q && (tolower((unsigned char) *p) == tolower((unsigned char) *q));
674  p++, q++)
675  {
676  }
677  if ((*q == '\0'))
678  return haystack;
679  haystack++;
680  }
681  return NULL;
682 }
683 
691 char *mutt_str_skip_whitespace(const char *p)
692 {
693  if (!p)
694  return NULL;
695  SKIPWS(p);
696  return (char *) p;
697 }
698 
706 {
707  if (!s)
708  return;
709 
710  for (char *p = s + mutt_str_len(s) - 1; (p >= s) && IS_SPACE(*p); p--)
711  *p = '\0';
712 }
713 
721 size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
722 {
723  if (!dest || (dsize == 0))
724  return 0;
725  if (!src)
726  {
727  dest[0] = '\0';
728  return 0;
729  }
730 
731  char *dest0 = dest;
732  while ((--dsize > 0) && (*src != '\0'))
733  *dest++ = *src++;
734 
735  *dest = '\0';
736  return dest - dest0;
737 }
738 
748 char *mutt_str_skip_email_wsp(const char *s)
749 {
750  if (!s)
751  return NULL;
752 
753  for (; mutt_str_is_email_wsp(*s); s++)
754  ; // Do nothing
755 
756  return (char *) s;
757 }
758 
765 {
766  return c && strchr(" \t\r\n", c);
767 }
768 
778 size_t mutt_str_lws_len(const char *s, size_t n)
779 {
780  if (!s)
781  return 0;
782 
783  const char *p = s;
784  size_t len = n;
785 
786  if (n == 0)
787  return 0;
788 
789  for (; p < (s + n); p++)
790  {
791  if (!strchr(" \t\r\n", *p))
792  {
793  len = p - s;
794  break;
795  }
796  }
797 
798  if ((len != 0) && strchr("\r\n", *(p - 1))) /* LWS doesn't end with CRLF */
799  len = 0;
800  return len;
801 }
802 
812 size_t mutt_str_lws_rlen(const char *s, size_t n)
813 {
814  if (!s)
815  return 0;
816 
817  const char *p = s + n - 1;
818  size_t len = n;
819 
820  if (n == 0)
821  return 0;
822 
823  if (strchr("\r\n", *p)) /* LWS doesn't end with CRLF */
824  return 0;
825 
826  for (; p >= s; p--)
827  {
828  if (!strchr(" \t\r\n", *p))
829  {
830  len = s + n - 1 - p;
831  break;
832  }
833  }
834 
835  return len;
836 }
837 
845 {
846  if (!s)
847  return;
848 
849  char *w = s;
850 
851  for (; *s; s++)
852  {
853  if (*s == '\\')
854  {
855  if (!*++s)
856  break; /* error? */
857  *w++ = *s;
858  }
859  else if (*s != '\"')
860  {
861  if (w != s)
862  *w = *s;
863  w++;
864  }
865  }
866  *w = '\0';
867 }
868 
876 bool mutt_str_equal(const char *a, const char *b)
877 {
878  return (a == b) || (mutt_str_cmp(a, b) == 0);
879 }
880 
888 bool mutt_istr_equal(const char *a, const char *b)
889 {
890  return (a == b) || (mutt_istr_cmp(a, b) == 0);
891 }
892 
903 const char *mutt_str_next_word(const char *s)
904 {
905  if (!s)
906  return NULL;
907 
908  while (*s && !IS_SPACE(*s))
909  s++;
910  SKIPWS(s);
911  return s;
912 }
913 
925 const char *mutt_strn_rfind(const char *haystack, size_t haystack_length, const char *needle)
926 {
927  if (!haystack || (haystack_length == 0) || !needle)
928  return NULL;
929 
930  int needle_length = strlen(needle);
931  const char *haystack_end = haystack + haystack_length - needle_length;
932 
933  for (const char *p = haystack_end; p >= haystack; --p)
934  {
935  for (size_t i = 0; i < needle_length; i++)
936  {
937  if (p[i] != needle[i])
938  goto next;
939  }
940  return p;
941 
942  next:;
943  }
944  return NULL;
945 }
946 
953 bool mutt_str_is_ascii(const char *str, size_t len)
954 {
955  if (!str)
956  return true;
957 
958  for (; (*str != '\0') && (len > 0); str++, len--)
959  if ((*str & 0x80) != 0)
960  return false;
961 
962  return true;
963 }
964 
976 const char *mutt_str_find_word(const char *src)
977 {
978  if (!src)
979  return NULL;
980 
981  while (*src && strchr(" \t\n", *src))
982  src++;
983  while (*src && !strchr(" \t\n", *src))
984  src++;
985  return src;
986 }
987 
996 const char *mutt_str_getenv(const char *name)
997 {
998  if (!name)
999  return NULL;
1000 
1001  const char *val = getenv(name);
1002  if (val && (val[0] != '\0'))
1003  return val;
1004 
1005  return NULL;
1006 }
1007 
1018 bool mutt_str_inline_replace(char *buf, size_t buflen, size_t xlen, const char *rstr)
1019 {
1020  if (!buf || !rstr || (xlen >= buflen))
1021  return false;
1022 
1023  size_t slen = mutt_str_len(buf + xlen);
1024  size_t rlen = mutt_str_len(rstr);
1025 
1026  if ((slen + rlen) >= buflen)
1027  return false;
1028 
1029  memmove(buf + rlen, buf + xlen, slen + 1);
1030  memmove(buf, rstr, rlen);
1031 
1032  return true;
1033 }
1034 
1042 int mutt_istr_remall(char *str, const char *target)
1043 {
1044  int rc = 1;
1045  if (!str || !target)
1046  return rc;
1047 
1048  // Look through an ensure all instances of the substring are gone.
1049  while ((str = (char *) strcasestr(str, target)))
1050  {
1051  size_t target_len = mutt_str_len(target);
1052  memmove(str, str + target_len, 1 + strlen(str + target_len));
1053  rc = 0; // If we got here, then a substring existed and has been removed.
1054  }
1055 
1056  return rc;
1057 }
1058 
1059 #ifdef HAVE_VASPRINTF
1060 
1068 int mutt_str_asprintf(char **strp, const char *fmt, ...)
1069 {
1070  if (!strp || !fmt)
1071  return -1;
1072 
1073  va_list ap;
1074  int n;
1075 
1076  va_start(ap, fmt);
1077  n = vasprintf(strp, fmt, ap);
1078  va_end(ap);
1079 
1080  /* GNU libc man page for vasprintf(3) states that the value of *strp
1081  * is undefined when the return code is -1. */
1082  if (n < 0)
1083  {
1084  mutt_error(_("Out of memory")); /* LCOV_EXCL_LINE */
1085  mutt_exit(1); /* LCOV_EXCL_LINE */
1086  }
1087 
1088  if (n == 0)
1089  {
1090  /* NeoMutt convention is to use NULL for 0-length strings */
1091  FREE(strp);
1092  }
1093 
1094  return n;
1095 }
1096 #else
1097 /* Allocate a C-string large enough to contain the formatted string.
1098  * This is essentially malloc+sprintf in one.
1099  */
1100 int mutt_str_asprintf(char **strp, const char *fmt, ...)
1101 {
1102  if (!strp || !fmt)
1103  return -1;
1104 
1105  int rlen = 256;
1106 
1107  *strp = mutt_mem_malloc(rlen);
1108  while (true)
1109  {
1110  va_list ap;
1111  va_start(ap, fmt);
1112  const int n = vsnprintf(*strp, rlen, fmt, ap);
1113  va_end(ap);
1114  if (n < 0)
1115  {
1116  FREE(strp);
1117  return n;
1118  }
1119 
1120  if (n < rlen)
1121  {
1122  /* reduce space to just that which was used. note that 'n' does not
1123  * include the terminal nul char. */
1124  if (n == 0) /* convention is to use NULL for zero-length strings. */
1125  FREE(strp);
1126  else if (n != rlen - 1)
1127  mutt_mem_realloc(strp, n + 1);
1128  return n;
1129  }
1130  /* increase size and try again */
1131  rlen = n + 1;
1132  mutt_mem_realloc(strp, rlen);
1133  }
1134  /* not reached */
1135 }
1136 #endif /* HAVE_ASPRINTF */
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:876
int mutt_istr_cmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:585
int mutt_str_cmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:572
char * mutt_str_skip_whitespace(const char *p)
Find the first non-whitespace character in a string.
Definition: string.c:691
static size_t startswith(const char *str, const char *prefix, bool match_case)
Check whether a string starts with a prefix.
Definition: string.c:136
#define NONULL(x)
Definition: string2.h:37
int mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
Definition: string.c:257
Memory management wrappers.
#define S_ERR
Definition: string2.h:41
char * mutt_strn_cat(char *d, size_t l, const char *s, size_t sl)
Concatenate two strings.
Definition: string.c:419
static int const char * fmt
Definition: acutest.h:488
vsnprintf(buffer, sizeof(buffer), fmt, args)
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
#define _(a)
Definition: message.h:28
void mutt_str_adjust(char **p)
Shrink-to-fit a string.
Definition: string.c:495
int mutt_str_atol(const char *str, long *dst)
Convert ASCII string to a long.
Definition: string.c:193
size_t mutt_str_lws_len(const char *s, size_t n)
Measure the linear-white-space at the beginning of a string.
Definition: string.c:778
int mutt_str_atos(const char *str, short *dst)
Convert ASCII string to a short.
Definition: string.c:227
int mutt_str_coll(const char *a, const char *b)
Collate two strings (compare using locale), safely.
Definition: string.c:649
Logging Dispatcher.
String manipulation functions.
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:996
bool mutt_istrn_equal(const char *a, const char *b, size_t l)
Check for equality of two strings ignoring case (to a maximum), safely.
Definition: string.c:626
#define mutt_array_size(x)
Definition: memory.h:33
Lookup table of error messages.
Definition: string.c:57
bool(* char_cmp)(char, char)
Pointer to a function taking two characters and returning bool.
Definition: string.c:52
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
Definition: string.c:553
va_start(args, fmt)
#define SKIPWS(ch)
Definition: string2.h:46
int mutt_istrn_cmp(const char *a, const char *b, size_t l)
Compare two strings ignoring case (to a maximum), safely.
Definition: string.c:612
char * mutt_strn_copy(char *dest, const char *src, size_t len, size_t dsize)
Copy a sub-string into a buffer.
Definition: string.c:533
char * mutt_str_lower(char *s)
Convert all characters in the string to lowercase.
Definition: string.c:509
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:888
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
Message logging.
const char * mutt_str_sysexit(int err_num)
Return a string matching an error code.
Definition: string.c:117
void mutt_str_remove_trailing_ws(char *s)
Trim trailing whitespace from a string.
Definition: string.c:705
bool mutt_str_is_ascii(const char *str, size_t len)
Is a string ASCII (7-bit)?
Definition: string.c:953
bool mutt_str_is_email_wsp(char c)
Is this a whitespace character (for an email header)
Definition: string.c:764
int mutt_istr_remall(char *str, const char *target)
Remove all occurrences of substring, ignoring case.
Definition: string.c:1042
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:165
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
Leave the program NOW.
int mutt_str_atoui(const char *str, unsigned int *dst)
Convert ASCII string to an unsigned integer.
Definition: string.c:287
int mutt_str_atoull(const char *str, unsigned long long *dst)
Convert ASCII string to an unsigned long long.
Definition: string.c:348
char * mutt_str_skip_email_wsp(const char *s)
Skip over whitespace as defined by RFC5322.
Definition: string.c:748
void mutt_str_dequote_comment(char *s)
Un-escape characters in an email address comment.
Definition: string.c:844
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:177
bool mutt_strn_equal(const char *a, const char *b, size_t l)
Check for equality of two strings (to a maximum), safely.
Definition: string.c:598
char * mutt_str_cat(char *buf, size_t buflen, const char *s)
Concatenate two strings.
Definition: string.c:390
#define IS_SPACE(ch)
Definition: string2.h:38
void mutt_exit(int code)
Leave NeoMutt NOW.
Definition: main.c:137
size_t mutt_str_lws_rlen(const char *s, size_t n)
Measure the linear-white-space at the end of a string.
Definition: string.c:812
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:636
const char * mutt_istr_find(const char *haystack, const char *needle)
Find first occurrence of string (ignoring case)
Definition: string.c:661
int n
Definition: acutest.h:492
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:721
const char * err_str
Definition: string.c:60
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:451
#define mutt_error(...)
Definition: logging.h:84
int mutt_str_atoul(const char *str, unsigned long *dst)
Convert ASCII string to an unsigned long.
Definition: string.c:316
#define FREE(x)
Definition: memory.h:40
bool mutt_str_inline_replace(char *buf, size_t buflen, size_t xlen, const char *rstr)
Replace the beginning of a string.
Definition: string.c:1018
const char * mutt_strn_rfind(const char *haystack, size_t haystack_length, const char *needle)
Find last instance of a substring.
Definition: string.c:925
int mutt_str_asprintf(char **strp, const char *fmt,...)
Definition: string.c:1100
void mutt_str_append_item(char **str, const char *item, char sep)
Add string to another separated by sep.
Definition: string.c:471
const char * mutt_str_next_word(const char *s)
Find the next word in a string.
Definition: string.c:903
const char * mutt_str_find_word(const char *src)
Find the end of a word (non-space)
Definition: string.c:976
int err_num
Definition: string.c:59
va_end(args)