pseudo_emulator_custom_command_arg.c 858 B

123456789101112131415161718192021222324252627282930
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. // Usage:
  5. //
  6. // /path/to/program arg1 [arg2 [...]]
  7. //
  8. // Return EXIT_SUCCESS if 'custom_argument' string was found
  9. // in <arg1> and 'generated_exe_emulator_expected'
  10. // string was found in <arg2>
  11. // Return EXIT_FAILURE if 'custom_argument' string was not
  12. // found in <arg1> or 'generated_exe_emulator_expected'
  13. // string was not found in <arg2>.
  14. int main(int argc, const char* argv[])
  15. {
  16. // Require a slash to make sure it is a path and not a target name.
  17. const char* substring_success = "/generated_exe_emulator_expected";
  18. const char* substring_custom_argument = "custom_argument";
  19. if (argc < 2) {
  20. return EXIT_FAILURE;
  21. }
  22. if (strstr(argv[1], substring_custom_argument) != 0 &&
  23. strstr(argv[2], substring_success) != 0) {
  24. return EXIT_SUCCESS;
  25. }
  26. return EXIT_FAILURE;
  27. }