Migrated uci_parser_t to INIT/METHOD macros.
This commit is contained in:
@@ -57,10 +57,8 @@ typedef struct {
|
|||||||
char *keywords[];
|
char *keywords[];
|
||||||
} section_enumerator_t;
|
} section_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, section_enumerator_enumerate, bool,
|
||||||
* Implementation of section_enumerator_t.enumerate
|
section_enumerator_t *this, ...)
|
||||||
*/
|
|
||||||
static bool section_enumerator_enumerate(section_enumerator_t *this, ...)
|
|
||||||
{
|
{
|
||||||
struct uci_element *element;
|
struct uci_element *element;
|
||||||
char **value;
|
char **value;
|
||||||
@@ -104,19 +102,15 @@ static bool section_enumerator_enumerate(section_enumerator_t *this, ...)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, section_enumerator_destroy, void,
|
||||||
* Implementation of section_enumerator_t.public.destroy
|
section_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void section_enumerator_destroy(section_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
uci_free_context(this->ctx);
|
uci_free_context(this->ctx);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(uci_parser_t, create_section_enumerator, enumerator_t*,
|
||||||
* Implementation of backend_t.create_section_enumerator.
|
private_uci_parser_t *this, ...)
|
||||||
*/
|
|
||||||
static enumerator_t* create_section_enumerator(private_uci_parser_t *this, ...)
|
|
||||||
{
|
{
|
||||||
section_enumerator_t *e;
|
section_enumerator_t *e;
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -140,8 +134,8 @@ static enumerator_t* create_section_enumerator(private_uci_parser_t *this, ...)
|
|||||||
while (e->keywords[i++]);
|
while (e->keywords[i++]);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
e->public.enumerate = (void*)section_enumerator_enumerate;
|
e->public.enumerate = (void*)_section_enumerator_enumerate;
|
||||||
e->public.destroy = (void*)section_enumerator_destroy;
|
e->public.destroy = _section_enumerator_destroy;
|
||||||
|
|
||||||
/* load uci context */
|
/* load uci context */
|
||||||
e->ctx = uci_alloc_context();
|
e->ctx = uci_alloc_context();
|
||||||
@@ -160,10 +154,8 @@ static enumerator_t* create_section_enumerator(private_uci_parser_t *this, ...)
|
|||||||
return &e->public;
|
return &e->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(uci_parser_t, destroy, void,
|
||||||
* Implementation of uci_parser_t.destroy.
|
private_uci_parser_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_uci_parser_t *this)
|
|
||||||
{
|
{
|
||||||
free(this->package);
|
free(this->package);
|
||||||
free(this);
|
free(this);
|
||||||
@@ -174,12 +166,15 @@ static void destroy(private_uci_parser_t *this)
|
|||||||
*/
|
*/
|
||||||
uci_parser_t *uci_parser_create(char *package)
|
uci_parser_t *uci_parser_create(char *package)
|
||||||
{
|
{
|
||||||
private_uci_parser_t *this = malloc_thing(private_uci_parser_t);
|
private_uci_parser_t *this;
|
||||||
|
|
||||||
this->public.create_section_enumerator = (enumerator_t*(*)(uci_parser_t*, ...))create_section_enumerator;
|
INIT(this,
|
||||||
this->public.destroy = (void(*)(uci_parser_t*))destroy;
|
.public = {
|
||||||
|
.create_section_enumerator = _create_section_enumerator,
|
||||||
this->package = strdup(package);
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.package = strdup(package),
|
||||||
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user