From 443737834c6ee26c5e2c5df1c996ce155ac12c5b Mon Sep 17 00:00:00 2001 From: ERIK ALEXANDRE PUCCI <eap08@c3sl.ufpr.br> Date: Thu, 4 Feb 2010 10:06:37 -0200 Subject: [PATCH] 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: ERIK ALEXANDRE PUCCI <eap08@c3sl.ufpr.br> Acked-by: Bruno Ribas <ribas@c3sl.ufpr.br> Acked-by: Diego Giovane Pasqualin <dgp06@c3sl.ufpr.br> Signed-off-by: Danilo K. S. Yorinori <danilok@c3sl.ufpr.br> --- src/client.c | 64 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/src/client.c b/src/client.c index 228f3df..ccbc153 100644 --- a/src/client.c +++ b/src/client.c @@ -35,39 +35,42 @@ int main(int argc, char **argv) { struct soap *soap = soap_new(); char *url, *inep, *macAddr, *basedir, *clientVersion; - int arglen, len; + int arglen, len, update = 0; /* Initialization * *----------------------------------------------------------------------- * 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, "Usage: client url INEP MacAddress [proxy_host "); - fprintf(stderr, "[proxy_port [proxy_userid proxy_passwd]]]\n"); + fprintf(stderr, "Usage: client [--update] url INEP MacAddress "); + 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 */ exit(1); } /* Set parameters passed by user * Basic information */ - url = argv[1]; - inep = argv[2]; - macAddr = argv[3]; + url = argv[1 + update]; + inep = argv[2 + update]; + macAddr = argv[3 + update]; /* 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_passwd = argv[7]; + soap->proxy_userid = argv[6 + update]; + soap->proxy_passwd = argv[7 + update]; } /* Get basedir */ @@ -81,22 +84,29 @@ int main(int argc, char **argv) printf("Arg: %s basedir: %s\n", argv[0], basedir); } - /* Get client version from file */ - if ( ! (clientVersion = read_version_file(basedir)) ) - { - /* Error when open version file */ - exit(3); - } - /* End of Initialization *----------------------------------------------------------------------- - * Agent Version method */ - check_version(soap, url, clientVersion); - /* End of Agent Version method + * Update option */ + if (update) + { + /* Get client version from file */ + if ( ! (clientVersion = read_version_file(basedir)) ) + { + /* Error when open version file */ + exit(3); + } + /* Agent Version method */ + check_version(soap, url, clientVersion); + } + /* End of Update option *------------------------------------------------------------------------ - * Availability method */ - availability(soap, url, inep, macAddr); - /* End of Availability method + * Update option off */ + else + { + /* Availability method */ + availability(soap, url, inep, macAddr); + } + /* End of update option off *------------------------------------------------------------------------ * Finalize execution */ soap_end(soap); -- GitLab