@@ -37,6 +37,8 @@ limitations under the License.
3737#include " apib/apib_util.h"
3838#include " third_party/base64.h"
3939
40+ static const std::string kApibVersion = " 1.2" ;
41+
4042using apib::eqcase;
4143using apib::IOThread;
4244using apib::OAuthInfo;
@@ -74,7 +76,7 @@ static int SetHeaders = 0;
7476
7577static OAuthInfo *OAuth = nullptr ;
7678
77- static const char *const OPTIONS = " c:d:f:hk:t:u:vw:x:C:F:H:O:K:M:X:N:STVW:1 " ;
79+ static const char *const OPTIONS = " c:d:f:hk:t:u:vw:x:C:F:H:O:K:M:X:N:STVW:Z1 " ;
7880
7981static const struct option Options[] = {
8082 {" concurrency" , required_argument, NULL , ' c' },
@@ -85,6 +87,7 @@ static const struct option Options[] = {
8587 {" content-type" , required_argument, NULL , ' t' },
8688 {" username-password" , required_argument, NULL , ' u' },
8789 {" verbose" , no_argument, NULL , ' v' },
90+ {" version" , no_argument, NULL , ' Z' },
8891 {" warmup" , required_argument, NULL , ' w' },
8992 {" method" , required_argument, NULL , ' x' },
9093 {" cipherlist" , required_argument, NULL , ' C' },
@@ -113,6 +116,7 @@ static const char *const USAGE_DOCS =
113116 " -u --username-password Credentials for HTTP Basic authentication\n "
114117 " in username:password format\n "
115118 " -v --verbose Verbose output\n "
119+ " --version Version information\n "
116120 " -w --warmup Warm-up duration, in seconds (default 0)\n "
117121 " -x --method HTTP request method (default GET)\n "
118122 " -C --cipherlist Cipher list offered to server for HTTPS\n "
@@ -149,14 +153,17 @@ static void printUsage() {
149153}
150154
151155static void printLibraryInfo () {
152- cout << " Using Libev " << ev_version_major () << ' .' << ev_version_minor ()
153- << endl;
156+ cout << " apib " << kApibVersion << ' \n ' ;
157+ cout << " (git commit $Id$)\n " ;
158+ cout << " libev " << ev_version_major () << ' .' << ev_version_minor () << ' \n ' ;
154159 cout << " Supported backends: "
155- << IOThread::GetEvBackends (ev_supported_backends ()) << endl ;
160+ << IOThread::GetEvBackends (ev_supported_backends ()) << ' \n ' ;
156161 cout << " Recommended backends: "
157- << IOThread::GetEvBackends (ev_recommended_backends ()) << endl;
158- cout << " Using " << OpenSSL_version (OPENSSL_VERSION) << ' '
159- << OPENSSL_VERSION_TEXT << endl;
162+ << IOThread::GetEvBackends (ev_recommended_backends ()) << ' \n ' ;
163+ cout << " http_parser " << HTTP_PARSER_VERSION_MAJOR << ' .'
164+ << HTTP_PARSER_VERSION_MINOR << ' .' << HTTP_PARSER_VERSION_PATCH << ' \n ' ;
165+ cout << OpenSSL_version (OPENSSL_VERSION) << ' ' << OPENSSL_VERSION_TEXT
166+ << ' \n ' ;
160167}
161168
162169static int setProcessLimits (int numConnections) {
@@ -359,6 +366,7 @@ int main(int argc, char *const *argv) {
359366 int duration = DefaultDuration;
360367 int warmupTime = DefaultWarmup;
361368 bool doHelp = false ;
369+ bool doVersion = false ;
362370 std::string url;
363371 std::string monitorHost;
364372 std::string monitor2Host;
@@ -406,6 +414,9 @@ int main(int argc, char *const *argv) {
406414 case ' x' :
407415 Verb = optarg;
408416 break ;
417+ case ' Z' :
418+ doVersion = true ;
419+ break ;
409420 case ' C' :
410421 SslCipher = optarg;
411422 break ;
@@ -465,6 +476,14 @@ int main(int argc, char *const *argv) {
465476 }
466477 } while (arg >= 0 );
467478
479+ if (doHelp) {
480+ printUsage ();
481+ return 0 ;
482+ } else if (doVersion) {
483+ printLibraryInfo ();
484+ return 0 ;
485+ }
486+
468487 if (!failed && (optind == (argc - 1 ))) {
469488 url = argv[optind];
470489 } else {
@@ -475,9 +494,6 @@ int main(int argc, char *const *argv) {
475494 if (failed) {
476495 printUsage ();
477496 return 1 ;
478- } else if (doHelp) {
479- printUsage ();
480- return 0 ;
481497 }
482498
483499 if (!ContentType.empty ()) {
0 commit comments