pseudo_emulator_custom_command.c 823 B

12345678910111213141516171819202122232425262728293031
  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. return EXIT_FAILURE;
  19. }
  20. if (strstr(str, substring_success) != 0) {
  21. return EXIT_SUCCESS;
  22. }
  23. if (strstr(str, substring_failure) != 0) {
  24. return EXIT_FAILURE;
  25. }
  26. fprintf(stderr, "Failed to find string '%s' in '%s'\n", substring_success,
  27. str);
  28. return EXIT_FAILURE;
  29. }