output.h revision 90111
12965Swollman/*- 22965Swollman * Copyright (c) 1991, 1993 32965Swollman * The Regents of the University of California. All rights reserved. 42965Swollman * 52965Swollman * This code is derived from software contributed to Berkeley by 62965Swollman * Kenneth Almquist. 72965Swollman * 82965Swollman * Redistribution and use in source and binary forms, with or without 92965Swollman * modification, are permitted provided that the following conditions 102965Swollman * are met: 112965Swollman * 1. Redistributions of source code must retain the above copyright 122965Swollman * notice, this list of conditions and the following disclaimer. 132965Swollman * 2. Redistributions in binary form must reproduce the above copyright 142965Swollman * notice, this list of conditions and the following disclaimer in the 152965Swollman * documentation and/or other materials provided with the distribution. 162965Swollman * 3. All advertising materials mentioning features or use of this software 172965Swollman * must display the following acknowledgement: 182965Swollman * This product includes software developed by the University of 192965Swollman * California, Berkeley and its contributors. 202965Swollman * 4. Neither the name of the University nor the names of its contributors 212965Swollman * may be used to endorse or promote products derived from this software 222965Swollman * without specific prior written permission. 232965Swollman * 242965Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 252965Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 262965Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 272965Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 282965Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 292965Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 302965Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 312965Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 322965Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 332965Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 342965Swollman * SUCH DAMAGE. 352965Swollman * 362965Swollman * @(#)output.h 8.2 (Berkeley) 5/4/95 372965Swollman * $FreeBSD: head/bin/sh/output.h 90111 2002-02-02 06:50:57Z imp $ 382965Swollman */ 392965Swollman 402965Swollman#ifndef OUTPUT_INCL 412965Swollman 422965Swollman#ifdef __STDC__ 432965Swollman#include <stdarg.h> 442965Swollman#else 452965Swollman#include <varargs.h> 462965Swollman#endif 472965Swollman 482965Swollmanstruct output { 492965Swollman char *nextc; 502965Swollman int nleft; 51 char *buf; 52 int bufsize; 53 short fd; 54 short flags; 55}; 56 57extern struct output output; 58extern struct output errout; 59extern struct output memout; 60extern struct output *out1; 61extern struct output *out2; 62 63void open_mem(char *, int, struct output *); 64void out1str(const char *); 65void out2str(const char *); 66void outstr(const char *, struct output *); 67void emptyoutbuf(struct output *); 68void flushall(void); 69void flushout(struct output *); 70void freestdout(void); 71void outfmt(struct output *, const char *, ...) __printflike(2, 3); 72void out1fmt(const char *, ...) __printflike(1, 2); 73void dprintf(const char *, ...) __printflike(1, 2); 74void fmtstr(char *, int, const char *, ...) __printflike(3, 4); 75void doformat(struct output *, const char *, va_list) __printflike(2, 0); 76int xwrite(int, char *, int); 77 78#define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c))) 79#define out1c(c) outc(c, out1); 80#define out2c(c) outc(c, out2); 81 82#define OUTPUT_INCL 83#endif 84