fld_ftlink.c revision 1.1
1/*	$OpenBSD: fld_ftlink.c,v 1.1 1997/12/03 05:39:53 millert Exp $	*/
2
3/*-----------------------------------------------------------------------------+
4|           The ncurses form library is  Copyright (C) 1995-1997               |
5|             by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de>                 |
6|                          All Rights Reserved.                                |
7|                                                                              |
8| Permission to use, copy, modify, and distribute this software and its        |
9| documentation for any purpose and without fee is hereby granted, provided    |
10| that the above copyright notice appear in all copies and that both that      |
11| copyright notice and this permission notice appear in supporting             |
12| documentation, and that the name of the above listed copyright holder(s) not |
13| be used in advertising or publicity pertaining to distribution of the        |
14| software without specific, written prior permission.                         |
15|                                                                              |
16| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO  |
17| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-  |
18| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR   |
19| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
20| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
21| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH    |
22| THE USE OR PERFORMANCE OF THIS SOFTWARE.                                     |
23+-----------------------------------------------------------------------------*/
24
25#include "form.priv.h"
26
27MODULE_ID("Id: fld_ftlink.c,v 1.1 1997/10/21 13:24:19 juergen Exp $")
28
29/*---------------------------------------------------------------------------
30|   Facility      :  libnform
31|   Function      :  FIELDTYPE *link_fieldtype(
32|                                FIELDTYPE *type1,
33|                                FIELDTYPE *type2)
34|
35|   Description   :  Create a new fieldtype built from the two given types.
36|                    They are connected by an logical 'OR'.
37|                    If an error occurs, errno is set to
38|                       E_BAD_ARGUMENT  - invalid arguments
39|                       E_SYSTEM_ERROR  - system error (no memory)
40|
41|   Return Values :  Fieldtype pointer or NULL if error occured.
42+--------------------------------------------------------------------------*/
43FIELDTYPE *link_fieldtype(FIELDTYPE * type1, FIELDTYPE * type2)
44{
45  FIELDTYPE *nftyp = (FIELDTYPE *)0;
46
47  if ( type1 && type2 )
48    {
49      nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
50      if (nftyp)
51	{
52	  *nftyp = *_nc_Default_FieldType;
53	  nftyp->status |= _LINKED_TYPE;
54	  if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS) )
55	    nftyp->status |= _HAS_ARGS;
56	  if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE) )
57	    nftyp->status |= _HAS_CHOICE;
58	  nftyp->left  = type1;
59	  nftyp->right = type2;
60	  type1->ref++;
61	  type2->ref++;
62	}
63      else
64	{
65	  SET_ERROR( E_SYSTEM_ERROR );
66	}
67    }
68  else
69    {
70      SET_ERROR( E_BAD_ARGUMENT );
71    }
72  return nftyp;
73}
74
75/* fld_ftlink.c ends here */
76