summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2010-12-14 17:55:39 +0100
committerSamuel Lidén Borell <samuel@slbdata.se>2010-12-14 18:14:40 +0100
commit93b11bdd26707c4eb9135c2764c5fa1b43a645e8 (patch)
treef6d39f5a3ecc125b47aa335514caf19b77d1eece
parent1fc3089f2b11b705d14e391824e0340a964c40e4 (diff)
downloadfribid-93b11bdd26707c4eb9135c2764c5fa1b43a645e8.tar.gz
fribid-93b11bdd26707c4eb9135c2764c5fa1b43a645e8.tar.bz2
fribid-93b11bdd26707c4eb9135c2764c5fa1b43a645e8.zip
Move some duplicated code to a function
-rw-r--r--plugin/ipc.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/plugin/ipc.c b/plugin/ipc.c
index 311d2ea..a9e0546 100644
--- a/plugin/ipc.c
+++ b/plugin/ipc.c
@@ -104,6 +104,15 @@ static void openInteractivePipes(PipeInfo *pipeinfo, Plugin *plugin) {
openPipes(pipeinfo, argv);
}
+static BankIDError waitReply(PipeInfo *pipeinfo) {
+ pipe_finishCommand(pipeinfo->out);
+
+ pipe_waitData(pipeinfo->in);
+
+ // Return error code
+ return pipe_readInt(pipeinfo->in);
+}
+
static void closePipes(PipeInfo *pipeinfo) {
fclose(pipeinfo->out);
fclose(pipeinfo->in);
@@ -143,10 +152,7 @@ int sign_performAction_Authenticate(Plugin *plugin) {
sendSignCommon(pipeinfo, plugin);
- pipe_finishCommand(pipeinfo.out);
-
- pipe_waitData(pipeinfo.in);
- plugin->lastError = pipe_readInt(pipeinfo.in);
+ plugin->lastError = waitReply(&pipeinfo);
plugin->info.auth.signature = pipe_readString(pipeinfo.in);
closePipes(&pipeinfo);
return plugin->lastError;
@@ -162,10 +168,7 @@ int sign_performAction_Sign(Plugin *plugin) {
pipe_sendString(pipeinfo.out, plugin->info.sign.message);
pipe_sendOptionalString(pipeinfo.out, plugin->info.sign.invisibleMessage);
- pipe_finishCommand(pipeinfo.out);
-
- pipe_waitData(pipeinfo.in);
- plugin->lastError = pipe_readInt(pipeinfo.in);
+ plugin->lastError = waitReply(&pipeinfo);
plugin->info.auth.signature = pipe_readString(pipeinfo.in);
closePipes(&pipeinfo);
return plugin->lastError;