|
|
1.1 ! root 1: #include "curses.ext" ! 2: /* @(#) cntcostfn.c: 1.1 10/15/83 (1.13 8/20/82) */ ! 3: ! 4: static counter = 0; ! 5: /* ARGSUSED */ ! 6: _countchar(ch) ! 7: char ch; ! 8: { ! 9: counter++; ! 10: } ! 11: ! 12: /* ! 13: * Figure out the _cost in characters to print this string. ! 14: * Due to padding, we can't just use strlen, so instead we ! 15: * feed it through tputs and trap the results. ! 16: * Even if the terminal uses xon/xoff handshaking, count the ! 17: * pad chars here since they estimate the real time to do the ! 18: * operation, useful in calculating costs. ! 19: */ ! 20: _cost_fn(str, affcnt) ! 21: char *str; ! 22: { ! 23: int save_xflag = xon_xoff; ! 24: ! 25: if (str == NULL) ! 26: return INFINITY; ! 27: counter = 0; ! 28: xon_xoff = 0; ! 29: tputs(str, affcnt, _countchar); ! 30: xon_xoff = save_xflag; ! 31: return counter; ! 32: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.