1*a0e6850fSThomas Cort.\" $NetBSD: form_field_buffer.3,v 1.13 2010/03/22 21:58:31 joerg Exp $ 2*a0e6850fSThomas Cort.\" 3*a0e6850fSThomas Cort.\" Copyright (c) 2001 4*a0e6850fSThomas Cort.\" Brett Lymn - blymn@baea.com.au, brett_lymn@yahoo.com.au 5*a0e6850fSThomas Cort.\" 6*a0e6850fSThomas Cort.\" This code is donated to The NetBSD Foundation by the author. 7*a0e6850fSThomas Cort.\" 8*a0e6850fSThomas Cort.\" Redistribution and use in source and binary forms, with or without 9*a0e6850fSThomas Cort.\" modification, are permitted provided that the following conditions 10*a0e6850fSThomas Cort.\" are met: 11*a0e6850fSThomas Cort.\" 1. Redistributions of source code must retain the above copyright 12*a0e6850fSThomas Cort.\" notice, this list of conditions and the following disclaimer. 13*a0e6850fSThomas Cort.\" 2. Redistributions in binary form must reproduce the above copyright 14*a0e6850fSThomas Cort.\" notice, this list of conditions and the following disclaimer in the 15*a0e6850fSThomas Cort.\" documentation and/or other materials provided with the distribution. 16*a0e6850fSThomas Cort.\" 3. The name of the Author may not be used to endorse or promote 17*a0e6850fSThomas Cort.\" products derived from this software without specific prior written 18*a0e6850fSThomas Cort.\" permission. 19*a0e6850fSThomas Cort.\" 20*a0e6850fSThomas Cort.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 21*a0e6850fSThomas Cort.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22*a0e6850fSThomas Cort.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23*a0e6850fSThomas Cort.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 24*a0e6850fSThomas Cort.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25*a0e6850fSThomas Cort.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26*a0e6850fSThomas Cort.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27*a0e6850fSThomas Cort.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28*a0e6850fSThomas Cort.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29*a0e6850fSThomas Cort.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30*a0e6850fSThomas Cort.\" SUCH DAMAGE. 31*a0e6850fSThomas Cort.\" 32*a0e6850fSThomas Cort.Dd October 15, 2005 33*a0e6850fSThomas Cort.Dt FORMS 3 34*a0e6850fSThomas Cort.Os 35*a0e6850fSThomas Cort.Sh NAME 36*a0e6850fSThomas Cort.Nm field_buffer , 37*a0e6850fSThomas Cort.Nm field_status , 38*a0e6850fSThomas Cort.Nm set_field_buffer , 39*a0e6850fSThomas Cort.Nm set_field_printf , 40*a0e6850fSThomas Cort.Nm set_field_status , 41*a0e6850fSThomas Cort.Nm set_max_field 42*a0e6850fSThomas Cort.Nd form library 43*a0e6850fSThomas Cort.Sh LIBRARY 44*a0e6850fSThomas Cort.Lb libform 45*a0e6850fSThomas Cort.Sh SYNOPSIS 46*a0e6850fSThomas Cort.In form.h 47*a0e6850fSThomas Cort.Ft char * 48*a0e6850fSThomas Cort.Fn field_buffer "FIELD *field" "int buffer" 49*a0e6850fSThomas Cort.Ft int 50*a0e6850fSThomas Cort.Fn field_status "FIELD *field" 51*a0e6850fSThomas Cort.Ft int 52*a0e6850fSThomas Cort.Fn set_field_buffer "FIELD *field" "int buffer" "char *value" 53*a0e6850fSThomas Cort.Ft int 54*a0e6850fSThomas Cort.Fn set_field_printf "FIELD *field" "int buffer" "char *fmt" "..." 55*a0e6850fSThomas Cort.Ft int 56*a0e6850fSThomas Cort.Fn set_field_status "FIELD *field" "int status" 57*a0e6850fSThomas Cort.Ft int 58*a0e6850fSThomas Cort.Fn set_max_field "FIELD *field" "int max" 59*a0e6850fSThomas Cort.Sh DESCRIPTION 60*a0e6850fSThomas CortThe 61*a0e6850fSThomas Cort.Fn field_buffer 62*a0e6850fSThomas Cortfunction returns the contents of the buffer number specified by 63*a0e6850fSThomas Cort.Fa buffer 64*a0e6850fSThomas Cortfor the given field. 65*a0e6850fSThomas CortIf the requested buffer number exceeds the 66*a0e6850fSThomas Cortnumber of buffers attached to the field then 67*a0e6850fSThomas Cort.Dv NULL 68*a0e6850fSThomas Cortwill be returned. 69*a0e6850fSThomas CortIf the field option 70*a0e6850fSThomas Cort.Dv O_REFORMAT 71*a0e6850fSThomas Cortis enabled on the given field then 72*a0e6850fSThomas Cortstorage will be allocated to hold the reformatted buffer. 73*a0e6850fSThomas CortThis storage must be release by calling 74*a0e6850fSThomas Cort.Xr free 3 75*a0e6850fSThomas Cortwhen it is no longer required. 76*a0e6850fSThomas CortIf the 77*a0e6850fSThomas Cort.Dv O_REFORMAT 78*a0e6850fSThomas Cortfield option is not set then no extra storage is allocated. 79*a0e6850fSThomas CortThe field buffer may be set by calling 80*a0e6850fSThomas Cort.Fn set_field_buffer 81*a0e6850fSThomas Cortwhich will set the given buffer number to the contents of the string 82*a0e6850fSThomas Cortpassed. 83*a0e6850fSThomas CortA buffer may also be set by calling 84*a0e6850fSThomas Cort.Fn set_field_printf 85*a0e6850fSThomas Cortwhich sets the buffer using the format arg 86*a0e6850fSThomas Cort.Fa fmt 87*a0e6850fSThomas Cortafter being expanded using the subsequent arguments in the same manner 88*a0e6850fSThomas Cortas 89*a0e6850fSThomas Cort.Xr sprintf 3 90*a0e6850fSThomas Cortdoes. 91*a0e6850fSThomas CortCalling 92*a0e6850fSThomas Cort.Fn field_status 93*a0e6850fSThomas Cortwill return the status of the first buffer attached to the field. 94*a0e6850fSThomas CortIf the field has been modified then the function will return 95*a0e6850fSThomas Cort.Dv TRUE 96*a0e6850fSThomas Cortotherwise 97*a0e6850fSThomas Cort.Dv FALSE 98*a0e6850fSThomas Cortis returned, the status of the first buffer may be 99*a0e6850fSThomas Cortprogrammatically set by calling 100*a0e6850fSThomas Cort.Fn set_field_status . 101*a0e6850fSThomas CortThe maximum growth of a dynamic field can be set by calling 102*a0e6850fSThomas Cort.Fn set_max_field 103*a0e6850fSThomas Cortwhich limits the fields rows if the field is a multiline field or the 104*a0e6850fSThomas Cortfields columns if the field only has a single row. 105*a0e6850fSThomas Cort.Sh RETURN VALUES 106*a0e6850fSThomas CortFunctions returning pointers will return 107*a0e6850fSThomas Cort.Dv NULL 108*a0e6850fSThomas Cortif an error is detected. 109*a0e6850fSThomas CortThe functions that return an int will return one of the following error 110*a0e6850fSThomas Cortvalues: 111*a0e6850fSThomas Cort.Pp 112*a0e6850fSThomas Cort.Bl -tag -width E_UNKNOWN_COMMAND -compact 113*a0e6850fSThomas Cort.It Er E_OK 114*a0e6850fSThomas CortThe function was successful. 115*a0e6850fSThomas Cort.It Er E_BAD_ARGUMENT 116*a0e6850fSThomas CortA bad parameter was passed to the function. 117*a0e6850fSThomas Cort.It Er E_SYSTEM_ERROR 118*a0e6850fSThomas CortA system error occurred performing the function. 119*a0e6850fSThomas Cort.El 120*a0e6850fSThomas Cort.Sh SEE ALSO 121*a0e6850fSThomas Cort.Xr curses 3 , 122*a0e6850fSThomas Cort.Xr forms 3 123*a0e6850fSThomas Cort.Sh NOTES 124*a0e6850fSThomas CortThe header 125*a0e6850fSThomas Cort.In form.h 126*a0e6850fSThomas Cortautomatically includes both 127*a0e6850fSThomas Cort.In curses.h 128*a0e6850fSThomas Cortand 129*a0e6850fSThomas Cort.In eti.h . 130*a0e6850fSThomas CortThe function 131*a0e6850fSThomas Cort.Fn set_field_printf 132*a0e6850fSThomas Cortis a 133*a0e6850fSThomas Cort.Nx 134*a0e6850fSThomas Cortextension and must not be used in portable code. 135