plugin-feature: Function added to exactly compare plugin features
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2012 Tobias Brunner
|
* Copyright (C) 2012-2013 Tobias Brunner
|
||||||
* Hochschule fuer Technik Rapperswil
|
* Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Martin Willi
|
* Copyright (C) 2011 Martin Willi
|
||||||
@@ -169,6 +169,55 @@ bool plugin_feature_matches(plugin_feature_t *a, plugin_feature_t *b)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See header.
|
||||||
|
*/
|
||||||
|
bool plugin_feature_equals(plugin_feature_t *a, plugin_feature_t *b)
|
||||||
|
{
|
||||||
|
if (a->type == b->type)
|
||||||
|
{
|
||||||
|
switch (a->type)
|
||||||
|
{
|
||||||
|
case FEATURE_NONE:
|
||||||
|
case FEATURE_CRYPTER:
|
||||||
|
case FEATURE_AEAD:
|
||||||
|
case FEATURE_SIGNER:
|
||||||
|
case FEATURE_HASHER:
|
||||||
|
case FEATURE_PRF:
|
||||||
|
case FEATURE_DH:
|
||||||
|
case FEATURE_NONCE_GEN:
|
||||||
|
case FEATURE_PRIVKEY:
|
||||||
|
case FEATURE_PRIVKEY_GEN:
|
||||||
|
case FEATURE_PUBKEY:
|
||||||
|
case FEATURE_PRIVKEY_SIGN:
|
||||||
|
case FEATURE_PUBKEY_VERIFY:
|
||||||
|
case FEATURE_PRIVKEY_DECRYPT:
|
||||||
|
case FEATURE_PUBKEY_ENCRYPT:
|
||||||
|
case FEATURE_CERT_DECODE:
|
||||||
|
case FEATURE_CERT_ENCODE:
|
||||||
|
case FEATURE_CONTAINER_DECODE:
|
||||||
|
case FEATURE_CONTAINER_ENCODE:
|
||||||
|
case FEATURE_EAP_SERVER:
|
||||||
|
case FEATURE_EAP_PEER:
|
||||||
|
case FEATURE_CUSTOM:
|
||||||
|
case FEATURE_XAUTH_SERVER:
|
||||||
|
case FEATURE_XAUTH_PEER:
|
||||||
|
return plugin_feature_matches(a, b);
|
||||||
|
case FEATURE_RNG:
|
||||||
|
return a->arg.rng_quality == b->arg.rng_quality;
|
||||||
|
case FEATURE_DATABASE:
|
||||||
|
return a->arg.database == b->arg.database;
|
||||||
|
case FEATURE_FETCHER:
|
||||||
|
if (a->arg.fetcher && b->arg.fetcher)
|
||||||
|
{
|
||||||
|
return streq(a->arg.fetcher, b->arg.fetcher);
|
||||||
|
}
|
||||||
|
return !a->arg.fetcher && !b->arg.fetcher;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See header.
|
* See header.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2012 Tobias Brunner
|
* Copyright (C) 2012-2013 Tobias Brunner
|
||||||
* Hochschule fuer Technik Rapperswil
|
* Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Martin Willi
|
* Copyright (C) 2011 Martin Willi
|
||||||
@@ -340,12 +340,25 @@ u_int32_t plugin_feature_hash(plugin_feature_t *feature);
|
|||||||
/**
|
/**
|
||||||
* Check if feature a matches to feature b.
|
* Check if feature a matches to feature b.
|
||||||
*
|
*
|
||||||
|
* This is no check for equality. For instance, for FEATURE_RNG a matches b if
|
||||||
|
* a's strength is at least the strength of b. Or for FEATURE_SQL if a is
|
||||||
|
* DB_ANY it will match b if it is of the same type.
|
||||||
|
*
|
||||||
* @param a feature to check
|
* @param a feature to check
|
||||||
* @param b feature to match against
|
* @param b feature to match against
|
||||||
* @return TRUE if a matches b
|
* @return TRUE if a matches b
|
||||||
*/
|
*/
|
||||||
bool plugin_feature_matches(plugin_feature_t *a, plugin_feature_t *b);
|
bool plugin_feature_matches(plugin_feature_t *a, plugin_feature_t *b);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if feature a equals feature b.
|
||||||
|
*
|
||||||
|
* @param a feature
|
||||||
|
* @param b feature to compare
|
||||||
|
* @return TRUE if a equals b
|
||||||
|
*/
|
||||||
|
bool plugin_feature_equals(plugin_feature_t *a, plugin_feature_t *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a string describing feature.
|
* Get a string describing feature.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ static plugin_t *static_features_create(const char *name,
|
|||||||
/**
|
/**
|
||||||
* Compare function for hashtable of loaded features.
|
* Compare function for hashtable of loaded features.
|
||||||
*/
|
*/
|
||||||
static bool plugin_feature_equals(plugin_feature_t *a, plugin_feature_t *b)
|
static bool plugin_feature_equals_ptr(plugin_feature_t *a, plugin_feature_t *b)
|
||||||
{
|
{
|
||||||
return a == b;
|
return a == b;
|
||||||
}
|
}
|
||||||
@@ -850,7 +850,7 @@ plugin_loader_t *plugin_loader_create()
|
|||||||
.plugins = linked_list_create(),
|
.plugins = linked_list_create(),
|
||||||
.loaded_features = hashtable_create(
|
.loaded_features = hashtable_create(
|
||||||
(hashtable_hash_t)plugin_feature_hash,
|
(hashtable_hash_t)plugin_feature_hash,
|
||||||
(hashtable_equals_t)plugin_feature_equals, 64),
|
(hashtable_equals_t)plugin_feature_equals_ptr, 64),
|
||||||
);
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
|
|||||||
Reference in New Issue
Block a user