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

1.1       root        1: /* mailbox.c - otherMailbox attribute */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/dsap/common/RCS/mailbox.c,v 7.0 89/11/23 21:42:29 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/dsap/common/RCS/mailbox.c,v 7.0 89/11/23 21:42:29 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       mailbox.c,v $
                     12:  * Revision 7.0  89/11/23  21:42:29  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:        mailbox ::= <printablestring> '$' <IA5String>
                     31:        
                     32:        EXAMPLE
                     33:        internet $ [email protected]
                     34: */
                     35: 
                     36: /* LINTLIBRARY */
                     37: 
                     38: #include "quipu/util.h"
                     39: #include "quipu/entry.h"
                     40: 
                     41: static mailbox_free (ptr)
                     42: struct mailbox * ptr;
                     43: {
                     44:        free (ptr->mbox);
                     45:        free (ptr->mtype);
                     46: 
                     47:        free ((char *) ptr);
                     48: }
                     49: 
                     50: 
                     51: static struct mailbox * mailbox_cpy (a)
                     52: struct mailbox * a;
                     53: {
                     54: struct mailbox * result;
                     55: 
                     56:        result = (struct mailbox *) smalloc (sizeof (struct mailbox));
                     57:        result->mbox = strdup (a->mbox);
                     58:        result->mtype = strdup (a->mtype);
                     59:        return (result);
                     60: }
                     61: 
                     62: static mailbox_cmp (a,b)
                     63: struct mailbox * a;
                     64: struct mailbox * b;
                     65: {
                     66: int res;
                     67: 
                     68:        if (a == (struct mailbox *) NULL)
                     69:                if (b == (struct mailbox *) NULL)
                     70:                        return (0);
                     71:                else 
                     72:                        return (-1);
                     73: 
                     74:        if ( (res = lexequ(a->mbox,b->mbox)) != 0) 
                     75:                return (res);
                     76:        if ( (res = lexequ(a->mtype,b->mtype)) != 0)
                     77:                return (res);
                     78:        return (0);
                     79: }
                     80: 
                     81: 
                     82: static mailbox_print (ps,mail,format)
                     83: register PS ps;
                     84: struct   mailbox* mail;
                     85: int format;
                     86: {
                     87:        if (format == READOUT)
                     88:                ps_printf (ps,"%s: %s",mail->mtype, mail->mbox);
                     89:        else
                     90:                ps_printf (ps,"%s $ %s",mail->mtype, mail->mbox);
                     91: }
                     92: 
                     93: 
                     94: static struct mailbox* str2mailbox (str)
                     95: char * str;
                     96: {
                     97: struct mailbox * result;
                     98: char * ptr;
                     99: char * mark = NULLCP;
                    100: 
                    101:        if ( (ptr=index (str,'$')) == NULLCP) {
                    102:                parse_error ("seperator missing in mailbox '%s'",str);
                    103:                return ((struct mailbox *) NULL);
                    104:        }
                    105: 
                    106:        result = (struct mailbox *) smalloc (sizeof (struct mailbox));
                    107:        *ptr--= 0;
                    108:        if (isspace (*ptr)) {
                    109:                *ptr = 0;
                    110:                mark = ptr;
                    111:        }
                    112:        ptr++;
                    113:        result->mtype = strdup (str);
                    114:        *ptr++ = '$';
                    115:        result->mbox = strdup (SkipSpace(ptr)); 
                    116: 
                    117:        if (mark != NULLCP)
                    118:                *mark = ' ';
                    119: 
                    120:        return (result);
                    121: }
                    122: 
                    123: static PE mail_enc (m)
                    124: struct mailbox * m;
                    125: {
                    126: PE ret_pe;
                    127: 
                    128:         (void) encode_Thorn_MailBox (&ret_pe,0,0,NULLCP,m);
                    129: 
                    130:        return (ret_pe);
                    131: }
                    132: 
                    133: static struct mailbox * mail_dec (pe)
                    134: PE pe;
                    135: {
                    136: struct mailbox * m;
                    137: 
                    138:        m = (struct mailbox *) smalloc (sizeof (struct mailbox));
                    139: 
                    140:        if (decode_Thorn_MailBox (pe,1,NULLIP,NULLVP,m) == NOTOK) {
                    141:                free ((char *)m);
                    142:                return ((struct mailbox *) NULL);
                    143:        }
                    144:        return (m);
                    145: }
                    146: 
                    147: mailbox_syntax ()
                    148: {
                    149:        (void) add_attribute_syntax ("Mailbox",
                    150:                (IFP) mail_enc,         (IFP) mail_dec,
                    151:                (IFP) str2mailbox,      mailbox_print,
                    152:                (IFP) mailbox_cpy,      mailbox_cmp,
                    153:                mailbox_free,           NULLCP,
                    154:                NULLIFP,                TRUE);
                    155: }

unix.superglobalmegacorp.com

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