Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 1 | #include "ikvm_args.hpp" |
| 2 | |
| 3 | #include <getopt.h> |
| 4 | #include <rfb/rfb.h> |
| 5 | #include <stdio.h> |
| 6 | #include <stdlib.h> |
| 7 | |
| 8 | namespace ikvm |
| 9 | { |
| 10 | |
| 11 | Args::Args(int argc, char* argv[]) : frameRate(30), commandLine(argc, argv) |
| 12 | { |
| 13 | int option; |
| 14 | const char* opts = "f:hi:v:"; |
| 15 | struct option lopts[] = {{"frameRate", 1, 0, 'f'}, |
| 16 | {"help", 0, 0, 'h'}, |
| 17 | {"input", 1, 0, 'i'}, |
| 18 | {"videoDevice", 1, 0, 'v'}, |
| 19 | {0, 0, 0, 0}}; |
| 20 | |
| 21 | while ((option = getopt_long(argc, argv, opts, lopts, NULL)) != -1) |
| 22 | { |
| 23 | switch (option) |
| 24 | { |
| 25 | case 'f': |
| 26 | frameRate = (int)strtol(optarg, NULL, 0); |
| 27 | if (frameRate < 0 || frameRate > 60) |
| 28 | frameRate = 30; |
| 29 | break; |
| 30 | case 'h': |
| 31 | printUsage(); |
| 32 | exit(0); |
| 33 | case 'i': |
| 34 | inputPath = std::string(optarg); |
| 35 | break; |
| 36 | case 'v': |
| 37 | videoPath = std::string(optarg); |
| 38 | break; |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | void Args::printUsage() |
| 44 | { |
| 45 | // use fprintf(stderr to match rfbUsage() |
| 46 | fprintf(stderr, "OpenBMC IKVM daemon\n"); |
| 47 | fprintf(stderr, "Usage: obmc-ikvm [options]\n"); |
| 48 | fprintf(stderr, "-f frame rate try this frame rate\n"); |
| 49 | fprintf(stderr, "-h, --help show this message and exit\n"); |
| 50 | fprintf(stderr, "-i device HID gadget device\n"); |
| 51 | fprintf(stderr, "-v device V4L2 device\n"); |
| 52 | rfbUsage(); |
| 53 | } |
| 54 | |
| 55 | } // namespace ikvm |