Rocco Rutte:
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Mon, 8 Aug 2005 12:19:36 +0000 (12:19 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Mon, 8 Aug 2005 12:19:36 +0000 (12:19 +0000)
- move more data structs out to dedicated source files

git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@382 e385b8ad-14ed-0310-8656-cc95a2468c6d

Makefile.am
enter.h [new file with mode: 0644]
handler.c
mutt.h
muttlib.c
protos.h
state.c [new file with mode: 0644]
state.h [new file with mode: 0644]

index 019fa53..71d7cc4 100644 (file)
@@ -29,8 +29,8 @@ bin_PROGRAMS = muttng @DOTLOCK_TARGET@ @PGPAUX_TARGET@ @SMIMEAUX_TARGET@
 muttng_SOURCES = $(BUILT_SOURCES) \
        alias.c ascii.c attach.c \
        base64.c buffer.c browser.c buffy.c \
 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 \
        date.c \
        edit.c editmsg.c enter.c \
        flags.c filter.c from.c \
@@ -43,7 +43,7 @@ muttng_SOURCES = $(BUILT_SOURCES) \
        pager.c parse.c pattern.c postpone.c \
        query.c \
        recvattach.c recvcmd.c rfc822.c rfc1524.c rfc2047.c rfc2231.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 \
        thread.c \
        url.c utf8.c \
        wcwidth.c \
@@ -82,9 +82,11 @@ EXTRA_muttng_SOURCES = \
        pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \
        alias.h \
        buffer.h browser.h \
        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 \
        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 \
 
 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
        configure acconfig.h \
@@ -92,12 +94,13 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
        buffer.h buffy.h \
        charset.h compress.h copy.h crypthash.h \
        dotlock.h functions.h gen_defs \
        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 \
        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       \
        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       \
diff --git a/enter.h b/enter.h
new file mode 100644 (file)
index 0000000..aaf677f
--- /dev/null
+++ b/enter.h
@@ -0,0 +1,26 @@
+/*
+ * 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 */
index 8373635..521bcc3 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -26,6 +26,7 @@
 #include "copy.h"
 #include "charset.h"
 #include "mutt_crypt.h"
 #include "copy.h"
 #include "charset.h"
 #include "mutt_crypt.h"
+#include "state.h"
 #include "lib.h"
 
 #include "lib/mem.h"
 #include "lib.h"
 
 #include "lib/mem.h"
 #include "lib/str.h"
 #include "lib/debug.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;
 
 typedef void handler_f (BODY *, STATE *);
 typedef handler_f *handler_t;
 
@@ -62,52 +59,6 @@ int Index_64[128] = {
   41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
 };
 
   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;
 void mutt_decode_xbit (STATE * s, long len, int istext, iconv_t cd)
 {
   int c, ch;
diff --git a/mutt.h b/mutt.h
index 5593224..03fe55b 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -879,48 +879,11 @@ typedef struct attachptr {
   unsigned int unowned:1;       /* don't unlink on detach */
 } ATTACHPTR;
 
   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 "ascii.h"
 #include "alias.h"
-#include "addrbook.h"
 #include "buffer.h"
 #include "buffer.h"
+#include "state.h"
+#include "enter.h"
 #include "protos.h"
 #include "lib.h"
 #include "globals.h"
 #include "protos.h"
 #include "lib.h"
 #include "globals.h"
index b8059f0..c037f76 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -1277,81 +1277,6 @@ int mutt_save_confirm (const char *s, struct stat *st)
   return (ret);
 }
 
   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_display_sanitize (char *s)
 {
   for (; *s; s++) {
index 2f375c2..5136460 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -183,7 +183,6 @@ void mutt_forward_intro (FILE * fp, HEADER * cur);
 void mutt_forward_trailer (FILE * fp);
 void mutt_free_body (BODY **);
 void mutt_free_color (int fg, int bg);
 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 **);
 void mutt_free_envelope (ENVELOPE **);
 void mutt_free_header (HEADER **);
 void mutt_free_parameter (PARAMETER **);
@@ -282,9 +281,6 @@ int mutt_resend_message (FILE *, CONTEXT *, HEADER *);
 #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 *);
 #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);
 #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);
diff --git a/state.c b/state.c
new file mode 100644 (file)
index 0000000..715cc9e
--- /dev/null
+++ b/state.c
@@ -0,0 +1,138 @@
+/*
+ * 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);
+  }
+}
diff --git a/state.h b/state.h
new file mode 100644 (file)
index 0000000..45f97e2
--- /dev/null
+++ b/state.h
@@ -0,0 +1,46 @@
+/*
+ * 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 */