home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/tasks.h>
- #include <libraries/dosextens.h>
-
- typedef struct CommandLineInterface CLI;
- typedef struct Process PROC;
- typedef struct FileHandle HANDLE;
-
- long
- fexecv(cmd, argv)
- char *cmd, *argv[];
- {
- register CLI *cli;
- PROC *pp;
- PROC *FindTask();
- HANDLE *fhp;
- long sav, ret_val;
- union {
- long *lp;
- long ll;
- } path;
- long LoadSeg(), CurrentDir();
- char buf[128];
-
- /*
- * Make sure I'm running from the CLI.
- */
-
- pp = FindTask(0L);
- if ((cli = (CLI *)((long)pp->pr_CLI << 2)) == NULL) {
- return(-1);
- }
-
- /*
- * Search currentdir and "Path" for the cmd.
- */
-
- if (seg = LoadSeg(cmd))
- goto found;
-
- path.lp = (long *) cli->cli_CommandDir;
- while (path.ll) {
- path.ll <<= 2;
- sav = CurrentDir(path.lp[1]);
- seg = LoadSeg(cmd);
- CurrentDir(sav);
- if (seg)
- goto found;
- path.ll = *path.lp;
- }
-
- strcpy(buf, "c:");
- strcat(buf, cmd);
- if (seg = LoadSeg(buf))
- goto found;
- return(-1);
-
- found:
- ret_val = System0(cmd, seg, argv);
- UnLoadSeg(seg);
- return ret_val;
- }
-