Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2014, Google Inc. |
| 2 | * |
| 3 | * Permission to use, copy, modify, and/or distribute this software for any |
| 4 | * purpose with or without fee is hereby granted, provided that the above |
| 5 | * copyright notice and this permission notice appear in all copies. |
| 6 | * |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 14 | |
| 15 | #include <string> |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 16 | #include <vector> |
| 17 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 18 | #include <openssl/err.h> |
Adam Langley | aacec17 | 2014-06-20 12:00:00 -0700 | [diff] [blame^] | 19 | #include <openssl/ssl.h> |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 20 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 21 | |
Adam Langley | c5c0c7e | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 22 | bool Speed(const std::vector<std::string> &args); |
Adam Langley | aacec17 | 2014-06-20 12:00:00 -0700 | [diff] [blame^] | 23 | bool Client(const std::vector<std::string> &args); |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 24 | |
Adam Langley | c5c0c7e | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 25 | static void usage(const char *name) { |
Adam Langley | aacec17 | 2014-06-20 12:00:00 -0700 | [diff] [blame^] | 26 | printf("Usage: %s [speed|client]\n", name); |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | int main(int argc, char **argv) { |
| 30 | std::string tool; |
| 31 | if (argc >= 2) { |
| 32 | tool = argv[1]; |
| 33 | } |
| 34 | |
Adam Langley | aacec17 | 2014-06-20 12:00:00 -0700 | [diff] [blame^] | 35 | SSL_library_init(); |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 36 | |
| 37 | std::vector<std::string> args; |
| 38 | for (int i = 2; i < argc; i++) { |
| 39 | args.push_back(argv[i]); |
| 40 | } |
| 41 | |
| 42 | if (tool == "speed") { |
| 43 | return !Speed(args); |
Adam Langley | aacec17 | 2014-06-20 12:00:00 -0700 | [diff] [blame^] | 44 | } else if (tool == "s_client" || tool == "client") { |
| 45 | return !Client(args); |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 46 | } else { |
| 47 | usage(argv[0]); |
| 48 | return 1; |
| 49 | } |
| 50 | } |