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
0f915db0
...
0f915db027193fa5665d5c7f54c8a8a3e2af6f63
authored
2002-08-28 11:52:32 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Implemented envelope test (see comment, though)
1 parent
1cc0e3cf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
47 deletions
sieve/svcb.c
sieve/svcb.c
View file @
0f915db
...
...
@@ -31,17 +31,18 @@
/** mailutils errno to sieve error code translation. */
/*
Note:
Note:
The sieve engine doesn't really care what you return from the callbacks, it's
either SIEVE_OK (== 0) or an error. This has the effect that if getheader()
fails due to, for example, an IMAP protocol error, it will be assumed the
header isn't present, which isn't true.
The sieve engine doesn't really care what you return from the callbacks, it's
either SIEVE_OK (== 0) or an error. This has the effect that if getheader()
fails due to, for example, an IMAP protocol error, it will be assumed the
header isn't present, which isn't true.
On the other hand, it makes this really simple mapping below possible.
*/
On the other hand, it makes this really simple mapping below possible.
*/
static
int
sieve_err
(
int
rc
)
static
int
sieve_err
(
int
rc
)
{
return
rc
;
}
...
...
@@ -68,9 +69,9 @@ sv_getsize (void *mc, int *size)
}
/*
A given header can occur multiple times, so we return a pointer to a null
terminated array of pointers to the values found for the named header.
*/
A given header can occur multiple times, so we return a pointer to a null
terminated array of pointers to the values found for the named header.
*/
int
sv_getheader
(
void
*
mc
,
const
char
*
name
,
const
char
***
body
)
{
...
...
@@ -149,51 +150,61 @@ sv_getheader (void *mc, const char *name, const char ***body)
return
sieve_err
(
m
->
rc
);
}
/*
We need to do a little more work to deduce the envelope addresses, they
aren't necessarily stored in the mailbox.
CMU sieve cheesy sample implementation:
name will always be "to" or "from"
/* We need to do a little more work to deduce the envelope addresses, they
aren't necessarily stored in the mailbox. */
int
getenvelope (void *mc
, const char *name, const char ***body)
sv_getenvelope
(
void
*
m
,
const
char
*
name
,
const
char
***
body
)
{
static const char *buf[2];
if (buf[0] == NULL)
if
(
!
name
||
strcasecmp
(
name
,
"from"
)
==
0
)
{
sv_msg_ctx_t
*
mc
=
m
;
envelope_t
env
=
NULL
;
char
buffer
[
128
];
address_t
addr
;
const
char
**
tmp
;
message_get_envelope
(
mc
->
msg
,
&
env
);
if
(
envelope_sender
(
env
,
buffer
,
sizeof
(
buffer
),
NULL
)
||
address_create
(
&
addr
,
buffer
))
return
SIEVE_RUN_ERROR
;
if
(
address_get_email
(
addr
,
1
,
buffer
,
sizeof
(
buffer
),
NULL
))
{
buf[0] = malloc (sizeof (char) * 256
);
buf[1] = NULL
;
address_destroy
(
&
addr
);
return
SIEVE_RUN_ERROR
;
}
printf ("Envelope body of '%s'? ", head);
scanf ("%s", buf[0]);
body = buf;
address_destroy
(
&
addr
);
tmp
=
calloc
(
2
,
sizeof
(
tmp
[
0
]));
if
(
!
tmp
||
!
(
tmp
[
0
]
=
strdup
(
buffer
)))
return
SIEVE_NOMEM
;
tmp
[
1
]
=
NULL
;
*
body
=
tmp
;
return
SIEVE_OK
;
}
return
SIEVE_RUN_ERROR
;
}
*/
/** message action callbacks */
/*
The actions arguments are mostly callback data provided during the
setup of the intepreter object, script object, and the execution of
a script.
The actions arguments are mostly callback data provided during the
setup of the intepreter object, script object, and the execution of
a script.
The args are:
The args are:
void* ac; // action context, the member of the union Action.u associated
void* ac; // action context, the member of the union Action.u associated
// with this kind of action.
void* ic, // from sieve_interp_alloc(, ic);
void* sc, // from sieve_script_parse(, , sc, );
void* mc, // from sieve_execute_script(, mc);
const char** errmsg // you can fill it in if you return failure
*/
void* ic, // from sieve_interp_alloc(, ic);
void* sc, // from sieve_script_parse(, , sc, );
void* mc, // from sieve_execute_script(, mc);
const char** errmsg // you can fill it in if you return failure
*/
static
void
action_log
(
sv_msg_ctx_t
*
mc
,
const
char
*
action
,
const
char
*
fmt
,
...)
action_log
(
sv_msg_ctx_t
*
mc
,
const
char
*
action
,
const
char
*
fmt
,...)
{
const
char
*
script
=
mc
->
sc
->
file
;
message_t
msg
=
mc
->
msg
;
...
...
@@ -328,7 +339,6 @@ int
sv_discard
(
void
*
ac
,
void
*
ic
,
void
*
sc
,
void
*
mc
,
const
char
**
errmsg
)
{
sv_msg_ctx_t
*
m
=
(
sv_msg_ctx_t
*
)
mc
;
//sv_interp_ctx_t *i = (sv_interp_ctx_t *) ic;
m
->
rc
=
0
;
...
...
@@ -337,6 +347,7 @@ sv_discard (void *ac, void *ic, void *sc, void *mc, const char **errmsg)
if
((
m
->
svflags
&
SV_FLAG_NO_ACTIONS
)
==
0
)
{
m
->
rc
=
sv_mu_mark_deleted
(
m
->
msg
,
1
);
if
(
m
->
rc
)
mu_debug_print
(
m
->
debug
,
MU_DEBUG_ERROR
,
"discard - deleting failed: [%d] %s
\n
"
,
m
->
rc
,
mu_errstring
(
m
->
rc
));
...
...
@@ -380,15 +391,18 @@ sv_send_response (void *ac, void *ic, void *sc, void *mc, const char **errmsg)
return SIEVE_FAIL;
}
sieve_vacation_t vacation = {
sieve_vacation_t vacation =
{
0, /* min response */
0, /* max response */
&sv_autorespond, /* autorespond() */
&sv_send_response /* send_response() */
};
char *markflags[] = { "\\flagged" };
sieve_imapflags_t mark = { markflags, 1 };
char *markflags[] =
{"\\flagged"};
sieve_imapflags_t mark =
{markflags, 1};
#endif
/* sieve error callbacks */
...
...
@@ -435,12 +449,12 @@ sv_register_callbacks (sieve_interp_t * i)
if
(
!
rc
)
rc
=
sieve_register_keep
(
i
,
&
sv_keep
);
#if 0
if
(
!
rc
)
rc
=
sieve_register_envelope
(
i
,
&
sv_getenvelope
);
#endif
if
(
!
rc
)
rc
=
sieve_register_discard
(
i
,
&
sv_discard
);
#if 0
if (!rc)
rc = sieve_register_reject (i, &sv_reject);
...
...
Please
register
or
sign in
to post a comment