1
/* Copyright (c) 2002-2009 Dovecot Sieve authors, see the included COPYING file
4
#include "sieve-common.h"
5
#include "sieve-extensions.h"
6
#include "sieve-code.h"
7
#include "sieve-binary.h"
8
#include "sieve-dump.h"
9
#include "sieve-interpreter.h"
11
#include "sieve-objects.h"
17
void sieve_opr_object_emit
18
(struct sieve_binary *sbin, const struct sieve_object *obj)
20
struct sieve_extension_objects *objs =
21
(struct sieve_extension_objects *) obj->operand->interface;
23
(void) sieve_operand_emit_code(sbin, obj->operand);
25
if ( objs->count > 1 ) {
26
(void) sieve_binary_emit_byte(sbin, obj->code);
30
const struct sieve_object *sieve_opr_object_read_data
31
(struct sieve_binary *sbin, const struct sieve_operand *operand,
32
const struct sieve_operand_class *opclass, sieve_size_t *address)
34
const struct sieve_extension_objects *objs;
35
unsigned int obj_code;
37
if ( operand == NULL || operand->class != opclass )
40
objs = (struct sieve_extension_objects *) operand->interface;
44
if ( objs->count > 1 ) {
45
if ( !sieve_binary_read_byte(sbin, address, &obj_code) )
48
if ( obj_code < objs->count ) {
49
const struct sieve_object *const *objects =
50
(const struct sieve_object* const *) objs->objects;
51
return objects[obj_code];
55
return (const struct sieve_object *) objs->objects;
58
const struct sieve_object *sieve_opr_object_read
59
(const struct sieve_runtime_env *renv,
60
const struct sieve_operand_class *opclass, sieve_size_t *address)
62
const struct sieve_operand *operand = sieve_operand_read(renv->sbin, address);
64
return sieve_opr_object_read_data(renv->sbin, operand, opclass, address);
67
bool sieve_opr_object_dump
68
(const struct sieve_dumptime_env *denv,
69
const struct sieve_operand_class *opclass, sieve_size_t *address,
70
const struct sieve_object **object_r)
72
const struct sieve_operand *operand;
73
const struct sieve_object *obj;
76
sieve_code_mark(denv);
78
operand = sieve_operand_read(denv->sbin, address);
79
obj = sieve_opr_object_read_data(denv->sbin, operand, opclass, address);
84
if ( operand->class == NULL )
87
class = operand->class->name;
89
sieve_code_dumpf(denv, "%s: %s", class, obj->identifier);
91
if ( object_r != NULL )