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

1.1       root        1: /* teletex.c - Teletex attribute */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/dsap/common/RCS/teletex.c,v 7.0 89/11/23 21:44:35 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/dsap/common/RCS/teletex.c,v 7.0 89/11/23 21:44:35 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       teletex.c,v $
                     12:  * Revision 7.0  89/11/23  21:44:35  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: /*
                     29:        SYNTAX
                     30:        teletex ::= <printablestring> '$' <printablestring> '$' <printablestring>...
                     31:        
                     32:        REPRESENTING
                     33:        terminal $ graphic $ control $ page $ misc $ private
                     34: */
                     35: 
                     36: /* LINTLIBRARY */
                     37: 
                     38: #include "quipu/util.h"
                     39: #include "quipu/entry.h"
                     40: 
                     41: #define nfree(x) if (x != NULLCP) free (x)
                     42: 
                     43: static teletex_free (ptr)
                     44: struct teletex * ptr;
                     45: {
                     46:        nfree (ptr->terminal);
                     47:        nfree (ptr->graphic);
                     48:        nfree (ptr->control);
                     49:        nfree (ptr->page);
                     50:        nfree (ptr->misc);
                     51:        nfree (ptr->t_private);
                     52: 
                     53:        free ((char *) ptr);
                     54: }
                     55: 
                     56: static char * xstrdup (a)
                     57: char * a;
                     58: {
                     59:        if (( a == NULLCP) || (*a == NULL))
                     60:                return (NULLCP);
                     61:        else
                     62:                return (strdup (a));
                     63: }
                     64: 
                     65: static struct teletex * teletex_cpy (a)
                     66: struct teletex * a;
                     67: {
                     68: struct teletex * result;
                     69: 
                     70:        result = (struct teletex *) smalloc (sizeof (struct teletex));
                     71:        result->terminal = strdup (a->terminal);
                     72:        result->graphic  = xstrdup (a->graphic);
                     73:        result->control  = xstrdup (a->control);
                     74:        result->page     = xstrdup (a->page);
                     75:        result->misc     = xstrdup (a->misc);
                     76:        result->t_private  = xstrdup (a->t_private);
                     77:        return (result);
                     78: }
                     79: 
                     80: static teletex_cmp (a,b)
                     81: struct teletex * a;
                     82: struct teletex * b;
                     83: {
                     84: int res;
                     85: 
                     86:        if (a == (struct teletex *) NULL)
                     87:                if (b == (struct teletex *) NULL)
                     88:                        return (0);
                     89:                else 
                     90:                        return (-1);
                     91: 
                     92:        if ( (res = lexequ(a->terminal,b->terminal)) != 0) 
                     93:                return (res);
                     94:        if ( (res = lexequ(a->graphic,b->graphic)) != 0) 
                     95:                return (res);
                     96:        if ( (res = lexequ(a->control,b->control)) != 0) 
                     97:                return (res);
                     98:        if ( (res = lexequ(a->page,b->page)) != 0) 
                     99:                return (res);
                    100:        if ( (res = lexequ(a->misc,b->misc)) != 0) 
                    101:                return (res);
                    102:        if ( (res = lexequ(a->t_private,b->t_private)) != 0) 
                    103:                return (res);
                    104:        return (0);
                    105: }
                    106: 
                    107: 
                    108: static teletex_print (ps,teletex,format)
                    109: register PS ps;
                    110: struct   teletex* teletex;
                    111: int format;
                    112: {
                    113:        if (format == READOUT)
                    114:                ps_print (ps,"terminal: ");
                    115:        ps_print (ps,teletex->terminal);
                    116: 
                    117:        if (format != READOUT)
                    118:                ps_print (ps," $ ");
                    119:        if (teletex->graphic != NULLCP) {
                    120:                if (format == READOUT)
                    121:                        ps_print (ps,", graphic: ");
                    122:                ps_print (ps,teletex->graphic);
                    123:        } 
                    124: 
                    125:        if (format != READOUT)
                    126:                ps_print (ps," $ ");
                    127:        if (teletex->control != NULLCP) {
                    128:                if (format == READOUT)
                    129:                        ps_print (ps,", control: ");
                    130:                ps_print (ps,teletex->control);
                    131:        } 
                    132: 
                    133:        if (format != READOUT)
                    134:                ps_print (ps," $ ");
                    135:        if (teletex->page != NULLCP) {
                    136:                if (format == READOUT)
                    137:                        ps_print (ps,", page: ");
                    138:                ps_print (ps,teletex->page);
                    139:        } 
                    140: 
                    141:        if (format != READOUT)
                    142:                ps_print (ps," $ ");
                    143:        if (teletex->misc != NULLCP) {
                    144:                if (format == READOUT)
                    145:                        ps_print (ps,", misc: ");
                    146:                ps_print (ps,teletex->misc);
                    147:        } 
                    148: 
                    149:        if (format != READOUT)
                    150:                ps_print (ps," $ ");
                    151:        if (teletex->t_private != NULLCP) {
                    152:                if (format == READOUT)
                    153:                        ps_print (ps,", private: ");
                    154:                ps_print (ps,teletex->t_private);
                    155:        } 
                    156:                
                    157: }
                    158: 
                    159: 
                    160: static struct teletex* str2teletex (str)
                    161: char * str;
                    162: {
                    163: struct teletex * result;
                    164: char * ptr;
                    165: char * mark = NULLCP;
                    166: char * prtparse ();
                    167: 
                    168:        if ( (ptr=index (str,'$')) == NULLCP) {
                    169:                parse_error ("seperator missing in teletex '%s'",str);
                    170:                return ((struct teletex *) NULL);
                    171:        }
                    172: 
                    173:        result = (struct teletex *) smalloc (sizeof (struct teletex));
                    174:        *ptr--= 0;
                    175:        if (isspace (*ptr)) {
                    176:                *ptr = 0;
                    177:                mark = ptr;
                    178:        }
                    179:        ptr++;
                    180:        if ((result->terminal = prtparse(str)) == NULLCP)
                    181:                 return ((struct teletex *) NULL);
                    182: 
                    183:         if (strlen (result->terminal) > UB_TELETEX_TERMINAL_ID) {
                    184:                 parse_error ("teletex string too long",NULLCP);
                    185:                 return ((struct teletex *) NULL);
                    186:         }
                    187: 
                    188:        *ptr++ = '$';
                    189: 
                    190:        if (mark != NULLCP)
                    191:                *mark = ' ';
                    192: 
                    193:        str = SkipSpace(ptr);   
                    194:        if ( (ptr=index (str,'$')) == NULLCP) {
                    195:                parse_error ("2nd seperator missing in teletex '%s'",str);
                    196:                return ((struct teletex *) NULL);
                    197:        }
                    198:        *ptr--= 0;
                    199:        if (isspace (*ptr)) {
                    200:                *ptr = 0;
                    201:                mark = ptr;
                    202:        } else
                    203:                mark = NULLCP;
                    204:        ptr++;
                    205:        result->graphic = xstrdup(str);
                    206:        *ptr++ = '$';
                    207:        if (mark != NULLCP)
                    208:                *mark = ' ';
                    209: 
                    210: 
                    211:        str = SkipSpace(ptr);   
                    212:        if ( (ptr=index (str,'$')) == NULLCP) {
                    213:                parse_error ("3rd seperator missing in teletex '%s'",str);
                    214:                return ((struct teletex *) NULL);
                    215:        }
                    216:        *ptr--= 0;
                    217:        if (isspace (*ptr)) {
                    218:                *ptr = 0;
                    219:                mark = ptr;
                    220:        } else
                    221:                mark = NULLCP;
                    222:        ptr++;
                    223:        result->control = xstrdup(str);
                    224:        *ptr++ = '$';
                    225:        if (mark != NULLCP)
                    226:                *mark = ' ';
                    227: 
                    228: 
                    229:        str = SkipSpace(ptr);   
                    230:        if ( (ptr=index (str,'$')) == NULLCP) {
                    231:                parse_error ("4th seperator missing in teletex '%s'",str);
                    232:                return ((struct teletex *) NULL);
                    233:        }
                    234:        *ptr--= 0;
                    235:        if (isspace (*ptr)) {
                    236:                *ptr = 0;
                    237:                mark = ptr;
                    238:        } else
                    239:                mark = NULLCP;
                    240:        ptr++;
                    241:        result->page = xstrdup(str);
                    242:        *ptr++ = '$';
                    243:        if (mark != NULLCP)
                    244:                *mark = ' ';
                    245: 
                    246: 
                    247:        str = SkipSpace(ptr);   
                    248:        if ( (ptr=index (str,'$')) == NULLCP) {
                    249:                parse_error ("5th seperator missing in teletex '%s'",str);
                    250:                return ((struct teletex *) NULL);
                    251:        }
                    252:        *ptr--= 0;
                    253:        if (isspace (*ptr)) {
                    254:                *ptr = 0;
                    255:                mark = ptr;
                    256:        } else
                    257:                mark = NULLCP;
                    258:        ptr++;
                    259:        result->misc = xstrdup(str);
                    260:        *ptr++ = '$';
                    261:        if (mark != NULLCP)
                    262:                *mark = ' ';
                    263: 
                    264:        result->t_private = xstrdup(SkipSpace(ptr));
                    265: 
                    266:        return (result);
                    267: }
                    268: 
                    269: static PE teletex_enc (m)
                    270: struct teletex * m;
                    271: {
                    272: PE ret_pe;
                    273: 
                    274:         (void) encode_SA_TeletexTerminalIdentifier (&ret_pe,0,0,NULLCP,m);
                    275: 
                    276:        return (ret_pe);
                    277: }
                    278: 
                    279: static struct teletex * teletex_dec (pe)
                    280: PE pe;
                    281: {
                    282: struct teletex * m;
                    283: 
                    284:        m = (struct teletex *) smalloc (sizeof (struct teletex));
                    285:        bzero ((char *)m,sizeof(struct teletex));
                    286: 
                    287:        if (decode_SA_TeletexTerminalIdentifier (pe,1,NULLIP,NULLVP,m) == NOTOK) {
                    288:                free ((char *)m);
                    289:                return ((struct teletex *) NULL);
                    290:        }
                    291: 
                    292:        return (m);
                    293: }
                    294: 
                    295: teletex_syntax ()
                    296: {
                    297:        (void) add_attribute_syntax ("TeletexTerminalIdentifier",
                    298:                (IFP) teletex_enc,      (IFP) teletex_dec,
                    299:                (IFP) str2teletex,      teletex_print,
                    300:                (IFP) teletex_cpy,      teletex_cmp,
                    301:                teletex_free,           NULLCP,
                    302:                NULLIFP,                TRUE);
                    303: }

unix.superglobalmegacorp.com

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