1/*	$OpenBSD: fld_info.c,v 1.7 2023/10/17 09:52:10 nicm Exp $	*/
2/****************************************************************************
3 * Copyright 2020,2021 Thomas E. Dickey                                     *
4 * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
5 *                                                                          *
6 * Permission is hereby granted, free of charge, to any person obtaining a  *
7 * copy of this software and associated documentation files (the            *
8 * "Software"), to deal in the Software without restriction, including      *
9 * without limitation the rights to use, copy, modify, merge, publish,      *
10 * distribute, distribute with modifications, sublicense, and/or sell       *
11 * copies of the Software, and to permit persons to whom the Software is    *
12 * furnished to do so, subject to the following conditions:                 *
13 *                                                                          *
14 * The above copyright notice and this permission notice shall be included  *
15 * in all copies or substantial portions of the Software.                   *
16 *                                                                          *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24 *                                                                          *
25 * Except as contained in this notice, the name(s) of the above copyright   *
26 * holders shall not be used in advertising or otherwise to promote the     *
27 * sale, use or other dealings in this Software without prior written       *
28 * authorization.                                                           *
29 ****************************************************************************/
30
31/****************************************************************************
32 *   Author:  Juergen Pfeifer, 1995,1997                                    *
33 ****************************************************************************/
34
35#include "form.priv.h"
36
37MODULE_ID("$Id: fld_info.c,v 1.7 2023/10/17 09:52:10 nicm Exp $")
38
39/*---------------------------------------------------------------------------
40|   Facility      :  libnform
41|   Function      :  int field_info(const FIELD *field,
42|                                   int *rows, int *cols,
43|                                   int *frow, int *fcol,
44|                                   int *nrow, int *nbuf)
45|
46|   Description   :  Retrieve information about the field's creation parameters.
47|
48|   Return Values :  E_OK           - success
49|                    E_BAD_ARGUMENT - invalid field pointer
50+--------------------------------------------------------------------------*/
51FORM_EXPORT(int)
52field_info(const FIELD *field,
53	   int *rows, int *cols,
54	   int *frow, int *fcol,
55	   int *nrow, int *nbuf)
56{
57  T((T_CALLED("field_info(%p,%p,%p,%p,%p,%p,%p)"),
58     (const void *)field,
59     (void *)rows, (void *)cols,
60     (void *)frow, (void *)fcol,
61     (void *)nrow, (void *)nbuf));
62
63  if (!field)
64    RETURN(E_BAD_ARGUMENT);
65
66  if (rows)
67    *rows = field->rows;
68  if (cols)
69    *cols = field->cols;
70  if (frow)
71    *frow = field->frow;
72  if (fcol)
73    *fcol = field->fcol;
74  if (nrow)
75    *nrow = field->nrow;
76  if (nbuf)
77    *nbuf = field->nbuf;
78  RETURN(E_OK);
79}
80
81/*---------------------------------------------------------------------------
82|   Facility      :  libnform
83|   Function      :  int dynamic_field_info(const FIELD *field,
84|                                           int *drows, int *dcols,
85|                                           int *maxgrow)
86|
87|   Description   :  Retrieve information about a dynamic field's current
88|                    dynamic parameters.
89|
90|   Return Values :  E_OK           - success
91|                    E_BAD_ARGUMENT - invalid argument
92+--------------------------------------------------------------------------*/
93FORM_EXPORT(int)
94dynamic_field_info(const FIELD *field, int *drows, int *dcols, int *maxgrow)
95{
96  T((T_CALLED("dynamic_field_info(%p,%p,%p,%p)"),
97     (const void *)field,
98     (void *)drows,
99     (void *)dcols,
100     (void *)maxgrow));
101
102  if (!field)
103    RETURN(E_BAD_ARGUMENT);
104
105  if (drows)
106    *drows = field->drows;
107  if (dcols)
108    *dcols = field->dcols;
109  if (maxgrow)
110    *maxgrow = field->maxgrow;
111
112  RETURN(E_OK);
113}
114
115/* fld_info.c ends here */
116