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
75559f96
...
75559f96d46edb89e133d8475929ee686e973268
authored
2002-11-14 07:14:32 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Reflect change of sieve_machine_t type.
1 parent
e46587af
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
37 deletions
libsieve/runtime.c
libsieve/sieve.y
libsieve/runtime.c
View file @
75559f9
...
...
@@ -26,11 +26,13 @@
#define SIEVE_ARG(m,n,t) ((m)->prog[(m)->pc+(n)].t)
#define SIEVE_ADJUST(m,n) (m)->pc+=(n)
#define INSTR_DEBUG(m) ((m)->debug_level > 90 && (m)->debug_printer)
#define INSTR_DISASS(m) ((m)->debug_level == 100)
#define INSTR_DEBUG(m) \
(((m)->debug_level & (MU_SIEVE_DEBUG_INSTR|MU_SIEVE_DEBUG_DISAS)) \
&& (m)->debug_printer)
#define INSTR_DISASS(m) ((m)->debug_level & MU_SIEVE_DEBUG_DISAS)
static
int
instr_run
(
sieve_machine_t
*
mach
)
instr_run
(
sieve_machine_t
mach
)
{
sieve_handler_t
han
=
SIEVE_ARG
(
mach
,
0
,
handler
);
list_t
arg_list
=
SIEVE_ARG
(
mach
,
1
,
list
);
...
...
@@ -52,7 +54,7 @@ instr_run (sieve_machine_t *mach)
}
void
instr_action
(
sieve_machine_t
*
mach
)
instr_action
(
sieve_machine_t
mach
)
{
if
(
INSTR_DEBUG
(
mach
))
sieve_debug
(
mach
,
"%4lu: ACTION: %s
\n
"
,
...
...
@@ -62,7 +64,7 @@ instr_action (sieve_machine_t *mach)
}
void
instr_test
(
sieve_machine_t
*
mach
)
instr_test
(
sieve_machine_t
mach
)
{
if
(
INSTR_DEBUG
(
mach
))
sieve_debug
(
mach
,
"%4lu: TEST: %s
\n
"
,
...
...
@@ -72,7 +74,7 @@ instr_test (sieve_machine_t *mach)
}
void
instr_push
(
sieve_machine_t
*
mach
)
instr_push
(
sieve_machine_t
mach
)
{
if
(
INSTR_DEBUG
(
mach
))
{
...
...
@@ -90,7 +92,7 @@ instr_push (sieve_machine_t *mach)
}
void
instr_pop
(
sieve_machine_t
*
mach
)
instr_pop
(
sieve_machine_t
mach
)
{
if
(
INSTR_DEBUG
(
mach
))
{
...
...
@@ -109,7 +111,7 @@ instr_pop (sieve_machine_t *mach)
}
void
instr_allof
(
sieve_machine_t
*
mach
)
instr_allof
(
sieve_machine_t
mach
)
{
int
num
=
SIEVE_ARG
(
mach
,
0
,
number
);
int
val
=
1
;
...
...
@@ -133,7 +135,7 @@ instr_allof (sieve_machine_t *mach)
}
void
instr_anyof
(
sieve_machine_t
*
mach
)
instr_anyof
(
sieve_machine_t
mach
)
{
int
num
=
SIEVE_ARG
(
mach
,
0
,
number
);
int
val
=
0
;
...
...
@@ -151,13 +153,13 @@ instr_anyof (sieve_machine_t *mach)
while
(
num
--
>
0
)
{
instr_pop
(
mach
);
val
&
=
mach
->
reg
;
val
|
=
mach
->
reg
;
}
mach
->
reg
=
val
;
}
void
instr_not
(
sieve_machine_t
*
mach
)
instr_not
(
sieve_machine_t
mach
)
{
if
(
INSTR_DEBUG
(
mach
))
{
...
...
@@ -169,7 +171,7 @@ instr_not (sieve_machine_t *mach)
}
void
instr_branch
(
sieve_machine_t
*
mach
)
instr_branch
(
sieve_machine_t
mach
)
{
long
num
=
SIEVE_ARG
(
mach
,
0
,
number
);
...
...
@@ -187,7 +189,7 @@ instr_branch (sieve_machine_t *mach)
}
void
instr_brz
(
sieve_machine_t
*
mach
)
instr_brz
(
sieve_machine_t
mach
)
{
long
num
=
SIEVE_ARG
(
mach
,
0
,
number
);
SIEVE_ADJUST
(
mach
,
1
);
...
...
@@ -201,24 +203,24 @@ instr_brz (sieve_machine_t *mach)
return
;
}
if
(
mach
->
reg
)
if
(
!
mach
->
reg
)
mach
->
pc
+=
num
;
}
void
sieve_abort
(
sieve_machine_t
*
mach
)
sieve_abort
(
sieve_machine_t
mach
)
{
longjmp
(
mach
->
errbuf
,
1
);
}
void
*
sieve_get_data
(
sieve_machine_t
*
mach
)
sieve_get_data
(
sieve_machine_t
mach
)
{
return
mach
->
data
;
}
message_t
sieve_get_message
(
sieve_machine_t
*
mach
)
sieve_get_message
(
sieve_machine_t
mach
)
{
if
(
!
mach
->
msg
)
mailbox_get_message
(
mach
->
mailbox
,
mach
->
msgno
,
&
mach
->
msg
);
...
...
@@ -226,19 +228,25 @@ sieve_get_message (sieve_machine_t *mach)
}
size_t
sieve_get_message_num
(
sieve_machine_t
*
mach
)
sieve_get_message_num
(
sieve_machine_t
mach
)
{
return
mach
->
msgno
;
}
int
sieve_get_debug_level
(
sieve_machine_t
*
mach
)
sieve_get_debug_level
(
sieve_machine_t
mach
)
{
return
mach
->
debug_level
;
}
int
sieve_run
(
sieve_machine_t
*
mach
)
sieve_is_dry_run
(
sieve_machine_t
mach
)
{
return
mach
->
debug_level
&
MU_SIEVE_DRY_RUN
;
}
int
sieve_run
(
sieve_machine_t
mach
)
{
if
(
setjmp
(
mach
->
errbuf
))
return
1
;
...
...
@@ -253,12 +261,12 @@ sieve_run (sieve_machine_t *mach)
}
int
sieve_disass
(
sieve_machine_t
*
mach
)
sieve_disass
(
sieve_machine_t
mach
)
{
int
level
=
mach
->
debug_level
;
int
rc
;
mach
->
debug_level
=
100
;
mach
->
debug_level
=
MU_SIEVE_DEBUG_INSTR
|
MU_SIEVE_DEBUG_DISAS
;
rc
=
sieve_run
(
mach
);
mach
->
debug_level
=
level
;
return
rc
;
...
...
@@ -267,7 +275,7 @@ sieve_disass (sieve_machine_t *mach)
static
int
_sieve_action
(
observer_t
obs
,
size_t
type
)
{
sieve_machine_t
*
mach
;
sieve_machine_t
mach
;
if
(
type
!=
MU_EVT_MESSAGE_ADD
)
return
0
;
...
...
@@ -280,7 +288,7 @@ _sieve_action (observer_t obs, size_t type)
}
int
sieve_mailbox
(
sieve_machine_t
*
mach
,
mailbox_t
mbox
)
sieve_mailbox
(
sieve_machine_t
mach
,
mailbox_t
mbox
)
{
int
rc
;
size_t
total
;
...
...
@@ -291,7 +299,7 @@ sieve_mailbox (sieve_machine_t *mach, mailbox_t mbox)
return
EINVAL
;
observer_create
(
&
observer
,
mach
);
observer_set_action
(
observer
,
_sieve_action
,
m
box
);
observer_set_action
(
observer
,
_sieve_action
,
m
ach
);
mailbox_get_observable
(
mbox
,
&
observable
);
observable_attach
(
observable
,
MU_EVT_MESSAGE_ADD
,
observer
);
...
...
libsieve/sieve.y
View file @
75559f9
...
...
@@ -24,7 +24,7 @@
#include <assert.h>
#include <sieve.h>
sieve_machine_t
*
sieve_machine;
sieve_machine_t sieve_machine;
int sieve_error_count;
static void branch_fixup __P((size_t start, size_t end));
...
...
@@ -336,42 +336,80 @@ yyerror (char *s)
return 0;
}
void
sieve_machine_init (sieve_machine_t *mach, void *data)
int
sieve_machine_init (sieve_machine_t *
p
mach, void *data)
{
int rc;
sieve_machine_t mach;
mach = malloc (sizeof (*mach));
if (!mach)
return ENOMEM;
memset (mach, 0, sizeof (*mach));
rc = list_create (&mach->memory_pool);
if (rc)
{
free (mach);
return NULL;
}
list_append (mach->memory_pool, mach);
mach->data = data;
mach->error_printer = _sieve_default_error_printer;
mach->parse_error_printer = _sieve_default_parse_error;
*pmach = mach;
return 0;
}
void
sieve_machine_set_error (sieve_machine_t
*
mach, sieve_printf_t error_printer)
sieve_machine_set_error (sieve_machine_t mach, sieve_printf_t error_printer)
{
mach->error_printer = error_printer ?
error_printer : _sieve_default_error_printer;
}
void
sieve_machine_set_parse_error (sieve_machine_t
*
mach, sieve_parse_error_t p)
sieve_machine_set_parse_error (sieve_machine_t mach, sieve_parse_error_t p)
{
mach->parse_error_printer = p ? p : _sieve_default_parse_error;
}
void
sieve_machine_set_debug (sieve_machine_t *mach,
sieve_printf_t debug, int level)
sieve_machine_set_debug (sieve_machine_t mach, sieve_printf_t debug)
{
if (debug)
mach->debug_printer = debug;
}
void
sieve_machine_set_debug_level (sieve_machine_t mach, mu_debug_t dbg, int level)
{
mach->mu_debug = dbg;
mach->debug_level = level;
}
void
sieve_machine_set_logger (sieve_machine_t mach, sieve_action_log_t logger)
{
mach->logger = logger;
}
void
sieve_machine_set_ticket (sieve_machine_t mach, ticket_t ticket)
{
mach->ticket = ticket;
}
ticket_t
sieve_get_ticket (sieve_machine_t mach)
{
return mach->ticket;
}
/* FIXME: When posix thread support is added, sieve_machine_begin() should
acquire the global mutex, locking the current compilation session, and
sieve_machine_finish() should release it */
void
sieve_machine_begin (sieve_machine_t
*
mach)
sieve_machine_begin (sieve_machine_t mach)
{
sieve_machine = mach;
sieve_error_count = 0;
...
...
@@ -379,22 +417,28 @@ sieve_machine_begin (sieve_machine_t *mach)
}
void
sieve_machine_finish (sieve_machine_t
*
mach)
sieve_machine_finish (sieve_machine_t mach)
{
sieve_code_instr (NULL);
}
int
sieve_compile (sieve_machine_t
*
mach, const char *name)
sieve_compile (sieve_machine_t mach, const char *name)
{
int rc;
sieve_machine_begin (mach);
sieve_register_standard_actions ();
sieve_register_standard_tests ();
sieve_lex_begin (name);
if (sieve_lex_begin (name) == 0)
{
sieve_machine->filename = sieve_pstrdup (&sieve_machine->memory_pool,
name);
rc = yyparse ();
sieve_lex_finish ();
}
else
rc = 1;
sieve_machine_finish (mach);
if (sieve_error_count)
rc = 1;
...
...
Please
register
or
sign in
to post a comment