3-52
if ((regs.x.cflag & 0x01) == 1) return(-1);
else return(regs.x.ax);
}
3D Open file
The file must exist in the file table. This function returns the file handle.
Entry Parameters: AH = 3D
AL = 0 ; Read only
1 ; Write only
2 ; Both Read and Write
DS:DX = segment:offset of ASCIIZ file name
Returned Values: if successful : Carry = clear, AX = handle
if fail : Carry = set, AX = 2
When a file is opened, the file manager searches the file table for a file name
match. If a match is found, the corresponding file handle is returned. The
current pointer is reset to the beginning of the file, i.e. the current offset field
is set to zero.
int TS_open_file(char *fn,int mode)
{
regs.h.al=(unsigned char)mode;
segregs.ds = FP_SEG(fn);
regs.x.dx = FP_OFF(fn);
regs.h.ah=0x3D;
int86x(0x21,&regs,&regs,&segregs);
if ((regs.x.cflag & 0x01) == 1) return(-1);
else return(regs.x.ax);
}
3E Close file
Entry Parameters: AH = 3E
BX = file handle
Returned Values: Carry = clear ; OK
= set ; Failed
void TS_close_file(int hdl)
{
regs.h.ah= 0x3e;
regs.x.bx= hdl;
int86(0x21,&regs,&regs);
}