Rocco Rutte:
[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
11 #ifndef _LIB_STR_H
12 #define _LIB_STR_H
13
14 #include <sys/types.h>
15
16 #define NONULL(x) x?x:""
17
18 # define HUGE_STRING    5120
19 # define LONG_STRING     1024
20 # define STRING          256
21 # define SHORT_STRING    128
22
23 /*
24  * Create a format string to be used with scanf.
25  * To use it, write, for instance, MUTT_FORMAT(HUGE_STRING).
26  * 
27  * See K&R 2nd ed, p. 231 for an explanation.
28  */
29 # define _MUTT_FORMAT_2(a,b)    "%" a  b
30 # define _MUTT_FORMAT_1(a, b)   _MUTT_FORMAT_2(#a, b)
31 # define MUTT_FORMAT(a)         _MUTT_FORMAT_1(a, "s")
32 # define MUTT_FORMAT2(a,b)      _MUTT_FORMAT_1(a, b)
33
34 # define ISSPACE(c) isspace((unsigned char)c)
35 # define strfcpy(A,B,C) strncpy(A,B,C), *(A+(C)-1)=0
36
37 /* this macro must check for *c == 0 since isspace(0) has unreliable behavior
38    on some systems */
39 # define SKIPWS(c) while (*(c) && isspace ((unsigned char) *(c))) c++;
40
41 #define ISBLANK(c) (c == ' ' || c == '\t')
42 /*
43  * These functions aren't defined in lib.c, but
44  * they are used there.
45  *
46  * A non-mutt "implementation" (ahem) can be found in extlib.c.
47  */
48
49 char *mutt_strlower (char *);
50 char *mutt_substrcpy (char *, const char *, const char *, size_t);
51 char *mutt_substrdup (const char *, const char *);
52 char *safe_strcat (char *, size_t, const char *);
53 char *safe_strncat (char *, size_t, const char *, size_t);
54 char *safe_strdup (const char *);
55 int mutt_strcasecmp (const char *, const char *);
56 int mutt_strcmp (const char *, const char *);
57 int mutt_strncasecmp (const char *, const char *, size_t);
58 int mutt_strncmp (const char *, const char *, size_t);
59 int mutt_strcoll (const char *, const char *);
60 void mutt_str_replace (char **p, const char *s);
61 void mutt_str_adjust (char **p);
62 size_t mutt_strlen (const char *a);
63
64 #endif /* !_LIB_STR_H */