Skip to content
Snippets Groups Projects
Commit 44373783 authored by ERIK ALEXANDRE PUCCI's avatar ERIK ALEXANDRE PUCCI Committed by Danilo K. S. Yorinori
Browse files

client.c: Added update option


The client now checks if it was called with update option. If that is true,
the client will check for updates and finalize execution, returning
appropriate messages. Otherwise, the client will not check for updates, but
will send the availability data to the server.

Signed-off-by: default avatarERIK ALEXANDRE PUCCI <eap08@c3sl.ufpr.br>
Acked-by: default avatarBruno Ribas <ribas@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 37e98def
Branches
Tags
No related merge requests found
...@@ -35,39 +35,42 @@ int main(int argc, char **argv) ...@@ -35,39 +35,42 @@ int main(int argc, char **argv)
{ {
struct soap *soap = soap_new(); struct soap *soap = soap_new();
char *url, *inep, *macAddr, *basedir, *clientVersion; char *url, *inep, *macAddr, *basedir, *clientVersion;
int arglen, len; int arglen, len, update = 0;
/* Initialization * /* Initialization *
*----------------------------------------------------------------------- *-----------------------------------------------------------------------
* Verify parameters */ * Verify parameters */
if ( argc < 4 || argc > 8 || argc == 7) if ( argc < 4 || argc > 9 || ((update = !strcmp(argv[1], UPDATEOPTION))
&& argc == 8) || (!update && argc == 7) )
{ {
fprintf(stderr, "Wrong number of parameters.\n"); fprintf(stderr, "Wrong number of parameters.\n");
fprintf(stderr, "Usage: client url INEP MacAddress [proxy_host "); fprintf(stderr, "Usage: client [--update] url INEP MacAddress ");
fprintf(stderr, "[proxy_port [proxy_userid proxy_passwd]]]\n"); fprintf(stderr, "[proxy_host [proxy_port [proxy_userid ");
fprintf(stderr, "proxy_passwd]]]\nUse the option ");
fprintf(stderr, "\"--update\" to check for updates.\n");
/* Parameter error */ /* Parameter error */
exit(1); exit(1);
} }
/* Set parameters passed by user /* Set parameters passed by user
* Basic information */ * Basic information */
url = argv[1]; url = argv[1 + update];
inep = argv[2]; inep = argv[2 + update];
macAddr = argv[3]; macAddr = argv[3 + update];
/* Proxy informations */ /* Proxy informations */
if (argc >= 5) if (argc >= 5 + update)
{ {
soap->proxy_host = argv[4]; soap->proxy_host = argv[4 + update];
} }
if (argc >= 6) if (argc >= 6 + update)
{ {
soap->proxy_port = atoi(argv[5]); soap->proxy_port = atoi(argv[5 + update]);
} }
if (argc >= 8) if (argc >= 8 + update)
{ {
soap->proxy_userid = argv[6]; soap->proxy_userid = argv[6 + update];
soap->proxy_passwd = argv[7]; soap->proxy_passwd = argv[7 + update];
} }
/* Get basedir */ /* Get basedir */
...@@ -81,22 +84,29 @@ int main(int argc, char **argv) ...@@ -81,22 +84,29 @@ int main(int argc, char **argv)
printf("Arg: %s basedir: %s\n", argv[0], basedir); printf("Arg: %s basedir: %s\n", argv[0], basedir);
} }
/* End of Initialization
*-----------------------------------------------------------------------
* Update option */
if (update)
{
/* Get client version from file */ /* Get client version from file */
if ( ! (clientVersion = read_version_file(basedir)) ) if ( ! (clientVersion = read_version_file(basedir)) )
{ {
/* Error when open version file */ /* Error when open version file */
exit(3); exit(3);
} }
/* Agent Version method */
/* End of Initialization
*-----------------------------------------------------------------------
* Agent Version method */
check_version(soap, url, clientVersion); check_version(soap, url, clientVersion);
/* End of Agent Version method }
/* End of Update option
*------------------------------------------------------------------------ *------------------------------------------------------------------------
* Availability method */ * Update option off */
else
{
/* Availability method */
availability(soap, url, inep, macAddr); availability(soap, url, inep, macAddr);
/* End of Availability method }
/* End of update option off
*------------------------------------------------------------------------ *------------------------------------------------------------------------
* Finalize execution */ * Finalize execution */
soap_end(soap); soap_end(soap);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment