home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / execp.c < prev    next >
C/C++ Source or Header  |  1993-05-25  |  1KB  |  53 lines

  1. /*
  2.     execxxx stuff for MiNT/TOS; written by Eric R. Smith, and
  3.     placed in the public domain
  4.  
  5.     uo, 3.5.93: replaced findfile -> buffindfile (no static buffer
  6.         anymore)
  7. */
  8.  
  9. #include <stdarg.h>
  10. #include <process.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <errno.h>
  14. #include <unistd.h>
  15. #include <limits.h>
  16. #include <support.h>
  17.  
  18. /* execvp, execlp: try to execute a program on the default system
  19.    execution path. WARNING: the current directory is always searched
  20.    first.
  21. */
  22.  
  23. static char *extensions[] = { "ttp", "prg", "tos", NULL };
  24.  
  25. #ifdef __STDC__
  26. int execvp(char *name, char **argv)
  27. #else
  28. int execvp(name, argv) char *name; char **argv;
  29. #endif
  30. {
  31.     char *execname;
  32.     char buffer[PATH_MAX];
  33.     execname = buffindfile(name, getenv("PATH"), extensions,buffer);
  34.     if (!execname) {
  35.         errno = ENOENT;
  36.         return -1;        /* file not found */
  37.     }
  38.     return _spawnve(P_OVERLAY, execname, argv, (char **)NULL);
  39. }
  40.  
  41. #ifdef __STDC__
  42. int execlp(char *name, ...)
  43. #else
  44. int execlp(name)
  45.     char    *name;
  46. #endif
  47. {
  48.     va_list args;
  49.  
  50.     va_start(args, name);
  51.     return execvp(name, (char **)args);
  52. }
  53.