home *** CD-ROM | disk | FTP | other *** search
-
- /*************************************************************/
- /* NeonSoft (C) 06-04-'88 */
- /* moredos.c */
- /*************************************************************/
-
- #include <exec/types.h>
- #include <libraries/dosextens.h>
- #include "hh:moredos.h"
- #include <ctype.h>
-
-
- static BOOL
- devcmp(nstr,bstr)
- TEXT *nstr;
- BPTR *bstr;
- {
- TEXT *bptr = BADDR(bstr);
- UCOUNT blen = *(TEXT *)bptr, nlen = 0;
-
- bptr++;
- while (nlen<blen && ((isalpha(*nstr))?(_toupper(*nstr)):(*nstr))==*bptr) {
- nstr++; bptr++; nlen++;
- }
- return(((!*nstr) || (*nstr==':' && !nstr[1])) && nlen==blen);
- }
-
- BPTR
- FindDevice(Entry,Name)
- BPTR Entry;
- TEXT (*Name)[];
- {
- BOOL found = FALSE;
- struct DeviceList *dl = BADDR(Entry);
-
- Forbid();
- while (dl && !found) {
- if (devcmp(Name,dl->dl_Name)) {
- found = TRUE;
- } else {
- dl = BADDR((dl->dl_Next));
- }
- }
- Permit();
- return((found)?(NADDR(dl)):(NULL));
- }
-
- BPTR
- RemoveDevice(Entry,Device)
- BPTR *Entry;
- BPTR Device;
- {
- BOOL found = FALSE;
- struct DeviceList *dl = BADDR(Device);
- struct DeviceList *pl = BADDR((*Entry));
-
- Forbid();
- if (pl==dl) {
- *Entry = dl->dl_Next;
- found = TRUE;
- } else {
- while (pl->dl_Next && !found) {
- if (pl->dl_Next==Device) {
- pl->dl_Next = dl->dl_Next;
- found = TRUE;
- } else {
- pl = BADDR((pl->dl_Next));
- }
- }
- }
- if (found) {
- dl->dl_Next = NULL;
- }
- Permit();
- return((found)?(Device):(NULL));
- }
-
- VOID
- InsertDevice(Entry,Device)
- BPTR *Entry;
- BPTR Device;
- {
- struct DeviceList *dl = BADDR(Device);
-
- Forbid();
- if (dl) {
- dl->dl_Next = *Entry;
- *Entry = Device;
- }
- Permit();
- }
-
-
-