From 90e4c69eeb32e6fcc91b73b7acfda032261827eb Mon Sep 17 00:00:00 2001 From: Erik Alexandre Pucci <eap08@c3sl.ufpr.br> Date: Sun, 28 Nov 2010 16:04:47 -0200 Subject: [PATCH] client.c: Modified error exit when calling a server method Now the client checks to see if the GSOAP error is the network device bind, exiting with it (value 50) or exiting with 2 otherwise. Signed-off-by: Erik Alexandre Pucci <eap08@c3sl.ufpr.br> Acked-by: Ricardo Tavares de Oliveira <rto07@c3sl.ufpr.br> Signed-off-by: Danilo K. S. Yorinori <danilok@c3sl.ufpr.br> --- src/client.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/client.c b/src/client.c index b81d126..dda8781 100644 --- a/src/client.c +++ b/src/client.c @@ -311,11 +311,13 @@ static char *read_version_file(char *basedir) void print_update_link(struct soap *soap, char *url) { char *updateLink; + int error; - if (soap_call_ns1__getUpdateLink(soap, url, "", &updateLink) != SOAP_OK) + error = soap_call_ns1__getUpdateLink(soap, url, "", &updateLink); + if (error != SOAP_OK) { soap_print_fault(soap, stderr); - exit(2); + exit(error == NIC_ERROR ? error : 2); } /* Get update link from response */ @@ -344,12 +346,13 @@ void print_update_link(struct soap *soap, char *url) void check_version(struct soap *soap, char *url, char *clientVersion) { char *versionFromServer; + int error; - if (soap_call_ns1__getAgentVersion(soap, url, "", &versionFromServer) != - SOAP_OK) + error = soap_call_ns1__getAgentVersion(soap, url, "", &versionFromServer); + if (error != SOAP_OK) { soap_print_fault(soap, stderr); - exit(2); + exit(error == NIC_ERROR ? error : 2); } DEBUG("Version from server: %s\n", versionFromServer); @@ -451,14 +454,16 @@ char *read_xml_file(char *basedir) void inventory(struct soap *soap, char *url, char *basedir) { char *invResult, *xmlInventory; + int error; xmlInventory = read_xml_file(basedir); - if (soap_call_ns1__setInventory(soap, url, "", xmlInventory, &invResult) - != SOAP_OK) + error = soap_call_ns1__setInventory(soap, url, "", xmlInventory, + &invResult); + if (error != SOAP_OK) { soap_print_fault(soap, stderr); - exit(2); + exit(error == NIC_ERROR ? error : 2); } /* Get inventory result from response */ -- GitLab