|
|
1.1 ! root 1: /* $Header: /newbits/usr/lib/libcurses/RCS/need.c,v 1.2 91/09/30 13:06:39 bin Exp Locker: bin $ ! 2: * ! 3: * The information contained herein is a trade secret of INETCO ! 4: * Systems, and is confidential information. It is provided under ! 5: * a license agreement, and may be copied or disclosed only under ! 6: * the terms of that agreement. Any reproduction or disclosure of ! 7: * this material without the express written authorization of ! 8: * INETCO Systems or persuant to the license agreement is unlawful. ! 9: * ! 10: * Copyright (c) 1989 ! 11: * An unpublished work by INETCO Systems, Ltd. ! 12: * All rights reserved. ! 13: */ ! 14: ! 15: # include "curses.ext" ! 16: ! 17: #ifdef COHERENT ! 18: /** ! 19: * ! 20: * _need( s ) ! 21: * char * s; ! 22: * ! 23: * Input: s = string which will eventually be passed to _putchar(). ! 24: * ! 25: * Action: If output buffering is enabled, and there is insufficient ! 26: * room in the output buffer for the specified string, ! 27: * flush the output buffer. ! 28: * ! 29: * Return: 0 = atomic output is guaranteed. ! 30: * -1 = buffering disabled. ! 31: * ! 32: * Notes: This attempts to ensure that escape sequences are sent to ! 33: * the terminal in one atomic operation, without being split ! 34: * by other terminal output. ! 35: */ ! 36: int ! 37: _need( s ) ! 38: uchar * s; ! 39: { ! 40: reg FILE * fp = stdout; ! 41: ! 42: /* ! 43: * Stdout exists, and has a buffer allocated. ! 44: * _bp = pointer to beginning of buffer. ! 45: * _cp = pointer to current char in buffer. ! 46: * Flush stdout if insufficient room for string. ! 47: */ ! 48: if ( (fp != NULL) && (fp->_bp != NULL) && (fp->_cp != NULL) ) { ! 49: if ( ((fp->_cp - fp->_bp) + strlen(s)) >= BUFSIZ ) ! 50: fflush( stdout ); ! 51: return (0); ! 52: } ! 53: ! 54: /* ! 55: * Atomic output by stdio cannot be guaranteed. ! 56: */ ! 57: return (-1); ! 58: } ! 59: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.