2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 Miscellanous support functions.
9 #include <aros/debug.h>
11 #include <aros/atomic.h>
12 #include <dos/dostags.h>
15 #include "workbench_intern.h"
18 void __AddHiddenDevice(STRPTR name
, struct WorkbenchBase
*WorkbenchBase
)
20 /* Make sure we got valid pointers... */
21 if ((name
== NULL
) || (WorkbenchBase
== NULL
))
23 D(bug("Workbench/AddHiddenDevice: Got NULL pointers!\n"));
27 /* Only add the device name if it isn't already the list. */
28 if (FindName(&(WorkbenchBase
->wb_HiddenDevices
), name
) == NULL
)
30 struct Node
*deviceName
;
32 if ((deviceName
= AllocMem(sizeof(struct Node
), MEMF_ANY
| MEMF_CLEAR
)))
34 deviceName
->ln_Name
= name
;
35 AddTail(&(WorkbenchBase
->wb_HiddenDevices
), deviceName
);
37 /* FIXME: Notify WB App. Not here though. (We might want to use this
38 * onn startup for adding all hidden devices that was set in prefs,
39 * then unneccesery to notify app at each addition... */
44 void __RemoveHiddenDevice(STRPTR name
, struct WorkbenchBase
*WorkbenchBase
)
46 struct Node
*deviceName
;
48 /* Make sure we got valid pointers... */
49 if ((name
== NULL
) || (WorkbenchBase
== NULL
))
51 D(bug("Workbench/RemoveHiddenDevice: Got NULL pointers!\n"));
55 if ((deviceName
= FindName(&(WorkbenchBase
->wb_HiddenDevices
), name
)))
60 /* TODO: Notify WB App. Maybe not here...*/
64 STRPTR
__AllocateNameFromLock(BPTR lock
, struct WorkbenchBase
*WorkbenchBase
)
72 if (buffer
!= NULL
) FreeVec(buffer
);
74 buffer
= AllocVec(length
, MEMF_ANY
);
77 if (NameFromLock(lock
, buffer
, length
))
84 if (IoErr() == ERROR_LINE_TOO_LONG
)
97 SetIoErr(ERROR_NO_FREE_STORE
);
108 if (buffer
!= NULL
) FreeVec(buffer
);
113 STRPTR
__StrDup(CONST_STRPTR str
, struct WorkbenchBase
*WorkbenchBase
)
118 if (str
== NULL
) return NULL
;
121 dup
= AllocVec(len
+ 1, MEMF_PUBLIC
);
122 if (dup
!= NULL
) CopyMem(str
, dup
, len
+ 1);
127 BPTR
__DuplicateSearchPath(BPTR list
, struct WorkbenchBase
*WorkbenchBase
)
129 BPTR
*paths
, *current
= NULL
, *previous
= NULL
, first
= NULL
;
133 paths
= (BPTR
*) BADDR(list
);
135 paths
= (BPTR
*) BADDR(paths
[0]) /* next path */
138 if ((current
= (BPTR
*) AllocVec(2 * sizeof(BPTR
), MEMF_ANY
)) != NULL
)
141 current
[1] = DupLock(paths
[1]);
143 if (previous
!= NULL
) previous
[0] = (BPTR
) MKBADDR(current
);
144 else first
= (BPTR
) MKBADDR(current
);
157 VOID
__FreeSearchPath(BPTR list
, struct WorkbenchBase
*WorkbenchBase
)
159 BPTR
*current
= BADDR(list
);
161 while (current
!= NULL
)
163 BPTR
*next
= (BPTR
*) BADDR(current
[0]);