8a480c33b0b2ee7e2bf1ca629e111a8480ba30ed
[apps/madmutt.git] / lib / str.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4  * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
5  *
6  * This file is part of mutt-ng, see http://www.muttng.org/.
7  * It's licensed under the GNU General Public License,
8  * please see the file GPL in the top level source directory.
9  */
10 #ifndef _LIB_STR_H
11 #define _LIB_STR_H
12
13 #include <sys/types.h>
14
15 # define HUGE_STRING     5120
16 # define LONG_STRING     1024
17 # define STRING          256
18 # define SHORT_STRING    128
19
20 /*
21  * Create a format string to be used with scanf.
22  * To use it, write, for instance, MUTT_FORMAT(HUGE_STRING).
23  * 
24  * See K&R 2nd ed, p. 231 for an explanation.
25  */
26 # define _MUTT_FORMAT_2(a,b)    "%" a  b
27 # define _MUTT_FORMAT_1(a, b)   _MUTT_FORMAT_2(#a, b)
28 # define MUTT_FORMAT(a)         _MUTT_FORMAT_1(a, "s")
29 # define MUTT_FORMAT2(a,b)      _MUTT_FORMAT_1(a, b)
30
31 # define ISSPACE(c) isspace((unsigned char)c)
32 # define ISBLANK(c) (c == ' ' || c == '\t')
33 # define strfcpy(A,B,C)  m_strcpy(A,C,B)
34 /* this macro must check for *c == 0 since isspace(0) has
35  * unreliable behavior on some systems */
36 # define SKIPWS(c) while (*(c) && isspace ((unsigned char) *(c))) c++;
37
38 /*
39  * tools
40  */
41 char *str_tolower (char*);
42 char *str_substrcpy (char*, const char*, const char*, size_t);
43 char *str_substrdup (const char*, const char*);
44 void str_replace (char**, const char*);
45 void str_adjust (char**);
46 int str_eq (const char*, const char*);
47 const char *str_isstr (const char*, const char*);
48 char* str_skip_initws (char*);
49 void str_skip_trailws (char*);
50
51 #endif /* !_LIB_STR_H */