/* Support routines for ZSDOS/ZDDOS for BDS compiler. Version 0.1 9/28/89 Cameron W. Cotrill */ #include /* Return dos id (h)/version (l) of zs/zddos or 0 if not zs/zddos. Call this function and be sure it returns non-zero before using any of the routines in this module. */ int zsvers() { int i,j; if(bdos(12,0) != 0x22) return(0); /* screen out all but 2.2 compat */ i=bdos(48,0); j=i>>8; return((j == 'S' || j == 'D')? i : 0); } /* Read clock into 6 byte buffer in ZSDOS/DateStamper format. If no clock, returns 0's in the buffer. Caller can determine if time is valid by looking at the month. It will NEVER be 0 if the clock read was done properly. */ char *rdtd(buf) char *buf; { int i; bdos(6,0xfe); /* some clocks need a bios call first... */ if(bdos(98,buf) != 1) for(i=0;i<6;buf[i++]='\0'); return(buf); } /* Read file stamp. Return 1 if ok, else 0. */ int getfs(fcb,buffer) char *fcb, *buffer; { int i,dma; dma=bdos(47,0); /* save current dma */ bdos(26,buffer); /* set dma for stamp read */ logud(fcb); i=bdos(102,fcb); /* read the stamp */ bdos(26,dma); /* restore user dma */ return(i == 1 ? 1:0); /* how did we do? */ } /* Write file stamp. Return 1 if ok, else 0. */ int setfs(fcb,buffer) char *fcb, buffer; { int i,dma; dma=bdos(47,0); /* save current dma */ bdos(26,buffer); /* set dma */ logud(fcb); i=bdos(103,fcb); bdos(26,dma); /* restore user dma */ return(i == 1 ? 1:0); /* read stamp */ } /* Return ZSDOS flags to application */ int getflags() { return(bdos(100,0)); } /* Set ZSDOS flags */ void setflags(flags) int flags; { bdos(101,flags); } /* set drive [0..15] */ int setdrv(drive) int drive; { int i; i = bdos(14,drive); /* a,l may = 0xff if $$$.sub present */ return((i >> 8) ? FALSE : TRUE); /* so look at h for error code */ } /* Set user area */ void setusr(user) int user; { bdos(32,user); } /* Log drive and user from fcb. Assumes fcb parsed by zsetfcb() or any other fully z33 compliant parser. */ int logud(fcb) char *fcb; { int i,error; error = FALSE; if(i = *fcb) error = setdrv(--i); setusr(*(fcb+13)); return(error); }