diff options
author | Samuel Lidén Borell <samuel@slbdata.se> | 2011-01-03 09:42:15 +0100 |
---|---|---|
committer | Samuel Lidén Borell <samuel@slbdata.se> | 2011-01-03 09:42:15 +0100 |
commit | fd20aca018a5dc3852f9785abecd9bc34abd6a39 (patch) | |
tree | 5af0aa62778e4af479ecffccf0e40eaf60e4555d /plugin | |
parent | 22a554dd0fedfb9d9c0654620fa8779804c3c2d3 (diff) | |
download | fribid-fd20aca018a5dc3852f9785abecd9bc34abd6a39.tar.gz fribid-fd20aca018a5dc3852f9785abecd9bc34abd6a39.tar.bz2 fribid-fd20aca018a5dc3852f9785abecd9bc34abd6a39.zip |
Set the last error correctly in PerformAction (and simplify the code)
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/plugin.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/plugin/plugin.c b/plugin/plugin.c index 491a0c8..c066a4f 100644 --- a/plugin/plugin.c +++ b/plugin/plugin.c @@ -214,28 +214,25 @@ static bool hasSignParams(const Plugin *plugin) { } int sign_performAction(Plugin *plugin, const char *action) { - plugin->lastError = BIDERR_InternalError; + int ret = BIDERR_InvalidAction; + + if (!lockURL(plugin->url)) return BIDERR_InternalError; + if ((plugin->type == PT_Authentication) && !strcmp(action, "Authenticate")) { - if (!hasSignParams(plugin)) { - return BIDERR_MissingParameter; - } else { - if (!lockURL(plugin->url)) return BIDERR_InternalError; - int ret = sign_performAction_Authenticate(plugin); - unlockURL(plugin->url); - return ret; - } + ret = (hasSignParams(plugin) ? + sign_performAction_Authenticate(plugin) : BIDERR_MissingParameter); + } else if ((plugin->type == PT_Signer) && !strcmp(action, "Sign")) { if (!hasSignParams(plugin) || !plugin->info.sign.message) { return BIDERR_MissingParameter; - } else { - if (!lockURL(plugin->url)) return BIDERR_InternalError; - int ret = sign_performAction_Sign(plugin); - unlockURL(plugin->url); - return ret; } - } else { - return BIDERR_InvalidAction; + ret = (hasSignParams(plugin) && plugin->info.sign.message ? + sign_performAction_Sign(plugin) : BIDERR_MissingParameter); } + + unlockURL(plugin->url); + plugin->lastError = ret; + return ret; } int sign_getLastError(Plugin *plugin) { |