150276Speter/**************************************************************************** 2174993Srafan * Copyright (c) 1998-2004,2007 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 35174993SrafanMODULE_ID("$Id: fld_link.c,v 1.11 2007/10/13 19:30:43 tom Exp $") 3650276Speter 3750276Speter/*--------------------------------------------------------------------------- 3850276Speter| Facility : libnform 3950276Speter| Function : FIELD *link_field(FIELD *field, int frow, int fcol) 4050276Speter| 4150276Speter| Description : Duplicates the field at the specified position. The 4250276Speter| new field shares its buffers with the original one, 4350276Speter| the attributes are independent. 4450276Speter| If an error occurs, errno is set to 4550276Speter| 4650276Speter| E_BAD_ARGUMENT - invalid argument 4750276Speter| E_SYSTEM_ERROR - system error 4850276Speter| 4950276Speter| Return Values : Pointer to the new field or NULL if failure 5050276Speter+--------------------------------------------------------------------------*/ 5176726SpeterNCURSES_EXPORT(FIELD *) 52166124Srafanlink_field(FIELD *field, int frow, int fcol) 5350276Speter{ 5450276Speter FIELD *New_Field = (FIELD *)0; 5550276Speter int err = E_BAD_ARGUMENT; 5650276Speter 57166124Srafan T((T_CALLED("link_field(%p,%d,%d)"), field, frow, fcol)); 58166124Srafan if (field && (frow >= 0) && (fcol >= 0) && 59166124Srafan ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */ 60174993Srafan (New_Field = typeMalloc(FIELD, 1))) 6150276Speter { 62174993Srafan T((T_CREATE("field %p"), New_Field)); 63166124Srafan *New_Field = *_nc_Default_Field; 64166124Srafan New_Field->frow = frow; 65166124Srafan New_Field->fcol = fcol; 66166124Srafan 67166124Srafan New_Field->link = field->link; 68166124Srafan field->link = New_Field; 69166124Srafan 70166124Srafan New_Field->buf = field->buf; 71166124Srafan New_Field->rows = field->rows; 72166124Srafan New_Field->cols = field->cols; 73166124Srafan New_Field->nrow = field->nrow; 74166124Srafan New_Field->nbuf = field->nbuf; 75166124Srafan New_Field->drows = field->drows; 76166124Srafan New_Field->dcols = field->dcols; 77166124Srafan New_Field->maxgrow = field->maxgrow; 78166124Srafan New_Field->just = field->just; 79166124Srafan New_Field->fore = field->fore; 80166124Srafan New_Field->back = field->back; 81166124Srafan New_Field->pad = field->pad; 82166124Srafan New_Field->opts = field->opts; 8350276Speter New_Field->usrptr = field->usrptr; 84166124Srafan 85166124Srafan if (_nc_Copy_Type(New_Field, field)) 86166124Srafan returnField(New_Field); 8750276Speter } 8850276Speter 89166124Srafan if (New_Field) 9050276Speter free_field(New_Field); 9150276Speter 92166124Srafan SET_ERROR(err); 93166124Srafan returnField((FIELD *)0); 9450276Speter} 9550276Speter 9650276Speter/* fld_link.c ends here */ 97