bbuffered.c - 9base - revived minimalist port of Plan 9 userland to Unix
 (HTM) git clone git://git.suckless.org/9base
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       bbuffered.c (291B)
       ---
            1 #include        "lib9.h"
            2 #include        <bio.h>
            3 
            4 int
            5 Bbuffered(Biobuf *bp)
            6 {
            7         switch(bp->state) {
            8         case Bracteof:
            9         case Bractive:
           10                 return -bp->icount;
           11 
           12         case Bwactive:
           13                 return bp->bsize + bp->ocount;
           14 
           15         case Binactive:
           16                 return 0;
           17         }
           18         fprint(2, "Bbuffered: unknown state %d\n", bp->state);
           19         return 0;
           20 }