pseudo_emulator_custom_command.c 841 B

12345678910111213141516171819202122232425262728293031323334
  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 'generated_exe_emulator_expected'
  9. // string was found in <arg1>.
  10. // Return EXIT_FAILURE if 'generated_exe_emulator_unexpected'
  11. // string was found in <arg1>.
  12. int main(int argc, const char* argv[])
  13. {
  14. const char* substring_failure = "generated_exe_emulator_unexpected";
  15. const char* substring_success = "generated_exe_emulator_expected";
  16. const char* str = argv[1];
  17. if (argc < 2)
  18. {
  19. return EXIT_FAILURE;
  20. }
  21. if (strstr(str, substring_success) != 0)
  22. {
  23. return EXIT_SUCCESS;
  24. }
  25. if (strstr(str, substring_failure) != 0)
  26. {
  27. return EXIT_FAILURE;
  28. }
  29. fprintf(stderr, "Failed to find string '%s' in '%s'\n",
  30. substring_success, str);
  31. return EXIT_FAILURE;
  32. }