
/****************************************************************************/

/*  Module PNLLV02C.C

    Copyright 1986 Roundhill Computer Systems Limited
    All rights reserved

    Use and disclosure of this code are prohibited unless in accordance
    with the terms of the PANEL software licence.

    ************************************************************************
    *** THE OBJECT CODE VERSION OF THIS MODULE IS INCLUDED IN THE PANEL  ***
    *** LIBRARY.  IF YOU AMEND AND COMPILE THIS MODULE AND LINK IT WITH  ***
    *** YOUR APPLICATION IT WILL SUPERSEDE THE LIBRARY VERSION.          ***
    ************************************************************************

    PANEL:  Type 4          : Validation
            Source Language : C

    Modification History (Push-Down List):  

            28.12.85        : Convert to table-driven operation

*****************************************************************************/

#include <pnl4.h>

/*  Line validation 2 is used in conjunction with the 'Value List' extended
    attribute (number NXAVL).  The attribute string contains substrings which
    correspond to the valid contents of the field line.

    If a substring is longer than the field, its excess is ignored; if shorter
    the field is valid only if all positions beyond the substring length are
    equal to the fill character.

******************************************************************************/

PALV02()

{
    int ii,jj,ll,eq,lv;
    uchar *q;

    if ( (PACRF.xa != PANULL) && (PACRF.xa->xbits & (1 << NXAVL) ) )
        {
        PAXASC(PACRF.xa->xattr[NXAVL]); /* use the XA string */
        for (ii = 0; ii < PAXASN; ii++) /* check each string */
            {
            q = PAXASP[ii];             /* start of supplied string */
            ll = strlen(q);             /* and its length */
            eq = 1;                     /* assume it is equal */
            for (jj = 0; jj < UCI(PACRF.sl); jj++)  /* check all displayed */
                {
                if ( *(PVWRKP+jj) != ( (jj >= ll) ? (PACRF.sf) : *(q+jj) )  )
                    {                   /* excess over supplied must be fill */
                    eq = 0;             /* this one is not it */
                    break;
                    }
                }
            if (eq) return(0);          /* found one with no differences */
            }
        }
    return(2);                          /* invalid, no match found */
}
