Skip to content
Snippets Groups Projects
Commit 6563259c authored by Erik Alexandre Pucci's avatar Erik Alexandre Pucci Committed by Danilo K. S. Yorinori
Browse files

client.c: Added more server responses checks


check_version() verifies more server responses:
- If versionFromServer is NULL;
- If the server read an invalid version file (versionFromServer contains
"Invalid version");
- And if the server could not find the version file (versionFromServer
contains "Version file not found").

Signed-off-by: default avatarErik Alexandre Pucci <eap08@c3sl.ufpr.br>
Acked-by: default avatarDiego Giovane Pasqualin <dgp06@c3sl.ufpr.br>
Signed-off-by: default avatarDanilo K. S. Yorinori <danilok@c3sl.ufpr.br>
parent 8ebf466d
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,9 @@
* 4) Client out-of-date
* 5) Server returned an error
* 6) Unexpected server result
* 7) Server returned an empty version string
* 8) Server returned an invalid version string
* 9) Server did not find the version file
*/
int main(int argc, char **argv)
{
......@@ -204,8 +207,27 @@ void check_version(struct soap *soap, char *url, char *clientVersion)
printf("Version from server: %s\n", versionFromServer);
}
/* Check server version string for errors */
if (versionFromServer == NULL)
{
fprintf(stderr, "Server returned an empty version string.\n");
/* Empty version */
exit(7);
}
else if (strcmp(versionFromServer, "Invalid version") == 0)
{
fprintf(stderr, "Server returned an invalid version string.\n");
/* Invalid version */
exit(8);
}
else if (strcmp(versionFromServer, "Version file not found") == 0)
{
fprintf(stderr, "Server did not find the version file.\n");
/* Version file not found (server) */
exit(9);
}
/* Compare client and server versions */
if (strcmp(clientVersion, versionFromServer) != 0)
else if (strcmp(clientVersion, versionFromServer) != 0)
{
fprintf(stderr, "Client version out-of-date. Update client.\n");
/* Client out-of-date version */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment