ESMTP is utterly broken, and pulls OpenSSL.
[apps/madmutt.git] / lib-lua / lua-token.gperf
1 #! /bin/sh -e
2
3 die() {
4     echo "$@" 1>&2
5     exit 2
6 }
7
8 do_hdr() {
9     cat <<EOF
10 /*
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or (at
14  *  your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful, but
17  *  WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  *  General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24  *  MA 02110-1301, USA.
25  *
26  *  Copyright © 2007 Pierre Habouzit
27  */
28
29 /*****     THIS FILE IS AUTOGENERATED DO NOT MODIFY DIRECTLY !    *****/
30
31 EOF
32 }
33
34 do_h() {
35     do_hdr
36     cat <<EOF
37 #ifndef MUTT_LIB_LUA_LUA_TOKEN_H
38 #define MUTT_LIB_LUA_LUA_TOKEN_H
39
40 typedef enum mlua_token {
41     LTK_UNKNOWN = -1,
42 `grep_self "$0" | tr 'a-z-/' 'A-Z__' | sed -e 's/.*/    LTK_&,/'`
43     LTK_count,
44 } mlua_token;
45
46 extern const char *__mlua_token[LTK_count];
47
48 __attribute__((pure))
49 mlua_token mlua_which_token(const char *s, ssize_t len);
50 #endif /* MUTT_LIB_LUA_LUA_TOKEN_H */
51 EOF
52 }
53
54 do_tokens() {
55     while read tok; do
56         echo "$tok, LTK_`echo $tok | tr 'a-z-' 'A-Z_'`"
57     done
58 }
59
60 do_c() {
61     cat <<EOF | gperf -m16 -l -t -C -F",0" -Nmlua_which_token_aux
62 %{
63 `do_hdr`
64
65 #include <lib-lib/lib-lib.h>
66 #include "lua-token.h"
67
68 static const struct tok *
69 mlua_which_token_aux(const char *str, unsigned int len);
70
71 %}
72 struct tok { const char *name; int val; };
73 %%
74 `grep_self "$0" | do_tokens`
75 %%
76
77 const char *__mlua_token[LTK_count] = {
78 `grep_self "$0" | sed -e 's/.*/    "&",/'`
79 };
80
81 mlua_token mlua_which_token(const char *s, ssize_t len)
82 {
83     if (len < 0)
84         len = m_strlen(s);
85
86     if (len) {
87         const struct tok *res = mlua_which_token_aux(s, len);
88         return res ? res->val : LTK_UNKNOWN;
89     } else {
90         return LTK_UNKNOWN;
91     }
92 }
93 EOF
94 }
95
96 grep_self() {
97     grep '^## ' "$1" | cut -d' ' -f2
98 }
99
100 trap "rm -f $1" 1 2 3 15
101
102 rm -f $1
103 case "$1" in
104     *.h) do_h > $1;;
105     *.c) do_c > $1;;
106     *)  die "you must ask for the 'h' or 'c' generation";;
107 esac
108 chmod -w $1
109
110 exit 0
111
112 ############ Put tokens here ############
113 ## alias_file
114 ## alias_format
115 ## ask-no
116 ## ask-yes
117 ## assumed_charset
118 ## autoencrypt
119 ## autopgp
120 ## autosign
121 ## autosmime
122 ## beep
123 ## beep_new
124 ## bindir
125 ## ca_certificates_file
126 ## cert_file
127 ## charset
128 ## docdir
129 ## dotlock
130 ## dsn_notify
131 ## dsn_return
132 ## editor
133 ## enable
134 ## envelope_from_address
135 ## file_charset
136 ## force_tls
137 ## from
138 ## gecos_mask
139 ## hcache_backend
140 ## homedir
141 ## hostname
142 ## mailcap_path
143 ## mailcap_sanitize
144 ## mail_check
145 ## min_dh_prime_bits
146 ## no
147 ## operating_system
148 ## pgp_entry_format
149 ## quit
150 ## record
151 ## replyencrypt
152 ## replysign
153 ## replysignencrypted
154 ## send_charset
155 ## sendmail
156 ## sendmail_wait
157 ## shell
158 ## shorthost
159 ## signature
160 ## smime_is_default
161 ## spam_separator
162 ## starttls
163 ## sysconfdir
164 ## threshold_delete
165 ## threshold_flag
166 ## threshold_read
167 ## tmpdir
168 ## use_8bitmime
169 ## use_domain
170 ## use_envelope_from
171 ## username
172 ## use_sslv3
173 ## use_tlsv1
174 ## verify_sig
175 ## version
176 ## yes