Migrated pgp_cert to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-09-29 21:35:20 +02:00
parent 658ed38d74
commit 4a679468a5
+51 -79
View File
@@ -74,35 +74,26 @@ struct private_pgp_cert_t {
}; };
/** METHOD(certificate_t, get_type, certificate_type_t,
* Implementation of certificate_t.get_type private_pgp_cert_t *this)
*/
static certificate_type_t get_type(private_pgp_cert_t *this)
{ {
return CERT_GPG; return CERT_GPG;
} }
/** METHOD(certificate_t, get_subject,identification_t*,
* Implementation of certificate_t.get_subject private_pgp_cert_t *this)
*/
static identification_t* get_subject(private_pgp_cert_t *this)
{ {
return this->user_id; return this->user_id;
} }
/** METHOD(certificate_t, get_issuer, identification_t*,
* Implementation of certificate_t.get_issuer private_pgp_cert_t *this)
*/
static identification_t* get_issuer(private_pgp_cert_t *this)
{ {
return this->user_id; return this->user_id;
} }
/** METHOD(certificate_t, has_subject, id_match_t,
* Implementation of certificate_t.has_subject. private_pgp_cert_t *this, identification_t *subject)
*/
static id_match_t has_subject(private_pgp_cert_t *this,
identification_t *subject)
{ {
id_match_t match_user_id; id_match_t match_user_id;
@@ -116,46 +107,36 @@ static id_match_t has_subject(private_pgp_cert_t *this,
return match_user_id; return match_user_id;
} }
/** METHOD(certificate_t, has_issuer, id_match_t,
* Implementation of certificate_t.has_subject. private_pgp_cert_t *this, identification_t *issuer)
*/
static id_match_t has_issuer(private_pgp_cert_t *this, identification_t *issuer)
{ {
return ID_MATCH_NONE; return ID_MATCH_NONE;
} }
/** METHOD(certificate_t, issued_by,bool,
* Implementation of certificate_t.issued_by private_pgp_cert_t *this, certificate_t *issuer)
*/
static bool issued_by(private_pgp_cert_t *this, certificate_t *issuer)
{ {
/* TODO: check signature blobs for a valid signature */ /* TODO: check signature blobs for a valid signature */
return FALSE; return FALSE;
} }
/** METHOD(certificate_t, get_public_key, public_key_t*,
* Implementation of certificate_t.get_public_key private_pgp_cert_t *this)
*/
static public_key_t* get_public_key(private_pgp_cert_t *this)
{ {
this->key->get_ref(this->key); this->key->get_ref(this->key);
return this->key; return this->key;
} }
/** METHOD(certificate_t, get_ref, certificate_t*,
* Implementation of certificate_t.get_ref private_pgp_cert_t *this)
*/
static private_pgp_cert_t* get_ref(private_pgp_cert_t *this)
{ {
ref_get(&this->ref); ref_get(&this->ref);
return this; return &this->public.interface.interface;
} }
/** METHOD(certificate_t, get_validity, bool,
* Implementation of certificate_t.get_validity. private_pgp_cert_t *this, time_t *when, time_t *not_before,
*/ time_t *not_after)
static bool get_validity(private_pgp_cert_t *this, time_t *when,
time_t *not_before, time_t *not_after)
{ {
time_t t, until; time_t t, until;
@@ -187,11 +168,8 @@ static bool get_validity(private_pgp_cert_t *this, time_t *when,
return (t >= this->valid && t <= until); return (t >= this->valid && t <= until);
} }
/** METHOD(certificate_t, get_encoding, bool,
* Implementation of certificate_t.get_encoding. private_pgp_cert_t *this, cred_encoding_type_t type, chunk_t *encoding)
*/
static bool get_encoding(private_pgp_cert_t *this, cred_encoding_type_t type,
chunk_t *encoding)
{ {
if (type == CERT_PGP_PKT) if (type == CERT_PGP_PKT)
{ {
@@ -202,10 +180,8 @@ static bool get_encoding(private_pgp_cert_t *this, cred_encoding_type_t type,
CRED_PART_PGP_CERT, this->encoding, CRED_PART_END); CRED_PART_PGP_CERT, this->encoding, CRED_PART_END);
} }
/** METHOD(certificate_t, equals, bool,
* Implementation of certificate_t.equals. private_pgp_cert_t *this, certificate_t *other)
*/
static bool equals(private_pgp_cert_t *this, certificate_t *other)
{ {
chunk_t encoding; chunk_t encoding;
bool equal; bool equal;
@@ -231,10 +207,8 @@ static bool equals(private_pgp_cert_t *this, certificate_t *other)
return equal; return equal;
} }
/** METHOD(certificate_t, destroy, void,
* Implementation of pgp_cert_t.destroy. private_pgp_cert_t *this)
*/
static void destroy(private_pgp_cert_t *this)
{ {
if (ref_put(&this->ref)) if (ref_put(&this->ref))
{ {
@@ -246,10 +220,8 @@ static void destroy(private_pgp_cert_t *this)
} }
} }
/** METHOD(pgp_certificate_t, get_fingerprint, chunk_t,
* Implementation of pgp_certificate_t.get_fingerprint. private_pgp_cert_t *this)
*/
static chunk_t get_fingerprint(private_pgp_cert_t *this)
{ {
return this->fingerprint; return this->fingerprint;
} }
@@ -259,30 +231,30 @@ static chunk_t get_fingerprint(private_pgp_cert_t *this)
*/ */
private_pgp_cert_t *create_empty() private_pgp_cert_t *create_empty()
{ {
private_pgp_cert_t *this = malloc_thing(private_pgp_cert_t); private_pgp_cert_t *this;
this->public.interface.interface.get_type = (certificate_type_t (*) (certificate_t*))get_type; INIT(this,
this->public.interface.interface.get_subject = (identification_t* (*) (certificate_t*))get_subject; .public = {
this->public.interface.interface.get_issuer = (identification_t* (*) (certificate_t*))get_issuer; .interface = {
this->public.interface.interface.has_subject = (id_match_t (*) (certificate_t*, identification_t*))has_subject; .interface = {
this->public.interface.interface.has_issuer = (id_match_t (*) (certificate_t*, identification_t*))has_issuer; .get_type = _get_type,
this->public.interface.interface.issued_by = (bool (*) (certificate_t*, certificate_t*))issued_by; .get_subject = _get_subject,
this->public.interface.interface.get_public_key = (public_key_t* (*) (certificate_t*))get_public_key; .get_issuer = _get_issuer,
this->public.interface.interface.get_validity = (bool (*) (certificate_t*, time_t*, time_t*, time_t*))get_validity; .has_subject = _has_subject,
this->public.interface.interface.get_encoding = (bool (*) (certificate_t*,cred_encoding_type_t,chunk_t*))get_encoding; .has_issuer = _has_issuer,
this->public.interface.interface.equals = (bool (*)(certificate_t*, certificate_t*))equals; .issued_by = _issued_by,
this->public.interface.interface.get_ref = (certificate_t* (*)(certificate_t*))get_ref; .get_public_key = _get_public_key,
this->public.interface.interface.destroy = (void (*)(certificate_t*))destroy; .get_validity = _get_validity,
this->public.interface.get_fingerprint = (chunk_t (*)(pgp_certificate_t*))get_fingerprint; .get_encoding = _get_encoding,
.equals = _equals,
this->key = NULL; .get_ref = _get_ref,
this->version = 0; .destroy = _destroy,
this->created = 0; },
this->valid = 0; .get_fingerprint = _get_fingerprint,
this->user_id = NULL; },
this->fingerprint = chunk_empty; },
this->encoding = chunk_empty; .ref = 1,
this->ref = 1; );
return this; return this;
} }