pseudo_emulator_custom_command.c 894 B

1234567891011121314151617181920212223242526272829303132
  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. // Require a slash to make sure it is a path and not a target name.
  16. const char* substring_success = "/generated_exe_emulator_expected";
  17. const char* str = argv[1];
  18. if (argc < 2) {
  19. return EXIT_FAILURE;
  20. }
  21. if (strstr(str, substring_success) != 0) {
  22. return EXIT_SUCCESS;
  23. }
  24. if (strstr(str, substring_failure) != 0) {
  25. return EXIT_FAILURE;
  26. }
  27. fprintf(stderr, "Failed to find string '%s' in '%s'\n", substring_success,
  28. str);
  29. return EXIT_FAILURE;
  30. }