HelenOS sources
This source file includes following definitions.
- bithenge_scope_inc_ref
- bithenge_transform_num_params
- bithenge_transform_inc_ref
- bithenge_transform_dec_ref
#ifndef BITHENGE_TRANSFORM_H_
#define BITHENGE_TRANSFORM_H_
#include "blob.h"
#include "tree.h"
typedef struct {
const struct bithenge_transform_ops *ops;
unsigned int refs;
int num_params;
} bithenge_transform_t;
typedef struct bithenge_scope {
unsigned int refs;
struct bithenge_scope *outer;
char *error;
bool barrier;
int num_params;
bithenge_node_t **params;
bithenge_node_t *current_node;
bithenge_node_t *in_node;
} bithenge_scope_t;
static inline void bithenge_scope_inc_ref(bithenge_scope_t *self)
{
assert(self);
self->refs++;
}
typedef struct bithenge_transform_ops {
errno_t (*apply)(bithenge_transform_t *self, bithenge_scope_t *scope,
bithenge_node_t *in, bithenge_node_t **out);
errno_t (*prefix_length)(bithenge_transform_t *self,
bithenge_scope_t *scope, bithenge_blob_t *blob, aoff64_t *out);
errno_t (*prefix_apply)(bithenge_transform_t *self,
bithenge_scope_t *scope, bithenge_blob_t *blob,
bithenge_node_t **out_node, aoff64_t *out_size);
void (*destroy)(bithenge_transform_t *self);
} bithenge_transform_ops_t;
static inline int bithenge_transform_num_params(bithenge_transform_t *self)
{
assert(self);
return self->num_params;
}
static inline void bithenge_transform_inc_ref(bithenge_transform_t *self)
{
assert(self);
self->refs++;
}
static inline void bithenge_transform_dec_ref(bithenge_transform_t *self)
{
if (!self)
return;
assert(self->ops);
assert(self->refs > 0);
if (--self->refs == 0)
self->ops->destroy(self);
}
typedef struct {
const char *name;
bithenge_transform_t *transform;
} bithenge_named_transform_t;
extern bithenge_transform_t bithenge_uint8_transform;
extern bithenge_transform_t bithenge_uint16le_transform;
extern bithenge_transform_t bithenge_uint16be_transform;
extern bithenge_transform_t bithenge_uint32le_transform;
extern bithenge_transform_t bithenge_uint32be_transform;
extern bithenge_transform_t bithenge_uint64le_transform;
extern bithenge_transform_t bithenge_uint64be_transform;
extern bithenge_transform_t bithenge_ascii_transform;
extern bithenge_transform_t bithenge_bit_transform;
extern bithenge_transform_t bithenge_bits_be_transform;
extern bithenge_transform_t bithenge_bits_le_transform;
extern bithenge_transform_t bithenge_invalid_transform;
extern bithenge_transform_t bithenge_known_length_transform;
extern bithenge_transform_t bithenge_nonzero_boolean_transform;
extern bithenge_transform_t bithenge_uint_le_transform;
extern bithenge_transform_t bithenge_uint_be_transform;
extern bithenge_transform_t bithenge_zero_terminated_transform;
extern bithenge_named_transform_t *bithenge_primitive_transforms;
errno_t bithenge_init_transform(bithenge_transform_t *,
const bithenge_transform_ops_t *, int);
errno_t bithenge_transform_apply(bithenge_transform_t *, bithenge_scope_t *,
bithenge_node_t *, bithenge_node_t **);
errno_t bithenge_transform_prefix_length(bithenge_transform_t *,
bithenge_scope_t *, bithenge_blob_t *, aoff64_t *);
errno_t bithenge_transform_prefix_apply(bithenge_transform_t *, bithenge_scope_t *,
bithenge_blob_t *, bithenge_node_t **, aoff64_t *);
errno_t bithenge_new_barrier_transform(bithenge_transform_t **, int);
errno_t bithenge_barrier_transform_set_subtransform(bithenge_transform_t *,
bithenge_transform_t *);
errno_t bithenge_scope_new(bithenge_scope_t **, bithenge_scope_t *);
void bithenge_scope_dec_ref(bithenge_scope_t *);
bithenge_scope_t *bithenge_scope_outer(bithenge_scope_t *);
const char *bithenge_scope_get_error(bithenge_scope_t *);
errno_t bithenge_scope_error(bithenge_scope_t *, const char *, ...);
bithenge_node_t *bithenge_scope_get_current_node(bithenge_scope_t *);
void bithenge_scope_set_current_node(bithenge_scope_t *, bithenge_node_t *);
bithenge_node_t *bithenge_scope_in_node(bithenge_scope_t *);
void bithenge_scope_set_in_node(bithenge_scope_t *, bithenge_node_t *);
void bithenge_scope_set_barrier(bithenge_scope_t *);
bool bithenge_scope_is_barrier(bithenge_scope_t *);
errno_t bithenge_scope_alloc_params(bithenge_scope_t *, int);
errno_t bithenge_scope_set_param(bithenge_scope_t *, int, bithenge_node_t *);
errno_t bithenge_scope_get_param(bithenge_scope_t *, int, bithenge_node_t **);
#endif
HelenOS homepage, sources at GitHub