use the toolchain names for the commands
[AROS.git] / rom / dos / packethelper.c
blobfeea9d24415ff92753cfeb823cff5f7808821c2b
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <aros/debug.h>
10 #include <proto/dos.h>
11 #include <proto/exec.h>
13 #include <string.h>
15 #include "dos_intern.h"
17 BOOL getpacketinfo(struct DosLibrary *DOSBase, CONST_STRPTR name, struct PacketHelperStruct *phs)
19 if (!strchr(name, ':'))
21 /* no ":" */
22 struct Process *me = (struct Process *)FindTask(NULL);
23 BPTR cur;
24 BSTR bstrname = C2BSTR(name);
25 struct FileLock *fl;
27 ASSERT_VALID_PROCESS(me);
29 cur = me->pr_CurrentDir;
30 if (cur && cur != (BPTR)-1) {
31 fl = BADDR(cur);
32 phs->port = fl->fl_Task;
33 phs->lock = cur;
34 } else {
35 phs->port = DOSBase->dl_Root->rn_BootProc;
36 phs->lock = BNULL;
38 phs->dp = NULL;
39 phs->name = bstrname;
40 return TRUE;
41 } else { /* ":" */
42 BSTR bstrname = C2BSTR(name);
43 struct DevProc *dvp = NULL;
44 if ((dvp = GetDeviceProc(name, dvp))) {
45 phs->name = bstrname;
46 phs->port = dvp->dvp_Port;
47 phs->lock = dvp->dvp_Lock;
48 phs->dp = dvp;
49 return TRUE;
52 return FALSE;
55 BOOL getdevpacketinfo(struct DosLibrary *DOSBase, CONST_STRPTR devname, CONST_STRPTR name, struct PacketHelperStruct *phs)
57 if ((phs->dp = GetDeviceProc(devname, NULL)) == NULL)
58 return DOSFALSE;
59 /* we're only interested in real devices */
60 if (phs->dp->dvp_DevNode == NULL ||
61 phs->dp->dvp_DevNode->dol_Type != DLT_DEVICE) {
62 FreeDeviceProc(phs->dp);
63 SetIoErr(ERROR_DEVICE_NOT_MOUNTED);
64 return DOSFALSE;
66 phs->port = phs->dp->dvp_Port;
67 phs->lock = BNULL;
68 phs->name = BNULL;
69 if (!name)
70 return TRUE;
71 phs->name = C2BSTR(name);
72 if (!phs->name) {
73 FreeDeviceProc(phs->dp);
74 SetIoErr(ERROR_NO_FREE_STORE);
75 return DOSFALSE;
77 return TRUE;
80 void freepacketinfo(struct DosLibrary *DOSBase, struct PacketHelperStruct *phs)
82 if (phs->dp)
83 FreeDeviceProc(phs->dp);
84 FREEC2BSTR(phs->name);