-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfcbname.c
63 lines (55 loc) · 1.36 KB
/
fcbname.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <cpm.h>
#include <string.h>
/*
* char * fcbname(i);
* short i;
*
* Returns a character string which is the name of the file currently
* open on file descriptor i. The name is extracted from the corresponding
* fcb.
*/
char *fcbname(short i)
{
register struct fcb *fc;
static char abuf[20];
register char *cp, *xp;
fc = &_fcb[i];
switch(fc->use)
{
case U_CON:
return "CON:";
case U_RDR:
if ((bdos(CPMVERS)&0xFF) < 0x30)
return "RDR:";
else
return "AUXIN:";
case U_PUN:
if ((bdos(CPMVERS)&0xFF) < 0x30)
return "PUN:";
else
return "AUXOUT:";
case U_LST:
return "LST:";
case U_READ:
case U_WRITE:
case U_RDWR:
cp = abuf;
if (fc->dr)
*cp++ = 'A' + fc->dr - 1;
sprintf(cp, "%d:", fc->uid);
cp += strlen(cp);
for (xp = fc->name ; *xp > ' ' && xp < fc->name+sizeof fc->name;)
*cp++ = (*xp++) & 0x7F;
*cp++ = '.';
for (xp = fc->ft ; *xp > ' ' && xp < fc->ft+sizeof fc->ft ;)
*cp++ = (*xp++) & 0x7F;
*cp = 0;
return abuf;
case U_RSX:
return "RSX:";
case U_ERR:
return "ERR:";
default:
return (char *)0;
}
}