bin_PROGRAMS = mutt $(DOTLOCK_TARGET) $(PGPAUX_TARGET)
mutt_SOURCES = \
- addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
+ addrbook.c alias.c attach.c base64.c browser.c buffer.c buffy.c color.c \
crypt.c cryptglue.c \
commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
edit.c enter.c flags.c init.c filter.c from.c \
EXTRA_DIST = COPYRIGHT LICENSE.md OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
account.h \
- attach.h buffy.h charset.h compress.h copy.h crypthash.h dotlock.h functions.h gen_defs \
- globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
+ attach.h buffer.h buffy.h charset.h compress.h copy.h crypthash.h dotlock.h functions.h gen_defs \
+ filter.h globals.h hash.h history.h init.h keymap.h mutt_crypt.h myvar.h \
mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
mutt_regex.h mutt_sasl.h mutt_sasl_plain.h mutt_socket.h mutt_ssl.h \
mutt_tunnel.h mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
#include "mutt.h"
#include "mutt_menu.h"
+#include "filter.h"
#include "attach.h"
#include "mutt_curses.h"
#include "keymap.h"
--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <string.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "lib.h"
+#include "myvar.h"
+#include "filter.h"
+#include "buffer.h"
+
+/* creates and initializes a BUFFER */
+BUFFER *mutt_buffer_new(void) {
+ BUFFER *b;
+
+ b = safe_malloc(sizeof(BUFFER));
+
+ mutt_buffer_init(b);
+
+ return b;
+}
+
+/* initialize a new BUFFER */
+BUFFER *mutt_buffer_init (BUFFER *b) {
+ memset(b, 0, sizeof(BUFFER));
+ return b;
+}
+
+/*
+ * Creates and initializes a BUFFER*. If passed an existing BUFFER*,
+ * just initializes. Frees anything already in the buffer. Copies in
+ * the seed string.
+ *
+ * Disregards the 'destroy' flag, which seems reserved for caller.
+ * This is bad, but there's no apparent protocol for it.
+ */
+BUFFER *mutt_buffer_from (char *seed) {
+ BUFFER *b;
+
+ if (!seed)
+ return NULL;
+
+ b = mutt_buffer_new ();
+ b->data = safe_strdup(seed);
+ b->dsize = mutt_strlen(seed);
+ b->dptr = (char *) b->data + b->dsize;
+ return b;
+}
+
+void mutt_buffer_free (BUFFER **p)
+{
+ if (!p || !*p)
+ return;
+
+ FREE(&(*p)->data);
+ /* dptr is just an offset to data and shouldn't be freed */
+ FREE(p); /* __FREE_CHECKED__ */
+}
+
+int mutt_buffer_printf (BUFFER* buf, const char* fmt, ...)
+{
+ va_list ap, ap_retry;
+ int len, blen, doff;
+
+ va_start (ap, fmt);
+ va_copy (ap_retry, ap);
+
+ if (!buf->dptr)
+ buf->dptr = buf->data;
+
+ doff = buf->dptr - buf->data;
+ blen = buf->dsize - doff;
+ /* solaris 9 vsnprintf barfs when blen is 0 */
+ if (!blen)
+ {
+ blen = 128;
+ buf->dsize += blen;
+ safe_realloc (&buf->data, buf->dsize);
+ buf->dptr = buf->data + doff;
+ }
+ if ((len = vsnprintf (buf->dptr, blen, fmt, ap)) >= blen)
+ {
+ blen = ++len - blen;
+ if (blen < 128)
+ blen = 128;
+ buf->dsize += blen;
+ safe_realloc (&buf->data, buf->dsize);
+ buf->dptr = buf->data + doff;
+ len = vsnprintf (buf->dptr, len, fmt, ap_retry);
+ }
+ if (len > 0)
+ buf->dptr += len;
+
+ va_end (ap);
+ va_end (ap_retry);
+
+ return len;
+}
+
+/* dynamically grows a BUFFER to accommodate s, in increments of 128 bytes.
+ * Always one byte bigger than necessary for the null terminator, and
+ * the buffer is always null-terminated */
+static void mutt_buffer_add (BUFFER* buf, const char* s, size_t len)
+{
+ size_t offset;
+
+ if (buf->dptr + len + 1 > buf->data + buf->dsize)
+ {
+ offset = buf->dptr - buf->data;
+ buf->dsize += len < 128 ? 128 : len + 1;
+ /* suppress compiler aliasing warning */
+ safe_realloc ((void**) (void*) &buf->data, buf->dsize);
+ buf->dptr = buf->data + offset;
+ }
+ memcpy (buf->dptr, s, len);
+ buf->dptr += len;
+ *(buf->dptr) = '\0';
+}
+
+void mutt_buffer_addstr (BUFFER* buf, const char* s)
+{
+ mutt_buffer_add (buf, s, mutt_strlen (s));
+}
+
+void mutt_buffer_addch (BUFFER* buf, char c)
+{
+ mutt_buffer_add (buf, &c, 1);
+}
+
+int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)
+{
+ char ch;
+ char qc = 0; /* quote char */
+ char *pc;
+
+ /* reset the destination pointer to the beginning of the buffer */
+ dest->dptr = dest->data;
+
+ SKIPWS (tok->dptr);
+ while ((ch = *tok->dptr))
+ {
+ if (!qc)
+ {
+ if ((ISSPACE (ch) && !(flags & MUTT_TOKEN_SPACE)) ||
+ (ch == '#' && !(flags & MUTT_TOKEN_COMMENT)) ||
+ (ch == '=' && (flags & MUTT_TOKEN_EQUAL)) ||
+ (ch == ';' && !(flags & MUTT_TOKEN_SEMICOLON)) ||
+ ((flags & MUTT_TOKEN_PATTERN) && strchr ("~%=!|", ch)))
+ break;
+ }
+
+ tok->dptr++;
+
+ if (ch == qc)
+ qc = 0; /* end of quote */
+ else if (!qc && (ch == '\'' || ch == '"') && !(flags & MUTT_TOKEN_QUOTE))
+ qc = ch;
+ else if (ch == '\\' && qc != '\'')
+ {
+ if (!*tok->dptr)
+ return -1; /* premature end of token */
+ switch (ch = *tok->dptr++)
+ {
+ case 'c':
+ case 'C':
+ if (!*tok->dptr)
+ return -1; /* premature end of token */
+ mutt_buffer_addch (dest, (toupper ((unsigned char) *tok->dptr)
+ - '@') & 0x7f);
+ tok->dptr++;
+ break;
+ case 'r':
+ mutt_buffer_addch (dest, '\r');
+ break;
+ case 'n':
+ mutt_buffer_addch (dest, '\n');
+ break;
+ case 't':
+ mutt_buffer_addch (dest, '\t');
+ break;
+ case 'f':
+ mutt_buffer_addch (dest, '\f');
+ break;
+ case 'e':
+ mutt_buffer_addch (dest, '\033');
+ break;
+ default:
+ if (isdigit ((unsigned char) ch) &&
+ isdigit ((unsigned char) *tok->dptr) &&
+ isdigit ((unsigned char) *(tok->dptr + 1)))
+ {
+
+ mutt_buffer_addch (dest, (ch << 6) + (*tok->dptr << 3) + *(tok->dptr + 1) - 3504);
+ tok->dptr += 2;
+ }
+ else
+ mutt_buffer_addch (dest, ch);
+ }
+ }
+ else if (ch == '^' && (flags & MUTT_TOKEN_CONDENSE))
+ {
+ if (!*tok->dptr)
+ return -1; /* premature end of token */
+ ch = *tok->dptr++;
+ if (ch == '^')
+ mutt_buffer_addch (dest, ch);
+ else if (ch == '[')
+ mutt_buffer_addch (dest, '\033');
+ else if (isalpha ((unsigned char) ch))
+ mutt_buffer_addch (dest, toupper ((unsigned char) ch) - '@');
+ else
+ {
+ mutt_buffer_addch (dest, '^');
+ mutt_buffer_addch (dest, ch);
+ }
+ }
+ else if (ch == '`' && (!qc || qc == '"'))
+ {
+ FILE *fp;
+ pid_t pid;
+ char *cmd, *ptr;
+ size_t expnlen;
+ BUFFER expn;
+ int line = 0;
+
+ pc = tok->dptr;
+ do {
+ if ((pc = strpbrk (pc, "\\`")))
+ {
+ /* skip any quoted chars */
+ if (*pc == '\\')
+ pc += 2;
+ }
+ } while (pc && *pc != '`');
+ if (!pc)
+ {
+ mutt_debug (1, "mutt_get_token: mismatched backticks\n");
+ return (-1);
+ }
+ cmd = mutt_substrdup (tok->dptr, pc);
+ if ((pid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0)
+ {
+ mutt_debug (1, "mutt_get_token: unable to fork command: %s", cmd);
+ FREE (&cmd);
+ return (-1);
+ }
+ FREE (&cmd);
+
+ tok->dptr = pc + 1;
+
+ /* read line */
+ mutt_buffer_init (&expn);
+ expn.data = mutt_read_line (NULL, &expn.dsize, fp, &line, 0);
+ safe_fclose (&fp);
+ mutt_wait_filter (pid);
+
+ /* if we got output, make a new string consisting of the shell output
+ plus whatever else was left on the original line */
+ /* BUT: If this is inside a quoted string, directly add output to
+ * the token */
+ if (expn.data && qc)
+ {
+ mutt_buffer_addstr (dest, expn.data);
+ FREE (&expn.data);
+ }
+ else if (expn.data)
+ {
+ expnlen = mutt_strlen (expn.data);
+ tok->dsize = expnlen + mutt_strlen (tok->dptr) + 1;
+ ptr = safe_malloc (tok->dsize);
+ memcpy (ptr, expn.data, expnlen);
+ strcpy (ptr + expnlen, tok->dptr); /* __STRCPY_CHECKED__ */
+ if (tok->destroy)
+ FREE (&tok->data);
+ tok->data = ptr;
+ tok->dptr = ptr;
+ tok->destroy = 1; /* mark that the caller should destroy this data */
+ ptr = NULL;
+ FREE (&expn.data);
+ }
+ }
+ else if (ch == '$' && (!qc || qc == '"') && (*tok->dptr == '{' || isalpha ((unsigned char) *tok->dptr)))
+ {
+ const char *env = NULL;
+ char *var = NULL;
+ int idx;
+
+ if (*tok->dptr == '{')
+ {
+ tok->dptr++;
+ if ((pc = strchr (tok->dptr, '}')))
+ {
+ var = mutt_substrdup (tok->dptr, pc);
+ tok->dptr = pc + 1;
+ }
+ }
+ else
+ {
+ for (pc = tok->dptr; isalnum ((unsigned char) *pc) || *pc == '_'; pc++)
+ ;
+ var = mutt_substrdup (tok->dptr, pc);
+ tok->dptr = pc;
+ }
+ if (var)
+ {
+ if ((env = getenv (var)) || (env = myvar_get (var)))
+ mutt_buffer_addstr (dest, env);
+ else if ((idx = mutt_option_index (var)) != -1)
+ {
+ /* expand settable mutt variables */
+ char val[LONG_STRING];
+
+ if (var_to_string (idx, val, sizeof (val)))
+ mutt_buffer_addstr (dest, val);
+ }
+ FREE (&var);
+ }
+ }
+ else
+ mutt_buffer_addch (dest, ch);
+ }
+ mutt_buffer_addch (dest, 0); /* terminate the string */
+ SKIPWS (tok->dptr);
+ return 0;
+}
--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BUFFER_INCLUDED
+#define BUFFER_INCLUDED
+
+#include <sys/types.h>
+
+typedef struct
+{
+ char *data; /* pointer to data */
+ char *dptr; /* current read/write position */
+ size_t dsize; /* length of data */
+ int destroy; /* destroy `data' when done? */
+} BUFFER;
+
+/* flags for mutt_extract_token() */
+#define MUTT_TOKEN_EQUAL 1 /* treat '=' as a special */
+#define MUTT_TOKEN_CONDENSE (1<<1) /* ^(char) to control chars (macros) */
+#define MUTT_TOKEN_SPACE (1<<2) /* don't treat whitespace as a term */
+#define MUTT_TOKEN_QUOTE (1<<3) /* don't interpret quotes */
+#define MUTT_TOKEN_PATTERN (1<<4) /* !)|~ are terms (for patterns) */
+#define MUTT_TOKEN_COMMENT (1<<5) /* don't reap comments */
+#define MUTT_TOKEN_SEMICOLON (1<<6) /* don't treat ; as special */
+
+BUFFER *mutt_buffer_new (void);
+BUFFER * mutt_buffer_init (BUFFER *);
+BUFFER * mutt_buffer_from (char *);
+void mutt_buffer_free(BUFFER **);
+int mutt_buffer_printf (BUFFER*, const char*, ...);
+void mutt_buffer_addstr (BUFFER* buf, const char* s);
+void mutt_buffer_addch (BUFFER* buf, char c);
+int mutt_extract_token (BUFFER *, BUFFER *, int);
+
+#endif
+
#endif
#include "mutt.h"
+#include "filter.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mime.h"
#include "mutt.h"
#include "mutt_curses.h"
+#include "filter.h"
#include <unistd.h>
#include <stdlib.h>
--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef FILTER_INCLUDED
+#define FILTER_INCLUDED
+
+#include <unistd.h>
+#include <stdio.h>
+
+pid_t
+mutt_create_filter_fd (const char *cmd, FILE **in, FILE **out, FILE **err,
+ int fdin, int fdout, int fderr);
+pid_t mutt_create_filter (const char *s, FILE **in, FILE **out, FILE **err);
+int mutt_wait_filter (pid_t pid);
+
+#endif
+
#include <ctype.h>
#include "mutt.h"
+#include "filter.h"
#include "pgp.h"
#include "charset.h"
#include <sys/stat.h>
#include "mutt.h"
+#include "filter.h"
#include "mutt_curses.h"
#include "rfc1524.h"
#include "keymap.h"
#endif
#include "mutt.h"
+#include "filter.h"
#include "mapping.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mx.h"
#include "init.h"
#include "mailbox.h"
+#include "myvar.h"
#include <ctype.h>
#include <stdlib.h>
static myvar_t* MyVars;
-static int var_to_string (int idx, char* val, size_t len);
-
static void myvar_set (const char* var, const char* val);
-static const char* myvar_get (const char* var);
static void myvar_del (const char* var);
#if USE_NOTMUCH
/* given the variable ``s'', return the index into the rc_vars array which
matches, or -1 if the variable is not found. */
-static int mutt_option_index (char *s)
+int mutt_option_index (char *s)
{
int i;
return (-1);
}
-int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)
-{
- char ch;
- char qc = 0; /* quote char */
- char *pc;
-
- /* reset the destination pointer to the beginning of the buffer */
- dest->dptr = dest->data;
-
- SKIPWS (tok->dptr);
- while ((ch = *tok->dptr))
- {
- if (!qc)
- {
- if ((ISSPACE (ch) && !(flags & MUTT_TOKEN_SPACE)) ||
- (ch == '#' && !(flags & MUTT_TOKEN_COMMENT)) ||
- (ch == '=' && (flags & MUTT_TOKEN_EQUAL)) ||
- (ch == ';' && !(flags & MUTT_TOKEN_SEMICOLON)) ||
- ((flags & MUTT_TOKEN_PATTERN) && strchr ("~%=!|", ch)))
- break;
- }
-
- tok->dptr++;
-
- if (ch == qc)
- qc = 0; /* end of quote */
- else if (!qc && (ch == '\'' || ch == '"') && !(flags & MUTT_TOKEN_QUOTE))
- qc = ch;
- else if (ch == '\\' && qc != '\'')
- {
- if (!*tok->dptr)
- return -1; /* premature end of token */
- switch (ch = *tok->dptr++)
- {
- case 'c':
- case 'C':
- if (!*tok->dptr)
- return -1; /* premature end of token */
- mutt_buffer_addch (dest, (toupper ((unsigned char) *tok->dptr)
- - '@') & 0x7f);
- tok->dptr++;
- break;
- case 'r':
- mutt_buffer_addch (dest, '\r');
- break;
- case 'n':
- mutt_buffer_addch (dest, '\n');
- break;
- case 't':
- mutt_buffer_addch (dest, '\t');
- break;
- case 'f':
- mutt_buffer_addch (dest, '\f');
- break;
- case 'e':
- mutt_buffer_addch (dest, '\033');
- break;
- default:
- if (isdigit ((unsigned char) ch) &&
- isdigit ((unsigned char) *tok->dptr) &&
- isdigit ((unsigned char) *(tok->dptr + 1)))
- {
-
- mutt_buffer_addch (dest, (ch << 6) + (*tok->dptr << 3) + *(tok->dptr + 1) - 3504);
- tok->dptr += 2;
- }
- else
- mutt_buffer_addch (dest, ch);
- }
- }
- else if (ch == '^' && (flags & MUTT_TOKEN_CONDENSE))
- {
- if (!*tok->dptr)
- return -1; /* premature end of token */
- ch = *tok->dptr++;
- if (ch == '^')
- mutt_buffer_addch (dest, ch);
- else if (ch == '[')
- mutt_buffer_addch (dest, '\033');
- else if (isalpha ((unsigned char) ch))
- mutt_buffer_addch (dest, toupper ((unsigned char) ch) - '@');
- else
- {
- mutt_buffer_addch (dest, '^');
- mutt_buffer_addch (dest, ch);
- }
- }
- else if (ch == '`' && (!qc || qc == '"'))
- {
- FILE *fp;
- pid_t pid;
- char *cmd, *ptr;
- size_t expnlen;
- BUFFER expn;
- int line = 0;
-
- pc = tok->dptr;
- do {
- if ((pc = strpbrk (pc, "\\`")))
- {
- /* skip any quoted chars */
- if (*pc == '\\')
- pc += 2;
- }
- } while (pc && *pc != '`');
- if (!pc)
- {
- mutt_debug (1, "mutt_get_token: mismatched backticks\n");
- return (-1);
- }
- cmd = mutt_substrdup (tok->dptr, pc);
- if ((pid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0)
- {
- mutt_debug (1, "mutt_get_token: unable to fork command: %s", cmd);
- FREE (&cmd);
- return (-1);
- }
- FREE (&cmd);
-
- tok->dptr = pc + 1;
-
- /* read line */
- mutt_buffer_init (&expn);
- expn.data = mutt_read_line (NULL, &expn.dsize, fp, &line, 0);
- safe_fclose (&fp);
- mutt_wait_filter (pid);
-
- /* if we got output, make a new string consisting of the shell output
- plus whatever else was left on the original line */
- /* BUT: If this is inside a quoted string, directly add output to
- * the token */
- if (expn.data && qc)
- {
- mutt_buffer_addstr (dest, expn.data);
- FREE (&expn.data);
- }
- else if (expn.data)
- {
- expnlen = mutt_strlen (expn.data);
- tok->dsize = expnlen + mutt_strlen (tok->dptr) + 1;
- ptr = safe_malloc (tok->dsize);
- memcpy (ptr, expn.data, expnlen);
- strcpy (ptr + expnlen, tok->dptr); /* __STRCPY_CHECKED__ */
- if (tok->destroy)
- FREE (&tok->data);
- tok->data = ptr;
- tok->dptr = ptr;
- tok->destroy = 1; /* mark that the caller should destroy this data */
- ptr = NULL;
- FREE (&expn.data);
- }
- }
- else if (ch == '$' && (!qc || qc == '"') && (*tok->dptr == '{' || isalpha ((unsigned char) *tok->dptr)))
- {
- const char *env = NULL;
- char *var = NULL;
- int idx;
-
- if (*tok->dptr == '{')
- {
- tok->dptr++;
- if ((pc = strchr (tok->dptr, '}')))
- {
- var = mutt_substrdup (tok->dptr, pc);
- tok->dptr = pc + 1;
- }
- }
- else
- {
- for (pc = tok->dptr; isalnum ((unsigned char) *pc) || *pc == '_'; pc++)
- ;
- var = mutt_substrdup (tok->dptr, pc);
- tok->dptr = pc;
- }
- if (var)
- {
- if ((env = getenv (var)) || (env = myvar_get (var)))
- mutt_buffer_addstr (dest, env);
- else if ((idx = mutt_option_index (var)) != -1)
- {
- /* expand settable mutt variables */
- char val[LONG_STRING];
-
- if (var_to_string (idx, val, sizeof (val)))
- mutt_buffer_addstr (dest, val);
- }
- FREE (&var);
- }
- }
- else
- mutt_buffer_addch (dest, ch);
- }
- mutt_buffer_addch (dest, 0); /* terminate the string */
- SKIPWS (tok->dptr);
- return 0;
-}
-
static void mutt_free_opt (struct option_t* p)
{
REGEXP* pp;
}
#endif
-static int var_to_string (int idx, char* val, size_t len)
+int var_to_string (int idx, char* val, size_t len)
{
char tmp[LONG_STRING];
static const char * const vals[] = { "no", "yes", "ask-no", "ask-yes" };
}
}
-static const char* myvar_get (const char* var)
+const char* myvar_get (const char* var)
{
myvar_t* cur;
# include <stdarg.h>
# include <stdbool.h>
# include <signal.h>
+# include <ctype.h>
# ifndef _POSIX_PATH_MAX
# include <limits.h>
#include "mutt.h"
#include "mbyte.h"
#include "charset.h"
+#include "buffer.h"
#include <errno.h>
#define WHERE_DEFINED 1
+#include "buffer.h"
#include "mutt_regex.h"
/* flags for mutt_enter_string() */
#define MUTT_NM_TAG (1<<10) /* Notmuch tag +/- mode. */
#endif
-/* flags for mutt_get_token() */
-#define MUTT_TOKEN_EQUAL 1 /* treat '=' as a special */
-#define MUTT_TOKEN_CONDENSE (1<<1) /* ^(char) to control chars (macros) */
-#define MUTT_TOKEN_SPACE (1<<2) /* don't treat whitespace as a term */
-#define MUTT_TOKEN_QUOTE (1<<3) /* don't interpret quotes */
-#define MUTT_TOKEN_PATTERN (1<<4) /* !)|~ are terms (for patterns) */
-#define MUTT_TOKEN_COMMENT (1<<5) /* don't reap comments */
-#define MUTT_TOKEN_SEMICOLON (1<<6) /* don't treat ; as special */
-
-typedef struct
-{
- char *data; /* pointer to data */
- char *dptr; /* current read/write position */
- size_t dsize; /* length of data */
- int destroy; /* destroy `data' when done? */
-} BUFFER;
-
/* flags for _mutt_system() */
#define MUTT_DETACH_PROCESS 1 /* detach subprocess from group */
# include "config.h"
#endif
+#include "buffer.h"
#include "mutt.h"
+#include "filter.h"
#include "mutt_curses.h"
#include "mime.h"
#include "mailbox.h"
sleep(s);
}
-/* creates and initializes a BUFFER */
-BUFFER *mutt_buffer_new(void) {
- BUFFER *b;
-
- b = safe_malloc(sizeof(BUFFER));
-
- mutt_buffer_init(b);
-
- return b;
-}
-
-/* initialize a new BUFFER */
-BUFFER *mutt_buffer_init (BUFFER *b) {
- memset(b, 0, sizeof(BUFFER));
- return b;
-}
-
-/*
- * Creates and initializes a BUFFER*. If passed an existing BUFFER*,
- * just initializes. Frees anything already in the buffer. Copies in
- * the seed string.
- *
- * Disregards the 'destroy' flag, which seems reserved for caller.
- * This is bad, but there's no apparent protocol for it.
- */
-BUFFER *mutt_buffer_from (char *seed) {
- BUFFER *b;
-
- if (!seed)
- return NULL;
-
- b = mutt_buffer_new ();
- b->data = safe_strdup(seed);
- b->dsize = mutt_strlen(seed);
- b->dptr = (char *) b->data + b->dsize;
- return b;
-}
-
-int mutt_buffer_printf (BUFFER* buf, const char* fmt, ...)
-{
- va_list ap, ap_retry;
- int len, blen, doff;
-
- va_start (ap, fmt);
- va_copy (ap_retry, ap);
-
- if (!buf->dptr)
- buf->dptr = buf->data;
-
- doff = buf->dptr - buf->data;
- blen = buf->dsize - doff;
- /* solaris 9 vsnprintf barfs when blen is 0 */
- if (!blen)
- {
- blen = 128;
- buf->dsize += blen;
- safe_realloc (&buf->data, buf->dsize);
- buf->dptr = buf->data + doff;
- }
- if ((len = vsnprintf (buf->dptr, blen, fmt, ap)) >= blen)
- {
- blen = ++len - blen;
- if (blen < 128)
- blen = 128;
- buf->dsize += blen;
- safe_realloc (&buf->data, buf->dsize);
- buf->dptr = buf->data + doff;
- len = vsnprintf (buf->dptr, len, fmt, ap_retry);
- }
- if (len > 0)
- buf->dptr += len;
-
- va_end (ap);
- va_end (ap_retry);
-
- return len;
-}
-
-void mutt_buffer_addstr (BUFFER* buf, const char* s)
-{
- mutt_buffer_add (buf, s, mutt_strlen (s));
-}
-
-void mutt_buffer_addch (BUFFER* buf, char c)
-{
- mutt_buffer_add (buf, &c, 1);
-}
-
-void mutt_buffer_free (BUFFER **p)
-{
- if (!p || !*p)
- return;
-
- FREE(&(*p)->data);
- /* dptr is just an offset to data and shouldn't be freed */
- FREE(p); /* __FREE_CHECKED__ */
-}
-
-/* dynamically grows a BUFFER to accommodate s, in increments of 128 bytes.
- * Always one byte bigger than necessary for the null terminator, and
- * the buffer is always null-terminated */
-void mutt_buffer_add (BUFFER* buf, const char* s, size_t len)
-{
- size_t offset;
-
- if (buf->dptr + len + 1 > buf->data + buf->dsize)
- {
- offset = buf->dptr - buf->data;
- buf->dsize += len < 128 ? 128 : len + 1;
- /* suppress compiler aliasing warning */
- safe_realloc ((void**) (void*) &buf->data, buf->dsize);
- buf->dptr = buf->data + offset;
- }
- memcpy (buf->dptr, s, len);
- buf->dptr += len;
- *(buf->dptr) = '\0';
-}
-
/* Decrease a file's modification time by 1 second */
time_t mutt_decrease_mtime (const char *f, struct stat *st)
--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef MYVAR_INCLUDED
+#define MYVAR_INCLUDED
+
+#include <sys/types.h>
+
+const char* myvar_get (const char* var);
+int var_to_string (int idx, char* val, size_t len);
+int mutt_option_index (char *s);
+
+#endif
+
#include "rfc2231.h"
#include "mutt_crypt.h"
#include "url.h"
+#include "buffer.h"
#include <string.h>
#include <ctype.h>
#endif
#include "mutt.h"
+#include "filter.h"
#include "mutt_crypt.h"
#include "mutt_curses.h"
#include "pgp.h"
#include <time.h>
#include "mutt.h"
+#include "filter.h"
#include "mutt_curses.h"
#include "mutt_idna.h"
#include "pgp.h"
#endif
#include "mutt.h"
+#include "filter.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mime.h"
void mutt_make_string_info (char *, size_t, int, const char *, struct hdr_format_info *, format_flag);
-int mutt_extract_token (BUFFER *, BUFFER *, int);
-BUFFER *mutt_buffer_new (void);
-BUFFER * mutt_buffer_init (BUFFER *);
-BUFFER * mutt_buffer_from (char *);
-void mutt_buffer_free(BUFFER **);
-int mutt_buffer_printf (BUFFER*, const char*, ...);
void mutt_buffer_add (BUFFER*, const char*, size_t);
void mutt_buffer_addstr (BUFFER*, const char*);
void mutt_buffer_addch (BUFFER*, char);
int mutt_thread_set_flag (HEADER *, int, int, int);
int mutt_user_is_recipient (HEADER *);
void mutt_update_num_postponed (void);
-int mutt_wait_filter (pid_t);
int mutt_which_case (const char *);
int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int, char *, char **);
int mutt_write_multiple_fcc (const char *path, HEADER *hdr, const char *msgid, int, char *, char **);
int mh_valid_message (const char *);
-pid_t mutt_create_filter (const char *, FILE **, FILE **, FILE **);
-pid_t mutt_create_filter_fd (const char *, FILE **, FILE **, FILE **, int, int, int);
-
ADDRESS *alias_reverse_lookup (ADDRESS *);
/* base64.c */
#endif
#include "mutt.h"
+#include "filter.h"
#include "mutt_menu.h"
#include "mutt_idna.h"
#include "mapping.h"
#endif
#include "mutt.h"
+#include "filter.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "rfc1524.h"
#endif
#include "mutt.h"
+#include "filter.h"
#include "mutt_curses.h"
#include "rfc2047.h"
#include "keymap.h"
#endif
#include "mutt.h"
+#include "filter.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "smime.h"