--- /dev/null
+#! /bin/sh -e
+
+die() {
+ echo "$@" 1>&2
+ exit 2
+}
+
+do_hdr() {
+ cat <<EOF
+/******************************************************************************/
+/* postlicyd: a postfix policy daemon with a lot of features */
+/* ~~~~~~~~~ */
+/* ________________________________________________________________________ */
+/* */
+/* Redistribution and use in source and binary forms, with or without */
+/* modification, are permitted provided that the following conditions */
+/* are met: */
+/* */
+/* 1. Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright */
+/* notice, this list of conditions and the following disclaimer in the */
+/* documentation and/or other materials provided with the distribution. */
+/* 3. The names of its contributors may not be used to endorse or promote */
+/* products derived from this software without specific prior written */
+/* permission. */
+/* */
+/* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND */
+/* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE */
+/* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
+/* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS */
+/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR */
+/* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF */
+/* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS */
+/* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) */
+/* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF */
+/* THE POSSIBILITY OF SUCH DAMAGE. */
+/******************************************************************************/
+
+/***** THIS FILE IS AUTOGENERATED DO NOT MODIFY DIRECTLY ! *****/
+
+EOF
+}
+
+do_h() {
+ do_hdr
+ cat <<EOF
+#ifndef PFIXTOOLS_FILTERS_H
+#define PFIXTOOLS_FILTERS_H
+
+typedef enum filter_token {
+ FTK_UNKNOWN = -1,
+`grep_self "$0" | tr 'a-z-/' 'A-Z__' | sed -e 's/.*/ FTK_&,/'`
+ FTK_count,
+} filter_token;
+
+extern const char *ftokens[FTK_count];
+
+__attribute__((pure))
+filter_token filter_tokenize(const char *s, ssize_t len);
+#endif /* MUTT_LIB_LUA_LUA_TOKEN_H */
+EOF
+}
+
+do_tokens() {
+ while read tok; do
+ echo "$tok, FTK_`echo $tok | tr 'a-z-' 'A-Z_'`"
+ done
+}
+
+do_c() {
+ this=`basename "$0"`
+ cat <<EOF | gperf -m16 -l -t -C -F",0" -Ntokenize_aux | \
+ sed -e '/__gnu_inline__/d;s/\<\(__\|\)inline\>//g'
+%{
+`do_hdr`
+
+#include "str.h"
+#include "`echo "${this%.sh}"`.h"
+
+static const struct tok *
+tokenize_aux(const char *str, unsigned int len);
+
+%}
+struct tok { const char *name; int val; };
+%%
+`grep_self "$0" | do_tokens`
+%%
+
+const char *ftokens[FTK_count] = {
+`grep_self "$0" | sed -e 's/.*/ "&",/'`
+};
+
+filter_token filter_tokenize(const char *s, ssize_t len)
+{
+ if (len < 0)
+ len = m_strlen(s);
+
+ if (len) {
+ const struct tok *res = tokenize_aux(s, len);
+ return res ? res->val : FTK_UNKNOWN;
+ } else {
+ return FTK_UNKNOWN;
+ }
+}
+EOF
+}
+
+grep_self() {
+ grep '^## ' "$1" | cut -d' ' -f2
+}
+
+trap "rm -f $1" 1 2 3 15
+rm -f $1
+case "$1" in
+ *.h) do_h > $1;;
+ *.c) do_c > $1;;
+ *) die "you must ask for the 'h' or 'c' generation";;
+esac
+chmod -w $1
+
+exit 0
+
+############ Put tokens here ############
+## rbl
+## greylist
+## poisonous
#include "buffer.h"
#include "common.h"
#include "epoll.h"
-#include "tokens.h"
+#include "policy_tokens.h"
#include "server.h"
#define DAEMON_NAME "postlicyd"
for (vlen = p - v; vlen && isblank(v[vlen]); vlen--);
p += 1; /* skip \n */
- vtk = tokenize(v, vlen);
- switch (tokenize(k, klen)) {
+ vtk = policy_tokenize(v, vlen);
+ switch (policy_tokenize(k, klen)) {
#define CASE(up, low) case PTK_##up: query->low = v; v[vlen] = '\0'; break;
CASE(HELO_NAME, helo_name);
CASE(QUEUE_ID, queue_id);
-#! /bin/sh -e
+#! /bin/bash -e
die() {
echo "$@" 1>&2
extern const char *ptokens[PTK_count];
__attribute__((pure))
-postlicyd_token tokenize(const char *s, ssize_t len);
+postlicyd_token policy_tokenize(const char *s, ssize_t len);
#endif /* MUTT_LIB_LUA_LUA_TOKEN_H */
EOF
}
}
do_c() {
+ this=`basename "$0"`
cat <<EOF | gperf -m16 -l -t -C -F",0" -Ntokenize_aux | \
sed -e '/__gnu_inline__/d;s/\<\(__\|\)inline\>//g'
%{
`do_hdr`
#include "str.h"
-#include "tokens.h"
+#include "`echo "${this%.sh}"`.h"
static const struct tok *
tokenize_aux(const char *str, unsigned int len);
`grep_self "$0" | sed -e 's/.*/ "&",/'`
};
-postlicyd_token tokenize(const char *s, ssize_t len)
+postlicyd_token policy_tokenize(const char *s, ssize_t len)
{
if (len < 0)
len = m_strlen(s);