muttng_SOURCES = $(BUILT_SOURCES) \
alias.c ascii.c attach.c \
base64.c buffer.c browser.c buffy.c \
- charset.c color.c compress.c crypt.c cryptglue.c commands.c complete.c compose.c \
- copy.c curs_lib.c curs_main.c crypt-mod.c crypt-mod.h \
+ charset.c color.c compress.c crypt.c cryptglue.c commands.c complete.c \
+ compose.c copy.c curs_lib.c curs_main.c crypt-mod.c crypt-mod.h \
date.c \
edit.c editmsg.c enter.c \
flags.c filter.c from.c \
pager.c parse.c pattern.c postpone.c \
query.c \
recvattach.c recvcmd.c rfc822.c rfc1524.c rfc2047.c rfc2231.c \
- score.c send.c sendlib.c sidebar.c signal.c sort.c status.c system.c \
+ score.c send.c sendlib.c sidebar.c signal.c sort.c state.c status.c system.c \
thread.c \
url.c utf8.c \
wcwidth.c \
pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \
alias.h \
buffer.h browser.h \
- mbyte.h remailer.h url.h \
+ enter.h \
+ mbyte.h remailer.h url.h state.h \
pgppacket.c mutt_idna.h mutt_libesmtp.c \
- sidebar.h crypt-mod-pgp-classic.c crypt-mod-smime-classic.c
+ crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
+ sidebar.h state.h
EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
configure acconfig.h \
buffer.h buffy.h \
charset.h compress.h copy.h crypthash.h \
dotlock.h functions.h gen_defs \
+ enter.h \
globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
mbox.h mh.h mx.h pager.h pgp.h protos.h reldate.h rfc1524.h rfc2047.h \
rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION autogen.sh \
- _regex.h OPS.MIX remailer.c remailer.h browser.h \
+ _regex.h OPS.MIX remailer.c remailer.h browser.h state.h \
mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttngrc.head Muttngrc \
makedoc.c stamp-doc-rc README.SSL smime.h\
muttngbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
--- /dev/null
+/*
+ * Copyright notice from original mutt:
+ * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+#ifndef _MUTT_ENTER_H
+#define _MUTT_ENTER_H
+
+typedef struct {
+ wchar_t *wbuf;
+ size_t wbuflen;
+ size_t lastchar;
+ size_t curpos;
+ size_t begin;
+ int tabs;
+} ENTER_STATE;
+
+void mutt_free_enter_state (ENTER_STATE **);
+int mutt_enter_string (char *buf, size_t buflen, int y, int x, int flags);
+int _mutt_enter_string (char *, size_t, int, int, int, int, char ***, int *,
+ ENTER_STATE *);
+
+#endif /* !_MUTT_ENTER_H */
#include "copy.h"
#include "charset.h"
#include "mutt_crypt.h"
+#include "state.h"
#include "lib.h"
#include "lib/mem.h"
#include "lib/str.h"
#include "lib/debug.h"
-#define BUFI_SIZE 1000
-#define BUFO_SIZE 2000
-
-
typedef void handler_f (BODY *, STATE *);
typedef handler_f *handler_t;
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
};
-static void state_prefix_put (const char *d, size_t dlen, STATE * s)
-{
- if (s->prefix)
- while (dlen--)
- state_prefix_putc (*d++, s);
- else
- fwrite (d, dlen, 1, s->fpout);
-}
-
-void mutt_convert_to_state (iconv_t cd, char *bufi, size_t * l, STATE * s)
-{
- char bufo[BUFO_SIZE];
- ICONV_CONST char *ib;
- char *ob;
- size_t ibl, obl;
-
- if (!bufi) {
- if (cd != (iconv_t) (-1)) {
- ob = bufo, obl = sizeof (bufo);
- iconv (cd, 0, 0, &ob, &obl);
- if (ob != bufo)
- state_prefix_put (bufo, ob - bufo, s);
- }
- if (Quotebuf[0] != '\0')
- state_prefix_putc ('\n', s);
- return;
- }
-
- if (cd == (iconv_t) (-1)) {
- state_prefix_put (bufi, *l, s);
- *l = 0;
- return;
- }
-
- ib = bufi, ibl = *l;
- for (;;) {
- ob = bufo, obl = sizeof (bufo);
- mutt_iconv (cd, &ib, &ibl, &ob, &obl, 0, "?");
- if (ob == bufo)
- break;
- state_prefix_put (bufo, ob - bufo, s);
- }
- memmove (bufi, ib, ibl);
- *l = ibl;
-}
-
void mutt_decode_xbit (STATE * s, long len, int istext, iconv_t cd)
{
int c, ch;
unsigned int unowned:1; /* don't unlink on detach */
} ATTACHPTR;
-typedef struct {
- FILE *fpin;
- FILE *fpout;
- char *prefix;
- int flags;
-} STATE;
-
-/* used by enter.c */
-
-typedef struct {
- wchar_t *wbuf;
- size_t wbuflen;
- size_t lastchar;
- size_t curpos;
- size_t begin;
- int tabs;
-} ENTER_STATE;
-
-/* flags for the STATE struct */
-#define M_DISPLAY (1<<0) /* output is displayed to the user */
-#define M_VERIFY (1<<1) /* perform signature verification */
-#define M_PENDINGPREFIX (1<<2) /* prefix to write, but character must follow */
-#define M_WEED (1<<3) /* weed headers even when not in display mode */
-#define M_CHARCONV (1<<4) /* Do character set conversions */
-#define M_PRINTING (1<<5) /* are we printing? - M_DISPLAY "light" */
-#define M_REPLYING (1<<6) /* are we replying? */
-#define M_FIRSTDONE (1<<7) /* the first attachment has been done */
-
-#define state_set_prefix(s) ((s)->flags |= M_PENDINGPREFIX)
-#define state_reset_prefix(s) ((s)->flags &= ~M_PENDINGPREFIX)
-#define state_puts(x,y) fputs(x,(y)->fpout)
-#define state_putc(x,y) fputc(x,(y)->fpout)
-
-void state_mark_attach (STATE *);
-void state_attach_puts (const char *, STATE *);
-void state_prefix_putc (char, STATE *);
-int state_printf (STATE *, const char *, ...);
-
#include "ascii.h"
#include "alias.h"
-#include "addrbook.h"
#include "buffer.h"
+#include "state.h"
+#include "enter.h"
#include "protos.h"
#include "lib.h"
#include "globals.h"
return (ret);
}
-void state_prefix_putc (char c, STATE * s)
-{
- if (s->flags & M_PENDINGPREFIX) {
- int i;
-
- i = str_len (Quotebuf);
- Quotebuf[i++] = c;
- Quotebuf[i] = '\0';
- if (i == sizeof (Quotebuf) - 1 || c == '\n') {
- char buf[2 * SHORT_STRING];
- int j = 0, offset = 0;
- regmatch_t pmatch[1];
-
- state_reset_prefix (s);
- while (regexec
- ((regex_t *) QuoteRegexp.rx, &Quotebuf[offset], 1, pmatch,
- 0) == 0)
- offset += pmatch->rm_eo;
-
- if (!option (OPTQUOTEEMPTY) && Quotebuf[offset] == '\n') {
- buf[0] = '\n';
- buf[1] = '\0';
- }
- else if (option (OPTQUOTEQUOTED) && offset) {
- for (i = 0; i < offset; i++)
- if (Quotebuf[i] != ' ')
- j = i;
- strncpy (buf, Quotebuf, j + 1);
- strcpy (buf + j + 1, Quotebuf + j);
- }
- else
- snprintf (buf, sizeof (buf), "%s%s", NONULL (s->prefix), Quotebuf);
-
- state_puts (buf, s);
- }
- }
- else
- state_putc (c, s);
-
- if (c == '\n') {
- state_set_prefix (s);
- Quotebuf[0] = '\0';
- }
-}
-
-int state_printf (STATE * s, const char *fmt, ...)
-{
- int rv;
- va_list ap;
-
- va_start (ap, fmt);
- rv = vfprintf (s->fpout, fmt, ap);
- va_end (ap);
-
- return rv;
-}
-
-void state_mark_attach (STATE * s)
-{
- if ((s->flags & M_DISPLAY) && !str_cmp (Pager, "builtin"))
- state_puts (AttachmentMarker, s);
-}
-
-void state_attach_puts (const char *t, STATE * s)
-{
- if (*t != '\n')
- state_mark_attach (s);
- while (*t) {
- state_putc (*t, s);
- if (*t++ == '\n' && *t)
- if (*t != '\n')
- state_mark_attach (s);
- }
-}
-
void mutt_display_sanitize (char *s)
{
for (; *s; s++) {
void mutt_forward_trailer (FILE * fp);
void mutt_free_body (BODY **);
void mutt_free_color (int fg, int bg);
-void mutt_free_enter_state (ENTER_STATE **);
void mutt_free_envelope (ENVELOPE **);
void mutt_free_header (HEADER **);
void mutt_free_parameter (PARAMETER **);
#define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL)
int _mutt_enter_fname (const char *, char *, size_t, int *, int, int,
char ***, int *);
-int mutt_enter_string (char *buf, size_t buflen, int y, int x, int flags);
-int _mutt_enter_string (char *, size_t, int, int, int, int, char ***, int *,
- ENTER_STATE *);
#define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
int _mutt_get_field (char *, char *, size_t, int, int, char ***, int *);
int mutt_get_field_unbuffered (char *, char *, size_t, int);
--- /dev/null
+/*
+ * Copyright notice from original mutt:
+ * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "mutt.h"
+#include "state.h"
+
+static void state_prefix_put (const char *d, size_t dlen, STATE * s)
+{
+ if (s->prefix)
+ while (dlen--)
+ state_prefix_putc (*d++, s);
+ else
+ fwrite (d, dlen, 1, s->fpout);
+}
+
+void mutt_convert_to_state (iconv_t cd, char *bufi, size_t * l, STATE * s)
+{
+ char bufo[BUFO_SIZE];
+ ICONV_CONST char *ib;
+ char *ob;
+ size_t ibl, obl;
+
+ if (!bufi) {
+ if (cd != (iconv_t) (-1)) {
+ ob = bufo, obl = sizeof (bufo);
+ iconv (cd, 0, 0, &ob, &obl);
+ if (ob != bufo)
+ state_prefix_put (bufo, ob - bufo, s);
+ }
+ if (Quotebuf[0] != '\0')
+ state_prefix_putc ('\n', s);
+ return;
+ }
+
+ if (cd == (iconv_t) (-1)) {
+ state_prefix_put (bufi, *l, s);
+ *l = 0;
+ return;
+ }
+
+ ib = bufi, ibl = *l;
+ for (;;) {
+ ob = bufo, obl = sizeof (bufo);
+ mutt_iconv (cd, &ib, &ibl, &ob, &obl, 0, "?");
+ if (ob == bufo)
+ break;
+ state_prefix_put (bufo, ob - bufo, s);
+ }
+ memmove (bufi, ib, ibl);
+ *l = ibl;
+}
+
+void state_prefix_putc (char c, STATE * s)
+{
+ if (s->flags & M_PENDINGPREFIX) {
+ int i;
+
+ i = str_len (Quotebuf);
+ Quotebuf[i++] = c;
+ Quotebuf[i] = '\0';
+ if (i == sizeof (Quotebuf) - 1 || c == '\n') {
+ char buf[2 * SHORT_STRING];
+ int j = 0, offset = 0;
+ regmatch_t pmatch[1];
+
+ state_reset_prefix (s);
+ while (regexec
+ ((regex_t *) QuoteRegexp.rx, &Quotebuf[offset], 1, pmatch,
+ 0) == 0)
+ offset += pmatch->rm_eo;
+
+ if (!option (OPTQUOTEEMPTY) && Quotebuf[offset] == '\n') {
+ buf[0] = '\n';
+ buf[1] = '\0';
+ }
+ else if (option (OPTQUOTEQUOTED) && offset) {
+ for (i = 0; i < offset; i++)
+ if (Quotebuf[i] != ' ')
+ j = i;
+ strncpy (buf, Quotebuf, j + 1);
+ strcpy (buf + j + 1, Quotebuf + j);
+ }
+ else
+ snprintf (buf, sizeof (buf), "%s%s", NONULL (s->prefix), Quotebuf);
+
+ state_puts (buf, s);
+ }
+ }
+ else
+ state_putc (c, s);
+
+ if (c == '\n') {
+ state_set_prefix (s);
+ Quotebuf[0] = '\0';
+ }
+}
+
+int state_printf (STATE * s, const char *fmt, ...)
+{
+ int rv;
+ va_list ap;
+
+ va_start (ap, fmt);
+ rv = vfprintf (s->fpout, fmt, ap);
+ va_end (ap);
+
+ return rv;
+}
+
+void state_mark_attach (STATE * s)
+{
+ if ((s->flags & M_DISPLAY) && !str_cmp (Pager, "builtin"))
+ state_puts (AttachmentMarker, s);
+}
+
+void state_attach_puts (const char *t, STATE * s)
+{
+ if (*t != '\n')
+ state_mark_attach (s);
+ while (*t) {
+ state_putc (*t, s);
+ if (*t++ == '\n' && *t)
+ if (*t != '\n')
+ state_mark_attach (s);
+ }
+}
--- /dev/null
+/*
+ * Copyright notice from original mutt:
+ * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+#ifndef _MUTT_STATE_H
+#define _MUTT_STATE_H
+
+#include "charset.h"
+
+typedef struct {
+ FILE *fpin;
+ FILE *fpout;
+ char *prefix;
+ int flags;
+} STATE;
+
+#define BUFI_SIZE 1000
+#define BUFO_SIZE 2000
+
+/* flags for the STATE struct */
+#define M_DISPLAY (1<<0) /* output is displayed to the user */
+#define M_VERIFY (1<<1) /* perform signature verification */
+#define M_PENDINGPREFIX (1<<2) /* prefix to write, but character must follow */
+#define M_WEED (1<<3) /* weed headers even when not in display mode */
+#define M_CHARCONV (1<<4) /* Do character set conversions */
+#define M_PRINTING (1<<5) /* are we printing? - M_DISPLAY "light" */
+#define M_REPLYING (1<<6) /* are we replying? */
+#define M_FIRSTDONE (1<<7) /* the first attachment has been done */
+
+#define state_set_prefix(s) ((s)->flags |= M_PENDINGPREFIX)
+#define state_reset_prefix(s) ((s)->flags &= ~M_PENDINGPREFIX)
+#define state_puts(x,y) fputs(x,(y)->fpout)
+#define state_putc(x,y) fputc(x,(y)->fpout)
+
+void state_mark_attach (STATE *);
+void state_attach_puts (const char *, STATE *);
+void state_prefix_putc (char, STATE *);
+int state_printf (STATE *, const char *, ...);
+
+void mutt_convert_to_state (iconv_t, char*, size_t*, STATE*);
+
+#endif /* !_MUTT_STATE_H */