| 28 | static bool l_Debug; |
| 29 | |
| 30 | static int parseArguments(int ac, WCHAR **av, po::variables_map& vm, printInfoStruct& printInfo) |
| 31 | { |
| 32 | WCHAR namePath[MAX_PATH]; |
| 33 | GetModuleFileName(NULL, namePath, MAX_PATH); |
| 34 | WCHAR *progName = PathFindFileName(namePath); |
| 35 | |
| 36 | po::options_description desc; |
| 37 | |
| 38 | desc.add_options() |
| 39 | ("help,h", "Print help message and exit") |
| 40 | ("version,V", "Print version and exit") |
| 41 | ("debug,d", "Verbose/Debug output") |
| 42 | ("warning,w", po::value<int>(), "Number of updates to trigger a warning.") |
| 43 | ("critical,c", po::value<int>(), "Number of updates to trigger a critical.") |
| 44 | ("possible-reboot", "Treat \"update may need reboot\" as \"update needs reboot\"") |
| 45 | ("no-reboot-critical", "Do not automatically return critical if an update requiring reboot is present.") |
| 46 | ; |
| 47 | |
| 48 | po::wcommand_line_parser parser(ac, av); |
| 49 | |
| 50 | try { |
| 51 | po::store( |
| 52 | parser |
| 53 | .options(desc) |
| 54 | .style( |
| 55 | po::command_line_style::unix_style | |
| 56 | po::command_line_style::allow_long_disguise) |
| 57 | .run(), |
| 58 | vm); |
| 59 | vm.notify(); |
| 60 | } catch (const std::exception& e) { |
| 61 | std::cout << e.what() << '\n' << desc << '\n'; |
| 62 | return 3; |
| 63 | } |
| 64 | |
| 65 | if (vm.count("help")) { |
| 66 | std::wcout << progName << " Help\n\tVersion: " << VERSION << '\n'; |
| 67 | wprintf( |
| 68 | L"%s is a simple program to check a machines required updates.\n" |
| 69 | L"You can use the following options to define its behaviour:\n\n", progName); |
| 70 | std::cout << desc; |
| 71 | wprintf( |
| 72 | L"\nAfter some time, it will then output a string like this one:\n\n" |
| 73 | L"\tUPDATE WARNING 8 | updates=8;1;1;0\n\n" |
| 74 | L"\"UPDATE\" being the type of the check, \"WARNING\" the returned status\n" |
| 75 | L"and \"8\" is the number of important updates.\n" |
| 76 | L"The performance data is found behind the \"|\", in order:\n" |
| 77 | L"returned value, warning threshold, critical threshold, minimal value and,\n" |
| 78 | L"if applicable, the maximal value.\n\n" |
| 79 | L"An update counts as important when it is part of the Security- or\n" |
| 80 | L"CriticalUpdates group.\n" |
| 81 | L"Consult the msdn on WSUS Classification GUIDs for more information.\n" |
| 82 | L"%s' exit codes denote the following:\n" |
| 83 | L" 0\tOK,\n\tNo Thresholds were broken or the programs check part was not executed\n" |
| 84 | L" 1\tWARNING,\n\tThe warning, but not the critical threshold was broken\n" |
| 85 | L" 2\tCRITICAL,\n\tThe critical threshold was broken or an update required reboot.\n" |
| 86 | L" 3\tUNKNOWN, \n\tThe program experienced an internal or input error\n\n" |
| 87 | L"If a warning threshold is set but not a critical threshold, the critical\n" |