1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
23*0Sstevel@tonic-gate /* All Rights Reserved */
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate * Copyright (c) 1997, by Sun Microsystems, Inc.
28*0Sstevel@tonic-gate * All rights reserved.
29*0Sstevel@tonic-gate */
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate /*LINTLIBRARY*/
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate #include <sys/types.h>
36*0Sstevel@tonic-gate #include "utility.h"
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate typedef struct {
39*0Sstevel@tonic-gate PTF_int class;
40*0Sstevel@tonic-gate PTF_int act;
41*0Sstevel@tonic-gate } REQUEST;
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gate static REQUEST parse(int);
44*0Sstevel@tonic-gate
45*0Sstevel@tonic-gate #define COMMAND(x) (x.class)
46*0Sstevel@tonic-gate #define CALL(x, f) (x.class ? (*x.class) (x.act, f) : E_SYSTEM_ERROR)
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gate /* command array(carray) order is significant(see form.h REQ_*) */
49*0Sstevel@tonic-gate static REQUEST carray [MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
50*0Sstevel@tonic-gate {
51*0Sstevel@tonic-gate _page_navigation, _next_page, /* REQ_NEXT_PAGE */
52*0Sstevel@tonic-gate _page_navigation, _prev_page, /* REQ_PREV_PAGE */
53*0Sstevel@tonic-gate _page_navigation, _first_page, /* REQ_FIRST_PAGE */
54*0Sstevel@tonic-gate _page_navigation, _last_page, /* REQ_LAST_PAGE */
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gate _field_navigation, _next_field, /* REQ_NEXT_FIELD */
57*0Sstevel@tonic-gate _field_navigation, _prev_field, /* REQ_PREV_FIELD */
58*0Sstevel@tonic-gate _field_navigation, _first_field, /* REQ_FIRST_FIELD */
59*0Sstevel@tonic-gate _field_navigation, _last_field, /* REQ_LAST_FIELD */
60*0Sstevel@tonic-gate _field_navigation, _snext_field, /* REQ_SNEXT_FIELD */
61*0Sstevel@tonic-gate _field_navigation, _sprev_field, /* REQ_SPREV_FIELD */
62*0Sstevel@tonic-gate _field_navigation, _sfirst_field, /* REQ_SFIRST_FIELD */
63*0Sstevel@tonic-gate _field_navigation, _slast_field, /* REQ_SLAST_FIELD */
64*0Sstevel@tonic-gate _field_navigation, _left_field, /* REQ_LEFT_FIELD */
65*0Sstevel@tonic-gate _field_navigation, _right_field, /* REQ_RIGHT_FIELD */
66*0Sstevel@tonic-gate _field_navigation, _up_field, /* REQ_UP_FIELD */
67*0Sstevel@tonic-gate _field_navigation, _down_field, /* REQ_DOWN_FIELD */
68*0Sstevel@tonic-gate
69*0Sstevel@tonic-gate _data_navigation, _next_char, /* REQ_NEXT_CHAR */
70*0Sstevel@tonic-gate _data_navigation, _prev_char, /* REQ_PREV_CHAR */
71*0Sstevel@tonic-gate _data_navigation, _next_line, /* REQ_NEXT_LINE */
72*0Sstevel@tonic-gate _data_navigation, _prev_line, /* REQ_PREV_LINE */
73*0Sstevel@tonic-gate _data_navigation, _next_word, /* REQ_NEXT_WORD */
74*0Sstevel@tonic-gate _data_navigation, _prev_word, /* REQ_PREV_WORD */
75*0Sstevel@tonic-gate _data_navigation, _beg_field, /* REQ_BEG_FIELD */
76*0Sstevel@tonic-gate _data_navigation, _end_field, /* REQ_END_FIELD */
77*0Sstevel@tonic-gate _data_navigation, _beg_line, /* REQ_BEG_LINE */
78*0Sstevel@tonic-gate _data_navigation, _end_line, /* REQ_END_LINE */
79*0Sstevel@tonic-gate _data_navigation, _left_char, /* REQ_LEFT_CHAR */
80*0Sstevel@tonic-gate _data_navigation, _right_char, /* REQ_RIGHT_CHAR */
81*0Sstevel@tonic-gate _data_navigation, _up_char, /* REQ_UP_CHAR */
82*0Sstevel@tonic-gate _data_navigation, _down_char, /* REQ_DOWN_CHAR */
83*0Sstevel@tonic-gate
84*0Sstevel@tonic-gate _misc_request, _new_line, /* REQ_NEW_LINE */
85*0Sstevel@tonic-gate _data_manipulation, _ins_char, /* REQ_INS_CHAR */
86*0Sstevel@tonic-gate _data_manipulation, _ins_line, /* REQ_INS_LINE */
87*0Sstevel@tonic-gate _data_manipulation, _del_char, /* REQ_DEL_CHAR */
88*0Sstevel@tonic-gate _misc_request, _del_prev, /* REQ_DEL_PREV */
89*0Sstevel@tonic-gate _data_manipulation, _del_line, /* REQ_DEL_LINE */
90*0Sstevel@tonic-gate _data_manipulation, _del_word, /* REQ_DEL_WORD */
91*0Sstevel@tonic-gate _data_manipulation, _clr_eol, /* REQ_CLR_EOL */
92*0Sstevel@tonic-gate _data_manipulation, _clr_eof, /* REQ_CLR_EOF */
93*0Sstevel@tonic-gate _data_manipulation, _clr_field, /* REQ_CLR_FIELD */
94*0Sstevel@tonic-gate
95*0Sstevel@tonic-gate _misc_request, _ovl_mode, /* REQ_OVL_MODE */
96*0Sstevel@tonic-gate _misc_request, _ins_mode, /* REQ_INS_MODE */
97*0Sstevel@tonic-gate
98*0Sstevel@tonic-gate _data_navigation, _scr_fline, /* REQ_SCR_FLINE */
99*0Sstevel@tonic-gate _data_navigation, _scr_bline, /* REQ_SCR_BLINE */
100*0Sstevel@tonic-gate _data_navigation, _scr_fpage, /* REQ_SCR_FPAGE */
101*0Sstevel@tonic-gate _data_navigation, _scr_bpage, /* REQ_SCR_BPAGE */
102*0Sstevel@tonic-gate _data_navigation, _scr_fhpage, /* REQ_SCR_FHPAGE */
103*0Sstevel@tonic-gate _data_navigation, _scr_bhpage, /* REQ_SCR_BHPAGE */
104*0Sstevel@tonic-gate
105*0Sstevel@tonic-gate _data_navigation, _scr_fchar, /* REQ_SCR_FCHAR */
106*0Sstevel@tonic-gate _data_navigation, _scr_bchar, /* REQ_SCR_BCHAR */
107*0Sstevel@tonic-gate _data_navigation, _scr_hfline, /* REQ_SCR_HFLINE */
108*0Sstevel@tonic-gate _data_navigation, _scr_hbline, /* REQ_SCR_HBLINE */
109*0Sstevel@tonic-gate _data_navigation, _scr_hfhalf, /* REQ_SCR_HFHALF */
110*0Sstevel@tonic-gate _data_navigation, _scr_hbhalf, /* REQ_SCR_HBHALF */
111*0Sstevel@tonic-gate
112*0Sstevel@tonic-gate _misc_request, _validation, /* REQ_VALIDATION */
113*0Sstevel@tonic-gate _misc_request, _next_choice, /* REQ_NEXT_CHOICE */
114*0Sstevel@tonic-gate _misc_request, _prev_choice, /* REQ_PREV_CHOICE */
115*0Sstevel@tonic-gate };
116*0Sstevel@tonic-gate
117*0Sstevel@tonic-gate static REQUEST FAIL = { (PTF_int) 0, (PTF_int) 0 };
118*0Sstevel@tonic-gate
119*0Sstevel@tonic-gate /* _page_navigation - service page navigation request */
120*0Sstevel@tonic-gate int
_page_navigation(PTF_int act,FORM * f)121*0Sstevel@tonic-gate _page_navigation(PTF_int act, FORM *f)
122*0Sstevel@tonic-gate {
123*0Sstevel@tonic-gate int v;
124*0Sstevel@tonic-gate
125*0Sstevel@tonic-gate if (_validate(f)) {
126*0Sstevel@tonic-gate term_field(f);
127*0Sstevel@tonic-gate term_form(f);
128*0Sstevel@tonic-gate v = (*act) (f);
129*0Sstevel@tonic-gate init_form(f);
130*0Sstevel@tonic-gate init_field(f);
131*0Sstevel@tonic-gate } else
132*0Sstevel@tonic-gate v = E_INVALID_FIELD;
133*0Sstevel@tonic-gate
134*0Sstevel@tonic-gate return (v);
135*0Sstevel@tonic-gate }
136*0Sstevel@tonic-gate
137*0Sstevel@tonic-gate /* _field_navigation - service inter-field navigation request */
138*0Sstevel@tonic-gate int
_field_navigation(PTF_int act,FORM * f)139*0Sstevel@tonic-gate _field_navigation(PTF_int act, FORM *f)
140*0Sstevel@tonic-gate {
141*0Sstevel@tonic-gate int v;
142*0Sstevel@tonic-gate
143*0Sstevel@tonic-gate if (_validate(f)) {
144*0Sstevel@tonic-gate term_field(f);
145*0Sstevel@tonic-gate v = (*act) (f);
146*0Sstevel@tonic-gate init_field(f);
147*0Sstevel@tonic-gate } else
148*0Sstevel@tonic-gate v = E_INVALID_FIELD;
149*0Sstevel@tonic-gate
150*0Sstevel@tonic-gate return (v);
151*0Sstevel@tonic-gate }
152*0Sstevel@tonic-gate
153*0Sstevel@tonic-gate /* _data_navigation - service intra-field navagation request */
154*0Sstevel@tonic-gate int
_data_navigation(PTF_int act,FORM * f)155*0Sstevel@tonic-gate _data_navigation(PTF_int act, FORM *f)
156*0Sstevel@tonic-gate {
157*0Sstevel@tonic-gate return ((*act) (f));
158*0Sstevel@tonic-gate }
159*0Sstevel@tonic-gate
160*0Sstevel@tonic-gate /* _data_manipulation - service data modification request */
161*0Sstevel@tonic-gate int
_data_manipulation(PTF_int act,FORM * f)162*0Sstevel@tonic-gate _data_manipulation(PTF_int act, FORM *f)
163*0Sstevel@tonic-gate {
164*0Sstevel@tonic-gate int v = E_REQUEST_DENIED;
165*0Sstevel@tonic-gate FIELD * c = C(f);
166*0Sstevel@tonic-gate
167*0Sstevel@tonic-gate if (Opt(c, O_EDIT))
168*0Sstevel@tonic-gate if ((v = (*act) (f)) == E_OK)
169*0Sstevel@tonic-gate Set(f, WIN_CHG);
170*0Sstevel@tonic-gate return (v);
171*0Sstevel@tonic-gate }
172*0Sstevel@tonic-gate
173*0Sstevel@tonic-gate int
_misc_request(PTF_int act,FORM * f)174*0Sstevel@tonic-gate _misc_request(PTF_int act, FORM *f)
175*0Sstevel@tonic-gate {
176*0Sstevel@tonic-gate return ((*act) (f));
177*0Sstevel@tonic-gate }
178*0Sstevel@tonic-gate
179*0Sstevel@tonic-gate int
form_driver(FORM * f,int c)180*0Sstevel@tonic-gate form_driver(FORM *f, int c)
181*0Sstevel@tonic-gate {
182*0Sstevel@tonic-gate int v;
183*0Sstevel@tonic-gate REQUEST x;
184*0Sstevel@tonic-gate
185*0Sstevel@tonic-gate if (f) {
186*0Sstevel@tonic-gate if (Status(f, DRIVER))
187*0Sstevel@tonic-gate
188*0Sstevel@tonic-gate v = E_BAD_STATE;
189*0Sstevel@tonic-gate
190*0Sstevel@tonic-gate else if (Status(f, POSTED)) {
191*0Sstevel@tonic-gate x = parse(c);
192*0Sstevel@tonic-gate
193*0Sstevel@tonic-gate if (COMMAND(x))
194*0Sstevel@tonic-gate v = CALL(x, f);
195*0Sstevel@tonic-gate else {
196*0Sstevel@tonic-gate if (isascii(c) && isprint(c) &&
197*0Sstevel@tonic-gate CheckChar(C(f), c))
198*0Sstevel@tonic-gate v = _data_entry(f, c);
199*0Sstevel@tonic-gate else
200*0Sstevel@tonic-gate v = E_UNKNOWN_COMMAND;
201*0Sstevel@tonic-gate }
202*0Sstevel@tonic-gate (void) _update_current(f);
203*0Sstevel@tonic-gate } else
204*0Sstevel@tonic-gate v = E_NOT_POSTED;
205*0Sstevel@tonic-gate } else
206*0Sstevel@tonic-gate v = E_BAD_ARGUMENT;
207*0Sstevel@tonic-gate
208*0Sstevel@tonic-gate return (v);
209*0Sstevel@tonic-gate }
210*0Sstevel@tonic-gate
211*0Sstevel@tonic-gate static REQUEST
parse(int c)212*0Sstevel@tonic-gate parse(int c)
213*0Sstevel@tonic-gate {
214*0Sstevel@tonic-gate if (c < MIN_FORM_COMMAND || c > MAX_FORM_COMMAND)
215*0Sstevel@tonic-gate return (FAIL);
216*0Sstevel@tonic-gate
217*0Sstevel@tonic-gate return (carray[c - MIN_FORM_COMMAND]);
218*0Sstevel@tonic-gate }
219