Annotation of 43BSDReno/contrib/isode-beta/dsap/common/pdm.c, revision 1.1.1.1

1.1       root        1: /* pdm.c - preferred delivery method handling */
                      2: 
                      3: #ifndef lint
                      4: static char *rcsid = "$Header: /f/osi/dsap/common/RCS/pdm.c,v 7.0 89/11/23 21:42:37 mrose Rel $";
                      5: #endif
                      6: 
                      7: /*
                      8:  * $Header: /f/osi/dsap/common/RCS/pdm.c,v 7.0 89/11/23 21:42:37 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       pdm.c,v $
                     12:  * Revision 7.0  89/11/23  21:42:37  mrose
                     13:  * Release 6.0
                     14:  * 
                     15:  */
                     16: 
                     17: /*
                     18:  *                                NOTICE
                     19:  *
                     20:  *    Acquisition, use, and distribution of this module and related
                     21:  *    materials are subject to the restrictions of a license agreement.
                     22:  *    Consult the Preface in the User's Manual for the full terms of
                     23:  *    this agreement.
                     24:  *
                     25:  */
                     26: 
                     27: /*
                     28:        SYNTAX:
                     29:        pdm = <pdm_component> | <pdm_component> '$' <pdm>
                     30:        pdm_component = 'any' | 'mhs' | 'physical' | 'telex' | 'teletex' |
                     31:                        'g3fax' | 'g4fax' | 'ia5' | 'videotex' | 'telephone'
                     32: 
                     33:        EXAMPLE:
                     34:                mhs $ physical $ telex $ telephone
                     35: 
                     36: 
                     37: */
                     38: 
                     39: /* LINTLIBRARY */
                     40: 
                     41: #include "quipu/util.h"
                     42: #include "quipu/attrvalue.h"
                     43: #include "cmd_srch.h"
                     44: 
                     45: static CMD_TABLE pdm_table [] = {
                     46:        "ANY",          0,
                     47:        "MHS",          1,
                     48:        "PHYSICAL",     2,
                     49:        "TELEX",        3,
                     50:        "TELETEX",      4,
                     51:        "G3FAX",        5,
                     52:        "G4FAX",        6,
                     53:        "IA5",          7,
                     54:        "VIDEOTEX",     8,
                     55:        "TELEPHONE",    9,
                     56:        "UNKNOWN",      -1,
                     57:        0,              -1
                     58:        };
                     59: 
                     60: 
                     61: static pdmfree (pdm)
                     62: struct pref_deliv * pdm;
                     63: {
                     64:         struct pref_deliv *next;
                     65:        
                     66:        for (; pdm != (struct pref_deliv *) NULL; pdm = next)  {
                     67:                next = pdm -> pd_next;
                     68:                free ((char *) pdm);
                     69:        }
                     70: }
                     71: 
                     72: static pdmcmp (a,b)
                     73: struct pref_deliv * a, *b;
                     74: {
                     75:        /* matching here is a bit dubious !!! */
                     76: 
                     77:         for (; (a != (struct pref_deliv *) NULL) && (b != (struct pref_deliv *) NULL) ;
                     78:                        a = a->pd_next, b=b->pd_next) 
                     79:                if ( a->deliv != b->deliv )
                     80:                        return (a->deliv > b->deliv ? 1 : -1);
                     81: 
                     82:        if ( a != b)
                     83:                return ( a > b ? 1 : -1 );
                     84:        else
                     85:                return (0);
                     86:        
                     87: }
                     88: 
                     89: static struct pref_deliv * pdmcpy (a)
                     90: struct pref_deliv * a;
                     91: {
                     92: struct pref_deliv * b, *c, *result = (struct pref_deliv *) NULL;
                     93: 
                     94:        c = result; /* to keep lint happy */
                     95: 
                     96:         for (; a != (struct pref_deliv *) NULL; a = a->pd_next) {
                     97:                b = (struct pref_deliv *) smalloc (sizeof (struct pref_deliv));
                     98:                b -> deliv = a -> deliv;
                     99:                
                    100:                if (result == (struct pref_deliv *) NULL) 
                    101:                        result = b;
                    102:                else 
                    103:                        c->pd_next = b;
                    104:                c = b;
                    105:        }
                    106: 
                    107:        b->pd_next = (struct pref_deliv *) NULL;
                    108:        return (result);
                    109: }
                    110: 
                    111: static struct pref_deliv* pdmparse (str)
                    112: char * str;
                    113: {
                    114: struct pref_deliv * result = (struct pref_deliv *) NULL;
                    115: struct pref_deliv * a, *b;
                    116: char * ptr;
                    117: char * mark = NULLCP;
                    118: 
                    119:    b = result; /* to keep lint happy */
                    120: 
                    121:    for (;;) {
                    122:        mark = NULLCP;
                    123:        a = (struct pref_deliv *) smalloc (sizeof (struct pref_deliv));
                    124: 
                    125:        if ( (ptr=index (str,'$')) != NULLCP) {
                    126:                *ptr-- = 0;
                    127:                if (isspace (*ptr)) {
                    128:                        *ptr = 0;
                    129:                        mark = ptr;
                    130:                }
                    131:                ptr++;
                    132:        }
                    133: 
                    134:        if ((a -> deliv = cmd_srch (str,pdm_table)) == -1) {
                    135:                parse_error ("Unknown method %s",str);
                    136:                return ((struct pref_deliv *) NULL);
                    137:        }
                    138: 
                    139:        if (result == (struct pref_deliv *) NULL) 
                    140:                result = a;
                    141:        else 
                    142:                b->pd_next = a;
                    143:        b = a;
                    144: 
                    145:        if (ptr != NULLCP) {
                    146:                *ptr++ = '$';
                    147:                if (mark != NULLCP)
                    148:                        *mark = ' ';
                    149:                str = (SkipSpace(ptr)); 
                    150:                ptr = str;
                    151:        } else
                    152:                break;
                    153:    }
                    154:    a -> pd_next = (struct pref_deliv *) NULL ;
                    155: 
                    156:    return (result);
                    157: }
                    158: 
                    159: static pdmprint (ps,pdm,format)
                    160: PS ps;
                    161: struct pref_deliv * pdm;
                    162: int format;
                    163: {
                    164: char * prefix = NULLCP;
                    165: 
                    166:        for (; pdm != (struct pref_deliv *) NULL; pdm = pdm->pd_next) {
                    167:                if (prefix != NULLCP)
                    168:                        ps_print (ps,prefix);
                    169: 
                    170:                        
                    171:                ps_print (ps,rcmd_srch (pdm->deliv,pdm_table));
                    172: 
                    173:                if (format == READOUT)
                    174:                        prefix = " or ";
                    175:                else
                    176:                        prefix = " $ ";
                    177:        }
                    178: }
                    179: 
                    180: 
                    181: static PE pdmenc (m)
                    182: struct pref_deliv * m;
                    183: {
                    184: PE ret_pe;
                    185: 
                    186:         (void) encode_SA_PreferredDeliveryMethod (&ret_pe,0,0,NULLCP,m);
                    187: 
                    188:        return (ret_pe);
                    189: }
                    190: 
                    191: static struct pref_deliv * pdmdec (pe)
                    192: PE pe;
                    193: {
                    194: struct pref_deliv * m;
                    195: 
                    196:        if (decode_SA_PreferredDeliveryMethod (pe,1,NULLIP,NULLVP,&m) == NOTOK)
                    197:                return ((struct pref_deliv *) NULL);
                    198:        return (m);
                    199: }
                    200: 
                    201: pref_deliv_syntax ()
                    202: {
                    203:        (void) add_attribute_syntax ("DeliveryMethod",
                    204:                (IFP) pdmenc,   (IFP) pdmdec,
                    205:                (IFP) pdmparse,pdmprint,
                    206:                (IFP) pdmcpy,   pdmcmp,
                    207:                pdmfree,        NULLCP,
                    208:                NULLIFP,        TRUE);
                    209: 
                    210: }
                    211: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.