/****************************************************************************1* Copyright (c) 1998 Free Software Foundation, Inc. *2* *3* Permission is hereby granted, free of charge, to any person obtaining a *4* copy of this software and associated documentation files (the *5* "Software"), to deal in the Software without restriction, including *6* without limitation the rights to use, copy, modify, merge, publish, *7* distribute, distribute with modifications, sublicense, and/or sell *8* copies of the Software, and to permit persons to whom the Software is *9* furnished to do so, subject to the following conditions: *10* *11* The above copyright notice and this permission notice shall be included *12* in all copies or substantial portions of the Software. *13* *14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *15* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *16* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *17* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *20* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *21* *22* Except as contained in this notice, the name(s) of the above copyright *23* holders shall not be used in advertising or otherwise to promote the *24* sale, use or other dealings in this Software without prior written *25* authorization. *26****************************************************************************/2728/****************************************************************************29* Author: Juergen Pfeifer <[email protected]> 1995,1997 *30****************************************************************************/3132#include "form.priv.h"3334MODULE_ID("$Id$")3536/*---------------------------------------------------------------------------37| Facility : libnform38| Function : FIELD *dup_field(FIELD *field, int frow, int fcol)39|40| Description : Duplicates the field at the specified position. All41| field attributes and the buffers are copied.42| If an error occurs, errno is set to43|44| E_BAD_ARGUMENT - invalid argument45| E_SYSTEM_ERROR - system error46|47| Return Values : Pointer to the new field or NULL if failure48+--------------------------------------------------------------------------*/49FIELD *dup_field(FIELD * field, int frow, int fcol)50{51FIELD *New_Field = (FIELD *)0;52int err = E_BAD_ARGUMENT;5354if (field && (frow>=0) && (fcol>=0) &&55((err=E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */56(New_Field=(FIELD *)malloc(sizeof(FIELD))) )57{58*New_Field = *_nc_Default_Field;59New_Field->frow = frow;60New_Field->fcol = fcol;61New_Field->link = New_Field;62New_Field->rows = field->rows;63New_Field->cols = field->cols;64New_Field->nrow = field->nrow;65New_Field->drows = field->drows;66New_Field->dcols = field->dcols;67New_Field->maxgrow = field->maxgrow;68New_Field->nbuf = field->nbuf;69New_Field->just = field->just;70New_Field->fore = field->fore;71New_Field->back = field->back;72New_Field->pad = field->pad;73New_Field->opts = field->opts;74New_Field->usrptr = field->usrptr;7576if (_nc_Copy_Type(New_Field,field))77{78size_t len;7980len = Total_Buffer_Size(New_Field);81if ( (New_Field->buf=(char *)malloc(len)) )82{83memcpy(New_Field->buf,field->buf,len);84return New_Field;85}86}87}8889if (New_Field)90free_field(New_Field);9192SET_ERROR(err);93return (FIELD *)0;94}9596/* fld_dup.c ends here */979899