home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / SMALL_C / CTELL.C < prev    next >
Text File  |  1980-01-01  |  1KB  |  48 lines

  1. #define NOCCARGC  /* no arg count passing */
  2. #include stdio.h
  3. #include clib.def
  4. /*
  5. ** Return offset to current location in file
  6. ** tell() returns ERR if some error occured, (EOF) for
  7. ** non-file devices, 0 otherwise.
  8. ** offset is returned in offstlo & offsthi such that
  9. ** true offset = offsthi>>16 + offstlo
  10. */
  11. extern int Ufd[];
  12. tell(fd,offstlo,offsthi) int fd, *offstlo, *offsthi; {
  13.   if(!Umode(fd) || isatty(fd)) return (EOF);
  14.   return (utell(offstlo,offsthi,Ufd[fd]));
  15.   }
  16.  
  17. /* 
  18. ** MSDOS low-level routine for tell
  19. */
  20. utell(offstlo,offsthi,pfd) int pfd,*offstlo,*offsthi; {
  21. #asm
  22.   POP SI  ;Return address
  23.   POP BX  ;Handle
  24.   PUSH BX ;Restore
  25.   PUSH SI
  26.   XOR DX,DX ;Zero in DX
  27. ; Move file pointer 0 from current location
  28. ; this will return current location in DX:AX
  29.   MOV AX,4201H
  30.   INT 21H
  31.   JC UTELLC1  ;Jump if error
  32.   MOV BP,SP   ;Get SP
  33.   MOV SI,[BP+6] ;offset lo
  34.   MOV [SI],AX   ;move it in
  35.   MOV SI,[BP+4] ;Offset hi
  36.   MOV [SI],DX   ;Move it in
  37.   XOR AX,AX     ;Return no error
  38.   JMP UTELLC2
  39.  UTELLC1: 
  40.   MOV _ERRNO,AX  ;Return error
  41.   MOV AX,-2
  42.  UTELLC2:
  43.   MOV BX,AX
  44.   XOR CX,CX     ;Zero in CX
  45.   EXTRN _ERRNO:WORD
  46. #endasm
  47. }
  48.