17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 22*965005c8Schin 23*965005c8Schin /* 24*965005c8Schin * Copyright 1995 Sun Microsystems, Inc. All rights reserved. 25*965005c8Schin * Use is subject to license terms. 26*965005c8Schin */ 27*965005c8Schin 287c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 297c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate 32*965005c8Schin #pragma ident "%Z%%M% %I% %E% SMI" 337c478bd9Sstevel@tonic-gate /* 347c478bd9Sstevel@tonic-gate * UNIX shell 357c478bd9Sstevel@tonic-gate */ 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include "defs.h" 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* ======== general purpose string handling ======== */ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate unsigned char * 44*965005c8Schin movstr(unsigned char *a, unsigned char *b) 457c478bd9Sstevel@tonic-gate { 467c478bd9Sstevel@tonic-gate while (*b++ = *a++); 477c478bd9Sstevel@tonic-gate return(--b); 487c478bd9Sstevel@tonic-gate } 497c478bd9Sstevel@tonic-gate 50*965005c8Schin int 51*965005c8Schin any(wchar_t c, unsigned char *s) 527c478bd9Sstevel@tonic-gate { 53*965005c8Schin unsigned int d; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate while (d = *s++) 567c478bd9Sstevel@tonic-gate { 577c478bd9Sstevel@tonic-gate if (d == c) 587c478bd9Sstevel@tonic-gate return(TRUE); 597c478bd9Sstevel@tonic-gate } 607c478bd9Sstevel@tonic-gate return(FALSE); 617c478bd9Sstevel@tonic-gate } 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate int anys(c, s) 647c478bd9Sstevel@tonic-gate unsigned char *c, *s; 657c478bd9Sstevel@tonic-gate { 667c478bd9Sstevel@tonic-gate wchar_t f, e; 67*965005c8Schin wchar_t d; 68*965005c8Schin int n; 697c478bd9Sstevel@tonic-gate if((n = mbtowc(&f, (char *)c, MULTI_BYTE_MAX)) <= 0) 707c478bd9Sstevel@tonic-gate return(FALSE); 717c478bd9Sstevel@tonic-gate d = f; 727c478bd9Sstevel@tonic-gate while(1) { 737c478bd9Sstevel@tonic-gate if((n = mbtowc(&e, (char *)s, MULTI_BYTE_MAX)) <= 0) 747c478bd9Sstevel@tonic-gate return(FALSE); 757c478bd9Sstevel@tonic-gate if(d == e) 767c478bd9Sstevel@tonic-gate return(TRUE); 777c478bd9Sstevel@tonic-gate s += n; 787c478bd9Sstevel@tonic-gate } 797c478bd9Sstevel@tonic-gate } 807c478bd9Sstevel@tonic-gate 81*965005c8Schin int 82*965005c8Schin cf(unsigned char *s1, unsigned char *s2) 837c478bd9Sstevel@tonic-gate { 847c478bd9Sstevel@tonic-gate while (*s1++ == *s2) 857c478bd9Sstevel@tonic-gate if (*s2++ == 0) 867c478bd9Sstevel@tonic-gate return(0); 877c478bd9Sstevel@tonic-gate return(*--s1 - *s2); 887c478bd9Sstevel@tonic-gate } 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate int length(as) 917c478bd9Sstevel@tonic-gate unsigned char *as; 927c478bd9Sstevel@tonic-gate { 93*965005c8Schin unsigned char *s; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate if (s = as) 967c478bd9Sstevel@tonic-gate while (*s++); 977c478bd9Sstevel@tonic-gate return(s - as); 987c478bd9Sstevel@tonic-gate } 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate unsigned char * 101*965005c8Schin movstrn(unsigned char *a, unsigned char *b, int n) 1027c478bd9Sstevel@tonic-gate { 1037c478bd9Sstevel@tonic-gate while ((n-- > 0) && *a) 1047c478bd9Sstevel@tonic-gate *b++ = *a++; 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate return(b); 1077c478bd9Sstevel@tonic-gate } 108