|
|
1.1 ! root 1: /* psap.c - General PSAP utility routines */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/dsap/common/RCS/psap.c,v 7.0 89/11/23 21:44:24 mrose Rel $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/dsap/common/RCS/psap.c,v 7.0 89/11/23 21:44:24 mrose Rel $ ! 9: * ! 10: * ! 11: * $Log: psap.c,v $ ! 12: * Revision 7.0 89/11/23 21:44:24 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: /* LINTLIBRARY */ ! 29: ! 30: #include "quipu/util.h" ! 31: #include "quipu/attr.h" ! 32: #include "psap.h" ! 33: #include "isoaddrs.h" ! 34: ! 35: extern LLog * log_dsap; ! 36: ! 37: psap_free (psap) ! 38: struct PSAPaddr * psap; ! 39: { ! 40: free ((char *)psap) ; ! 41: } ! 42: ! 43: struct PSAPaddr * psap_cpy (a) ! 44: struct PSAPaddr * a; ! 45: { ! 46: struct PSAPaddr * r; ! 47: ! 48: r = (struct PSAPaddr *) smalloc (sizeof (struct PSAPaddr)); ! 49: bzero ((char *) r,sizeof (struct PSAPaddr)); ! 50: ! 51: *r = *a; /* struct copy */ ! 52: ! 53: return (r); ! 54: } ! 55: ! 56: psap_dup (r,a) ! 57: struct PSAPaddr * r, * a; ! 58: { ! 59: *r = *a; /* struct copy */ ! 60: } ! 61: ! 62: static psap_cmp (r,a) ! 63: struct PSAPaddr *r, *a; ! 64: { ! 65: return (bcmp ((char *) r, (char *) a, sizeof *a) ? (-1) : 0); ! 66: } ! 67: ! 68: static PE psap_enc (p) ! 69: struct PSAPaddr *p; ! 70: { ! 71: PE ret_pe; ! 72: ! 73: if (encode_DO_ISODEPresentationAddress (&ret_pe,0,0,NULLCP,p) == NOTOK ) { ! 74: ret_pe = NULLPE; ! 75: LLOG (log_dsap,LLOG_EXCEPTIONS, ("Failed to encode PSAP")); ! 76: } ! 77: return (ret_pe); ! 78: } ! 79: ! 80: static struct PSAPaddr * psap_dec (pe) ! 81: PE pe; ! 82: { ! 83: struct PSAPaddr * psap; ! 84: ! 85: psap = (struct PSAPaddr *) calloc (1,sizeof (struct PSAPaddr)); ! 86: if (decode_DO_ISODEPresentationAddress (pe,1,NULLIP,NULLVP,psap) == NOTOK) { ! 87: free ((char *)psap); ! 88: return (NULLPA); ! 89: } ! 90: ! 91: return (psap); ! 92: } ! 93: ! 94: static struct PSAPaddr * psap_parse (s) ! 95: char * s; ! 96: { ! 97: struct PSAPaddr *pa; ! 98: struct PSAPaddr *psap; ! 99: ! 100: psap = (struct PSAPaddr *) calloc (1,sizeof (struct PSAPaddr)); ! 101: if (pa=str2paddr(s)) { ! 102: *psap = *pa; /* struct copy */ ! 103: return (psap); ! 104: } else { ! 105: parse_error ("invalid presentation address %s",s); ! 106: free ((char *)psap); ! 107: return (NULLPA); ! 108: } ! 109: } ! 110: ! 111: static psap_print (ps,p,format) ! 112: PS ps; ! 113: struct PSAPaddr *p; ! 114: int format; ! 115: { ! 116: if (format != READOUT) ! 117: ps_printf (ps, "%s", _paddr2str(p,NULLNA,-1)); ! 118: else ! 119: ps_printf (ps, "%s", paddr2str(p,NULLNA)); ! 120: ! 121: } ! 122: ! 123: psap_syntax () ! 124: { ! 125: (void) add_attribute_syntax ("presentationAddress", ! 126: (IFP) psap_enc, (IFP) psap_dec, ! 127: (IFP) psap_parse, psap_print, ! 128: (IFP) psap_cpy, psap_cmp, ! 129: psap_free, NULLCP, ! 130: NULLIFP, TRUE ); ! 131: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.