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 * 4. Neither the name of the University nor the names of its contributors 171556Srgrimes * may be used to endorse or promote products derived from this software 181556Srgrimes * without specific prior written permission. 191556Srgrimes * 201556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231556Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301556Srgrimes * SUCH DAMAGE. 311556Srgrimes * 3217987Speter * @(#)bltin.h 8.2 (Berkeley) 5/4/95 3350471Speter * $FreeBSD$ 341556Srgrimes */ 351556Srgrimes 361556Srgrimes/* 371556Srgrimes * This file is included by programs which are optionally built into the 381556Srgrimes * shell. If SHELL is defined, we try to map the standard UNIX library 391556Srgrimes * routines to ash routines using defines. 401556Srgrimes */ 411556Srgrimes 421556Srgrimes#include "../shell.h" 431556Srgrimes#include "../mystring.h" 441556Srgrimes#ifdef SHELL 451556Srgrimes#include "../output.h" 46223060Sjilles#include "builtins.h" 47216629Sjilles#define FILE struct output 4812730Sjoerg#undef stdout 491556Srgrimes#define stdout out1 5012730Sjoerg#undef stderr 511556Srgrimes#define stderr out2 521556Srgrimes#define printf out1fmt 5312730Sjoerg#undef putc 541556Srgrimes#define putc(c, file) outc(c, file) 5512730Sjoerg#undef putchar 561556Srgrimes#define putchar(c) out1c(c) 571556Srgrimes#define fprintf outfmt 581556Srgrimes#define fputs outstr 59215303Sjilles#define fwrite(ptr, size, nmemb, file) outbin(ptr, (size) * (nmemb), file) 601556Srgrimes#define fflush flushout 611556Srgrimes#define INITARGS(argv) 62216622Sjilles#define warnx warning 63216629Sjilles#define warn(fmt, ...) warning(fmt ": %s", __VA_ARGS__, strerror(errno)) 64216606Sjilles#define errx(exitstatus, ...) error(__VA_ARGS__) 6520425Ssteve 661556Srgrimes#else 671556Srgrimes#undef NULL 681556Srgrimes#include <stdio.h> 691556Srgrimes#undef main 701556Srgrimes#define INITARGS(argv) if ((commandname = argv[0]) == NULL) {fputs("Argc is zero\n", stderr); exit(2);} else 711556Srgrimes#endif 721556Srgrimes 73216629Sjilles#include <unistd.h> 74216629Sjilles 751556Srgrimespointer stalloc(int); 7675577Skrisvoid error(const char *, ...) __printf0like(1, 2); 77216629Sjillespid_t getjobpgrp(char *); 781556Srgrimes 791556Srgrimesextern char *commandname; 80