home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * PATH.C
- *
- * (c)Copyright 1990, Matthew Dillon, All Rights Reserved
- *
- * Search the path for a command name
- */
-
- #include <exec/types.h>
- #include <exec/execbase.h>
- #include <libraries/dos.h>
- #include <libraries/dosextens.h>
- #include <stdio.h>
- #include <lib/bcpl.h>
-
- typedef struct CommandLineInterface CLI;
- typedef struct Process Process;
-
- typedef struct LockList {
- BPTR NextPath;
- BPTR PathLock;
- } LockList;
-
- extern struct ExecBase *SysBase;
-
- BPTR
- _SearchPath(cmd)
- char *cmd;
- {
- CLI *cli = BTOC(((Process *)SysBase->ThisTask)->pr_CLI, CLI);
- LockList *ll = BTOC(cli->cli_CommandDir, LockList);
-
- while (ll) {
- if (ll->PathLock) {
- long oldLock = CurrentDir(ll->PathLock);
- long lock;
-
- if (lock = Lock(cmd, SHARED_LOCK)) {
- UnLock(lock);
- CurrentDir(oldLock);
- return(ll->PathLock);
- }
- CurrentDir(oldLock);
- }
- ll = BTOC(ll->NextPath, LockList);
- }
- return(NULL);
- }
-
-
-