summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;