BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
blitzdos.h
Go to the documentation of this file.
1/*
2 * blitzdos.h - dos.library helpers from library code.
3 *
4 * bl_finddosentry_v34 look up a DOS list entry below dos.library V36
5 *
6 * Only what several libraries need; anything specific to one library
7 * stays in its source.
8 */
9#ifndef BLITZDOS_H
10#define BLITZDOS_H
11
12#include <exec/types.h>
13#include <dos/dos.h>
14#include <dos/dosextens.h>
15
16/* the character in upper case as utility.library's ToUpper: a-z and the
17 Latin-1 letters $E0-$FE except $F7 */
18static inline UBYTE bl_dosupper(UBYTE c)
19{
20 if ((c >= 'a' && c <= 'z') || (c >= 0xe0 && c <= 0xfe && c != 0xf7))
21 c -= 0x20;
22 return c;
23}
24
25/* bl_finddosentry_v34(dos, name, flags) - the entry of the DOS device
26 list named `name` (without ":", compared without case) whose type
27 `flags` asks for: LDF_DEVICES for DLT_DEVICE, LDF_VOLUMES for
28 DLT_VOLUME, LDF_ASSIGNS for the assigns (DLT_DIRECTORY, DLT_LATE,
29 DLT_NONBINDING), as FindDosEntry; NULL if there is none.
30 For dos.library below V36, which has no LockDosList: the list is
31 walked from DosInfo (dl_Root->rn_Info->di_DevInfo). The caller holds
32 Forbid for the walk and for every read of the entry, as programs did
33 before LockDosList existed. */
34static inline struct DosList *bl_finddosentry_v34(const struct DosLibrary *dos,
35 const UBYTE *name, ULONG flags)
36{
37 const struct DosInfo *di =
38 (const struct DosInfo *)BADDR(dos->dl_Root->rn_Info);
39 struct DosList *dl = (struct DosList *)BADDR(di->di_DevInfo);
40
41 for (; dl; dl = (struct DosList *)BADDR(dl->dol_Next)) {
42 ULONG want = dl->dol_Type == DLT_DEVICE ? LDF_DEVICES
43 : dl->dol_Type == DLT_VOLUME ? LDF_VOLUMES : LDF_ASSIGNS;
44 const UBYTE *b = (const UBYTE *)BADDR(dl->dol_Name);
45 const UBYTE *n = name;
46 ULONG len, i;
47
48 if (!(flags & want) || !b)
49 continue;
50 len = *b++;
51 for (i = 0; i < len && n[i]; i++)
52 if (bl_dosupper(b[i]) != bl_dosupper(n[i]))
53 break;
54 if (i == len && !n[i])
55 return dl;
56 }
57 return NULL;
58}
59
60#endif
UBYTE flags[2]
Definition 2dlib.c:297
ULONG WORD UWORD c
Definition 2dlib.c:2491
ULONG WORD UWORD UWORD border ULONG ULONG struct bb_bitmap *dst void UWORD n
Definition 2dlib.c:2498
ULONG len
Definition asllib.c:158
char * name
Definition asllib.c:150
static struct DosList * bl_finddosentry_v34(const struct DosLibrary *dos, const UBYTE *name, ULONG flags)
Definition blitzdos.h:34
static UBYTE bl_dosupper(UBYTE c)
Definition blitzdos.h:18
static struct @221055206046115340034120160022264336056254327304 dl