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>
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.
11 /* mutt functions which are generally useful. */
19 # include <unistd.h> /* needed for SEEK_SET */
21 # include <sys/types.h>
22 # include <sys/stat.h>
28 # ifndef _POSIX_PATH_MAX
29 # include <posix1_lim.h>
35 # define HUGE_STRING 5120
36 # define LONG_STRING 1024
38 # define SHORT_STRING 128
41 * Create a format string to be used with scanf.
42 * To use it, write, for instance, MUTT_FORMAT(HUGE_STRING).
44 * See K&R 2nd ed, p. 231 for an explanation.
46 # define _MUTT_FORMAT_2(a,b) "%" a b
47 # define _MUTT_FORMAT_1(a, b) _MUTT_FORMAT_2(#a, b)
48 # define MUTT_FORMAT(a) _MUTT_FORMAT_1(a, "s")
49 # define MUTT_FORMAT2(a,b) _MUTT_FORMAT_1(a, b)
51 # define ISSPACE(c) isspace((unsigned char)c)
52 # define strfcpy(A,B,C) strncpy(A,B,C), *(A+(C)-1)=0
56 # define MAX(a,b) ((a) < (b) ? (b) : (a))
57 # define MIN(a,b) ((a) < (b) ? (a) : (b))
59 #define FOREVER while (1)
61 /* this macro must check for *c == 0 since isspace(0) has unreliable behavior
63 # define SKIPWS(c) while (*(c) && isspace ((unsigned char) *(c))) c++;
65 #define ISBLANK(c) (c == ' ' || c == '\t')
67 * These functions aren't defined in lib.c, but
68 * they are used there.
70 * A non-mutt "implementation" (ahem) can be found in extlib.c.
74 extern void (*mutt_error) (const char *, ...);
78 /* The actual library functions. */
80 FILE *safe_fopen (const char *, const char *);
82 char *mutt_concat_path (char *, const char *, const char *, size_t);
83 char *mutt_read_line (char *, size_t *, FILE *, int *);
84 char *mutt_skip_whitespace (char *);
85 char *mutt_strlower (char *);
86 char *mutt_substrcpy (char *, const char *, const char *, size_t);
87 char *mutt_substrdup (const char *, const char *);
88 char *safe_strcat (char *, size_t, const char *);
89 char *safe_strncat (char *, size_t, const char *, size_t);
90 char *safe_strdup (const char *);
92 const char *mutt_stristr (const char *, const char *);
93 const char *mutt_basename (const char *);
95 int mutt_copy_stream (FILE *, FILE *);
96 int mutt_copy_bytes (FILE *, FILE *, size_t);
97 int mutt_rx_sanitize_string (char *, size_t, const char *);
98 int mutt_strcasecmp (const char *, const char *);
99 int mutt_strcmp (const char *, const char *);
100 int mutt_strncasecmp (const char *, const char *, size_t);
101 int mutt_strncmp (const char *, const char *, size_t);
102 int mutt_strcoll (const char *, const char *);
103 int safe_open (const char *, int);
104 int safe_symlink (const char *, const char *);
105 int safe_rename (const char *, const char *);
106 int safe_fclose (FILE **);
108 size_t mutt_quote_filename (char *, size_t, const char *);
109 size_t mutt_strlen (const char *);
111 void mutt_nocurses_error (const char *, ...);
112 void mutt_remove_trailing_ws (char *);
113 void mutt_sanitize_filename (char *, short);
114 void mutt_str_replace (char **p, const char *s);
115 void mutt_str_adjust (char **p);
116 void mutt_unlink (const char *);