output.h revision 20425
199045Sdes/*- 299045Sdes * Copyright (c) 1991, 1993 399045Sdes * The Regents of the University of California. All rights reserved. 4294666Sdes * 5294666Sdes * This code is derived from software contributed to Berkeley by 699045Sdes * Kenneth Almquist. 7294666Sdes * 8294666Sdes * Redistribution and use in source and binary forms, with or without 999045Sdes * modification, are permitted provided that the following conditions 10294666Sdes * are met: 1199045Sdes * 1. Redistributions of source code must retain the above copyright 12294666Sdes * notice, this list of conditions and the following disclaimer. 1399045Sdes * 2. Redistributions in binary form must reproduce the above copyright 14294666Sdes * notice, this list of conditions and the following disclaimer in the 15176070Sdes * documentation and/or other materials provided with the distribution. 16294666Sdes * 3. All advertising materials mentioning features or use of this software 1799045Sdes * must display the following acknowledgement: 18294666Sdes * This product includes software developed by the University of 1999045Sdes * California, Berkeley and its contributors. 20294666Sdes * 4. Neither the name of the University nor the names of its contributors 21294666Sdes * may be used to endorse or promote products derived from this software 22124213Sdes * without specific prior written permission. 23294666Sdes * 2499045Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25294666Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26294666Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2799045Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28294666Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2999045Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30294666Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3199045Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32294666Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3399045Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34294666Sdes * SUCH DAMAGE. 35295367Sdes * 36295367Sdes * @(#)output.h 8.2 (Berkeley) 5/4/95 3799045Sdes * $Id: output.h,v 1.3 1996/09/01 10:21:29 peter Exp $ 38295367Sdes */ 39295367Sdes 4099045Sdes#ifndef OUTPUT_INCL 41294666Sdes 42294666Sdes#if __STDC__ 43294666Sdes#include <stdarg.h> 4499045Sdes#else 45294666Sdes#include <varargs.h> 46162952Sdes#endif 47294666Sdes 4899045Sdesstruct output { 49294666Sdes char *nextc; 50294666Sdes int nleft; 51294666Sdes char *buf; 5299045Sdes int bufsize; 53294666Sdes short fd; 5499045Sdes short flags; 55295367Sdes}; 56295367Sdes 57162952Sdesextern struct output output; 58294666Sdesextern struct output errout; 59294666Sdesextern struct output memout; 60294666Sdesextern struct output *out1; 61294666Sdesextern struct output *out2; 6299045Sdes 63295367Sdesvoid open_mem __P((char *, int, struct output *)); 64295367Sdesvoid out1str __P((const char *)); 65294666Sdesvoid out2str __P((const char *)); 66294666Sdesvoid outstr __P((const char *, struct output *)); 67294666Sdesvoid emptyoutbuf __P((struct output *)); 68294666Sdesvoid flushall __P((void)); 69294666Sdesvoid flushout __P((struct output *)); 70294666Sdesvoid freestdout __P((void)); 71294666Sdesvoid outfmt __P((struct output *, char *, ...)); 72295367Sdesvoid out1fmt __P((char *, ...)); 73294666Sdesvoid dprintf __P((char *, ...)); 74294666Sdesvoid fmtstr __P((char *, int, char *, ...)); 75294666Sdesvoid doformat __P((struct output *, char *, va_list)); 76294666Sdesint xwrite __P((int, char *, int)); 77294666Sdesint xioctl __P((int, unsigned long, char *)); 78294666Sdes 79294666Sdes#define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c))) 80294666Sdes#define out1c(c) outc(c, out1); 81294666Sdes#define out2c(c) outc(c, out2); 82294666Sdes 83294666Sdes#define OUTPUT_INCL 84294666Sdes#endif 85294666Sdes