aboutsummaryrefslogtreecommitdiff
path: root/form/frm_def.c
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2014-02-28 19:18:07 +0000
committerXin LI <delphij@FreeBSD.org>2014-02-28 19:18:07 +0000
commita0044ffc69cfe39a3b0b2d208e0952254555afc6 (patch)
tree7b2d708d03277cdd2560e9ce6572bdafc2e58bab /form/frm_def.c
parent4b819fa20a8d007a10f2d3e8d6a5dedf7f18fc9a (diff)
downloadsrc-a0044ffc69cfe39a3b0b2d208e0952254555afc6.tar.gz
src-a0044ffc69cfe39a3b0b2d208e0952254555afc6.zip
Redo import of ncurses 5.9 (stripped).vendor/ncurses/5.9-20110404_stripped
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=262617 svn path=/vendor/ncurses/5.9-20110404_stripped/; revision=262631; tag=vendor/ncurses/5.9-20110404_stripped
Diffstat (limited to 'form/frm_def.c')
-rw-r--r--form/frm_def.c67
1 files changed, 49 insertions, 18 deletions
diff --git a/form/frm_def.c b/form/frm_def.c
index e6897514ffdd..86500f239863 100644
--- a/form/frm_def.c
+++ b/form/frm_def.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -32,7 +32,7 @@
#include "form.priv.h"
-MODULE_ID("$Id: frm_def.c,v 1.23 2008/08/04 00:07:55 tom Exp $")
+MODULE_ID("$Id: frm_def.c,v 1.25 2010/01/23 21:14:36 tom Exp $")
/* this can't be readonly */
static FORM default_form =
@@ -160,7 +160,7 @@ Connect_Fields(FORM *form, FIELD **fields)
int maximum_row_in_field, maximum_col_in_field;
_PAGE *pg;
- T((T_CALLED("Connect_Fields(%p,%p)"), form, fields));
+ T((T_CALLED("Connect_Fields(%p,%p)"), (void *)form, (void *)fields));
assert(form);
@@ -188,7 +188,7 @@ Connect_Fields(FORM *form, FIELD **fields)
/* allocate page structures */
if ((pg = typeMalloc(_PAGE, page_nr)) != (_PAGE *) 0)
{
- T((T_CREATE("_PAGE %p"), pg));
+ T((T_CREATE("_PAGE %p"), (void *)pg));
form->page = pg;
}
else
@@ -283,7 +283,7 @@ Associate_Fields(FORM *form, FIELD **fields)
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : FORM *new_form( FIELD **fields )
+| Function : FORM *new_form_sp(SCREEN* sp, FIELD** fields )
|
| Description : Create new form with given array of fields.
|
@@ -295,21 +295,31 @@ Associate_Fields(FORM *form, FIELD **fields)
| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FORM *)
-new_form(FIELD **fields)
+NCURSES_SP_NAME(new_form) (NCURSES_SP_DCLx FIELD **fields)
{
int err = E_SYSTEM_ERROR;
+ FORM *form = (FORM *)0;
- FORM *form = typeMalloc(FORM, 1);
+ T((T_CALLED("new_form(%p,%p)"), (void *)SP_PARM, (void *)fields));
- T((T_CALLED("new_form(%p)"), fields));
- if (form)
+ if (IsValidScreen(SP_PARM))
{
- T((T_CREATE("form %p"), form));
- *form = *_nc_Default_Form;
- if ((err = Associate_Fields(form, fields)) != E_OK)
+ form = typeMalloc(FORM, 1);
+
+ if (form)
{
- free_form(form);
- form = (FORM *)0;
+ T((T_CREATE("form %p"), (void *)form));
+ *form = *_nc_Default_Form;
+ /* This ensures win and sub are always non-null,
+ so we can derive always the SCREEN that this form is
+ running on. */
+ form->win = StdScreen(SP_PARM);
+ form->sub = StdScreen(SP_PARM);
+ if ((err = Associate_Fields(form, fields)) != E_OK)
+ {
+ free_form(form);
+ form = (FORM *)0;
+ }
}
}
@@ -321,6 +331,27 @@ new_form(FIELD **fields)
/*---------------------------------------------------------------------------
| Facility : libnform
+| Function : FORM* new_form(FIELD** fields )
+|
+| Description : Create new form with given array of fields.
+|
+| Return Values : Pointer to form. NULL if error occurred.
+! Set errno:
+| E_OK - success
+| E_BAD_ARGUMENT - Invalid form pointer or field array
+| E_CONNECTED - a field is already connected
+| E_SYSTEM_ERROR - not enough memory
++--------------------------------------------------------------------------*/
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(FORM *)
+new_form(FIELD **fields)
+{
+ return NCURSES_SP_NAME(new_form) (CURRENT_SCREEN, fields);
+}
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
| Function : int free_form( FORM *form )
|
| Description : Release internal memory associated with form.
@@ -332,7 +363,7 @@ new_form(FIELD **fields)
NCURSES_EXPORT(int)
free_form(FORM *form)
{
- T((T_CALLED("free_form(%p)"), form));
+ T((T_CALLED("free_form(%p)"), (void *)form));
if (!form)
RETURN(E_BAD_ARGUMENT);
@@ -366,7 +397,7 @@ set_form_fields(FORM *form, FIELD **fields)
FIELD **old;
int res;
- T((T_CALLED("set_form_fields(%p,%p)"), form, fields));
+ T((T_CALLED("set_form_fields(%p,%p)"), (void *)form, (void *)fields));
if (!form)
RETURN(E_BAD_ARGUMENT);
@@ -394,7 +425,7 @@ set_form_fields(FORM *form, FIELD **fields)
NCURSES_EXPORT(FIELD **)
form_fields(const FORM *form)
{
- T((T_CALLED("form_field(%p)"), form));
+ T((T_CALLED("form_field(%p)"), (const void *)form));
returnFieldPtr(Normalize_Form(form)->field);
}
@@ -409,7 +440,7 @@ form_fields(const FORM *form)
NCURSES_EXPORT(int)
field_count(const FORM *form)
{
- T((T_CALLED("field_count(%p)"), form));
+ T((T_CALLED("field_count(%p)"), (const void *)form));
returnCode(Normalize_Form(form)->maxfield);
}