9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

boffset.c (342B)


      1 #include	"lib9.h"
      2 #include	<bio.h>
      3 
      4 vlong
      5 Boffset(Biobuf *bp)
      6 {
      7 	vlong n;
      8 
      9 	switch(bp->state) {
     10 	default:
     11 		fprint(2, "Boffset: unknown state %d\n", bp->state);
     12 		n = Beof;
     13 		break;
     14 
     15 	case Bracteof:
     16 	case Bractive:
     17 		n = bp->offset + bp->icount;
     18 		break;
     19 
     20 	case Bwactive:
     21 		n = bp->offset + (bp->bsize + bp->ocount);
     22 		break;
     23 	}
     24 	return n;
     25 }