system_.c 652 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. char buff0[256], *buff;
  21. register char *bp, *blast;
  22. integer rv;
  23. buff = bp = n < sizeof(buff0)
  24. ? buff0 : F77_aloc(n+1, "system_");
  25. blast = bp + n;
  26. while(bp < blast && *s)
  27. *bp++ = *s++;
  28. *bp = 0;
  29. rv = system(buff);
  30. if (buff != buff0)
  31. free(buff);
  32. return rv;
  33. }
  34. #ifdef __cplusplus
  35. }
  36. #endif