diff options
Diffstat (limited to 'config/src')
-rw-r--r-- | config/src/apps/vespa-configproxy-cmd/main.cpp | 21 | ||||
-rw-r--r-- | config/src/apps/vespa-get-config/getconfig.cpp | 27 | ||||
-rw-r--r-- | config/src/apps/vespa-ping-configproxy/pingproxy.cpp | 11 |
3 files changed, 28 insertions, 31 deletions
diff --git a/config/src/apps/vespa-configproxy-cmd/main.cpp b/config/src/apps/vespa-configproxy-cmd/main.cpp index ec5d2167a72..2af645b9351 100644 --- a/config/src/apps/vespa-configproxy-cmd/main.cpp +++ b/config/src/apps/vespa-configproxy-cmd/main.cpp @@ -4,6 +4,7 @@ #include "methods.h" #include <vespa/fastos/app.h> #include <iostream> +#include <unistd.h> class Application : public FastOS_Application { @@ -20,18 +21,16 @@ bool Application::parseOpts() { int c = '?'; - const char *optArg = NULL; - int optInd = 0; - while ((c = GetOpt("m:s:p:h", optArg, optInd)) != -1) { + while ((c = getopt(_argc, _argv, "m:s:p:h")) != -1) { switch (c) { case 'm': - _flags.method = optArg; + _flags.method = optarg; break; case 's': - _flags.targethost = optArg; + _flags.targethost = optarg; break; case 'p': - _flags.portnumber = atoi(optArg); + _flags.portnumber = atoi(optarg); break; case 'h': default: @@ -39,18 +38,18 @@ Application::parseOpts() } } const Method method = methods::find(_flags.method); - if (optInd + method.args <= _argc) { + if (optind + method.args <= _argc) { for (int i = 0; i < method.args; ++i) { - vespalib::string arg = _argv[optInd++]; + vespalib::string arg = _argv[optind++]; _flags.args.push_back(arg); } } else { std::cerr << "ERROR: method "<< _flags.method << " requires " << method.args - << " arguments, only got " << (_argc - optInd) << std::endl; + << " arguments, only got " << (_argc - optind) << std::endl; return false; } - if (optInd != _argc) { - std::cerr << "ERROR: "<<(_argc - optInd)<<" extra arguments\n"; + if (optind != _argc) { + std::cerr << "ERROR: "<<(_argc - optind)<<" extra arguments\n"; return false; } _flags.method = method.rpcMethod; diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp index 5c681d09526..e62521d8db1 100644 --- a/config/src/apps/vespa-get-config/getconfig.cpp +++ b/config/src/apps/vespa-get-config/getconfig.cpp @@ -12,6 +12,7 @@ #include <vespa/config/common/configresponse.h> #include <vespa/config/common/trace.h> #include <vespa/fastos/app.h> +#include <unistd.h> #include <sstream> #include <fstream> @@ -117,24 +118,22 @@ GetConfig::Main() int serverPort = 19090; - const char *optArg = nullptr; - int optInd = 0; - while ((c = GetOpt("a:n:v:g:i:jlm:c:t:V:w:r:s:p:dh", optArg, optInd)) != -1) { + while ((c = getopt(_argc, _argv, "a:n:v:g:i:jlm:c:t:V:w:r:s:p:dh")) != -1) { int retval = 1; switch (c) { case 'a': - schemaString = optArg; + schemaString = optarg; break; case 'n': - defName = optArg; + defName = optarg; break; case 'v': break; case 'g': - generation = atoll(optArg); + generation = atoll(optarg); break; case 'i': - configId = optArg; + configId = optarg; break; case 'j': printAsJson = true; @@ -143,25 +142,25 @@ GetConfig::Main() printAsJson = false; break; case 'm': - defMD5 = optArg; + defMD5 = optarg; break; case 't': - serverTimeout = vespalib::from_s(atof(optArg)); + serverTimeout = vespalib::from_s(atof(optarg)); break; case 'w': - clientTimeout = vespalib::from_s(atof(optArg)); + clientTimeout = vespalib::from_s(atof(optarg)); break; case 'r': - traceLevel = atoi(optArg); + traceLevel = atoi(optarg); break; case 'V': - vespaVersionString = optArg; + vespaVersionString = optarg; break; case 's': - serverHost = optArg; + serverHost = optarg; break; case 'p': - serverPort = atoi(optArg); + serverPort = atoi(optarg); break; case 'd': debugging = true; diff --git a/config/src/apps/vespa-ping-configproxy/pingproxy.cpp b/config/src/apps/vespa-ping-configproxy/pingproxy.cpp index 3d3e3081108..92d07b743f5 100644 --- a/config/src/apps/vespa-ping-configproxy/pingproxy.cpp +++ b/config/src/apps/vespa-ping-configproxy/pingproxy.cpp @@ -4,6 +4,7 @@ #include <vespa/fnet/frt/target.h> #include <vespa/fnet/frt/rpcrequest.h> #include <vespa/fastos/app.h> +#include <unistd.h> #include <sstream> @@ -76,18 +77,16 @@ PingProxy::Main() int clientTimeout = 5; int serverPort = 19090; - const char *optArg = nullptr; - int optInd = 0; - while ((c = GetOpt("w:s:p:dh", optArg, optInd)) != -1) { + while ((c = getopt(_argc, _argv, "w:s:p:dh")) != -1) { switch (c) { case 'w': - clientTimeout = atoi(optArg); + clientTimeout = atoi(optarg); break; case 's': - serverHost = optArg; + serverHost = optarg; break; case 'p': - serverPort = atoi(optArg); + serverPort = atoi(optarg); break; case 'd': debugging = true; |