11541Srgrimes/* $NetBSD: metachar.h,v 1.4 2015/06/21 20:26:02 christos Exp $ */ 21541Srgrimes 31541Srgrimes/*- 41541Srgrimes * Copyright (c) 2015 The NetBSD Foundation, Inc. 551138Salfred * All rights reserved. 6153681Sphk * 71541Srgrimes * This code is derived from software contributed to The NetBSD Foundation 81541Srgrimes * by Christos Zoulas. 9106149Sdwmalone * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 1164002Speter * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 191541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201541Srgrimes * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211541Srgrimes * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221541Srgrimes * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231541Srgrimes * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241541Srgrimes * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251541Srgrimes * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261541Srgrimes * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271541Srgrimes * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28122540Smckusick * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291541Srgrimes * POSSIBILITY OF SUCH DAMAGE. 301541Srgrimes */ 311541Srgrimes#ifndef _METACHAR_H 321541Srgrimes#define _METACHAR_H 331541Srgrimes 341541Srgrimes#include <ctype.h> 351541Srgrimes 361541Srgrimesextern unsigned char _metachar[]; 371541Srgrimes 381541Srgrimes#define ismeta(c) _metachar[(c) & 0x7f] 391541Srgrimes 401541Srgrimesstatic inline int 411541Srgrimeshasmeta(const char *cmd) 421541Srgrimes{ 431541Srgrimes while (!ismeta(*cmd)) 441541Srgrimes cmd++; 451541Srgrimes 461541Srgrimes return *cmd != '\0'; 471541Srgrimes} 481541Srgrimes 491541Srgrimesstatic inline int 501541Srgrimesneedshell(const char *cmd, int white) 511541Srgrimes{ 521541Srgrimes while (!ismeta(*cmd) && *cmd != ':' && *cmd != '=') { 531541Srgrimes if (white && isspace((unsigned char)*cmd)) 541541Srgrimes break; 551541Srgrimes cmd++; 5652150Smarcel } 571541Srgrimes 5852150Smarcel return *cmd != '\0'; 591541Srgrimes} 601541Srgrimes 611541Srgrimes#endif /* _METACHAR_H */ 6252150Smarcel