8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libeti / form / common / ty_alnum.c
blob1b2074602205641da0e25919dd2250b8c57e0c46
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_ALNUM
42 * usage:
43 * set_field_type(f, TYPE_ALNUM, width);
45 * int width; minimum token width
47 static char * make_alnum(va_list *);
48 static char * copy_alnum(char *);
49 static void free_alnum(char *);
50 static int fcheck_alnum(FIELD *, char *);
51 static int ccheck_alnum(int, char *);
53 static FIELDTYPE typeALNUM =
55 ARGS, /* status */
56 1, /* ref */
57 (FIELDTYPE *) 0, /* left */
58 (FIELDTYPE *) 0, /* right */
59 make_alnum, /* makearg */
60 copy_alnum, /* copyarg */
61 free_alnum, /* freearg */
62 fcheck_alnum, /* fcheck */
63 ccheck_alnum, /* ccheck */
64 (PTF_int) 0, /* next */
65 (PTF_int) 0, /* prev */
68 FIELDTYPE * TYPE_ALNUM = &typeALNUM;
70 static char *
71 make_alnum(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_alnum(char *arg)
83 int * width;
85 if (Alloc(width, int))
86 *width = *((int *) arg);
87 return ((char *) width);
90 static void
91 free_alnum(char *arg)
93 Free(arg);
96 static int
97 fcheck_alnum(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 && isalnum(*v))
108 ++v;
109 n = (int) (v - vbeg);
110 while (*v && *v == ' ')
111 ++v;
113 return (*v || n < width ? FALSE : TRUE);
116 /*ARGSUSED*/
117 static int
118 ccheck_alnum(int c, char *arg)
120 return (isalnum(c));