1928e054931d357326613c78e62f4d850b7c442ffJeff Brown/*	$NetBSD: bltin.h,v 1.11 2003/08/07 09:05:40 agc Exp $	*/
2928e054931d357326613c78e62f4d850b7c442ffJeff Brown
3928e054931d357326613c78e62f4d850b7c442ffJeff Brown/*-
4928e054931d357326613c78e62f4d850b7c442ffJeff Brown * Copyright (c) 1991, 1993
5928e054931d357326613c78e62f4d850b7c442ffJeff Brown *	The Regents of the University of California.  All rights reserved.
6928e054931d357326613c78e62f4d850b7c442ffJeff Brown *
7928e054931d357326613c78e62f4d850b7c442ffJeff Brown * This code is derived from software contributed to Berkeley by
8928e054931d357326613c78e62f4d850b7c442ffJeff Brown * Kenneth Almquist.
9928e054931d357326613c78e62f4d850b7c442ffJeff Brown *
10928e054931d357326613c78e62f4d850b7c442ffJeff Brown * Redistribution and use in source and binary forms, with or without
11928e054931d357326613c78e62f4d850b7c442ffJeff Brown * modification, are permitted provided that the following conditions
12928e054931d357326613c78e62f4d850b7c442ffJeff Brown * are met:
13928e054931d357326613c78e62f4d850b7c442ffJeff Brown * 1. Redistributions of source code must retain the above copyright
14928e054931d357326613c78e62f4d850b7c442ffJeff Brown *    notice, this list of conditions and the following disclaimer.
15928e054931d357326613c78e62f4d850b7c442ffJeff Brown * 2. Redistributions in binary form must reproduce the above copyright
16928e054931d357326613c78e62f4d850b7c442ffJeff Brown *    notice, this list of conditions and the following disclaimer in the
17928e054931d357326613c78e62f4d850b7c442ffJeff Brown *    documentation and/or other materials provided with the distribution.
18928e054931d357326613c78e62f4d850b7c442ffJeff Brown * 3. Neither the name of the University nor the names of its contributors
19928e054931d357326613c78e62f4d850b7c442ffJeff Brown *    may be used to endorse or promote products derived from this software
20b93a03f841d93498bfea6cc92a22faa34bce1337Mathias Agopian *    without specific prior written permission.
21928e054931d357326613c78e62f4d850b7c442ffJeff Brown *
22928e054931d357326613c78e62f4d850b7c442ffJeff Brown * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23928e054931d357326613c78e62f4d850b7c442ffJeff Brown * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24928e054931d357326613c78e62f4d850b7c442ffJeff Brown * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25928e054931d357326613c78e62f4d850b7c442ffJeff Brown * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26928e054931d357326613c78e62f4d850b7c442ffJeff Brown * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27928e054931d357326613c78e62f4d850b7c442ffJeff Brown * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28928e054931d357326613c78e62f4d850b7c442ffJeff Brown * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
299302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown * SUCH DAMAGE.
33cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown *
34cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown *	@(#)bltin.h	8.1 (Berkeley) 5/31/93
35cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown */
36cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown
37cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown/*
38cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown * This file is included by programs which are optionally built into the
399302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown * shell.  If SHELL is defined, we try to map the standard UNIX library
409302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown * routines to ash routines using defines.
41928e054931d357326613c78e62f4d850b7c442ffJeff Brown */
42928e054931d357326613c78e62f4d850b7c442ffJeff Brown
43928e054931d357326613c78e62f4d850b7c442ffJeff Brown#include "../shell.h"
449302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#include "../mystring.h"
45cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#ifdef SHELL
46cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#include "../output.h"
47cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#include "../error.h"
48cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#undef stdout
49cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#undef stderr
50cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#undef putc
51cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#undef putchar
52cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#undef fileno
53cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define stdout out1
54cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define stderr out2
55cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define printf out1fmt
569302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define putc(c, file)	outc(c, file)
579302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define putchar(c)	out1c(c)
589302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define FILE struct output
599302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define fprintf outfmt
609302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define fputs outstr
619302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define fflush flushout
629302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define fileno(f) ((f)->fd)
639302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define INITARGS(argv)
649302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define	err sh_err
659302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define	verr sh_verr
66cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define	errx sh_errx
67cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define	verrx sh_verrx
68cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define	warn sh_warn
69cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define	vwarn sh_vwarn
70cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define	warnx sh_warnx
71cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define	vwarnx sh_vwarnx
72cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define exit sh_exit
739302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown#define setprogname(s)
74928e054931d357326613c78e62f4d850b7c442ffJeff Brown#define getprogname() commandname
75cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define setlocate(l,s) 0
76cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown
77cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown#define getenv(p) bltinlookup((p),0)
78cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown
79928e054931d357326613c78e62f4d850b7c442ffJeff Brown#else
80928e054931d357326613c78e62f4d850b7c442ffJeff Brown#undef NULL
81928e054931d357326613c78e62f4d850b7c442ffJeff Brown#include <stdio.h>
82928e054931d357326613c78e62f4d850b7c442ffJeff Brown#undef main
83928e054931d357326613c78e62f4d850b7c442ffJeff Brown#define INITARGS(argv)	if ((commandname = argv[0]) == NULL) {fputs("Argc is zero\n", stderr); exit(2);} else
84#endif
85
86pointer stalloc(int);
87void error(const char *, ...);
88void sh_warnx(const char *, ...);
89void sh_exit(int) __attribute__((__noreturn__));
90
91int echocmd(int, char **);
92
93
94extern const char *commandname;
95