10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 22*527Schin 23*527Schin /* 24*527Schin * Copyright 1995 Sun Microsystems, Inc. All rights reserved. 25*527Schin * Use is subject to license terms. 26*527Schin */ 27*527Schin 280Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 290Sstevel@tonic-gate /* All Rights Reserved */ 300Sstevel@tonic-gate 310Sstevel@tonic-gate 32*527Schin #pragma ident "%Z%%M% %I% %E% SMI" 330Sstevel@tonic-gate /* 340Sstevel@tonic-gate * UNIX shell 350Sstevel@tonic-gate */ 360Sstevel@tonic-gate 370Sstevel@tonic-gate #include "defs.h" 380Sstevel@tonic-gate 390Sstevel@tonic-gate 400Sstevel@tonic-gate /* ======== general purpose string handling ======== */ 410Sstevel@tonic-gate 420Sstevel@tonic-gate 430Sstevel@tonic-gate unsigned char * 44*527Schin movstr(unsigned char *a, unsigned char *b) 450Sstevel@tonic-gate { 460Sstevel@tonic-gate while (*b++ = *a++); 470Sstevel@tonic-gate return(--b); 480Sstevel@tonic-gate } 490Sstevel@tonic-gate 50*527Schin int 51*527Schin any(wchar_t c, unsigned char *s) 520Sstevel@tonic-gate { 53*527Schin unsigned int d; 540Sstevel@tonic-gate 550Sstevel@tonic-gate while (d = *s++) 560Sstevel@tonic-gate { 570Sstevel@tonic-gate if (d == c) 580Sstevel@tonic-gate return(TRUE); 590Sstevel@tonic-gate } 600Sstevel@tonic-gate return(FALSE); 610Sstevel@tonic-gate } 620Sstevel@tonic-gate 630Sstevel@tonic-gate int anys(c, s) 640Sstevel@tonic-gate unsigned char *c, *s; 650Sstevel@tonic-gate { 660Sstevel@tonic-gate wchar_t f, e; 67*527Schin wchar_t d; 68*527Schin int n; 690Sstevel@tonic-gate if((n = mbtowc(&f, (char *)c, MULTI_BYTE_MAX)) <= 0) 700Sstevel@tonic-gate return(FALSE); 710Sstevel@tonic-gate d = f; 720Sstevel@tonic-gate while(1) { 730Sstevel@tonic-gate if((n = mbtowc(&e, (char *)s, MULTI_BYTE_MAX)) <= 0) 740Sstevel@tonic-gate return(FALSE); 750Sstevel@tonic-gate if(d == e) 760Sstevel@tonic-gate return(TRUE); 770Sstevel@tonic-gate s += n; 780Sstevel@tonic-gate } 790Sstevel@tonic-gate } 800Sstevel@tonic-gate 81*527Schin int 82*527Schin cf(unsigned char *s1, unsigned char *s2) 830Sstevel@tonic-gate { 840Sstevel@tonic-gate while (*s1++ == *s2) 850Sstevel@tonic-gate if (*s2++ == 0) 860Sstevel@tonic-gate return(0); 870Sstevel@tonic-gate return(*--s1 - *s2); 880Sstevel@tonic-gate } 890Sstevel@tonic-gate 900Sstevel@tonic-gate int length(as) 910Sstevel@tonic-gate unsigned char *as; 920Sstevel@tonic-gate { 93*527Schin unsigned char *s; 940Sstevel@tonic-gate 950Sstevel@tonic-gate if (s = as) 960Sstevel@tonic-gate while (*s++); 970Sstevel@tonic-gate return(s - as); 980Sstevel@tonic-gate } 990Sstevel@tonic-gate 1000Sstevel@tonic-gate unsigned char * 101*527Schin movstrn(unsigned char *a, unsigned char *b, int n) 1020Sstevel@tonic-gate { 1030Sstevel@tonic-gate while ((n-- > 0) && *a) 1040Sstevel@tonic-gate *b++ = *a++; 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate return(b); 1070Sstevel@tonic-gate } 108