kernel - VM PAGER part 2/2 - Expand vinitvmio() and vnode_pager_alloc()
[dragonfly.git] / contrib / ncurses / form / fty_alpha.c
blobbd49544ffdb5b5553f5d42169fca1c9e097ff86c
1 /****************************************************************************
2 * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
3 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
11 * *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
14 * *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22 * *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
26 * authorization. *
27 ****************************************************************************/
29 /***************************************************************************
30 * *
31 * Author : Juergen Pfeifer *
32 * *
33 ***************************************************************************/
35 #include "form.priv.h"
37 MODULE_ID("$Id: fty_alpha.c,v 1.23 2007/10/13 19:32:09 tom Exp $")
39 #define thisARG alphaARG
41 typedef struct
43 int width;
45 thisARG;
47 /*---------------------------------------------------------------------------
48 | Facility : libnform
49 | Function : static void *Make_This_Type(va_list *ap)
51 | Description : Allocate structure for alpha type argument.
53 | Return Values : Pointer to argument structure or NULL on error
54 +--------------------------------------------------------------------------*/
55 static void *
56 Make_This_Type(va_list *ap)
58 thisARG *argp = typeMalloc(thisARG, 1);
60 if (argp)
62 T((T_CREATE("thisARG %p"), argp));
63 argp->width = va_arg(*ap, int);
66 return ((void *)argp);
69 /*---------------------------------------------------------------------------
70 | Facility : libnform
71 | Function : static void *Copy_This_Type(const void * argp)
73 | Description : Copy structure for alpha type argument.
75 | Return Values : Pointer to argument structure or NULL on error.
76 +--------------------------------------------------------------------------*/
77 static void *
78 Copy_This_Type(const void *argp)
80 const thisARG *ap = (const thisARG *)argp;
81 thisARG *result = typeMalloc(thisARG, 1);
83 if (result)
85 T((T_CREATE("thisARG %p"), result));
86 *result = *ap;
89 return ((void *)result);
92 /*---------------------------------------------------------------------------
93 | Facility : libnform
94 | Function : static void Free_This_Type(void *argp)
96 | Description : Free structure for alpha type argument.
98 | Return Values : -
99 +--------------------------------------------------------------------------*/
100 static void
101 Free_This_Type(void *argp)
103 if (argp)
104 free(argp);
107 /*---------------------------------------------------------------------------
108 | Facility : libnform
109 | Function : static bool Check_This_Character(
110 | int c,
111 | const void *argp)
113 | Description : Check a character for the alpha type.
115 | Return Values : TRUE - character is valid
116 | FALSE - character is invalid
117 +--------------------------------------------------------------------------*/
118 static bool
119 Check_This_Character(int c, const void *argp GCC_UNUSED)
121 #if USE_WIDEC_SUPPORT
122 if (iswalpha((wint_t) c))
123 return TRUE;
124 #endif
125 return (isalpha(UChar(c)) ? TRUE : FALSE);
128 /*---------------------------------------------------------------------------
129 | Facility : libnform
130 | Function : static bool Check_This_Field(
131 | FIELD *field,
132 | const void *argp)
134 | Description : Validate buffer content to be a valid alpha value
136 | Return Values : TRUE - field is valid
137 | FALSE - field is invalid
138 +--------------------------------------------------------------------------*/
139 static bool
140 Check_This_Field(FIELD *field, const void *argp)
142 int width = ((const thisARG *)argp)->width;
143 unsigned char *bp = (unsigned char *)field_buffer(field, 0);
144 bool result = (width < 0);
146 Check_CTYPE_Field(result, bp, width, Check_This_Character);
147 return (result);
150 static FIELDTYPE typeTHIS =
152 _HAS_ARGS | _RESIDENT,
153 1, /* this is mutable, so we can't be const */
154 (FIELDTYPE *)0,
155 (FIELDTYPE *)0,
156 Make_This_Type,
157 Copy_This_Type,
158 Free_This_Type,
159 Check_This_Field,
160 Check_This_Character,
161 NULL,
162 NULL
165 NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeTHIS;
167 /* fty_alpha.c ends here */