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