Lei YU | 6520748 | 2019-10-11 16:39:36 +0800 | [diff] [blame^] | 1 | #include <cstdio> |
| 2 | #include <string> |
| 3 | #include <vector> |
| 4 | |
| 5 | // Get the version string for a PSU and output to stdout |
| 6 | // In this example, it just returns the last 8 bytes as the version |
| 7 | constexpr int NUM_OF_BYTES = 8; |
| 8 | |
| 9 | int main(int argc, char** argv) |
| 10 | { |
| 11 | if (argc < 2) |
| 12 | { |
| 13 | printf("Usage: %s versions...\n", argv[0]); |
| 14 | return 1; |
| 15 | } |
| 16 | |
| 17 | std::vector<std::string> versions(argv + 1, argv + argc); |
| 18 | std::string latest; |
| 19 | for (const auto& s : versions) |
| 20 | { |
| 21 | if (latest < s) |
| 22 | { |
| 23 | latest = s; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | printf("%s", latest.c_str()); |
| 28 | return 0; |
| 29 | } |