Lines Matching defs:iop

195 			 * We also automatically skip non allocated iop's.
267 * for finer granularity, use fp->_lock for allocating an iop
387 isseekable(FILE *iop)
394 if (fstat64(GET_FD(iop), &fstatbuf) != 0) {
400 SET_SEEKABLE(iop);
413 CLEAR_SEEKABLE(iop);
415 SET_SEEKABLE(iop);
423 _setbufend(FILE *iop, Uchar *end) /* set the end pointer for this iop */
425 iop->_end = end;
427 isseekable(iop);
433 _realbufend(FILE *iop) /* get the end pointer for this iop */
435 return (iop->_end);
452 getxfdat(FILE *iop)
454 if (STDIOP(iop))
455 return (&_xftab[IOPIND(iop)]);
456 else if (VALIDXFILE(FILEx(iop)))
457 return (&FILEx(iop)->_xdat);
463 _setbufend(FILE *iop, Uchar *end) /* set the end pointer for this iop */
465 struct xFILEdata *dat = getxfdat(iop);
470 isseekable(iop);
477 if (iop->_magic < _NFILE)
478 _bufendtab[iop->_magic] = end;
483 _realbufend(FILE *iop) /* get the end pointer for this iop */
485 struct xFILEdata *dat = getxfdat(iop);
500 _reallock(FILE *iop)
502 if (VALIDXFILE(FILEx(iop)))
503 return (&FILEx(iop)->xlock);
512 _bufsync(FILE *iop, Uchar *bufend)
516 spaceleft = bufend - iop->_ptr;
517 if (bufend < iop->_ptr) {
518 iop->_ptr = bufend;
519 iop->_cnt = 0;
520 } else if (spaceleft < iop->_cnt)
521 iop->_cnt = spaceleft;
526 _xflsbuf(FILE *iop)
529 Uchar *base = iop->_base;
536 n = iop->_ptr - base;
537 iop->_ptr = base;
538 bufend = _bufend(iop);
539 if (iop->_flag & (_IOLBF | _IONBF))
540 iop->_cnt = 0; /* always go to a flush */
542 iop->_cnt = bufend - base;
544 if (_needsync(iop, bufend)) /* recover from interrupts */
545 _bufsync(iop, bufend);
548 int fd = GET_FD(iop);
552 iop->_flag |= _IOERR;
564 fflush(FILE *iop)
569 if (iop) {
570 FLOCKFILE(lk, iop);
571 res = _fflush_u(iop);
582 FPDECL(iop);
615 FIRSTFP(lp, iop);
616 for (i = lp->niob; --i >= 0; NEXTFP(iop)) {
617 unsigned int flag = iop->_flag;
624 lk = FPLOCK(iop);
629 if (!(iop->_flag & _IONBF)) {
632 * since the iop will also marked with _IOREAD
635 if (iop->_flag & _IOWRT) {
637 res |= _fflush_u(iop);
638 } else if (iop->_flag & _IOREAD) {
643 if (GET_SEEKABLE(iop)) {
644 res |= _fflush_u(iop);
659 _fflush_u(FILE *iop)
664 if (!(iop->_flag & _IOWRT)) {
665 (void) lseek64(GET_FD(iop), -iop->_cnt, SEEK_CUR);
666 iop->_cnt = 0;
668 iop->_ptr = iop->_base;
669 if (iop->_flag & _IORW) {
670 iop->_flag &= ~_IOREAD;
674 if (iop->_base != NULL && iop->_ptr > iop->_base) {
675 res = _xflsbuf(iop);
677 if (iop->_flag & _IORW) {
678 iop->_flag &= ~_IOWRT;
679 iop->_cnt = 0;
686 fclose(FILE *iop)
691 if (iop == NULL) {
695 FLOCKFILE(lk, iop);
696 if (iop->_flag == 0) {
701 if (!(iop->_flag & _IONBF) && (iop->_flag & (_IOWRT | _IOREAD | _IORW)))
702 res = _fflush_u(iop);
703 if (close(GET_FD(iop)) < 0)
705 if (iop->_flag & _IOMYBUF) {
706 (void) free((char *)iop->_base - PUSHBACK);
708 iop->_base = NULL;
709 iop->_ptr = NULL;
710 iop->_cnt = 0;
711 iop->_flag = 0; /* marks it as available */
727 FPDECL(iop);
740 FIRSTFP(lp, iop);
741 for (i = lp->niob; --i >= 0; NEXTFP(iop)) {
744 FLOCKFILE(lk, iop);
745 if (iop->_flag == 0) {
751 if (!(iop->_flag & _IONBF) &&
752 (iop->_flag & (_IOWRT | _IOREAD | _IORW)))
753 (void) _fflush_u(iop);
754 (void) close(GET_FD(iop));
755 if (iop->_flag & _IOMYBUF)
756 free((char *)iop->_base - PUSHBACK);
757 iop->_base = NULL;
758 iop->_ptr = NULL;
759 iop->_cnt = 0;
760 iop->_flag = 0; /* marks it as available */
774 close_fd(FILE *iop)
779 if (iop == NULL || iop->_flag == 0)
782 if (!(iop->_flag & _IONBF) && (iop->_flag & (_IOWRT | _IOREAD | _IORW)))
783 res = _fflush_u(iop);
784 if (close(GET_FD(iop)) < 0)
786 if (iop->_flag & _IOMYBUF) {
787 (void) free((char *)iop->_base - PUSHBACK);
789 iop->_base = NULL;
790 iop->_ptr = NULL;
791 mb = _getmbstate(iop);
794 iop->_cnt = 0;
795 _setorientation(iop, _NO_MODE);
825 * with the specified iop.
832 _getmbstate(FILE *iop)
834 struct xFILEdata *dat = getxfdat(iop);
854 _file_get(FILE *iop)
864 if (STDIOP(iop))
865 altfd = _xftab[IOPIND(iop)]._altfd;
866 else if (VALIDXFILE(FILEx(iop)))
867 altfd = FILEx(iop)->_xdat._altfd;
869 return (iop->_magic);
877 if (!iop->__xf_nocheck && bad_fd > -1 && iop->_magic != bad_fd) {
887 _file_set(FILE *iop, int fd, const char *type)
902 dat = getxfdat(iop);
903 iop->__extendedfd = 1;
904 iop->__xf_nocheck = Fflag;
906 iop->_magic = (unsigned char)bad_fd;