Migrated parser_t to INIT/METHOD macros.
This commit is contained in:
parent
339fe4fda3
commit
13e5a32a1e
|
@ -85,12 +85,6 @@ struct private_parser_t {
|
||||||
encoding_rule_t *rules;
|
encoding_rule_t *rules;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Forward declaration
|
|
||||||
*/
|
|
||||||
static status_t parse_payload(private_parser_t *this,
|
|
||||||
payload_type_t payload_type, payload_t **payload);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log invalid length error
|
* Log invalid length error
|
||||||
*/
|
*/
|
||||||
|
@ -320,7 +314,8 @@ static bool parse_list(private_parser_t *this, int rule_number,
|
||||||
DBG2(DBG_ENC, " %d bytes left, parsing recursively %N",
|
DBG2(DBG_ENC, " %d bytes left, parsing recursively %N",
|
||||||
length, payload_type_names, payload_type);
|
length, payload_type_names, payload_type);
|
||||||
|
|
||||||
if (parse_payload(this, payload_type, &payload) != SUCCESS)
|
if (this->public.parse_payload(&this->public, payload_type,
|
||||||
|
&payload) != SUCCESS)
|
||||||
{
|
{
|
||||||
DBG1(DBG_ENC, " parsing of a %N substructure failed",
|
DBG1(DBG_ENC, " parsing of a %N substructure failed",
|
||||||
payload_type_names, payload_type);
|
payload_type_names, payload_type);
|
||||||
|
@ -363,11 +358,8 @@ static bool parse_chunk(private_parser_t *this, int rule_number,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(parser_t, parse_payload, status_t,
|
||||||
* Implementation of parser_t.parse_payload.
|
private_parser_t *this, payload_type_t payload_type, payload_t **payload)
|
||||||
*/
|
|
||||||
static status_t parse_payload(private_parser_t *this,
|
|
||||||
payload_type_t payload_type, payload_t **payload)
|
|
||||||
{
|
{
|
||||||
payload_t *pld;
|
payload_t *pld;
|
||||||
void *output;
|
void *output;
|
||||||
|
@ -785,27 +777,21 @@ static status_t parse_payload(private_parser_t *this,
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(parser_t, get_remaining_byte_count, int,
|
||||||
* Implementation of parser_t.get_remaining_byte_count.
|
private_parser_t *this)
|
||||||
*/
|
|
||||||
static int get_remaining_byte_count (private_parser_t *this)
|
|
||||||
{
|
{
|
||||||
return this->input_roof - this->byte_pos;
|
return this->input_roof - this->byte_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(parser_t, reset_context, void,
|
||||||
* Implementation of parser_t.reset_context.
|
private_parser_t *this)
|
||||||
*/
|
|
||||||
static void reset_context (private_parser_t *this)
|
|
||||||
{
|
{
|
||||||
this->byte_pos = this->input;
|
this->byte_pos = this->input;
|
||||||
this->bit_pos = 0;
|
this->bit_pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(parser_t, destroy, void,
|
||||||
* Implementation of parser_t.destroy.
|
private_parser_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_parser_t *this)
|
|
||||||
{
|
{
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
@ -815,17 +801,19 @@ static void destroy(private_parser_t *this)
|
||||||
*/
|
*/
|
||||||
parser_t *parser_create(chunk_t data)
|
parser_t *parser_create(chunk_t data)
|
||||||
{
|
{
|
||||||
private_parser_t *this = malloc_thing(private_parser_t);
|
private_parser_t *this;
|
||||||
|
|
||||||
this->public.parse_payload = (status_t(*)(parser_t*,payload_type_t,payload_t**))parse_payload;
|
INIT(this,
|
||||||
this->public.reset_context = (void(*)(parser_t*)) reset_context;
|
.public = {
|
||||||
this->public.get_remaining_byte_count = (int (*) (parser_t *))get_remaining_byte_count;
|
.parse_payload = _parse_payload,
|
||||||
this->public.destroy = (void(*)(parser_t*)) destroy;
|
.reset_context = _reset_context,
|
||||||
|
.get_remaining_byte_count = _get_remaining_byte_count,
|
||||||
this->input = data.ptr;
|
.destroy = _destroy,
|
||||||
this->byte_pos = data.ptr;
|
},
|
||||||
this->bit_pos = 0;
|
.input = data.ptr,
|
||||||
this->input_roof = data.ptr + data.len;
|
.byte_pos = data.ptr,
|
||||||
|
.input_roof = data.ptr + data.len,
|
||||||
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue