Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
fa5efdb3
...
fa5efdb30791b8a00904d9f379638aee211a5169
authored
2001-02-22 06:20:56 +0000
by
Alain Magloire
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
First try at implementing seive with lex/yacc.
1 parent
dfe52103
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
189 additions
and
0 deletions
mailbox/mbx_imap.c
sieve/gram-sieve.y
sieve/lex-sieve.lex
mailbox/mbx_imap.c
View file @
fa5efdb
...
...
@@ -533,8 +533,14 @@ imap_scan (mailbox_t mailbox, size_t msgno, size_t *pcount)
if
(
mailbox
->
observable
==
NULL
)
return
0
;
for
(
i
=
msgno
;
i
<=
*
pcount
;
i
++
)
{
if
(
observable_notify
(
mailbox
->
observable
,
MU_EVT_MESSAGE_ADD
)
!=
0
)
break
;
if
(((
i
+
1
)
%
10
)
==
0
)
{
observable_notify
(
mailbox
->
observable
,
MU_EVT_MAILBOX_PROGRESS
);
}
}
return
0
;
}
...
...
sieve/gram-sieve.y
0 → 100644
View file @
fa5efdb
%{
%}
%token SIEVE_ADDRESS SIEVE_ALL SIEVE_ALLOF SIEVE_ANYOF SIEVE_COMPARATOR
%token SIEVE_CONTAINS SIEVE_DISCARD SIEVE_DOMAIN SIEVE_ELSE SIEVE_ELSIF
%token SIEVE_ENVELOPE SIEVE_EXISTS SIEVE_FALSE SIEVE_FILEINTO SIEVE_HEADER
%token SIEVE_IF SIEVE_IS SIEVE_KEEP SIEVE_LOCALPART SIEVE_MATCHES
%token SIEVE_NOT SIEVE_NUMBER SIEVE_OVER SIEVE_STRING
%token SIEVE_REDIRECT SIEVE_REJECT SIEVE_REQUIRE SIEVE_SIZE SIEVE_STOP
%token SIEVE_TEST SIEVE_TRUE SIEVE_UNDER
%%
commands : command | command commands ;
command : action_command | control_command | test_command ;
block : '{' commands '}' | '{' /* Empty block. */ '}' ;
action_command : action ';' ;
action : discard | fileinto | keep | redirect | require | reject | stop ;
control_command : SIEVE_IF test_command block else_part
| SIEVE_IF test_command block
;
else_part : SIEVE_ELSIF test_command block else_part
| SIEVE_ELSE block
test_command : test_address | test_allof | test_anyof | test_envelope
| test_exists | test_false | test_header | test_not
| test_size | test_true ;
fileinto : SIEVE_FILEINTO string_list ;
stop : SIEVE_STOP ;
discard : SIEVE_DISCARD ;
keep : SIEVE_KEEP ;
redirect : SIEVE_REDIRECT string_list ;
reject : SIEVE_REJECT SIEVE_STRING ;
require : SIEVE_REQUIRE string_list ;
test_list : '(' test ')' | '(' test ',' test ')' | test;
test : test_address | test_anyof | test_envelope | test_false | test_exists
| test_header | test_not | test_size | test_true ;
test_address : SIEVE_ADDRESS address_part match_type
| SIEVE_ADDRESS address_part string_list ;
test_allof : SIEVE_ALLOF test_list ;
test_anyof : SIEVE_ANYOF test_list ;
test_envelope : SIEVE_ENVELOPE ':' comparator | SIEVE_ENVELOPE ':' match_type ;
test_exists : SIEVE_EXISTS string_list ;
test_false : SIEVE_FALSE ;
test_header : SIEVE_HEADER comparator
| SIEVE_HEADER match_type
| SIEVE_HEADER string_list ;
test_not : SIEVE_NOT test | SIEVE_NOT '(' test ')' ;
test_size : SIEVE_SIZE ':' SIEVE_OVER SIEVE_NUMBER
| SIEVE_SIZE ':' SIEVE_UNDER SIEVE_NUMBER ;
test_true : SIEVE_TRUE ;
comparator : ':' SIEVE_COMPARATOR SIEVE_STRING SIEVE_STRING
match_type : ':' SIEVE_IS string_list string_list
| ':' SIEVE_CONTAINS string_list string_list
| ':' SIEVE_MATCHES string_list string_list ;
address_part : ':' SIEVE_DOMAIN ;
| ':' SIEVE_LOCALPART ;
| ':' SIEVE_ALL ;
strings : SIEVE_STRING | SIEVE_STRING ',' strings
string_list : '[' strings ']' | SIEVE_STRING ;
sieve/lex-sieve.lex
0 → 100644
View file @
fa5efdb
/* Scanner for Sieve
created : Alain Magloire
ref: RFC 3028 */
%{
#include <stdio.h>
#include "y.tab.h"
void count ();
%}
DIGIT [0-9]
WHITE_SPACE [ \r\t]
QUANTIFIER [KMG]
DELIM [ \t\v\f\n]
LETTER [A-Za-z_]
ID [A-Za-z_][A-Za-z0-9_]*
TAG {ID}:
%x COMMENT
%x MULTILINE
%%
"/*" { BEGIN COMMENT; count (); } /* Switch to comment state. */
<COMMENT>.|\n /* Throw away text. */;
<COMMENT>"*/" { BEGIN INITIAL; count (); }
"text:"\n { BEGIN MULTILINE; count (); }
<MULTILINE>.|\n { count (); }
<MULTILINE>^\.\n { BEGIN INITIAL; count (); return SIEVE_STRING; }
#.* /* Throw away. */;
{DIGIT}+[QUANTIFIER]? { count (); return SIEVE_NUMBER; }
\"[^\n"]+\" { /* " */ count (); return SIEVE_STRING; }
address { count (); return SIEVE_ADDRESS; }
all { count (); return SIEVE_ALL; }
allof { count (); return SIEVE_ALLOF; }
anyof { count (); return SIEVE_ANYOF; }
comparator { count (); return SIEVE_COMPARATOR; }
contains { count (); return SIEVE_CONTAINS; }
discard { count (); return SIEVE_DISCARD; }
domain { count (); return SIEVE_DOMAIN; }
else { count (); return SIEVE_ELSE; }
elsif { count (); return SIEVE_ELSIF; }
envelope { count (); return SIEVE_ENVELOPE; }
exists { count (); return SIEVE_EXISTS; }
false { count (); return SIEVE_FALSE; }
fileinto { count (); return SIEVE_FILEINTO; }
header { count (); return SIEVE_HEADER; }
if { count (); return SIEVE_IF; }
is { count (); return SIEVE_IS; }
keep { count (); return SIEVE_KEEP; }
localpart { count (); return SIEVE_LOCALPART; }
matches { count (); return SIEVE_MATCHES; }
not { count (); return SIEVE_NOT; }
over { count (); return SIEVE_OVER; }
redirect { count (); return SIEVE_REDIRECT; }
reject { count (); return SIEVE_REJECT; }
require { count (); return SIEVE_REQUIRE; }
size { count (); return SIEVE_SIZE; }
stop { count (); return SIEVE_STOP; }
true { count (); return SIEVE_TRUE; }
\: { count (); return ':'; }
\; { count (); return ';'; }
\, { count (); return ','; }
\( { count (); return '('; }
\) { count (); return ')'; }
\[ { count (); return '['; }
\] { count (); return ']'; }
\{ { count (); return '{'; }
\} { count (); return '}'; }
%%
int
yywrap ()
{
return (1);
}
void
count ()
{
ECHO;
}
int
yyerror (char *s)
{
fflush(stdout);
printf ("\n^ Syntax error.\n");
}
Please
register
or
sign in
to post a comment