Lines Matching refs:iop

391 isseekable(FILE *iop)  in isseekable()  argument
402 fd = _get_fd(iop); in isseekable()
412 SET_SEEKABLE(iop); in isseekable()
425 CLEAR_SEEKABLE(iop); in isseekable()
427 SET_SEEKABLE(iop); in isseekable()
435 _setbufend(FILE *iop, Uchar *end) /* set the end pointer for this iop */ in _setbufend() argument
437 iop->_end = end; in _setbufend()
439 isseekable(iop); in _setbufend()
445 _realbufend(FILE *iop) /* get the end pointer for this iop */ in _realbufend() argument
447 return (iop->_end); in _realbufend()
464 getxfdat(FILE *iop) in getxfdat() argument
466 if (STDIOP(iop)) in getxfdat()
467 return (&_xftab[IOPIND(iop)]); in getxfdat()
468 else if (VALIDXFILE(FILEx(iop))) in getxfdat()
469 return (&FILEx(iop)->_xdat); in getxfdat()
475 _setbufend(FILE *iop, Uchar *end) /* set the end pointer for this iop */ in _setbufend() argument
477 struct xFILEdata *dat = getxfdat(iop); in _setbufend()
482 isseekable(iop); in _setbufend()
489 if (iop->_magic < _NFILE) in _setbufend()
490 _bufendtab[iop->_magic] = end; in _setbufend()
495 _realbufend(FILE *iop) /* get the end pointer for this iop */ in _realbufend() argument
497 struct xFILEdata *dat = getxfdat(iop); in _realbufend()
512 _reallock(FILE *iop) in _reallock() argument
514 if (VALIDXFILE(FILEx(iop))) in _reallock()
515 return (&FILEx(iop)->xlock); in _reallock()
524 _bufsync(FILE *iop, Uchar *bufend) in _bufsync() argument
528 spaceleft = bufend - iop->_ptr; in _bufsync()
529 if (bufend < iop->_ptr) { in _bufsync()
530 iop->_ptr = bufend; in _bufsync()
531 iop->_cnt = 0; in _bufsync()
532 } else if (spaceleft < iop->_cnt) in _bufsync()
533 iop->_cnt = spaceleft; in _bufsync()
538 _xflsbuf(FILE *iop) in _xflsbuf() argument
541 Uchar *base = iop->_base; in _xflsbuf()
548 n = iop->_ptr - base; in _xflsbuf()
549 iop->_ptr = base; in _xflsbuf()
550 bufend = _bufend(iop); in _xflsbuf()
551 if (iop->_flag & (_IOLBF | _IONBF)) in _xflsbuf()
552 iop->_cnt = 0; /* always go to a flush */ in _xflsbuf()
554 iop->_cnt = bufend - base; in _xflsbuf()
556 if (_needsync(iop, bufend)) /* recover from interrupts */ in _xflsbuf()
557 _bufsync(iop, bufend); in _xflsbuf()
560 while ((num_wrote = _xwrite(iop, base, (size_t)n)) != n) { in _xflsbuf()
563 iop->_flag |= _IOERR; in _xflsbuf()
575 fflush(FILE *iop) in fflush() argument
580 if (iop) { in fflush()
581 FLOCKFILE(lk, iop); in fflush()
582 res = _fflush_u(iop); in fflush()
593 FPDECL(iop); in _fflush_l_iops()
626 FIRSTFP(lp, iop); in _fflush_l_iops()
627 for (i = lp->niob; --i >= 0; NEXTFP(iop)) { in _fflush_l_iops()
628 unsigned int flag = iop->_flag; in _fflush_l_iops()
635 lk = FPLOCK(iop); in _fflush_l_iops()
640 if (!(iop->_flag & _IONBF)) { in _fflush_l_iops()
646 if (iop->_flag & _IOWRT) { in _fflush_l_iops()
648 res |= _fflush_u(iop); in _fflush_l_iops()
649 } else if (iop->_flag & _IOREAD) { in _fflush_l_iops()
654 if (GET_SEEKABLE(iop)) { in _fflush_l_iops()
655 res |= _fflush_u(iop); in _fflush_l_iops()
670 _fflush_u(FILE *iop) in _fflush_u() argument
675 if (!(iop->_flag & _IOWRT)) { in _fflush_u()
676 (void) _xseek64(iop, -iop->_cnt, SEEK_CUR); in _fflush_u()
677 iop->_cnt = 0; in _fflush_u()
679 iop->_ptr = iop->_base; in _fflush_u()
680 if (iop->_flag & _IORW) { in _fflush_u()
681 iop->_flag &= ~_IOREAD; in _fflush_u()
685 if (iop->_base != NULL && iop->_ptr > iop->_base) { in _fflush_u()
686 res = _xflsbuf(iop); in _fflush_u()
688 if (iop->_flag & _IORW) { in _fflush_u()
689 iop->_flag &= ~_IOWRT; in _fflush_u()
690 iop->_cnt = 0; in _fflush_u()
697 fclose(FILE *iop) in fclose() argument
702 if (iop == NULL) { in fclose()
706 FLOCKFILE(lk, iop); in fclose()
707 if (iop->_flag == 0) { in fclose()
712 if (!(iop->_flag & _IONBF) && (iop->_flag & (_IOWRT | _IOREAD | _IORW))) in fclose()
713 res = _fflush_u(iop); in fclose()
714 if (_xclose(iop) < 0) in fclose()
716 if (iop->_flag & _IOMYBUF) { in fclose()
717 (void) free((char *)iop->_base - PUSHBACK); in fclose()
719 iop->_base = NULL; in fclose()
720 iop->_ptr = NULL; in fclose()
721 iop->_cnt = 0; in fclose()
722 iop->_flag = 0; /* marks it as available */ in fclose()
738 FPDECL(iop); in fcloseall()
751 FIRSTFP(lp, iop); in fcloseall()
752 for (i = lp->niob; --i >= 0; NEXTFP(iop)) { in fcloseall()
755 FLOCKFILE(lk, iop); in fcloseall()
756 if (iop->_flag == 0) { in fcloseall()
762 if (!(iop->_flag & _IONBF) && in fcloseall()
763 (iop->_flag & (_IOWRT | _IOREAD | _IORW))) in fcloseall()
764 (void) _fflush_u(iop); in fcloseall()
765 (void) _xclose(iop); in fcloseall()
766 if (iop->_flag & _IOMYBUF) in fcloseall()
767 free((char *)iop->_base - PUSHBACK); in fcloseall()
768 iop->_base = NULL; in fcloseall()
769 iop->_ptr = NULL; in fcloseall()
770 iop->_cnt = 0; in fcloseall()
771 iop->_flag = 0; /* marks it as available */ in fcloseall()
785 close_fd(FILE *iop) in close_fd() argument
790 if (iop == NULL || iop->_flag == 0) in close_fd()
793 if (!(iop->_flag & _IONBF) && (iop->_flag & (_IOWRT | _IOREAD | _IORW))) in close_fd()
794 res = _fflush_u(iop); in close_fd()
795 if (_xclose(iop) < 0) in close_fd()
797 if (iop->_flag & _IOMYBUF) { in close_fd()
798 (void) free((char *)iop->_base - PUSHBACK); in close_fd()
800 iop->_base = NULL; in close_fd()
801 iop->_ptr = NULL; in close_fd()
802 mb = _getmbstate(iop); in close_fd()
805 iop->_cnt = 0; in close_fd()
806 _setorientation(iop, _NO_MODE); in close_fd()
844 _getmbstate(FILE *iop) in _getmbstate() argument
846 struct xFILEdata *dat = getxfdat(iop); in _getmbstate()
866 _file_get(FILE *iop) in _file_get() argument
876 if (STDIOP(iop)) in _file_get()
877 altfd = _xftab[IOPIND(iop)]._altfd; in _file_get()
878 else if (VALIDXFILE(FILEx(iop))) in _file_get()
879 altfd = FILEx(iop)->_xdat._altfd; in _file_get()
881 return (iop->_magic); in _file_get()
889 if (!iop->__xf_nocheck && bad_fd > -1 && iop->_magic != bad_fd) { in _file_get()
899 _file_set(FILE *iop, int fd, const char *type) in _file_set() argument
914 dat = getxfdat(iop); in _file_set()
915 iop->__extendedfd = 1; in _file_set()
916 iop->__xf_nocheck = Fflag; in _file_set()
918 iop->_magic = (unsigned char)bad_fd; in _file_set()
964 get_stdops(FILE *iop) in get_stdops() argument
967 return (iop->_ops); in get_stdops()
969 struct xFILEdata *dat = getxfdat(iop); in get_stdops()
975 set_stdops(FILE *iop, stdio_ops_t *ops) in set_stdops() argument
978 ASSERT3P(iop->_ops, ==, NULL); in set_stdops()
979 iop->_ops = ops; in set_stdops()
981 struct xFILEdata *dat = getxfdat(iop); in set_stdops()
989 clr_stdops(FILE *iop) in clr_stdops() argument
992 iop->_ops = NULL; in clr_stdops()
994 struct xFILEdata *dat = getxfdat(iop); in clr_stdops()
1001 _xread(FILE *iop, void *buf, size_t nbytes) in _xread() argument
1003 stdio_ops_t *ops = get_stdops(iop); in _xread()
1005 return (ops->std_read(iop, buf, nbytes)); in _xread()
1008 return (read(_get_fd(iop), buf, nbytes)); in _xread()
1012 _xwrite(FILE *iop, const void *buf, size_t nbytes) in _xwrite() argument
1014 stdio_ops_t *ops = get_stdops(iop); in _xwrite()
1016 return (ops->std_write(iop, buf, nbytes)); in _xwrite()
1018 return (write(_get_fd(iop), buf, nbytes)); in _xwrite()
1022 _xseek(FILE *iop, off_t off, int whence) in _xseek() argument
1024 stdio_ops_t *ops = get_stdops(iop); in _xseek()
1026 return (ops->std_seek(iop, off, whence)); in _xseek()
1029 return (lseek(_get_fd(iop), off, whence)); in _xseek()
1033 _xseek64(FILE *iop, off64_t off, int whence) in _xseek64() argument
1035 stdio_ops_t *ops = get_stdops(iop); in _xseek64()
1047 return (ops->std_seek(iop, off, whence)); in _xseek64()
1050 return (lseek64(_get_fd(iop), off, whence)); in _xseek64()
1054 _xclose(FILE *iop) in _xclose() argument
1056 stdio_ops_t *ops = get_stdops(iop); in _xclose()
1058 return (ops->std_close(iop)); in _xclose()
1061 return (close(_get_fd(iop))); in _xclose()
1065 _xdata(FILE *iop) in _xdata() argument
1067 stdio_ops_t *ops = get_stdops(iop); in _xdata()
1076 _xassoc(FILE *iop, fread_t readf, fwrite_t writef, fseek_t seekf, in _xassoc() argument
1079 stdio_ops_t *ops = get_stdops(iop); in _xassoc()
1086 set_stdops(iop, ops); in _xassoc()
1099 _xunassoc(FILE *iop) in _xunassoc() argument
1101 stdio_ops_t *ops = get_stdops(iop); in _xunassoc()
1105 clr_stdops(iop); in _xunassoc()
1110 _get_fd(FILE *iop) in _get_fd() argument
1118 if (get_stdops(iop) != NULL) { in _get_fd()
1122 return (iop->_file); in _get_fd()
1124 if (iop->__extendedfd) { in _get_fd()
1125 return (_file_get(iop)); in _get_fd()
1127 return (iop->_magic); in _get_fd()