mappings as standalone module
authorPierre Habouzit <madcoder@debian.org>
Wed, 1 Nov 2006 00:15:49 +0000 (01:15 +0100)
committerPierre Habouzit <madcoder@debian.org>
Wed, 1 Nov 2006 00:15:49 +0000 (01:15 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
25 files changed:
Makefile.am
alias.c
browser.c
color.c
compose.c
curs_main.c
help.c
init.c
keymap.c
keymap.h
lib-lib/Makefile.am
lib-lib/mapping.c [new file with mode: 0644]
lib-lib/mapping.h [new file with mode: 0644]
mapping.h
pager.c
pattern.c
postpone.c
protos.h
query.c
recvattach.c
recvcmd.c
remailer.c
sort.h
status.c
url.c

index a3d64f6..c223c0c 100644 (file)
@@ -83,7 +83,7 @@ EXTRA_DIST = config.rpath  COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
        dotlock.h functions.h gen_defs \
        enter.h recvattach.h handler.h thread.h \
        globals.h history.h init.h keymap.h mutt_crypt.h \
        dotlock.h functions.h gen_defs \
        enter.h recvattach.h handler.h thread.h \
        globals.h history.h init.h keymap.h mutt_crypt.h \
-       mapping.h mime.h mutt.h mutt_curses.h mutt_menu.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 rfc1524.h rfc2047.h \
        rfc2231.h rfc822.h rfc3676.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 rfc1524.h rfc2047.h \
        rfc2231.h rfc822.h rfc3676.h \
diff --git a/alias.c b/alias.c
index b43689b..835d55a 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -19,6 +19,7 @@
 #include <lib-lib/str.h>
 #include <lib-lib/file.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/str.h>
 #include <lib-lib/file.h>
 #include <lib-lib/macros.h>
+#include <lib-lib/mapping.h>
 
 #include "lib/rx.h"
 #include "lib/debug.h"
 
 #include "lib/rx.h"
 #include "lib/debug.h"
@@ -28,7 +29,6 @@
 #include "mutt_curses.h"
 #include "mutt_idna.h"
 #include "mutt_menu.h"
 #include "mutt_curses.h"
 #include "mutt_idna.h"
 #include "mutt_menu.h"
-#include "mapping.h"
 #include "sort.h"
 
 #define RSORT(x) (SortAlias & SORT_REVERSE) ? -x : x
 #include "sort.h"
 
 #define RSORT(x) (SortAlias & SORT_REVERSE) ? -x : x
index fd607ce..e22e1ea 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -15,6 +15,7 @@
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "enter.h"
 
 #include "mutt.h"
 #include "enter.h"
@@ -22,7 +23,6 @@
 #include "mutt_curses.h"
 #include "mutt_menu.h"
 #include "buffy.h"
 #include "mutt_curses.h"
 #include "mutt_menu.h"
 #include "buffy.h"
-#include "mapping.h"
 #include "sort.h"
 #include "browser.h"
 #include "attach.h"
 #include "sort.h"
 #include "browser.h"
 #include "attach.h"
diff --git a/color.c b/color.c
index a28c513..17af49a 100644 (file)
--- a/color.c
+++ b/color.c
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/buffer.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/buffer.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "mutt_curses.h"
 
 #include "mutt.h"
 #include "mutt_curses.h"
-#include "mapping.h"
 
 #include "lib/debug.h"
 
 
 #include "lib/debug.h"
 
index b0b20aa..f94fe4c 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -19,6 +19,7 @@
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "enter.h"
 
 #include "mutt.h"
 #include "enter.h"
@@ -29,7 +30,6 @@
 #include "mime.h"
 #include "attach.h"
 #include "recvattach.h"
 #include "mime.h"
 #include "attach.h"
 #include "recvattach.h"
-#include "mapping.h"
 #include "sort.h"
 #include "charset.h"
 #include "mx.h"
 #include "sort.h"
 #include "charset.h"
 #include "mx.h"
index a7e8286..a62f166 100644 (file)
 #include <lib-lib/mem.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/mem.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "mutt_curses.h"
 #include "mx.h"
 #include "mutt_menu.h"
 
 #include "mutt.h"
 #include "mutt_curses.h"
 #include "mx.h"
 #include "mutt_menu.h"
-#include "mapping.h"
 #include "sort.h"
 #include "recvattach.h"
 #include "buffy.h"
 #include "sort.h"
 #include "recvattach.h"
 #include "buffy.h"
diff --git a/help.c b/help.c
index d8392b7..a7b8c9f 100644 (file)
--- a/help.c
+++ b/help.c
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 #include <lib-lib/str.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "mutt_curses.h"
 #include "keymap.h"
 #include "pager.h"
 
 #include "mutt.h"
 #include "mutt_curses.h"
 #include "keymap.h"
 #include "pager.h"
-#include "mapping.h"
 
 #include <wchar.h>
 #include <ctype.h>
 
 #include <wchar.h>
 #include <ctype.h>
diff --git a/init.c b/init.c
index 2d6f7fd..c96e350 100644 (file)
--- a/init.c
+++ b/init.c
@@ -20,9 +20,9 @@
 #include <lib-lib/ascii.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/buffer.h>
 #include <lib-lib/ascii.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/buffer.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 
 #include "mutt.h"
-#include "mapping.h"
 #include "mutt_curses.h"
 #include "history.h"
 #include "keymap.h"
 #include "mutt_curses.h"
 #include "history.h"
 #include "keymap.h"
@@ -2527,26 +2527,6 @@ int mutt_query_variables (LIST * queries)
   return 0;
 }
 
   return 0;
 }
 
-const char *mutt_getnamebyvalue (int val, const struct mapping_t *map)
-{
-  int i;
-
-  for (i = 0; map[i].name; i++)
-    if (map[i].value == val)
-      return (map[i].name);
-  return NULL;
-}
-
-int mutt_getvaluebyname (const char *name, const struct mapping_t *map)
-{
-  int i;
-
-  for (i = 0; map[i].name; i++)
-    if (ascii_strcasecmp (map[i].name, name) == 0)
-      return (map[i].value);
-  return (-1);
-}
-
 static int mutt_execute_commands (LIST * p)
 {
   BUFFER err, token;
 static int mutt_execute_commands (LIST * p)
 {
   BUFFER err, token;
index bc577b7..44ccfd3 100644 (file)
--- a/keymap.c
+++ b/keymap.c
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/buffer.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/buffer.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "mutt_menu.h"
 #include "mutt_curses.h"
 #include "keymap.h"
 
 #include "mutt.h"
 #include "mutt_menu.h"
 #include "mutt_curses.h"
 #include "keymap.h"
-#include "mapping.h"
 #include "mutt_crypt.h"
 
 
 #include "mutt_crypt.h"
 
 
index 6434c77..0f215c2 100644 (file)
--- a/keymap.h
+++ b/keymap.h
@@ -10,7 +10,7 @@
 #ifndef KEYMAP_H
 #define KEYMAP_H
 
 #ifndef KEYMAP_H
 #define KEYMAP_H
 
-#include "mapping.h"
+#include <lib-lib/mapping.h>
 
 /* maximal length of a key binding sequence used for buffer in km_bindkey */
 #define MAX_SEQ 8
 
 /* maximal length of a key binding sequence used for buffer in km_bindkey */
 #define MAX_SEQ 8
index c6c6da1..3545ecf 100644 (file)
@@ -1,7 +1,7 @@
 noinst_LIBRARIES = liblib.a
 
 noinst_LIBRARIES = liblib.a
 
-liblib_a_SOURCES = mem.h str.h ascii.h buffer.h hash.h list.h file.h         \
-                         str.c ascii.c buffer.c hash.c list.c file.c
+liblib_a_SOURCES = mem.h str.h ascii.h buffer.h hash.h list.h file.h mapping.h \
+                         str.c ascii.c buffer.c hash.c list.c file.c mapping.c
 
 
-noinst_HEADERS   = mem.h str.h ascii.h buffer.h hash.h list.h file.h
+noinst_HEADERS   = mem.h str.h ascii.h buffer.h hash.h list.h file.h mapping.h
 
 
diff --git a/lib-lib/mapping.c b/lib-lib/mapping.c
new file mode 100644 (file)
index 0000000..c3065ba
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *  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.
+ *
+ *  Copyright © 2006 Pierre Habouzit
+ */
+
+/*
+ * Copyright notice from original mutt:
+ * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
+ *
+ * Parts were written/modified by:
+ * Rocco Rutte <pdmef@cs.tu-berlin.de>
+ *
+ * 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.
+ */
+
+#include <stdlib.h>
+
+#include "mapping.h"
+
+const char *mutt_getnamebyvalue(int val, const struct mapping_t *map)
+{
+    int i;
+
+    for (i = 0; map[i].name; i++)
+        if (map[i].value == val)
+            return (map[i].name);
+
+    return NULL;
+}
+
+int mutt_getvaluebyname(const char *name, const struct mapping_t *map)
+{
+    int i;
+
+    for (i = 0; map[i].name; i++)
+        if (ascii_strcasecmp (map[i].name, name) == 0)
+            return (map[i].value);
+
+    return -1;
+}
+
diff --git a/lib-lib/mapping.h b/lib-lib/mapping.h
new file mode 100644 (file)
index 0000000..51cc822
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *  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.
+ *
+ *  Copyright © 2006 Pierre Habouzit
+ */
+
+/*
+ * 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_LIB_LIB_MAPPING_H
+#define MUTT_LIB_LIB_MAPPING_H
+
+struct mapping_t {
+    const char *name;
+    int value;
+};
+
+const char *mutt_getnamebyvalue(int, const struct mapping_t *);
+int mutt_getvaluebyname(const char *, const struct mapping_t *);
+
+#endif
+
index 5b0302e..6f6fb7b 100644 (file)
--- a/mapping.h
+++ b/mapping.h
@@ -16,8 +16,6 @@ struct mapping_t {
 };
 
 const char *mutt_getnamebyvalue (int, const struct mapping_t *);
 };
 
 const char *mutt_getnamebyvalue (int, const struct mapping_t *);
-char *mutt_compile_help (char *, size_t, int, struct mapping_t *);
-
 int mutt_getvaluebyname (const char *, const struct mapping_t *);
 
 #endif
 int mutt_getvaluebyname (const char *, const struct mapping_t *);
 
 #endif
diff --git a/pager.c b/pager.c
index 78b75ca..965a85e 100644 (file)
--- a/pager.c
+++ b/pager.c
 #include <lib-lib/mem.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/mem.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "enter.h"
 #include "mutt_curses.h"
 #include "keymap.h"
 #include "mutt_menu.h"
 
 #include "mutt.h"
 #include "enter.h"
 #include "mutt_curses.h"
 #include "keymap.h"
 #include "mutt_menu.h"
-#include "mapping.h"
 #include "sort.h"
 #include "pager.h"
 #include "attach.h"
 #include "sort.h"
 #include "pager.h"
 #include "attach.h"
index f40ea59..b1dba84 100644 (file)
--- a/pattern.c
+++ b/pattern.c
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 #include <lib-lib/buffer.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 #include <lib-lib/buffer.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "handler.h"
 #include "enter.h"
 #include "mx.h"
 
 #include "mutt.h"
 #include "handler.h"
 #include "enter.h"
 #include "mx.h"
-#include "mapping.h"
 #include "keymap.h"
 #include "copy.h"
 #include "mime.h"
 #include "keymap.h"
 #include "copy.h"
 #include "mime.h"
index bb99448..73a1057 100644 (file)
@@ -17,6 +17,7 @@
 #include <lib-lib/ascii.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 #include <lib-lib/ascii.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "enter.h"
 
 #include "mutt.h"
 #include "enter.h"
@@ -24,7 +25,6 @@
 #include "mutt_menu.h"
 #include "rfc1524.h"
 #include "mime.h"
 #include "mutt_menu.h"
 #include "rfc1524.h"
 #include "mime.h"
-#include "mapping.h"
 #include "sort.h"
 #include "thread.h"
 #include "mx.h"
 #include "sort.h"
 #include "thread.h"
 #include "mx.h"
index 52f0de8..d097ee6 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -20,6 +20,7 @@
 #include "mbyte.h"
 
 #include <lib-lib/buffer.h>
 #include "mbyte.h"
 
 #include <lib-lib/buffer.h>
+#include <lib-lib/mapping.h>
 
 #define MoreArgs(p) (*p->dptr && *p->dptr != ';' && *p->dptr != '#')
 
 
 #define MoreArgs(p) (*p->dptr && *p->dptr != ';' && *p->dptr != '#')
 
@@ -150,6 +151,7 @@ void mutt_draw_tree (CONTEXT *);
 void mutt_make_attribution (CONTEXT * ctx, HEADER * cur, FILE * out);
 void mutt_make_forward_subject (ENVELOPE * env, CONTEXT * ctx, HEADER * cur);
 void mutt_make_help (char *, size_t, char *, int, int);
 void mutt_make_attribution (CONTEXT * ctx, HEADER * cur, FILE * out);
 void mutt_make_forward_subject (ENVELOPE * env, CONTEXT * ctx, HEADER * cur);
 void mutt_make_help (char *, size_t, char *, int, int);
+char *mutt_compile_help(char *, size_t, int, struct mapping_t *);
 void mutt_make_misc_reply_headers (ENVELOPE * env, CONTEXT * ctx,
                                    HEADER * cur, ENVELOPE * curenv);
 void mutt_make_post_indent (CONTEXT * ctx, HEADER * cur, FILE * out);
 void mutt_make_misc_reply_headers (ENVELOPE * env, CONTEXT * ctx,
                                    HEADER * cur, ENVELOPE * curenv);
 void mutt_make_post_indent (CONTEXT * ctx, HEADER * cur, FILE * out);
diff --git a/query.c b/query.c
index 76eca91..e5dbd16 100644 (file)
--- a/query.c
+++ b/query.c
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "mutt_menu.h"
 #include "mutt_idna.h"
 
 #include "mutt.h"
 #include "mutt_menu.h"
 #include "mutt_idna.h"
-#include "mapping.h"
 #include "sort.h"
 
 #include "lib/debug.h"
 #include "sort.h"
 
 #include "lib/debug.h"
index cc093f5..1121d2d 100644 (file)
@@ -17,6 +17,7 @@
 #include <lib-lib/macros.h>
 #include <lib-lib/ascii.h>
 #include <lib-lib/file.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/ascii.h>
 #include <lib-lib/file.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "enter.h"
 
 #include "mutt.h"
 #include "enter.h"
@@ -27,7 +28,6 @@
 #include "rfc1524.h"
 #include "mime.h"
 #include "attach.h"
 #include "rfc1524.h"
 #include "mime.h"
 #include "attach.h"
-#include "mapping.h"
 #include "mx.h"
 #include "copy.h"
 #include "mutt_crypt.h"
 #include "mx.h"
 #include "copy.h"
 #include "mutt_crypt.h"
index 5e159ce..7cd9a16 100644 (file)
--- a/recvcmd.c
+++ b/recvcmd.c
@@ -15,6 +15,7 @@
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "enter.h"
 
 #include "mutt.h"
 #include "enter.h"
@@ -26,7 +27,6 @@
 #include "rfc1524.h"
 #include "mime.h"
 #include "attach.h"
 #include "rfc1524.h"
 #include "mime.h"
 #include "attach.h"
-#include "mapping.h"
 #include "mx.h"
 #include "copy.h"
 #include "mutt_idna.h"
 #include "mx.h"
 #include "copy.h"
 #include "mutt_idna.h"
index cb71404..b4e526e 100644 (file)
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "recvattach.h"
 #include "mutt_curses.h"
 #include "mutt_menu.h"
 
 #include "mutt.h"
 #include "recvattach.h"
 #include "mutt_curses.h"
 #include "mutt_menu.h"
-#include "mapping.h"
 
 #include "remailer.h"
 
 
 #include "remailer.h"
 
diff --git a/sort.h b/sort.h
index 76cd39d..fd9efa0 100644 (file)
--- a/sort.h
+++ b/sort.h
@@ -42,5 +42,5 @@ WHERE short SortAlias INITVAL (SORT_ALIAS);
 /* FIXME: This one does not belong to here */
 WHERE short PgpSortKeys INITVAL (SORT_ADDRESS);
 
 /* FIXME: This one does not belong to here */
 WHERE short PgpSortKeys INITVAL (SORT_ADDRESS);
 
-#include "mapping.h"
+#include <lib-lib/mapping.h>
 extern const struct mapping_t SortMethods[];
 extern const struct mapping_t SortMethods[];
index 86de939..f8ffd92 100644 (file)
--- a/status.c
+++ b/status.c
 #include <lib-lib/mem.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/mem.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 #include "mutt_menu.h"
 #include "mutt_curses.h"
 #include "sort.h"
 
 #include "mutt.h"
 #include "mutt_menu.h"
 #include "mutt_curses.h"
 #include "sort.h"
-#include "mapping.h"
 #include "mx.h"
 #include "buffy.h"
 
 #include "mx.h"
 #include "buffy.h"
 
diff --git a/url.c b/url.c
index 597fdca..67a94cd 100644 (file)
--- a/url.c
+++ b/url.c
@@ -17,9 +17,9 @@
 
 #include <lib-lib/mem.h>
 #include <lib-lib/ascii.h>
 
 #include <lib-lib/mem.h>
 #include <lib-lib/ascii.h>
+#include <lib-lib/mapping.h>
 
 #include "mutt.h"
 
 #include "mutt.h"
-#include "mapping.h"
 #include "url.h"
 
 #include "mime.h"
 #include "url.h"
 
 #include "mime.h"