expand.h revision 127958
1247738Sbapt/*- 2247738Sbapt * Copyright (c) 1991, 1993 3247738Sbapt * The Regents of the University of California. All rights reserved. 4247738Sbapt * 5247738Sbapt * This code is derived from software contributed to Berkeley by 6247738Sbapt * Kenneth Almquist. 7247738Sbapt * 8247738Sbapt * Redistribution and use in source and binary forms, with or without 9247738Sbapt * modification, are permitted provided that the following conditions 10247738Sbapt * are met: 11247738Sbapt * 1. Redistributions of source code must retain the above copyright 12247738Sbapt * notice, this list of conditions and the following disclaimer. 13247738Sbapt * 2. Redistributions in binary form must reproduce the above copyright 14247738Sbapt * notice, this list of conditions and the following disclaimer in the 15247738Sbapt * documentation and/or other materials provided with the distribution. 16247738Sbapt * 4. Neither the name of the University nor the names of its contributors 17247738Sbapt * may be used to endorse or promote products derived from this software 18247738Sbapt * without specific prior written permission. 19247738Sbapt * 20247738Sbapt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21247738Sbapt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22247738Sbapt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23247738Sbapt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24247738Sbapt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25247738Sbapt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26247738Sbapt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27247738Sbapt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28247738Sbapt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29247738Sbapt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30247738Sbapt * SUCH DAMAGE. 31247738Sbapt * 32247738Sbapt * @(#)expand.h 8.2 (Berkeley) 5/4/95 33247738Sbapt * $FreeBSD: head/bin/sh/expand.h 127958 2004-04-06 20:06:54Z markm $ 34247738Sbapt */ 35247738Sbapt 36247738Sbaptstruct strlist { 37247738Sbapt struct strlist *next; 38247738Sbapt char *text; 39247738Sbapt}; 40247738Sbapt 41247738Sbapt 42247738Sbaptstruct arglist { 43247738Sbapt struct strlist *list; 44247738Sbapt struct strlist **lastp; 45247738Sbapt}; 46247738Sbapt 47247738Sbapt/* 48247738Sbapt * expandarg() flags 49247738Sbapt */ 50247738Sbapt#define EXP_FULL 0x1 /* perform word splitting & file globbing */ 51247738Sbapt#define EXP_TILDE 0x2 /* do normal tilde expansion */ 52247738Sbapt#define EXP_VARTILDE 0x4 /* expand tildes in an assignment */ 53247738Sbapt#define EXP_REDIR 0x8 /* file glob for a redirection (1 match only) */ 54247738Sbapt#define EXP_CASE 0x10 /* keeps quotes around for CASE pattern */ 55247738Sbapt 56247738Sbapt 57247738Sbaptunion node; 58247738Sbaptvoid expandhere(union node *, int); 59247738Sbaptvoid expandarg(union node *, struct arglist *, int); 60247738Sbaptvoid expari(int); 61247738Sbaptint patmatch(char *, char *, int); 62247738Sbaptvoid rmescapes(char *); 63247738Sbaptint casematch(union node *, char *); 64247738Sbaptint wordexpcmd(int, char **); 65247738Sbapt