150276Speter/**************************************************************************** 2262685Sdelphij * Copyright (c) 1998-2010,2012 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 30166124Srafan * Author: Juergen Pfeifer, 1995,1997 * 3150276Speter ****************************************************************************/ 3250276Speter 3350276Speter#include "form.priv.h" 3450276Speter 35262685SdelphijMODULE_ID("$Id: fld_arg.c,v 1.13 2012/06/10 00:27:49 tom Exp $") 3650276Speter 3750276Speter/*--------------------------------------------------------------------------- 38166124Srafan| Facility : libnform 3950276Speter| Function : int set_fieldtype_arg( 4050276Speter| FIELDTYPE *typ, 4150276Speter| void * (* const make_arg)(va_list *), 4250276Speter| void * (* const copy_arg)(const void *), 4350276Speter| void (* const free_arg)(void *) ) 44166124Srafan| 4550276Speter| Description : Connects to the type additional arguments necessary 4650276Speter| for a set_field_type call. The various function pointer 4750276Speter| arguments are: 4850276Speter| make_arg : allocates a structure for the field 4950276Speter| specific parameters. 5050276Speter| copy_arg : duplicate the structure created by 5150276Speter| make_arg 5250276Speter| free_arg : Release the memory allocated by make_arg 5350276Speter| or copy_arg 5450276Speter| 5550276Speter| At least make_arg must be non-NULL. 5650276Speter| You may pass NULL for copy_arg and free_arg if your 5750276Speter| make_arg function doesn't allocate memory and your 5850276Speter| arg fits into the storage for a (void*). 5950276Speter| 6050276Speter| Return Values : E_OK - success 6150276Speter| E_BAD_ARGUMENT - invalid argument 6250276Speter+--------------------------------------------------------------------------*/ 6376726SpeterNCURSES_EXPORT(int) 64166124Srafanset_fieldtype_arg(FIELDTYPE *typ, 65166124Srafan void *(*const make_arg)(va_list *), 66166124Srafan void *(*const copy_arg)(const void *), 67166124Srafan void (*const free_arg) (void *)) 6850276Speter{ 69166124Srafan T((T_CALLED("set_fieldtype_arg(%p,%p,%p,%p)"), 70262629Sdelphij (void *)typ, make_arg, copy_arg, free_arg)); 7150276Speter 72166124Srafan if (typ != 0 && make_arg != (void *)0) 73166124Srafan { 74262685Sdelphij SetStatus(typ, _HAS_ARGS); 75166124Srafan typ->makearg = make_arg; 76166124Srafan typ->copyarg = copy_arg; 77166124Srafan typ->freearg = free_arg; 78166124Srafan RETURN(E_OK); 79166124Srafan } 80166124Srafan RETURN(E_BAD_ARGUMENT); 8150276Speter} 8250276Speter 8350276Speter/*--------------------------------------------------------------------------- 84166124Srafan| Facility : libnform 8550276Speter| Function : void *field_arg(const FIELD *field) 86166124Srafan| 8750276Speter| Description : Retrieve pointer to the fields argument structure. 8850276Speter| 8950276Speter| Return Values : Pointer to structure or NULL if none is defined. 9050276Speter+--------------------------------------------------------------------------*/ 9176726SpeterNCURSES_EXPORT(void *) 92166124Srafanfield_arg(const FIELD *field) 9350276Speter{ 94262629Sdelphij T((T_CALLED("field_arg(%p)"), (const void *)field)); 95166124Srafan returnVoidPtr(Normalize_Field(field)->arg); 9650276Speter} 9750276Speter 9850276Speter/* fld_arg.c ends here */ 99