Migrated medsrv_creds_t to INIT/METHOD macros.
This commit is contained in:
@@ -51,11 +51,8 @@ typedef struct {
|
|||||||
key_type_t type;
|
key_type_t type;
|
||||||
} cert_enumerator_t;
|
} cert_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||||
* Implementation of cert_enumerator_t.public.enumerate
|
cert_enumerator_t *this, certificate_t **cert)
|
||||||
*/
|
|
||||||
static bool cert_enumerator_enumerate(cert_enumerator_t *this,
|
|
||||||
certificate_t **cert)
|
|
||||||
{
|
{
|
||||||
certificate_t *trusted;
|
certificate_t *trusted;
|
||||||
public_key_t *public;
|
public_key_t *public;
|
||||||
@@ -91,22 +88,17 @@ static bool cert_enumerator_enumerate(cert_enumerator_t *this,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, cert_enumerator_destroy, void,
|
||||||
* Implementation of cert_enumerator_t.public.destroy
|
cert_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void cert_enumerator_destroy(cert_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
this->inner->destroy(this->inner);
|
this->inner->destroy(this->inner);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
||||||
* Implementation of credential_set_t.create_cert_enumerator.
|
private_medsrv_creds_t *this, certificate_type_t cert, key_type_t key,
|
||||||
*/
|
identification_t *id, bool trusted)
|
||||||
static enumerator_t* create_cert_enumerator(private_medsrv_creds_t *this,
|
|
||||||
certificate_type_t cert, key_type_t key,
|
|
||||||
identification_t *id, bool trusted)
|
|
||||||
{
|
{
|
||||||
cert_enumerator_t *e;
|
cert_enumerator_t *e;
|
||||||
|
|
||||||
@@ -116,15 +108,17 @@ static enumerator_t* create_cert_enumerator(private_medsrv_creds_t *this,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
e = malloc_thing(cert_enumerator_t);
|
INIT(e,
|
||||||
e->current = NULL;
|
.public = {
|
||||||
e->type = key;
|
.enumerate = (void*)_cert_enumerator_enumerate,
|
||||||
e->public.enumerate = (void*)cert_enumerator_enumerate;
|
.destroy = _cert_enumerator_destroy,
|
||||||
e->public.destroy = (void*)cert_enumerator_destroy;
|
},
|
||||||
e->inner = this->db->query(this->db,
|
.type = key,
|
||||||
"SELECT public_key FROM peer WHERE keyid = ?",
|
.inner = this->db->query(this->db,
|
||||||
DB_BLOB, id->get_encoding(id),
|
"SELECT public_key FROM peer WHERE keyid = ?",
|
||||||
DB_BLOB);
|
DB_BLOB, id->get_encoding(id),
|
||||||
|
DB_BLOB),
|
||||||
|
);
|
||||||
if (!e->inner)
|
if (!e->inner)
|
||||||
{
|
{
|
||||||
free(e);
|
free(e);
|
||||||
@@ -133,10 +127,8 @@ static enumerator_t* create_cert_enumerator(private_medsrv_creds_t *this,
|
|||||||
return &e->public;
|
return &e->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(medsrv_creds_t, destroy, void,
|
||||||
* Implementation of backend_t.destroy.
|
private_medsrv_creds_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_medsrv_creds_t *this)
|
|
||||||
{
|
{
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
@@ -146,17 +138,21 @@ static void destroy(private_medsrv_creds_t *this)
|
|||||||
*/
|
*/
|
||||||
medsrv_creds_t *medsrv_creds_create(database_t *db)
|
medsrv_creds_t *medsrv_creds_create(database_t *db)
|
||||||
{
|
{
|
||||||
private_medsrv_creds_t *this = malloc_thing(private_medsrv_creds_t);
|
private_medsrv_creds_t *this;
|
||||||
|
|
||||||
this->public.set.create_private_enumerator = (void*)return_null;
|
INIT(this,
|
||||||
this->public.set.create_cert_enumerator = (void*)create_cert_enumerator;
|
.public = {
|
||||||
this->public.set.create_shared_enumerator = (void*)return_null;
|
.set = {
|
||||||
this->public.set.create_cdp_enumerator = (void*)return_null;
|
.create_private_enumerator = (void*)return_null,
|
||||||
this->public.set.cache_cert = (void*)nop;
|
.create_cert_enumerator = _create_cert_enumerator,
|
||||||
|
.create_shared_enumerator = (void*)return_null,
|
||||||
this->public.destroy = (void (*)(medsrv_creds_t*))destroy;
|
.create_cdp_enumerator = (void*)return_null,
|
||||||
|
.cache_cert = (void*)nop,
|
||||||
this->db = db;
|
},
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.db = db,
|
||||||
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user