output.h revision 50471
11556Srgrimes/*- 21556Srgrimes * Copyright (c) 1991, 1993 31556Srgrimes * The Regents of the University of California. All rights reserved. 41556Srgrimes * 51556Srgrimes * This code is derived from software contributed to Berkeley by 61556Srgrimes * Kenneth Almquist. 71556Srgrimes * 81556Srgrimes * Redistribution and use in source and binary forms, with or without 91556Srgrimes * modification, are permitted provided that the following conditions 101556Srgrimes * are met: 111556Srgrimes * 1. Redistributions of source code must retain the above copyright 121556Srgrimes * notice, this list of conditions and the following disclaimer. 131556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141556Srgrimes * notice, this list of conditions and the following disclaimer in the 151556Srgrimes * documentation and/or other materials provided with the distribution. 161556Srgrimes * 3. All advertising materials mentioning features or use of this software 171556Srgrimes * must display the following acknowledgement: 181556Srgrimes * This product includes software developed by the University of 191556Srgrimes * California, Berkeley and its contributors. 201556Srgrimes * 4. Neither the name of the University nor the names of its contributors 211556Srgrimes * may be used to endorse or promote products derived from this software 221556Srgrimes * without specific prior written permission. 231556Srgrimes * 241556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271556Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 291556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341556Srgrimes * SUCH DAMAGE. 351556Srgrimes * 3617987Speter * @(#)output.h 8.2 (Berkeley) 5/4/95 3750471Speter * $FreeBSD: head/bin/sh/output.h 50471 1999-08-27 23:15:48Z peter $ 381556Srgrimes */ 391556Srgrimes 401556Srgrimes#ifndef OUTPUT_INCL 411556Srgrimes 4225222Ssteve#ifdef __STDC__ 4317987Speter#include <stdarg.h> 4417987Speter#else 4517987Speter#include <varargs.h> 4617987Speter#endif 4717987Speter 481556Srgrimesstruct output { 491556Srgrimes char *nextc; 501556Srgrimes int nleft; 511556Srgrimes char *buf; 521556Srgrimes int bufsize; 531556Srgrimes short fd; 541556Srgrimes short flags; 551556Srgrimes}; 561556Srgrimes 571556Srgrimesextern struct output output; 581556Srgrimesextern struct output errout; 591556Srgrimesextern struct output memout; 601556Srgrimesextern struct output *out1; 611556Srgrimesextern struct output *out2; 621556Srgrimes 6317987Spetervoid open_mem __P((char *, int, struct output *)); 6417987Spetervoid out1str __P((const char *)); 6517987Spetervoid out2str __P((const char *)); 6617987Spetervoid outstr __P((const char *, struct output *)); 6717987Spetervoid emptyoutbuf __P((struct output *)); 6817987Spetervoid flushall __P((void)); 6917987Spetervoid flushout __P((struct output *)); 7017987Spetervoid freestdout __P((void)); 7117987Spetervoid outfmt __P((struct output *, char *, ...)); 7220425Sstevevoid out1fmt __P((char *, ...)); 7317987Spetervoid dprintf __P((char *, ...)); 7417987Spetervoid fmtstr __P((char *, int, char *, ...)); 7517987Spetervoid doformat __P((struct output *, char *, va_list)); 7617987Speterint xwrite __P((int, char *, int)); 7717987Speterint xioctl __P((int, unsigned long, char *)); 781556Srgrimes 791556Srgrimes#define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c))) 801556Srgrimes#define out1c(c) outc(c, out1); 811556Srgrimes#define out2c(c) outc(c, out2); 821556Srgrimes 831556Srgrimes#define OUTPUT_INCL 841556Srgrimes#endif 85