163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore/*
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * Copyright (c) 1991, 1993
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * The Regents of the University of California. All rights reserved.
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore *
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * Redistribution and use in source and binary forms, with or without
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * modification, are permitted provided that the following conditions
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * are met:
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * 1. Redistributions of source code must retain the above copyright
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * notice, this list of conditions and the following disclaimer.
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * 2. Redistributions in binary form must reproduce the above copyright
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * notice, this list of conditions and the following disclaimer in the
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * documentation and/or other materials provided with the distribution.
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * 3. All advertising materials mentioning features or use of this software
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * must display the following acknowledgement:
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * This product includes software developed by the University of
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * California, Berkeley and its contributors.
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * 4. Neither the name of the University nor the names of its contributors
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * may be used to endorse or promote products derived from this software
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * without specific prior written permission.
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore *
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore * SUCH DAMAGE.
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore */
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore#include <limits.h>
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore#define NCHARS_SB (UCHAR_MAX + 1) /* Number of single-byte characters. */
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore#define OOBCH -1 /* Out of band character value. */
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amoretypedef struct {
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore enum { STRING1, STRING2 } which;
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore enum { EOS, INFINITE, NORMAL, RANGE, SEQUENCE,
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore CCLASS, CCLASS_UPPER, CCLASS_LOWER, SET } state;
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore int cnt; /* character count */
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore wint_t lastch; /* last character */
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore wctype_t cclass; /* character class from wctype() */
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore wint_t equiv[NCHARS_SB]; /* equivalence set */
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore wint_t *set; /* set of characters */
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore char *str; /* user's string */
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore} STR;
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amore
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amorewint_t next(STR *);
163bd69b3c164dda2a59c7f08ca788e7d6ba9beaGarrett D'Amoreint charcoll(const void *, const void *);