very temporary work on the new generation of config parser.
[apps/madmutt.git] / rctokens.sh
diff --git a/rctokens.sh b/rctokens.sh
new file mode 100755 (executable)
index 0000000..2ad6aa2
--- /dev/null
@@ -0,0 +1,138 @@
+#! /bin/sh -e
+
+die() {
+    echo "$@" 1>&2
+    exit 2
+}
+
+do_hdr() {
+    cat <<EOF
+/*
+ *  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
+ */
+
+/*****     THIS FILE IS AUTOGENERATED DO NOT MODIFY DIRECTLY !    *****/
+
+EOF
+}
+
+do_tokens() {
+    while read tok; do
+        echo "$tok, RCTK_`echo $tok | tr 'a-z-' 'A-Z_'`"
+    done
+}
+
+do_c() {
+    cat <<EOF | gperf --ignore-case -m16 -l -t -C -F",0" -Nrc_which_token_aux
+%{
+`do_hdr`
+
+#include <lib-lib/lib-lib.h>
+#include "rctoken.h"
+
+static const struct tok *
+rc_which_token_aux(const char *str, unsigned int len);
+
+%}
+struct tok { const char *name; int val; };
+%%
+`do_tokens`
+%%
+
+static int rc_which_token(const char *s, ssize_t len)
+{
+    if (len < 0)
+        len = m_strlen(s);
+
+    if (len) {
+        const struct tok *res = rc_which_token_aux(s, len);
+        return res ? res->val : -1;
+    } else {
+        return -1;
+    }
+}
+EOF
+}
+
+trap "rm -f $1" 1 2 3 15
+grep '^### ' < $0 | cut -d' ' -f2 | do_c
+
+exit 0
+
+#****************************************************************************#
+#                          muttrc tokens list                                #
+#****************************************************************************#
+### account-hook
+### alias
+### alternates
+### alternative_order
+### append-hook
+### attachments
+### auto_view
+### bind
+### charset-hook
+### close-hook
+### color
+### exec
+### fcc-hook
+### fcc-save-hook
+### folder-hook
+### hdr_order
+### open-hook
+### unalternates
+### unattachments
+### uncolor
+### iconv-hook
+### crypt-hook
+### ignore
+### lists
+### macro
+### mailboxes
+### mbox-hook
+### message-hook
+### mime_lookup
+### mono
+### my_hdr
+### nospam
+### pgp-hook
+### push
+### reply-hook
+### reset
+### save-hook
+### score
+### send2-hook
+### send-hook
+### set
+### source
+### spam
+### subscribe
+### toggle
+### unalias
+### unalternative_order
+### unauto_view
+### unhdr_order
+### unhook
+### unignore
+### unlists
+### unmailboxes
+### unmime_lookup
+### unmono
+### unmy_hdr
+### unscore
+### unset
+### unsubscribe