2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/* Copyright (c) 1988 AT&T */
2N/A/* All Rights Reserved */
2N/A
2N/A
2N/A/*
2N/A * Copyright (c) 1997, by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */
2N/A
2N/A/*LINTLIBRARY*/
2N/A
2N/A#include <sys/types.h>
2N/A#include <stdlib.h>
2N/A#include "utility.h"
2N/A
2N/A/*
2N/A * TYPE_ALPHA standard type
2N/A *
2N/A * usage:
2N/A * set_field_type(f, TYPE_ALPHA, width);
2N/A *
2N/A * int width; minimum token width
2N/A */
2N/Astatic char *make_alpha(va_list *);
2N/Astatic char *copy_alpha(char *);
2N/Astatic void free_alpha(char *);
2N/Astatic int fcheck_alpha(FIELD *, char *);
2N/Astatic int ccheck_alpha(int, char *);
2N/A
2N/Astatic FIELDTYPE typeALPHA =
2N/A{
2N/A ARGS, /* status */
2N/A 1, /* ref */
2N/A (FIELDTYPE *) 0, /* left */
2N/A (FIELDTYPE *) 0, /* right */
2N/A make_alpha, /* makearg */
2N/A copy_alpha, /* copyarg */
2N/A free_alpha, /* freearg */
2N/A fcheck_alpha, /* fcheck */
2N/A ccheck_alpha, /* ccheck */
2N/A (PTF_int) 0, /* next */
2N/A (PTF_int) 0, /* prev */
2N/A};
2N/A
2N/AFIELDTYPE * TYPE_ALPHA = &typeALPHA;
2N/A
2N/Astatic char *
2N/Amake_alpha(va_list *ap)
2N/A{
2N/A int * width;
2N/A
2N/A if (Alloc(width, int))
2N/A *width = va_arg(*ap, int);
2N/A return ((char *) width);
2N/A}
2N/A
2N/Astatic char *
2N/Acopy_alpha(char *arg)
2N/A{
2N/A int * width;
2N/A
2N/A if (Alloc(width, int))
2N/A *width = *((int *) arg);
2N/A return ((char *) width);
2N/A}
2N/A
2N/Astatic void
2N/Afree_alpha(char *arg)
2N/A{
2N/A Free(arg);
2N/A}
2N/A
2N/Astatic int
2N/Afcheck_alpha(FIELD *f, char *arg)
2N/A{
2N/A int width = *((int *) arg);
2N/A int n = 0;
2N/A char * v = field_buffer(f, 0);
2N/A
2N/A while (*v && *v == ' ')
2N/A ++v;
2N/A if (*v) {
2N/A char * vbeg = v;
2N/A while (*v && isalpha(*v))
2N/A ++v;
2N/A n = v - vbeg;
2N/A while (*v && *v == ' ')
2N/A ++v;
2N/A }
2N/A return (*v || n < width ? FALSE : TRUE);
2N/A}
2N/A
2N/A/*ARGSUSED*/
2N/A
2N/Astatic int
2N/Accheck_alpha(int c, char *arg)
2N/A{
2N/A return (isalpha(c));
2N/A}