xref: /titanic_41/usr/src/lib/libeti/form/common/field.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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"
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 <stdlib.h>
37*7c478bd9Sstevel@tonic-gate #include "utility.h"
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate 	/*
40*7c478bd9Sstevel@tonic-gate 	 *  default field
41*7c478bd9Sstevel@tonic-gate 	 */
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate static FIELD default_field =
44*7c478bd9Sstevel@tonic-gate {
45*7c478bd9Sstevel@tonic-gate 			0,			/* status	*/
46*7c478bd9Sstevel@tonic-gate 			0,			/* rows		*/
47*7c478bd9Sstevel@tonic-gate 			0,			/* cols		*/
48*7c478bd9Sstevel@tonic-gate 			0,			/* frow		*/
49*7c478bd9Sstevel@tonic-gate 			0,			/* fcol		*/
50*7c478bd9Sstevel@tonic-gate 			0,			/* drows	*/
51*7c478bd9Sstevel@tonic-gate 			0,			/* dcols	*/
52*7c478bd9Sstevel@tonic-gate 			0,			/* maxgrow	*/
53*7c478bd9Sstevel@tonic-gate 			0,			/* nrow		*/
54*7c478bd9Sstevel@tonic-gate 			0,			/* nbuf		*/
55*7c478bd9Sstevel@tonic-gate 			NO_JUSTIFICATION,	/* just		*/
56*7c478bd9Sstevel@tonic-gate 			0,			/* page		*/
57*7c478bd9Sstevel@tonic-gate 			0,			/* index	*/
58*7c478bd9Sstevel@tonic-gate 			' ',			/* pad		*/
59*7c478bd9Sstevel@tonic-gate 			A_NORMAL,		/* fore		*/
60*7c478bd9Sstevel@tonic-gate 			A_NORMAL,		/* back		*/
61*7c478bd9Sstevel@tonic-gate 			O_VISIBLE	|
62*7c478bd9Sstevel@tonic-gate 			O_ACTIVE	|
63*7c478bd9Sstevel@tonic-gate 			O_PUBLIC	|
64*7c478bd9Sstevel@tonic-gate 			O_EDIT		|
65*7c478bd9Sstevel@tonic-gate 			O_WRAP		|
66*7c478bd9Sstevel@tonic-gate 			O_BLANK		|
67*7c478bd9Sstevel@tonic-gate 			O_AUTOSKIP	|
68*7c478bd9Sstevel@tonic-gate 			O_NULLOK	|
69*7c478bd9Sstevel@tonic-gate 			O_PASSOK	|
70*7c478bd9Sstevel@tonic-gate 			O_STATIC,		/* opts		*/
71*7c478bd9Sstevel@tonic-gate 			(FIELD *)0,		/* snext	*/
72*7c478bd9Sstevel@tonic-gate 			(FIELD *)0,		/* sprev	*/
73*7c478bd9Sstevel@tonic-gate 			(FIELD *)0,		/* link		*/
74*7c478bd9Sstevel@tonic-gate 			(FORM *)0,		/* form		*/
75*7c478bd9Sstevel@tonic-gate 			(FIELDTYPE *)0,		/* type		*/
76*7c478bd9Sstevel@tonic-gate 			(char *)0,		/* arg		*/
77*7c478bd9Sstevel@tonic-gate 			(char *)0,		/* buf		*/
78*7c478bd9Sstevel@tonic-gate 			(char *)0,		/* usrptr	*/
79*7c478bd9Sstevel@tonic-gate };
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate FIELD * _DEFAULT_FIELD	= &default_field;
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate 	/*
84*7c478bd9Sstevel@tonic-gate 	 *  MakeType
85*7c478bd9Sstevel@tonic-gate 	 */
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate static int
MakeType(FIELD * f,va_list * ap)88*7c478bd9Sstevel@tonic-gate MakeType(FIELD *f, va_list *ap)
89*7c478bd9Sstevel@tonic-gate {
90*7c478bd9Sstevel@tonic-gate 	int err = 0;
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate 	f->arg = MakeArg(f, ap, &err);	/* pick off type specific args	*/
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate 	if (err) {
95*7c478bd9Sstevel@tonic-gate 		FreeArg(f);		/* release type specific args	*/
96*7c478bd9Sstevel@tonic-gate 		f->type = (FIELDTYPE *)0;
97*7c478bd9Sstevel@tonic-gate 		f->arg = (char *)0;
98*7c478bd9Sstevel@tonic-gate 		return (FALSE);
99*7c478bd9Sstevel@tonic-gate 	}
100*7c478bd9Sstevel@tonic-gate 	IncrType(f->type);		/* increment reference count	*/
101*7c478bd9Sstevel@tonic-gate 	return (TRUE);
102*7c478bd9Sstevel@tonic-gate }
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate 	/*
105*7c478bd9Sstevel@tonic-gate 	 *  CopyType
106*7c478bd9Sstevel@tonic-gate 	 */
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate static int
CopyType(FIELD * f,FIELD * fsrc)109*7c478bd9Sstevel@tonic-gate CopyType(FIELD *f, FIELD *fsrc)
110*7c478bd9Sstevel@tonic-gate {
111*7c478bd9Sstevel@tonic-gate 	int err = 0;
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate 	f->type = fsrc->type;		/* copy field type		*/
114*7c478bd9Sstevel@tonic-gate 	f->arg = CopyArg(fsrc, &err);	/* copy type specific info	*/
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate 	if (err) {
117*7c478bd9Sstevel@tonic-gate 		FreeArg(f);		/* release type specific args	*/
118*7c478bd9Sstevel@tonic-gate 		f->type = (FIELDTYPE *)0;
119*7c478bd9Sstevel@tonic-gate 		f->arg = (char *)0;
120*7c478bd9Sstevel@tonic-gate 		return (FALSE);
121*7c478bd9Sstevel@tonic-gate 	}
122*7c478bd9Sstevel@tonic-gate 	IncrType(f->type);		/* increment reference count	*/
123*7c478bd9Sstevel@tonic-gate 	return (TRUE);
124*7c478bd9Sstevel@tonic-gate }
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate 	/*
127*7c478bd9Sstevel@tonic-gate 	 *  FreeType
128*7c478bd9Sstevel@tonic-gate 	 */
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate static void
FreeType(FIELD * f)131*7c478bd9Sstevel@tonic-gate FreeType(FIELD *f)
132*7c478bd9Sstevel@tonic-gate {
133*7c478bd9Sstevel@tonic-gate 	DecrType(f->type);		/* decrement reference count	*/
134*7c478bd9Sstevel@tonic-gate 	FreeArg(f);			/* release type specific args	*/
135*7c478bd9Sstevel@tonic-gate }
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate 	/*
138*7c478bd9Sstevel@tonic-gate 	 *  new_field
139*7c478bd9Sstevel@tonic-gate 	 */
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate FIELD *
new_field(int rows,int cols,int frow,int fcol,int nrow,int nbuf)142*7c478bd9Sstevel@tonic-gate new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate /* int rows;	 number of visible rows		*/
145*7c478bd9Sstevel@tonic-gate /* int cols;	 number of visible cols		*/
146*7c478bd9Sstevel@tonic-gate /* int frow;	 first row relative to form origin	*/
147*7c478bd9Sstevel@tonic-gate /* int fcol;	 first col relative to form origin	*/
148*7c478bd9Sstevel@tonic-gate /* int nrow;	 number of off screen rows		*/
149*7c478bd9Sstevel@tonic-gate /* int nbuf;	 number of additional buffers		*/
150*7c478bd9Sstevel@tonic-gate {
151*7c478bd9Sstevel@tonic-gate 	FIELD *f = (FIELD *) 0;
152*7c478bd9Sstevel@tonic-gate 	int i, size;
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate 	if (rows > 0 &&	cols > 0 && frow >= 0 && fcol >= 0 && nrow >= 0 &&
155*7c478bd9Sstevel@tonic-gate 	    nbuf >= 0 && Alloc(f, FIELD)) {
156*7c478bd9Sstevel@tonic-gate 		*f = *_DEFAULT_FIELD;
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate 		f->rows	= rows;
159*7c478bd9Sstevel@tonic-gate 		f->cols	= cols;
160*7c478bd9Sstevel@tonic-gate 		f->frow	= frow;
161*7c478bd9Sstevel@tonic-gate 		f->fcol	= fcol;
162*7c478bd9Sstevel@tonic-gate 		f->drows	= rows + nrow;
163*7c478bd9Sstevel@tonic-gate 		f->dcols	= cols;
164*7c478bd9Sstevel@tonic-gate 		f->nrow	= nrow;
165*7c478bd9Sstevel@tonic-gate 		f->nbuf	= nbuf;
166*7c478bd9Sstevel@tonic-gate 		f->link	= f;
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate 		if (CopyType(f, _DEFAULT_FIELD)) {
169*7c478bd9Sstevel@tonic-gate 			size = TotalBuf(f);
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate 			if (arrayAlloc(Buf(f), size, char)) {
172*7c478bd9Sstevel@tonic-gate 				(void) memset(Buf(f), ' ', size);
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate 				for (i = 0; i <= f->nbuf; ++i)
175*7c478bd9Sstevel@tonic-gate 					*(Buffer(f, i + 1) - 1) = '\0';
176*7c478bd9Sstevel@tonic-gate 				return (f);
177*7c478bd9Sstevel@tonic-gate 			}
178*7c478bd9Sstevel@tonic-gate 		}
179*7c478bd9Sstevel@tonic-gate 	}
180*7c478bd9Sstevel@tonic-gate 	(void) free_field(f);
181*7c478bd9Sstevel@tonic-gate 	return ((FIELD *) 0);
182*7c478bd9Sstevel@tonic-gate }
183*7c478bd9Sstevel@tonic-gate 
184*7c478bd9Sstevel@tonic-gate 	/*
185*7c478bd9Sstevel@tonic-gate 	 *  dup_field
186*7c478bd9Sstevel@tonic-gate 	 */
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate FIELD *
dup_field(FIELD * field,int frow,int fcol)189*7c478bd9Sstevel@tonic-gate dup_field(FIELD *field, int frow, int fcol)
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate /* FIELD * field;	 field to duplicate		*/
192*7c478bd9Sstevel@tonic-gate /* int frow;	 first row relative to form origin	*/
193*7c478bd9Sstevel@tonic-gate /* int fcol;	 first col relative to form origin	*/
194*7c478bd9Sstevel@tonic-gate {
195*7c478bd9Sstevel@tonic-gate 	FIELD *f = (FIELD *) 0;
196*7c478bd9Sstevel@tonic-gate 	int size;
197*7c478bd9Sstevel@tonic-gate 
198*7c478bd9Sstevel@tonic-gate 	if (field && frow >= 0 && fcol >= 0 && Alloc(f, FIELD)) {
199*7c478bd9Sstevel@tonic-gate 		*f = *_DEFAULT_FIELD;
200*7c478bd9Sstevel@tonic-gate 
201*7c478bd9Sstevel@tonic-gate 		f->frow = frow;
202*7c478bd9Sstevel@tonic-gate 		f->fcol = fcol;
203*7c478bd9Sstevel@tonic-gate 		f->link = f;
204*7c478bd9Sstevel@tonic-gate 
205*7c478bd9Sstevel@tonic-gate 		f->rows	= field->rows;
206*7c478bd9Sstevel@tonic-gate 		f->cols	= field->cols;
207*7c478bd9Sstevel@tonic-gate 		f->drows = field->drows;
208*7c478bd9Sstevel@tonic-gate 		f->dcols = field->dcols;
209*7c478bd9Sstevel@tonic-gate 		f->maxgrow = field->maxgrow;
210*7c478bd9Sstevel@tonic-gate 		f->nrow = field->nrow;
211*7c478bd9Sstevel@tonic-gate 		f->nbuf	= field->nbuf;
212*7c478bd9Sstevel@tonic-gate 		f->just = field->just;
213*7c478bd9Sstevel@tonic-gate 		f->fore	= field->fore;
214*7c478bd9Sstevel@tonic-gate 		f->back	= field->back;
215*7c478bd9Sstevel@tonic-gate 		f->pad	= field->pad;
216*7c478bd9Sstevel@tonic-gate 		f->opts	= field->opts;
217*7c478bd9Sstevel@tonic-gate 		f->usrptr = field->usrptr;
218*7c478bd9Sstevel@tonic-gate 		f->status = Status(field, GROWABLE);
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate 		if (CopyType(f, field)) {
221*7c478bd9Sstevel@tonic-gate 			size = TotalBuf(f);
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate 			if (arrayAlloc(Buf(f), size, char)) {
224*7c478bd9Sstevel@tonic-gate 				(void) memcpy(Buf(f), Buf(field), size);
225*7c478bd9Sstevel@tonic-gate 				return (f);
226*7c478bd9Sstevel@tonic-gate 			}
227*7c478bd9Sstevel@tonic-gate 		}
228*7c478bd9Sstevel@tonic-gate 	}
229*7c478bd9Sstevel@tonic-gate 	(void) free_field(f);
230*7c478bd9Sstevel@tonic-gate 	return ((FIELD *) 0);
231*7c478bd9Sstevel@tonic-gate }
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate 	/*
234*7c478bd9Sstevel@tonic-gate 	 *  link_field
235*7c478bd9Sstevel@tonic-gate 	 */
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate FIELD *
link_field(FIELD * field,int frow,int fcol)238*7c478bd9Sstevel@tonic-gate link_field(FIELD *field, int frow, int fcol)
239*7c478bd9Sstevel@tonic-gate 
240*7c478bd9Sstevel@tonic-gate /* FIELD * field;	 field to link to		*/
241*7c478bd9Sstevel@tonic-gate /* int frow;	 first row relative to form origin	*/
242*7c478bd9Sstevel@tonic-gate /* int fcol;	 first col relative to form origin	*/
243*7c478bd9Sstevel@tonic-gate {
244*7c478bd9Sstevel@tonic-gate 	FIELD *f = (FIELD *) 0;
245*7c478bd9Sstevel@tonic-gate 
246*7c478bd9Sstevel@tonic-gate 	if (field && frow >= 0 && fcol >= 0 && Alloc(f, FIELD)) {
247*7c478bd9Sstevel@tonic-gate 		*f = *_DEFAULT_FIELD;
248*7c478bd9Sstevel@tonic-gate 
249*7c478bd9Sstevel@tonic-gate 		f->frow = frow;
250*7c478bd9Sstevel@tonic-gate 		f->fcol = fcol;
251*7c478bd9Sstevel@tonic-gate 
252*7c478bd9Sstevel@tonic-gate 		f->link = field->link;
253*7c478bd9Sstevel@tonic-gate 		field->link = f;		/* add field to linked list */
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate 		f->buf	= field->buf;
256*7c478bd9Sstevel@tonic-gate 		f->rows	= field->rows;
257*7c478bd9Sstevel@tonic-gate 		f->cols	= field->cols;
258*7c478bd9Sstevel@tonic-gate 		f->drows = field->drows;
259*7c478bd9Sstevel@tonic-gate 		f->dcols = field->dcols;
260*7c478bd9Sstevel@tonic-gate 		f->maxgrow = field->maxgrow;
261*7c478bd9Sstevel@tonic-gate 		f->nrow	= field->nrow;
262*7c478bd9Sstevel@tonic-gate 		f->nbuf	= field->nbuf;
263*7c478bd9Sstevel@tonic-gate 		f->just	= field->just;
264*7c478bd9Sstevel@tonic-gate 		f->fore	= field->fore;
265*7c478bd9Sstevel@tonic-gate 		f->back	= field->back;
266*7c478bd9Sstevel@tonic-gate 		f->pad	= field->pad;
267*7c478bd9Sstevel@tonic-gate 		f->opts	= field->opts;
268*7c478bd9Sstevel@tonic-gate 		f->usrptr = field->usrptr;
269*7c478bd9Sstevel@tonic-gate 		f->status = Status(field, GROWABLE);
270*7c478bd9Sstevel@tonic-gate 
271*7c478bd9Sstevel@tonic-gate 		if (CopyType(f, field))
272*7c478bd9Sstevel@tonic-gate 			return (f);
273*7c478bd9Sstevel@tonic-gate 	}
274*7c478bd9Sstevel@tonic-gate 	(void) free_field(f);
275*7c478bd9Sstevel@tonic-gate 	return ((FIELD *) 0);
276*7c478bd9Sstevel@tonic-gate }
277*7c478bd9Sstevel@tonic-gate 
278*7c478bd9Sstevel@tonic-gate 	/*
279*7c478bd9Sstevel@tonic-gate 	 *  free_field
280*7c478bd9Sstevel@tonic-gate 	 */
281*7c478bd9Sstevel@tonic-gate 
282*7c478bd9Sstevel@tonic-gate int
free_field(FIELD * f)283*7c478bd9Sstevel@tonic-gate free_field(FIELD *f)
284*7c478bd9Sstevel@tonic-gate {
285*7c478bd9Sstevel@tonic-gate 	FIELD *p;
286*7c478bd9Sstevel@tonic-gate 
287*7c478bd9Sstevel@tonic-gate 	if (!f)
288*7c478bd9Sstevel@tonic-gate 		return (E_BAD_ARGUMENT);
289*7c478bd9Sstevel@tonic-gate 
290*7c478bd9Sstevel@tonic-gate 	if (f->form)
291*7c478bd9Sstevel@tonic-gate 		return (E_CONNECTED);
292*7c478bd9Sstevel@tonic-gate 
293*7c478bd9Sstevel@tonic-gate 	if (f->link != f) {	/* check for linked field */
294*7c478bd9Sstevel@tonic-gate 		for (p = f->link; p->link != f; p = p->link)
295*7c478bd9Sstevel@tonic-gate 			;
296*7c478bd9Sstevel@tonic-gate 		p->link = f->link;	/* delete from list	*/
297*7c478bd9Sstevel@tonic-gate 	} else
298*7c478bd9Sstevel@tonic-gate 		Free(Buf(f));		/* free buffer space	*/
299*7c478bd9Sstevel@tonic-gate 
300*7c478bd9Sstevel@tonic-gate 	FreeType(f);
301*7c478bd9Sstevel@tonic-gate 	Free(f);
302*7c478bd9Sstevel@tonic-gate 	return (E_OK);
303*7c478bd9Sstevel@tonic-gate }
304*7c478bd9Sstevel@tonic-gate 
305*7c478bd9Sstevel@tonic-gate 	/*
306*7c478bd9Sstevel@tonic-gate 	 *  field_info
307*7c478bd9Sstevel@tonic-gate 	 */
308*7c478bd9Sstevel@tonic-gate 
309*7c478bd9Sstevel@tonic-gate int
field_info(FIELD * f,int * rows,int * cols,int * frow,int * fcol,int * nrow,int * nbuf)310*7c478bd9Sstevel@tonic-gate field_info(FIELD *f, int *rows, int *cols, int *frow, int *fcol,
311*7c478bd9Sstevel@tonic-gate 	int *nrow, int *nbuf)
312*7c478bd9Sstevel@tonic-gate 
313*7c478bd9Sstevel@tonic-gate /* FIELD *f;	field whose information is wanted */
314*7c478bd9Sstevel@tonic-gate /* int *rows;	number of visible rows		*/
315*7c478bd9Sstevel@tonic-gate /* int *cols;	number of visible cols		*/
316*7c478bd9Sstevel@tonic-gate /* int *frow;	first row relative to form origin */
317*7c478bd9Sstevel@tonic-gate /* int *fcol;	first col relative to form origin */
318*7c478bd9Sstevel@tonic-gate /* int *nrow;	number of off screen rows	*/
319*7c478bd9Sstevel@tonic-gate /* int *nbuf;	number of additional buffers	*/
320*7c478bd9Sstevel@tonic-gate {
321*7c478bd9Sstevel@tonic-gate 	if (!f)
322*7c478bd9Sstevel@tonic-gate 		return (E_BAD_ARGUMENT);
323*7c478bd9Sstevel@tonic-gate 
324*7c478bd9Sstevel@tonic-gate 	*rows = f->rows;
325*7c478bd9Sstevel@tonic-gate 	*cols = f->cols;
326*7c478bd9Sstevel@tonic-gate 	*frow = f->frow;
327*7c478bd9Sstevel@tonic-gate 	*fcol = f->fcol;
328*7c478bd9Sstevel@tonic-gate 	*nrow = f->nrow;
329*7c478bd9Sstevel@tonic-gate 	*nbuf = f->nbuf;
330*7c478bd9Sstevel@tonic-gate 	return (E_OK);
331*7c478bd9Sstevel@tonic-gate }
332*7c478bd9Sstevel@tonic-gate 
333*7c478bd9Sstevel@tonic-gate 	/*
334*7c478bd9Sstevel@tonic-gate 	 *  set_max_field
335*7c478bd9Sstevel@tonic-gate 	 */
336*7c478bd9Sstevel@tonic-gate 
337*7c478bd9Sstevel@tonic-gate int
set_max_field(FIELD * f,int max)338*7c478bd9Sstevel@tonic-gate set_max_field(FIELD *f, int max)
339*7c478bd9Sstevel@tonic-gate {
340*7c478bd9Sstevel@tonic-gate 	BOOLEAN	onerow = OneRow(f);
341*7c478bd9Sstevel@tonic-gate 
342*7c478bd9Sstevel@tonic-gate 	if (!f || max && ((onerow && f->dcols > max) ||
343*7c478bd9Sstevel@tonic-gate 	    (!onerow && f->drows > max)))
344*7c478bd9Sstevel@tonic-gate 		return (E_BAD_ARGUMENT);
345*7c478bd9Sstevel@tonic-gate 
346*7c478bd9Sstevel@tonic-gate 	f->maxgrow = max;
347*7c478bd9Sstevel@tonic-gate 	Clr(f, GROWABLE);
348*7c478bd9Sstevel@tonic-gate 
349*7c478bd9Sstevel@tonic-gate 	if (!Opt(f, O_STATIC) && ((!max || onerow && f->dcols < max) ||
350*7c478bd9Sstevel@tonic-gate 	    (!onerow && f->drows < max))) {
351*7c478bd9Sstevel@tonic-gate 		Set(f, GROWABLE);
352*7c478bd9Sstevel@tonic-gate 	}
353*7c478bd9Sstevel@tonic-gate 
354*7c478bd9Sstevel@tonic-gate 	return (E_OK);
355*7c478bd9Sstevel@tonic-gate }
356*7c478bd9Sstevel@tonic-gate 
357*7c478bd9Sstevel@tonic-gate 	/*
358*7c478bd9Sstevel@tonic-gate 	 *  dynamic_field_info
359*7c478bd9Sstevel@tonic-gate 	 */
360*7c478bd9Sstevel@tonic-gate 
361*7c478bd9Sstevel@tonic-gate int
dynamic_field_info(FIELD * f,int * drows,int * dcols,int * max)362*7c478bd9Sstevel@tonic-gate dynamic_field_info(FIELD *f, int *drows, int *dcols, int *max)
363*7c478bd9Sstevel@tonic-gate 
364*7c478bd9Sstevel@tonic-gate /* FIELD *f;	 field whose information is wanted */
365*7c478bd9Sstevel@tonic-gate /* int *drows;	 number of actual rows	*/
366*7c478bd9Sstevel@tonic-gate /* int *dcols;	 number of actual cols	*/
367*7c478bd9Sstevel@tonic-gate /* int *max;	 maximum growth allowable, else -1 */
368*7c478bd9Sstevel@tonic-gate {
369*7c478bd9Sstevel@tonic-gate 	if (!f)
370*7c478bd9Sstevel@tonic-gate 		return (E_BAD_ARGUMENT);
371*7c478bd9Sstevel@tonic-gate 
372*7c478bd9Sstevel@tonic-gate 	*drows = f->drows;
373*7c478bd9Sstevel@tonic-gate 	*dcols = f->dcols;
374*7c478bd9Sstevel@tonic-gate 	*max   = f->maxgrow;
375*7c478bd9Sstevel@tonic-gate 	return (E_OK);
376*7c478bd9Sstevel@tonic-gate }
377*7c478bd9Sstevel@tonic-gate 
378*7c478bd9Sstevel@tonic-gate 	/*
379*7c478bd9Sstevel@tonic-gate 	 *  move_field
380*7c478bd9Sstevel@tonic-gate 	 */
381*7c478bd9Sstevel@tonic-gate 
382*7c478bd9Sstevel@tonic-gate int
move_field(FIELD * f,int frow,int fcol)383*7c478bd9Sstevel@tonic-gate move_field(FIELD *f, int frow, int fcol)
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate /* FIELD *f;	field to move	*/
386*7c478bd9Sstevel@tonic-gate /* int frow;	first row relative to form origin */
387*7c478bd9Sstevel@tonic-gate /* int fcol;	first col relative to form origin */
388*7c478bd9Sstevel@tonic-gate {
389*7c478bd9Sstevel@tonic-gate 	if (! f || frow < 0 || fcol < 0)
390*7c478bd9Sstevel@tonic-gate 		return (E_BAD_ARGUMENT);
391*7c478bd9Sstevel@tonic-gate 
392*7c478bd9Sstevel@tonic-gate 	if (f->form)
393*7c478bd9Sstevel@tonic-gate 		return (E_CONNECTED);
394*7c478bd9Sstevel@tonic-gate 
395*7c478bd9Sstevel@tonic-gate 	f->frow = frow;
396*7c478bd9Sstevel@tonic-gate 	f->fcol = fcol;
397*7c478bd9Sstevel@tonic-gate 	return (E_OK);
398*7c478bd9Sstevel@tonic-gate }
399*7c478bd9Sstevel@tonic-gate 
400*7c478bd9Sstevel@tonic-gate 	/*
401*7c478bd9Sstevel@tonic-gate 	 *  set_field_type
402*7c478bd9Sstevel@tonic-gate 	 */
403*7c478bd9Sstevel@tonic-gate 
404*7c478bd9Sstevel@tonic-gate int
set_field_type(FIELD * f,FIELDTYPE * ft,...)405*7c478bd9Sstevel@tonic-gate set_field_type(FIELD *f, FIELDTYPE *ft, ...)
406*7c478bd9Sstevel@tonic-gate {
407*7c478bd9Sstevel@tonic-gate 	va_list		ap;
408*7c478bd9Sstevel@tonic-gate 	int		v = E_SYSTEM_ERROR;
409*7c478bd9Sstevel@tonic-gate 
410*7c478bd9Sstevel@tonic-gate 	va_start(ap, ft);
411*7c478bd9Sstevel@tonic-gate 	f = Field(f);
412*7c478bd9Sstevel@tonic-gate 	FreeType(f);				/* free old type	*/
413*7c478bd9Sstevel@tonic-gate 	f->type = ft;
414*7c478bd9Sstevel@tonic-gate 
415*7c478bd9Sstevel@tonic-gate 	if (MakeType(f, &ap))			/* set up new type	*/
416*7c478bd9Sstevel@tonic-gate 		v = E_OK;
417*7c478bd9Sstevel@tonic-gate 	va_end(ap);
418*7c478bd9Sstevel@tonic-gate 	return (v);
419*7c478bd9Sstevel@tonic-gate }
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate FIELDTYPE *
field_type(FIELD * f)422*7c478bd9Sstevel@tonic-gate field_type(FIELD *f)
423*7c478bd9Sstevel@tonic-gate {
424*7c478bd9Sstevel@tonic-gate 	return (Field(f)->type);
425*7c478bd9Sstevel@tonic-gate }
426*7c478bd9Sstevel@tonic-gate 
427*7c478bd9Sstevel@tonic-gate char *
field_arg(FIELD * f)428*7c478bd9Sstevel@tonic-gate field_arg(FIELD *f)
429*7c478bd9Sstevel@tonic-gate {
430*7c478bd9Sstevel@tonic-gate 	return (Field(f)->arg);
431*7c478bd9Sstevel@tonic-gate }
432*7c478bd9Sstevel@tonic-gate 
433*7c478bd9Sstevel@tonic-gate 	/*
434*7c478bd9Sstevel@tonic-gate 	 *  set_new_page
435*7c478bd9Sstevel@tonic-gate 	 */
436*7c478bd9Sstevel@tonic-gate 
437*7c478bd9Sstevel@tonic-gate int
set_new_page(FIELD * f,int flag)438*7c478bd9Sstevel@tonic-gate set_new_page(FIELD *f, int flag)
439*7c478bd9Sstevel@tonic-gate {
440*7c478bd9Sstevel@tonic-gate 	f = Field(f);
441*7c478bd9Sstevel@tonic-gate 
442*7c478bd9Sstevel@tonic-gate 	if (f->form)
443*7c478bd9Sstevel@tonic-gate 		return (E_CONNECTED);
444*7c478bd9Sstevel@tonic-gate 
445*7c478bd9Sstevel@tonic-gate 	if (flag)
446*7c478bd9Sstevel@tonic-gate 		Set(f, NEW_PAGE);
447*7c478bd9Sstevel@tonic-gate 	else
448*7c478bd9Sstevel@tonic-gate 		Clr(f, NEW_PAGE);
449*7c478bd9Sstevel@tonic-gate 
450*7c478bd9Sstevel@tonic-gate 	return (E_OK);
451*7c478bd9Sstevel@tonic-gate }
452*7c478bd9Sstevel@tonic-gate 
453*7c478bd9Sstevel@tonic-gate int
new_page(FIELD * f)454*7c478bd9Sstevel@tonic-gate new_page(FIELD *f)
455*7c478bd9Sstevel@tonic-gate {
456*7c478bd9Sstevel@tonic-gate 	if (Status(Field(f), NEW_PAGE))
457*7c478bd9Sstevel@tonic-gate 		return (TRUE);
458*7c478bd9Sstevel@tonic-gate 	else
459*7c478bd9Sstevel@tonic-gate 		return (FALSE);
460*7c478bd9Sstevel@tonic-gate }
461