fieldtype.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * CDDL HEADER START
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The contents of this file are subject to the terms of the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Common Development and Distribution License, Version 1.0 only
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (the "License"). You may not use this file except in compliance
199767f8919635c4928607450d9e0abb932109ceToomas Soome * with the License.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * or http://www.opensolaris.org/os/licensing.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * See the License for the specific language governing permissions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * and limitations under the License.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * When distributing Covered Code, include this CDDL HEADER in each
199767f8919635c4928607450d9e0abb932109ceToomas Soome * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * If applicable, add the following below this CDDL HEADER, with the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * fields enclosed by brackets "[]" replaced with your own identifying
199767f8919635c4928607450d9e0abb932109ceToomas Soome * information: Portions Copyright [yyyy] [name of copyright owner]
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * CDDL HEADER END
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Copyright (c) 1988 AT&T */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* All Rights Reserved */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1997, by Sun Microsystems, Inc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#pragma ident "%Z%%M% %I% %E% SMI"
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*LINTLIBRARY*/
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/types.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <stdlib.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include "utility.h"
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef struct {
199767f8919635c4928607450d9e0abb932109ceToomas Soome char *leftarg;
199767f8919635c4928607450d9e0abb932109ceToomas Soome char *rightarg;
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome LINK;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ArgL(n) (((LINK *)(n))->leftarg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ArgR(n) (((LINK *)(n))->rightarg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define Ref(t) ((t)->ref)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define TypeL(t) ((t)->left)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define TypeR(t) ((t)->right)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MakeA(t) ((t)->makearg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CopyA(t) ((t)->copyarg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FreeA(t) ((t)->freearg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define Fcheck(t) ((t)->fcheck)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define Ccheck(t) ((t)->ccheck)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define Next(t) ((t)->next)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define Prev(t) ((t)->prev)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * default fieldtype
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic FIELDTYPE default_fieldtype =
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome 0, /* status */
199767f8919635c4928607450d9e0abb932109ceToomas Soome 0, /* ref */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (FIELDTYPE *) 0, /* left */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (FIELDTYPE *) 0, /* right */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (PTF_charP) 0, /* makearg */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (PTF_charP) 0, /* copyarg */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (PTF_void) 0, /* freearg */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (PTF_int) 0, /* fcheck */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (PTF_int) 0, /* ccheck */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (PTF_int) 0, /* next */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (PTF_int) 0, /* prev */
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeFIELDTYPE * _DEFAULT_FIELDTYPE = &default_fieldtype;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* new_fieldtype - field & character validation function */
199767f8919635c4928607450d9e0abb932109ceToomas SoomeFIELDTYPE *
199767f8919635c4928607450d9e0abb932109ceToomas Soomenew_fieldtype(PTF_int fcheck, PTF_int ccheck)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome FIELDTYPE *t = (FIELDTYPE *) 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if ((fcheck || ccheck) && Alloc(t, FIELDTYPE)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome *t = *_DEFAULT_FIELDTYPE;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome Fcheck(t) = fcheck;
199767f8919635c4928607450d9e0abb932109ceToomas Soome Ccheck(t) = ccheck;
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeFIELDTYPE *
199767f8919635c4928607450d9e0abb932109ceToomas Soomelink_fieldtype(FIELDTYPE *left, FIELDTYPE *right)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome FIELDTYPE *t = (FIELDTYPE *) 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if ((left || right) && Alloc(t, FIELDTYPE)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome *t = *_DEFAULT_FIELDTYPE;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome Set(t, LINKED);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Status(left, ARGS) || Status(right, ARGS))
199767f8919635c4928607450d9e0abb932109ceToomas Soome Set(t, ARGS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Status(left, CHOICE) || Status(right, CHOICE))
199767f8919635c4928607450d9e0abb932109ceToomas Soome Set(t, CHOICE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome TypeL(t) = left;
199767f8919635c4928607450d9e0abb932109ceToomas Soome TypeR(t) = right;
199767f8919635c4928607450d9e0abb932109ceToomas Soome IncrType(left); /* increment reference count */
199767f8919635c4928607450d9e0abb932109ceToomas Soome IncrType(right); /* increment reference count */
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint
199767f8919635c4928607450d9e0abb932109ceToomas Soomefree_fieldtype(FIELDTYPE *t)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!t)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (E_BAD_ARGUMENT);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Ref(t))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (E_CONNECTED);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Status(t, LINKED)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome DecrType(TypeL(t)); /* decrement reference count */
199767f8919635c4928607450d9e0abb932109ceToomas Soome DecrType(TypeR(t)); /* decrement reference count */
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome Free(t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (E_OK);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint
199767f8919635c4928607450d9e0abb932109ceToomas Soomeset_fieldtype_arg(FIELDTYPE *t, PTF_charP makearg,
199767f8919635c4928607450d9e0abb932109ceToomas Soome PTF_charP copyarg, PTF_void freearg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (t && makearg && copyarg && freearg) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome Set(t, ARGS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome MakeA(t) = makearg;
199767f8919635c4928607450d9e0abb932109ceToomas Soome CopyA(t) = copyarg;
199767f8919635c4928607450d9e0abb932109ceToomas Soome FreeA(t) = freearg;
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (E_OK);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (E_BAD_ARGUMENT);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* set_fieldtype_choice next & prev choice function */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint
199767f8919635c4928607450d9e0abb932109ceToomas Soomeset_fieldtype_choice(FIELDTYPE *t, PTF_int next, PTF_int prev)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (t && next && prev) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome Set(t, CHOICE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome Next(t) = next;
199767f8919635c4928607450d9e0abb932109ceToomas Soome Prev(t) = prev;
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (E_OK);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (E_BAD_ARGUMENT);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *
199767f8919635c4928607450d9e0abb932109ceToomas Soome_makearg(FIELDTYPE *t, va_list *ap, int *err)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * invoke make_arg function associated with field type t.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * return pointer to argument information or null if none.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * increment err if an error is encountered.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome char *p = (char *)0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (! t || ! Status(t, ARGS))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (p);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Status(t, LINKED)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome LINK *n = (LINK *) 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Alloc(n, LINK)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome ArgL(n) = _makearg(TypeL(t), ap, err);
199767f8919635c4928607450d9e0abb932109ceToomas Soome ArgR(n) = _makearg(TypeR(t), ap, err);
199767f8919635c4928607450d9e0abb932109ceToomas Soome p = (char *)n;
199767f8919635c4928607450d9e0abb932109ceToomas Soome } else
199767f8919635c4928607450d9e0abb932109ceToomas Soome ++(*err); /* out of space */
199767f8919635c4928607450d9e0abb932109ceToomas Soome } else
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!(p = (*MakeA(t)) (ap)))
199767f8919635c4928607450d9e0abb932109ceToomas Soome ++(*err); /* make_arg had problem */
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (p);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *
199767f8919635c4928607450d9e0abb932109ceToomas Soome_copyarg(FIELDTYPE *t, char *arg, int *err)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * invoke copy_arg function associated with field type t.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * return pointer to argument information or null if none.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * increment err if an error is encountered.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome char *p = (char *)0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!t || !Status(t, ARGS))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (p);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Status(t, LINKED)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome LINK *n = (LINK *) 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Alloc(n, LINK)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome ArgL(n) = _copyarg(TypeL(t), ArgL(arg), err);
199767f8919635c4928607450d9e0abb932109ceToomas Soome ArgR(n) = _copyarg(TypeR(t), ArgR(arg), err);
199767f8919635c4928607450d9e0abb932109ceToomas Soome p = (char *)n;
199767f8919635c4928607450d9e0abb932109ceToomas Soome } else
199767f8919635c4928607450d9e0abb932109ceToomas Soome ++(*err); /* out of space */
199767f8919635c4928607450d9e0abb932109ceToomas Soome } else
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!(p = (*CopyA(t)) (arg)))
199767f8919635c4928607450d9e0abb932109ceToomas Soome ++(*err); /* copy_arg had problem */
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (p);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* _freearg - invoke free_arg function associated with field type t. */
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid
199767f8919635c4928607450d9e0abb932109ceToomas Soome_freearg(FIELDTYPE *t, char *arg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!t || !Status(t, ARGS))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Status(t, LINKED)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome _freearg(TypeL(t), ArgL(arg));
199767f8919635c4928607450d9e0abb932109ceToomas Soome _freearg(TypeR(t), ArgR(arg));
199767f8919635c4928607450d9e0abb932109ceToomas Soome Free(arg);
199767f8919635c4928607450d9e0abb932109ceToomas Soome } else
199767f8919635c4928607450d9e0abb932109ceToomas Soome (*FreeA(t)) (arg);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* _checkfield - invoke check_field function associated with field type t. */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint
199767f8919635c4928607450d9e0abb932109ceToomas Soome_checkfield(FIELDTYPE *t, FIELD *f, char *arg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!t)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (TRUE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Opt(f, O_NULLOK)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome char *v = Buf(f);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome while (*v && *v == ' ')
199767f8919635c4928607450d9e0abb932109ceToomas Soome ++v;
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!*v)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (TRUE); /* empty field */
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Status(t, LINKED))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (_checkfield(TypeL(t), f, ArgL(arg)) ||
199767f8919635c4928607450d9e0abb932109ceToomas Soome _checkfield(TypeR(t), f, ArgR(arg)));
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Fcheck(t))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return ((*Fcheck(t)) (f, arg));
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (TRUE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* _checkchar - invoke check_char function associated with field type t. */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint
199767f8919635c4928607450d9e0abb932109ceToomas Soome_checkchar(FIELDTYPE *t, int c, char *arg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!t)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (TRUE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Status(t, LINKED))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (_checkchar(TypeL(t), c, ArgL(arg)) ||
199767f8919635c4928607450d9e0abb932109ceToomas Soome _checkchar(TypeR(t), c, ArgR(arg)));
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Ccheck(t))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return ((*Ccheck(t)) (c, arg));
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (TRUE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* _nextchoice - invoke next_choice function associated with field type t. */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint
199767f8919635c4928607450d9e0abb932109ceToomas Soome_nextchoice(FIELDTYPE *t, FIELD *f, char *arg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!t || !Status(t, CHOICE))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (FALSE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Status(t, LINKED))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (_nextchoice(TypeL(t), f, ArgL(arg)) ||
199767f8919635c4928607450d9e0abb932109ceToomas Soome _nextchoice(TypeR(t), f, ArgR(arg)));
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome return ((*Next(t)) (f, arg));
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* _prevchoice - invoke prev_choice function associated with field type t. */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint
199767f8919635c4928607450d9e0abb932109ceToomas Soome_prevchoice(FIELDTYPE *t, FIELD *f, char *arg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!t || !Status(t, CHOICE))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (FALSE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (Status(t, LINKED))
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (_prevchoice(TypeL(t), f, ArgL(arg)) ||
199767f8919635c4928607450d9e0abb932109ceToomas Soome _prevchoice(TypeR(t), f, ArgR(arg)));
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome return ((*Prev(t)) (f, arg));
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome