X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=form%2Ffty_int.c;h=e13e5be203f7b66224a0307819ac6b2d35240648;hp=13fef6272366239b83e9cef45bf53a76e87719da;hb=f5da57ad7eb397b1001e2fca9cb0e278a6564716;hpb=027ae42953e3186daed8f3882da73de48291b606 diff --git a/form/fty_int.c b/form/fty_int.c index 13fef627..e13e5be2 100644 --- a/form/fty_int.c +++ b/form/fty_int.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2009 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 * @@ -34,7 +34,7 @@ #include "form.priv.h" -MODULE_ID("$Id: fty_int.c,v 1.20 2006/04/22 21:33:05 tom Exp $") +MODULE_ID("$Id: fty_int.c,v 1.24 2009/11/07 20:17:58 tom Exp $") #if USE_WIDEC_SUPPORT #define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c))) @@ -52,28 +52,61 @@ typedef struct } thisARG; +typedef struct + { + int precision; + long low; + long high; + } +integerPARM; + /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static void *Make_This_Type( va_list * ap ) +| Function : static void *Generic_This_Type( void * arg ) | | Description : Allocate structure for integer type argument. | | Return Values : Pointer to argument structure or NULL on error +--------------------------------------------------------------------------*/ static void * -Make_This_Type(va_list *ap) +Generic_This_Type(void *arg) { - thisARG *argp = (thisARG *) malloc(sizeof(thisARG)); + thisARG *argp = (thisARG *) 0; + thisARG *param = (thisARG *) arg; - if (argp) + if (param) { - argp->precision = va_arg(*ap, int); - argp->low = va_arg(*ap, long); - argp->high = va_arg(*ap, long); + argp = typeMalloc(thisARG, 1); + + if (argp) + { + T((T_CREATE("thisARG %p"), argp)); + *argp = *param; + } } return (void *)argp; } +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : static void *Make_This_Type( va_list * ap ) +| +| Description : Allocate structure for integer type argument. +| +| Return Values : Pointer to argument structure or NULL on error ++--------------------------------------------------------------------------*/ +static void * +Make_This_Type(va_list *ap) +{ + thisARG arg; + + arg.precision = va_arg(*ap, int); + arg.low = va_arg(*ap, long); + arg.high = va_arg(*ap, long); + + return Generic_This_Type((void *)&arg); +} + /*--------------------------------------------------------------------------- | Facility : libnform | Function : static void *Copy_This_Type(const void * argp) @@ -90,9 +123,12 @@ Copy_This_Type(const void *argp) if (argp) { - result = (thisARG *) malloc(sizeof(thisARG)); + result = typeMalloc(thisARG, 1); if (result) - *result = *ap; + { + T((T_CREATE("thisARG %p"), result)); + *result = *ap; + } } return (void *)result; } @@ -231,12 +267,27 @@ static FIELDTYPE typeTHIS = Make_This_Type, Copy_This_Type, Free_This_Type, - Check_This_Field, - Check_This_Character, - NULL, - NULL + INIT_FT_FUNC(Check_This_Field), + INIT_FT_FUNC(Check_This_Character), + INIT_FT_FUNC(NULL), + INIT_FT_FUNC(NULL), +#if NCURSES_INTEROP_FUNCS + Generic_This_Type +#endif }; NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeTHIS; +#if NCURSES_INTEROP_FUNCS +/* The next routines are to simplify the use of ncurses from + programming languages with restictions on interop with C level + constructs (e.g. variable access or va_list + ellipsis constructs) +*/ +NCURSES_EXPORT(FIELDTYPE *) +_nc_TYPE_INTEGER(void) +{ + return TYPE_INTEGER; +} +#endif + /* fty_int.c ends here */