8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libeti / form / common / ty_alpha.c
blobccaf5def593d64881468875e3f831c6f1e04d759
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright (c) 1997, by Sun Microsystems, Inc.
28 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */
33 /*LINTLIBRARY*/
35 #include <sys/types.h>
36 #include <stdlib.h>
37 #include "utility.h"
40 * TYPE_ALPHA standard type
42 * usage:
43 * set_field_type(f, TYPE_ALPHA, width);
45 * int width; minimum token width
47 static char *make_alpha(va_list *);
48 static char *copy_alpha(char *);
49 static void free_alpha(char *);
50 static int fcheck_alpha(FIELD *, char *);
51 static int ccheck_alpha(int, char *);
53 static FIELDTYPE typeALPHA =
55 ARGS, /* status */
56 1, /* ref */
57 (FIELDTYPE *) 0, /* left */
58 (FIELDTYPE *) 0, /* right */
59 make_alpha, /* makearg */
60 copy_alpha, /* copyarg */
61 free_alpha, /* freearg */
62 fcheck_alpha, /* fcheck */
63 ccheck_alpha, /* ccheck */
64 (PTF_int) 0, /* next */
65 (PTF_int) 0, /* prev */
68 FIELDTYPE * TYPE_ALPHA = &typeALPHA;
70 static char *
71 make_alpha(va_list *ap)
73 int * width;
75 if (Alloc(width, int))
76 *width = va_arg(*ap, int);
77 return ((char *) width);
80 static char *
81 copy_alpha(char *arg)
83 int * width;
85 if (Alloc(width, int))
86 *width = *((int *) arg);
87 return ((char *) width);
90 static void
91 free_alpha(char *arg)
93 Free(arg);
96 static int
97 fcheck_alpha(FIELD *f, char *arg)
99 int width = *((int *) arg);
100 int n = 0;
101 char * v = field_buffer(f, 0);
103 while (*v && *v == ' ')
104 ++v;
105 if (*v) {
106 char * vbeg = v;
107 while (*v && isalpha(*v))
108 ++v;
109 n = v - vbeg;
110 while (*v && *v == ' ')
111 ++v;
113 return (*v || n < width ? FALSE : TRUE);
116 /*ARGSUSED*/
118 static int
119 ccheck_alpha(int c, char *arg)
121 return (isalpha(c));