output.h revision 50471
1220908Sadrian/*- 2220908Sadrian * Copyright (c) 1991, 1993 3220908Sadrian * The Regents of the University of California. All rights reserved. 4220908Sadrian * 5220908Sadrian * This code is derived from software contributed to Berkeley by 6220908Sadrian * Kenneth Almquist. 7220908Sadrian * 8220908Sadrian * Redistribution and use in source and binary forms, with or without 9220908Sadrian * modification, are permitted provided that the following conditions 10220908Sadrian * are met: 11220908Sadrian * 1. Redistributions of source code must retain the above copyright 12220908Sadrian * notice, this list of conditions and the following disclaimer. 13220908Sadrian * 2. Redistributions in binary form must reproduce the above copyright 14220908Sadrian * notice, this list of conditions and the following disclaimer in the 15220908Sadrian * documentation and/or other materials provided with the distribution. 16220908Sadrian * 3. All advertising materials mentioning features or use of this software 17220908Sadrian * must display the following acknowledgement: 18220908Sadrian * This product includes software developed by the University of 19220908Sadrian * California, Berkeley and its contributors. 20220908Sadrian * 4. Neither the name of the University nor the names of its contributors 21220908Sadrian * may be used to endorse or promote products derived from this software 22220908Sadrian * without specific prior written permission. 23220908Sadrian * 24220908Sadrian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25220908Sadrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26220908Sadrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27220908Sadrian * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28220908Sadrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29220908Sadrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30220908Sadrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31220908Sadrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32220908Sadrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33220908Sadrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34220908Sadrian * SUCH DAMAGE. 35220908Sadrian * 36220908Sadrian * @(#)output.h 8.2 (Berkeley) 5/4/95 37220908Sadrian * $FreeBSD: head/bin/sh/output.h 50471 1999-08-27 23:15:48Z peter $ 38220908Sadrian */ 39220908Sadrian 40220908Sadrian#ifndef OUTPUT_INCL 41220908Sadrian 42220908Sadrian#ifdef __STDC__ 43220908Sadrian#include <stdarg.h> 44220908Sadrian#else 45220908Sadrian#include <varargs.h> 46220908Sadrian#endif 47220908Sadrian 48220908Sadrianstruct output { 49220908Sadrian char *nextc; 50220908Sadrian int nleft; 51220908Sadrian char *buf; 52220908Sadrian int bufsize; 53220908Sadrian short fd; 54220908Sadrian short flags; 55220908Sadrian}; 56220908Sadrian 57220908Sadrianextern struct output output; 58220908Sadrianextern struct output errout; 59220908Sadrianextern struct output memout; 60220908Sadrianextern struct output *out1; 61220908Sadrianextern struct output *out2; 62220908Sadrian 63220908Sadrianvoid open_mem __P((char *, int, struct output *)); 64220908Sadrianvoid out1str __P((const char *)); 65220908Sadrianvoid out2str __P((const char *)); 66220908Sadrianvoid outstr __P((const char *, struct output *)); 67221781Sadrianvoid emptyoutbuf __P((struct output *)); 68221782Sadrianvoid flushall __P((void)); 69220908Sadrianvoid flushout __P((struct output *)); 70220908Sadrianvoid freestdout __P((void)); 71220908Sadrianvoid outfmt __P((struct output *, char *, ...)); 72220908Sadrianvoid out1fmt __P((char *, ...)); 73220908Sadrianvoid dprintf __P((char *, ...)); 74220908Sadrianvoid fmtstr __P((char *, int, char *, ...)); 75220908Sadrianvoid doformat __P((struct output *, char *, va_list)); 76220908Sadrianint xwrite __P((int, char *, int)); 77220908Sadrianint xioctl __P((int, unsigned long, char *)); 78220908Sadrian 79220908Sadrian#define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c))) 80220908Sadrian#define out1c(c) outc(c, out1); 81220908Sadrian#define out2c(c) outc(c, out2); 82220908Sadrian 83220908Sadrian#define OUTPUT_INCL 84220908Sadrian#endif 85220908Sadrian