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