blob: c0e3033309def498804a385b4ea68a98e9f2d57c [file] [log] [blame]
Lei YU5f3584d2019-08-27 16:28:53 +08001#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
6constexpr int NUM_OF_BYTES = 8;
7
8int 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}