diff --git a/src/client.c b/src/client.c index 228f3df2054cae84b644898fbb5d8e06ff107495..ccbc153a8bdd7e9a04be2fae2bc21c0e93ed71f2 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);