2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
5 * This file is part of mutt-ng, see http://www.muttng.org/.
6 * It's licensed under the GNU General Public License,
7 * please see the file GPL in the top level source directory.
19 static void state_prefix_put (const char *d, size_t dlen, STATE * s)
23 state_prefix_putc (*d++, s);
25 fwrite (d, dlen, 1, s->fpout);
28 void mutt_convert_to_state (iconv_t cd, char *bufi, size_t * l, STATE * s)
36 if (cd != (iconv_t) (-1)) {
37 ob = bufo, obl = sizeof (bufo);
38 iconv (cd, 0, 0, &ob, &obl);
40 state_prefix_put (bufo, ob - bufo, s);
42 if (Quotebuf[0] != '\0')
43 state_prefix_putc ('\n', s);
47 if (cd == (iconv_t) (-1)) {
48 state_prefix_put (bufi, *l, s);
55 ob = bufo, obl = sizeof (bufo);
56 mutt_iconv (cd, &ib, &ibl, &ob, &obl, 0, "?");
59 state_prefix_put (bufo, ob - bufo, s);
61 memmove (bufi, ib, ibl);
65 void state_prefix_putc (char c, STATE * s)
67 if (s->flags & M_PENDINGPREFIX) {
70 i = str_len (Quotebuf);
73 if (i == sizeof (Quotebuf) - 1 || c == '\n') {
74 char buf[2 * SHORT_STRING];
75 int j = 0, offset = 0;
78 state_reset_prefix (s);
80 ((regex_t *) QuoteRegexp.rx, &Quotebuf[offset], 1, pmatch,
82 offset += pmatch->rm_eo;
84 if (!option (OPTQUOTEEMPTY) && Quotebuf[offset] == '\n') {
88 else if (option (OPTQUOTEQUOTED) && offset) {
89 for (i = 0; i < offset; i++)
90 if (Quotebuf[i] != ' ')
92 strncpy (buf, Quotebuf, j + 1);
93 strcpy (buf + j + 1, Quotebuf + j);
96 snprintf (buf, sizeof (buf), "%s%s", NONULL (s->prefix), Quotebuf);
105 state_set_prefix (s);
110 int state_printf (STATE * s, const char *fmt, ...)
116 rv = vfprintf (s->fpout, fmt, ap);
122 void state_mark_attach (STATE * s)
124 if ((s->flags & M_DISPLAY) && !str_cmp (Pager, "builtin"))
125 state_puts (AttachmentMarker, s);
128 void state_attach_puts (const char *t, STATE * s)
131 state_mark_attach (s);
134 if (*t++ == '\n' && *t)
136 state_mark_attach (s);