From: Pierre Habouzit Date: Wed, 1 Nov 2006 00:15:49 +0000 (+0100) Subject: mappings as standalone module X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=91d0c04349c9345f0ee29a61cc18dfc144b60edc mappings as standalone module Signed-off-by: Pierre Habouzit --- diff --git a/Makefile.am b/Makefile.am index a3d64f6..c223c0c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ - 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 \ diff --git a/alias.c b/alias.c index b43689b..835d55a 100644 --- a/alias.c +++ b/alias.c @@ -19,6 +19,7 @@ #include #include #include +#include #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 "mapping.h" #include "sort.h" #define RSORT(x) (SortAlias & SORT_REVERSE) ? -x : x diff --git a/browser.c b/browser.c index fd607ce..e22e1ea 100644 --- a/browser.c +++ b/browser.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "mutt.h" #include "enter.h" @@ -22,7 +23,6 @@ #include "mutt_curses.h" #include "mutt_menu.h" #include "buffy.h" -#include "mapping.h" #include "sort.h" #include "browser.h" #include "attach.h" diff --git a/color.c b/color.c index a28c513..17af49a 100644 --- a/color.c +++ b/color.c @@ -16,10 +16,10 @@ #include #include #include +#include #include "mutt.h" #include "mutt_curses.h" -#include "mapping.h" #include "lib/debug.h" diff --git a/compose.c b/compose.c index b0b20aa..f94fe4c 100644 --- a/compose.c +++ b/compose.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "mutt.h" #include "enter.h" @@ -29,7 +30,6 @@ #include "mime.h" #include "attach.h" #include "recvattach.h" -#include "mapping.h" #include "sort.h" #include "charset.h" #include "mx.h" diff --git a/curs_main.c b/curs_main.c index a7e8286..a62f166 100644 --- a/curs_main.c +++ b/curs_main.c @@ -17,12 +17,12 @@ #include #include #include +#include #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" diff --git a/help.c b/help.c index d8392b7..a7b8c9f 100644 --- a/help.c +++ b/help.c @@ -16,12 +16,12 @@ #include #include #include +#include #include "mutt.h" #include "mutt_curses.h" #include "keymap.h" #include "pager.h" -#include "mapping.h" #include #include diff --git a/init.c b/init.c index 2d6f7fd..c96e350 100644 --- a/init.c +++ b/init.c @@ -20,9 +20,9 @@ #include #include #include +#include #include "mutt.h" -#include "mapping.h" #include "mutt_curses.h" #include "history.h" #include "keymap.h" @@ -2527,26 +2527,6 @@ int mutt_query_variables (LIST * queries) 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; diff --git a/keymap.c b/keymap.c index bc577b7..44ccfd3 100644 --- a/keymap.c +++ b/keymap.c @@ -16,12 +16,12 @@ #include #include #include +#include #include "mutt.h" #include "mutt_menu.h" #include "mutt_curses.h" #include "keymap.h" -#include "mapping.h" #include "mutt_crypt.h" diff --git a/keymap.h b/keymap.h index 6434c77..0f215c2 100644 --- a/keymap.h +++ b/keymap.h @@ -10,7 +10,7 @@ #ifndef KEYMAP_H #define KEYMAP_H -#include "mapping.h" +#include /* maximal length of a key binding sequence used for buffer in km_bindkey */ #define MAX_SEQ 8 diff --git a/lib-lib/Makefile.am b/lib-lib/Makefile.am index c6c6da1..3545ecf 100644 --- a/lib-lib/Makefile.am +++ b/lib-lib/Makefile.am @@ -1,7 +1,7 @@ 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 index 0000000..c3065ba --- /dev/null +++ b/lib-lib/mapping.c @@ -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 + * + * Parts were written/modified by: + * Rocco Rutte + * + * 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 + +#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 index 0000000..51cc822 --- /dev/null +++ b/lib-lib/mapping.h @@ -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 + * + * 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 + diff --git a/mapping.h b/mapping.h index 5b0302e..6f6fb7b 100644 --- a/mapping.h +++ b/mapping.h @@ -16,8 +16,6 @@ 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 diff --git a/pager.c b/pager.c index 78b75ca..965a85e 100644 --- a/pager.c +++ b/pager.c @@ -18,13 +18,13 @@ #include #include #include +#include #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" diff --git a/pattern.c b/pattern.c index f40ea59..b1dba84 100644 --- a/pattern.c +++ b/pattern.c @@ -17,12 +17,12 @@ #include #include #include +#include #include "mutt.h" #include "handler.h" #include "enter.h" #include "mx.h" -#include "mapping.h" #include "keymap.h" #include "copy.h" #include "mime.h" diff --git a/postpone.c b/postpone.c index bb99448..73a1057 100644 --- a/postpone.c +++ b/postpone.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "mutt.h" #include "enter.h" @@ -24,7 +25,6 @@ #include "mutt_menu.h" #include "rfc1524.h" #include "mime.h" -#include "mapping.h" #include "sort.h" #include "thread.h" #include "mx.h" diff --git a/protos.h b/protos.h index 52f0de8..d097ee6 100644 --- a/protos.h +++ b/protos.h @@ -20,6 +20,7 @@ #include "mbyte.h" #include +#include #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); +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); diff --git a/query.c b/query.c index 76eca91..e5dbd16 100644 --- a/query.c +++ b/query.c @@ -15,11 +15,11 @@ #include #include #include +#include #include "mutt.h" #include "mutt_menu.h" #include "mutt_idna.h" -#include "mapping.h" #include "sort.h" #include "lib/debug.h" diff --git a/recvattach.c b/recvattach.c index cc093f5..1121d2d 100644 --- a/recvattach.c +++ b/recvattach.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "mutt.h" #include "enter.h" @@ -27,7 +28,6 @@ #include "rfc1524.h" #include "mime.h" #include "attach.h" -#include "mapping.h" #include "mx.h" #include "copy.h" #include "mutt_crypt.h" diff --git a/recvcmd.c b/recvcmd.c index 5e159ce..7cd9a16 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "mutt.h" #include "enter.h" @@ -26,7 +27,6 @@ #include "rfc1524.h" #include "mime.h" #include "attach.h" -#include "mapping.h" #include "mx.h" #include "copy.h" #include "mutt_idna.h" diff --git a/remailer.c b/remailer.c index cb71404..b4e526e 100644 --- a/remailer.c +++ b/remailer.c @@ -20,12 +20,12 @@ #include #include #include +#include #include "mutt.h" #include "recvattach.h" #include "mutt_curses.h" #include "mutt_menu.h" -#include "mapping.h" #include "remailer.h" diff --git a/sort.h b/sort.h index 76cd39d..fd9efa0 100644 --- 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); -#include "mapping.h" +#include extern const struct mapping_t SortMethods[]; diff --git a/status.c b/status.c index 86de939..f8ffd92 100644 --- a/status.c +++ b/status.c @@ -14,12 +14,12 @@ #include #include #include +#include #include "mutt.h" #include "mutt_menu.h" #include "mutt_curses.h" #include "sort.h" -#include "mapping.h" #include "mx.h" #include "buffy.h" diff --git a/url.c b/url.c index 597fdca..67a94cd 100644 --- a/url.c +++ b/url.c @@ -17,9 +17,9 @@ #include #include +#include #include "mutt.h" -#include "mapping.h" #include "url.h" #include "mime.h"