Migrated cred_encoding to INIT/METHOD macros
This commit is contained in:
@@ -110,11 +110,9 @@ static bool equals(void *key1, void *key2)
|
|||||||
return key1 == key2;
|
return key1 == key2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(cred_encoding_t, get_cache, bool,
|
||||||
* Implementation of cred_encoding_t.get_cache
|
private_cred_encoding_t *this, cred_encoding_type_t type, void *cache,
|
||||||
*/
|
chunk_t *encoding)
|
||||||
static bool get_cache(private_cred_encoding_t *this, cred_encoding_type_t type,
|
|
||||||
void *cache, chunk_t *encoding)
|
|
||||||
{
|
{
|
||||||
chunk_t *chunk;
|
chunk_t *chunk;
|
||||||
|
|
||||||
@@ -191,11 +189,9 @@ static bool encode(private_cred_encoding_t *this, cred_encoding_type_t type,
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(cred_encoding_t, cache, void,
|
||||||
* Implementation of cred_encoding_t.cache
|
private_cred_encoding_t *this, cred_encoding_type_t type, void *cache,
|
||||||
*/
|
chunk_t encoding)
|
||||||
static void cache(private_cred_encoding_t *this, cred_encoding_type_t type,
|
|
||||||
void *cache, chunk_t encoding)
|
|
||||||
{
|
{
|
||||||
chunk_t *chunk;
|
chunk_t *chunk;
|
||||||
|
|
||||||
@@ -216,10 +212,8 @@ static void cache(private_cred_encoding_t *this, cred_encoding_type_t type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(cred_encoding_t, clear_cache, void,
|
||||||
* Implementation of cred_encoding_t.clear_cache
|
private_cred_encoding_t *this, void *cache)
|
||||||
*/
|
|
||||||
static void clear_cache(private_cred_encoding_t *this, void *cache)
|
|
||||||
{
|
{
|
||||||
cred_encoding_type_t type;
|
cred_encoding_type_t type;
|
||||||
chunk_t *chunk;
|
chunk_t *chunk;
|
||||||
@@ -237,30 +231,24 @@ static void clear_cache(private_cred_encoding_t *this, void *cache)
|
|||||||
this->lock->unlock(this->lock);
|
this->lock->unlock(this->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(cred_encoding_t, add_encoder, void,
|
||||||
* Implementation of cred_encoding_t.add_encoder
|
private_cred_encoding_t *this, cred_encoder_t encoder)
|
||||||
*/
|
|
||||||
static void add_encoder(private_cred_encoding_t *this, cred_encoder_t encoder)
|
|
||||||
{
|
{
|
||||||
this->lock->write_lock(this->lock);
|
this->lock->write_lock(this->lock);
|
||||||
this->encoders->insert_last(this->encoders, encoder);
|
this->encoders->insert_last(this->encoders, encoder);
|
||||||
this->lock->unlock(this->lock);
|
this->lock->unlock(this->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(cred_encoding_t, remove_encoder, void,
|
||||||
* Implementation of cred_encoding_t.remove_encoder
|
private_cred_encoding_t *this, cred_encoder_t encoder)
|
||||||
*/
|
|
||||||
static void remove_encoder(private_cred_encoding_t *this, cred_encoder_t encoder)
|
|
||||||
{
|
{
|
||||||
this->lock->write_lock(this->lock);
|
this->lock->write_lock(this->lock);
|
||||||
this->encoders->remove(this->encoders, encoder, NULL);
|
this->encoders->remove(this->encoders, encoder, NULL);
|
||||||
this->lock->unlock(this->lock);
|
this->lock->unlock(this->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(cred_encoding_t, destroy, void,
|
||||||
* Implementation of cred_encoder_t.destroy.
|
private_cred_encoding_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_cred_encoding_t *this)
|
|
||||||
{
|
{
|
||||||
cred_encoding_type_t type;
|
cred_encoding_type_t type;
|
||||||
|
|
||||||
@@ -282,23 +270,27 @@ static void destroy(private_cred_encoding_t *this)
|
|||||||
*/
|
*/
|
||||||
cred_encoding_t *cred_encoding_create()
|
cred_encoding_t *cred_encoding_create()
|
||||||
{
|
{
|
||||||
private_cred_encoding_t *this = malloc_thing(private_cred_encoding_t);
|
private_cred_encoding_t *this;
|
||||||
cred_encoding_type_t type;
|
cred_encoding_type_t type;
|
||||||
|
|
||||||
this->public.encode = (bool(*)(cred_encoding_t*, cred_encoding_type_t type, void *cache, chunk_t *encoding, ...))encode;
|
INIT(this,
|
||||||
this->public.get_cache = (bool(*)(cred_encoding_t*, cred_encoding_type_t type, void *cache, chunk_t *encoding))get_cache;
|
.public = {
|
||||||
this->public.cache = (void(*)(cred_encoding_t*, cred_encoding_type_t type, void *cache, chunk_t encoding))cache;
|
.encode = (bool(*)(cred_encoding_t*, cred_encoding_type_t type, void *cache, chunk_t *encoding, ...))encode,
|
||||||
this->public.clear_cache = (void(*)(cred_encoding_t*, void *cache))clear_cache;
|
.get_cache = _get_cache,
|
||||||
this->public.add_encoder = (void(*)(cred_encoding_t*, cred_encoder_t encoder))add_encoder;
|
.cache = _cache,
|
||||||
this->public.remove_encoder = (void(*)(cred_encoding_t*, cred_encoder_t encoder))remove_encoder;
|
.clear_cache = _clear_cache,
|
||||||
this->public.destroy = (void(*)(cred_encoding_t*))destroy;
|
.add_encoder = _add_encoder,
|
||||||
|
.remove_encoder = _remove_encoder,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.encoders = linked_list_create(),
|
||||||
|
.lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
|
||||||
|
);
|
||||||
|
|
||||||
for (type = 0; type < CRED_ENCODING_MAX; type++)
|
for (type = 0; type < CRED_ENCODING_MAX; type++)
|
||||||
{
|
{
|
||||||
this->cache[type] = hashtable_create(hash, equals, 8);
|
this->cache[type] = hashtable_create(hash, equals, 8);
|
||||||
}
|
}
|
||||||
this->encoders = linked_list_create();
|
|
||||||
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
|
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user