Migrated mconsole_t to INIT/METHOD macros.
This commit is contained in:
+19
-24
@@ -168,10 +168,8 @@ static void ignore(void *data, char *buf, size_t len)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(mconsole_t, add_iface, bool,
|
||||||
* Implementation of mconsole_t.add_iface.
|
private_mconsole_t *this, char *guest, char *host)
|
||||||
*/
|
|
||||||
static bool add_iface(private_mconsole_t *this, char *guest, char *host)
|
|
||||||
{
|
{
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
|
|
||||||
@@ -186,10 +184,8 @@ static bool add_iface(private_mconsole_t *this, char *guest, char *host)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(mconsole_t, del_iface, bool,
|
||||||
* Implementation of mconsole_t.del_iface.
|
private_mconsole_t *this, char *guest)
|
||||||
*/
|
|
||||||
static bool del_iface(private_mconsole_t *this, char *guest)
|
|
||||||
{
|
{
|
||||||
if (request(this, NULL, NULL, "remove %s", guest) != 0)
|
if (request(this, NULL, NULL, "remove %s", guest) != 0)
|
||||||
{
|
{
|
||||||
@@ -198,11 +194,9 @@ static bool del_iface(private_mconsole_t *this, char *guest)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(mconsole_t, exec, int,
|
||||||
* Implementation of mconsole_t.exec
|
private_mconsole_t *this, void(*cb)(void*,char*,size_t), void *data,
|
||||||
*/
|
char *cmd)
|
||||||
static int exec(private_mconsole_t *this, void(*cb)(void*,char*,size_t),
|
|
||||||
void *data, char *cmd)
|
|
||||||
{
|
{
|
||||||
return request(this, cb, data, "%s", cmd);
|
return request(this, cb, data, "%s", cmd);
|
||||||
}
|
}
|
||||||
@@ -223,10 +217,8 @@ static void wait_bootup(private_mconsole_t *this)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(mconsole_t, destroy, void,
|
||||||
* Implementation of mconsole_t.destroy.
|
private_mconsole_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_mconsole_t *this)
|
|
||||||
{
|
{
|
||||||
close(this->console);
|
close(this->console);
|
||||||
close(this->notify);
|
close(this->notify);
|
||||||
@@ -327,14 +319,17 @@ static bool setup_console(private_mconsole_t *this)
|
|||||||
*/
|
*/
|
||||||
mconsole_t *mconsole_create(char *notify, void(*idle)(void))
|
mconsole_t *mconsole_create(char *notify, void(*idle)(void))
|
||||||
{
|
{
|
||||||
private_mconsole_t *this = malloc_thing(private_mconsole_t);
|
private_mconsole_t *this;
|
||||||
|
|
||||||
this->public.add_iface = (bool(*)(mconsole_t*, char *guest, char *host))add_iface;
|
INIT(this,
|
||||||
this->public.del_iface = (bool(*)(mconsole_t*, char *guest))del_iface;
|
.public = {
|
||||||
this->public.exec = (int(*)(mconsole_t*, void(*cb)(void*,char*,size_t), void *data, char *cmd))exec;
|
.add_iface = _add_iface,
|
||||||
this->public.destroy = (void*)destroy;
|
.del_iface = _del_iface,
|
||||||
|
.exec = _exec,
|
||||||
this->idle = idle;
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.idle = idle,
|
||||||
|
);
|
||||||
|
|
||||||
if (!wait_for_notify(this, notify))
|
if (!wait_for_notify(this, notify))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user