Added a final flag to builder registration to enumerate the actually supported algorithms
This commit is contained in:
@@ -64,18 +64,21 @@ struct entry_t {
|
||||
credential_type_t type;
|
||||
/** subtype of credential, e.g. certificate_type_t */
|
||||
int subtype;
|
||||
/** registered with final flag? */
|
||||
bool final;
|
||||
/** builder function */
|
||||
builder_function_t constructor;
|
||||
};
|
||||
|
||||
METHOD(credential_factory_t, add_builder, void,
|
||||
private_credential_factory_t *this, credential_type_t type, int subtype,
|
||||
builder_function_t constructor)
|
||||
bool final, builder_function_t constructor)
|
||||
{
|
||||
entry_t *entry = malloc_thing(entry_t);
|
||||
|
||||
entry->type = type;
|
||||
entry->subtype = subtype;
|
||||
entry->final = final;
|
||||
entry->constructor = constructor;
|
||||
this->lock->write_lock(this->lock);
|
||||
this->constructors->insert_last(this->constructors, entry);
|
||||
@@ -153,16 +156,15 @@ METHOD(credential_factory_t, create, void*,
|
||||
* Filter function for builder enumerator
|
||||
*/
|
||||
static bool builder_filter(void *null, entry_t **entry, credential_type_t *type,
|
||||
void *dummy1, int *subtype,
|
||||
void *dummy2, builder_function_t *constructor)
|
||||
void *dummy1, int *subtype)
|
||||
{
|
||||
*type = (*entry)->type;
|
||||
*subtype = (*entry)->subtype;
|
||||
if (constructor)
|
||||
if ((*entry)->final)
|
||||
{
|
||||
*constructor = (*entry)->constructor;
|
||||
*type = (*entry)->type;
|
||||
*subtype = (*entry)->subtype;
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(credential_factory_t, create_builder_enumerator, enumerator_t*,
|
||||
|
||||
@@ -64,21 +64,21 @@ struct credential_factory_t {
|
||||
*/
|
||||
void* (*create)(credential_factory_t *this, credential_type_t type,
|
||||
int subtype, ...);
|
||||
/**
|
||||
* Create an enumerator over registered builder functions.
|
||||
*
|
||||
* @return enumerator (credential_type_t, int, build_function_t)
|
||||
*/
|
||||
enumerator_t* (*create_builder_enumerator)(credential_factory_t *this);
|
||||
|
||||
/**
|
||||
* Register a credential builder function.
|
||||
*
|
||||
* The final flag indicates if the registered builder can build such
|
||||
* a credential itself the most common encoding, without the need
|
||||
* for an additional builder.
|
||||
*
|
||||
* @param type type of credential the builder creates
|
||||
* @param subtype subtype of the credential, type specific
|
||||
* @param final TRUE if this build does not invoke other builders
|
||||
* @param constructor builder constructor function to register
|
||||
*/
|
||||
void (*add_builder)(credential_factory_t *this,
|
||||
credential_type_t type, int subtype,
|
||||
credential_type_t type, int subtype, bool final,
|
||||
builder_function_t constructor);
|
||||
/**
|
||||
* Unregister a credential builder function.
|
||||
@@ -88,6 +88,16 @@ struct credential_factory_t {
|
||||
void (*remove_builder)(credential_factory_t *this,
|
||||
builder_function_t constructor);
|
||||
|
||||
/**
|
||||
* Create an enumerator over registered builder types.
|
||||
*
|
||||
* The enumerator returns only builder types registered with the final
|
||||
* flag set.
|
||||
*
|
||||
* @return enumerator (credential_type_t, int subtype)
|
||||
*/
|
||||
enumerator_t* (*create_builder_enumerator)(credential_factory_t *this);
|
||||
|
||||
/**
|
||||
* Destroy a credential_factory instance.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user