system_.c 742 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* f77 interface to system routine */
  2. #include "f2c.h"
  3. #ifdef KR_headers
  4. extern char *F77_aloc();
  5. integer
  6. system_(s, n) register char *s; ftnlen n;
  7. #else
  8. #undef abs
  9. #undef min
  10. #undef max
  11. #include "stdlib.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. extern char *F77_aloc(ftnlen, const char*);
  16. integer
  17. system_(register char *s, ftnlen n)
  18. #endif
  19. {
  20. #if !defined(__IOS__)
  21. char buff0[256], *buff;
  22. register char *bp, *blast;
  23. integer rv;
  24. buff = bp = n < sizeof(buff0)
  25. ? buff0 : F77_aloc(n+1, "system_");
  26. blast = bp + n;
  27. while(bp < blast && *s)
  28. *bp++ = *s++;
  29. *bp = 0;
  30. rv = system(buff);
  31. if (buff != buff0)
  32. free(buff);
  33. return rv;
  34. #else
  35. // system() is not available on iOS
  36. return -1;
  37. #endif
  38. }
  39. #ifdef __cplusplus
  40. }
  41. #endif