|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T a
Length: 6090 (0x17ca)
Types: TextFile
Names: »asn_ext.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/dsap/x500as/asn_ext.c«
/* asn_ext.c - ASN.1 functionality extension stuff */
#ifndef lint
static char *rcsid = "$Header: /f/osi/dsap/x500as/RCS/asn_ext.c,v 6.0 89/03/18 23:29:15 mrose Rel $";
#endif
/*
* $Header: /f/osi/dsap/x500as/RCS/asn_ext.c,v 6.0 89/03/18 23:29:15 mrose Rel $
*
*
* $Log: asn_ext.c,v $
* Revision 6.0 89/03/18 23:29:15 mrose
* Release 5.0
*
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
/* LINTLIBRARY */
#include "quipu/util.h"
#include "quipu/common.h"
#include "quipu/entry.h"
#include "varargs.h"
extern LLog * log_dsap;
OID grab_oid(at)
AttributeType at;
{
if(at->at_oid == NULLOID)
return(at->at_table->oa_ot.ot_oid);
else
return(at->at_oid);
}
PE grab_pe(av)
AttributeValue av;
{
PE ret_pe = NULLPE;
int av_syntax;
if ( av->av_syntax >= AV_WRITE_FILE )
av_syntax = av->av_syntax - AV_WRITE_FILE;
else
av_syntax = av->av_syntax;
if(av->av_pe != NULLPE)
return(pe_cpy(av->av_pe));
switch(av_syntax)
{
case AV_CASEEXACTSTRING:
case AV_CASEIGNORESTRING:
ret_pe = prts2prim(av->av_un.av_str, strlen(av->av_un.av_str));
break;
case AV_NUMERICSTRING:
ret_pe = nums2prim(av->av_un.av_num, strlen(av->av_un.av_num));
break;
case AV_OID:
ret_pe = oid2prim(av->av_un.av_oid);
break;
case AV_OBJECTCLASS:
ret_pe = oid2prim(av->av_un.av_objectclass->oc_ot.ot_oid);
break;
case AV_ACL:
(void) encode_Quipu_ACLSyntax (&ret_pe,0,0,NULLCP,av->av_un.av_acl);
break;
case AV_PRESENTATIONADDRESS:
if (encode_DO_ISODEPresentationAddress (&ret_pe,0,0,NULLCP,av->av_un.av_psap) == NOTOK ) {
ret_pe = NULLPE;
LLOG (log_dsap,LLOG_EXCEPTIONS, ("Failed to encode PSAP"));
}
break;
case AV_DN:
(void) encode_IF_DistinguishedName (&ret_pe,0,0,NULLCP,av->av_un.av_dn);
break;
case AV_SCHEMA:
(void) encode_Quipu_TreeStructureSyntax(&ret_pe,0,0,NULLCP,av->av_un.av_tree);
break;
case AV_UPDATE:
(void) encode_Quipu_EDBInfoSyntax (&ret_pe,0,0,NULLCP,av->av_un.av_update);
break;
case AV_BOOLEAN:
ret_pe = bool2prim(av->av_un.av_boolean);
break;
case AV_INTEGER:
ret_pe = int2prim(av->av_un.av_integer);
break;
case AV_TIME:
{
UTCtime utime;
tm2ut (gmtime(&(av->av_un.av_time)),&utime);
ret_pe = utct2prim(&utime);
break;
}
case AV_FILE:
{
FILE * fptr;
if ((fptr = fopen (av->av_un.av_file.fs_name,"r")) != NULL) {
if ((av->av_un.av_file.fs_real_syntax == AV_ASN) ||
(av->av_un.av_file.fs_real_syntax == AV_PHOTO)) {
PS fps;
fps = ps_alloc (std_open);
if ((std_setup (fps,fptr)) == NOTOK) {
(void) fclose (fptr);
ps_free (fps);
break;
}
ret_pe = ps2pe (fps);
(void) fclose (fptr);
ps_free (fps);
} else {
char buffer [LINESIZE];
AttributeValue newav;
extern char * TidyString ();
(void) fread (buffer,LINESIZE,1,fptr);
(void) fclose (fptr);
if ((newav = str2AttrV (TidyString(buffer),av->av_un.av_file.fs_real_syntax)) == NULLAttrV){
LLOG (log_dsap,LLOG_EXCEPTIONS,("invalid format in file %s",av->av_un.av_file.fs_name));
break;
}
ret_pe = grab_pe (newav);
AttrV_free (newav);
}
} else
LLOG(log_dsap,LLOG_EXCEPTIONS,("Can't open %s",av->av_un.av_file.fs_name));
break;
}
default:
LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unknown syntax %d in grab_pe",av->av_syntax));
case AV_ASN:
case AV_PHOTO:
return(pe_cpy(av->av_un.av_asn));
}
/* remove optimisation for now ...
av->av_pe = pe_cpy (ret_pe); /* optimisation - save pe for */
/* future use - memory expensive */
return (ret_pe);
}
AttrV_do_decode(x,y)
register AttributeType x;
register AttributeValue y;
{
int z;
int y_syntax;
if (x == NULLAttrT)
return;
AttrT_decode (x);
if (x->at_table == NULLTABLE_ATTR)
return;
if (y == NULLAttrV)
return;
y->av_syntax = x->at_table->oa_syntax;
if ( y->av_syntax >= AV_WRITE_FILE )
y_syntax = y->av_syntax - AV_WRITE_FILE;
else
y_syntax = y->av_syntax;
switch (y_syntax) {
case AV_CASEEXACTSTRING:
case AV_CASEIGNORESTRING:
y->av_un.av_str = prim2str (y->av_pe, &z);
break;
case AV_NUMERICSTRING:
y->av_un.av_num = prim2str (y->av_pe, &z);
break;
case AV_OID:
y->av_un.av_oid = oid_cpy(prim2oid(y->av_pe));
break;
case AV_OBJECTCLASS:
y->av_un.av_objectclass = oid2oc (prim2oid(y->av_pe));
break;
case AV_ASN:
case AV_PHOTO:
y->av_un.av_asn = y->av_pe;
break;
case AV_BOOLEAN:
y->av_un.av_boolean = (char) prim2flag (y->av_pe) ;
break;
case AV_INTEGER:
y->av_un.av_integer = prim2num (y->av_pe);
break;
case AV_TIME:
y->av_un.av_time = gtime(ut2tm(prim2utct(y->av_pe)));
break;
case AV_PRESENTATIONADDRESS:
{
y->av_un.av_psap = (struct PSAPaddr *) calloc (1,sizeof (struct PSAPaddr));
(void) decode_DO_ISODEPresentationAddress (y->av_pe,1,NULLIP,NULLVP,y->av_un.av_psap);
break;
}
case AV_ACL:
y->av_un.av_acl = acl_alloc ();
(void) decode_Quipu_ACLSyntax(y->av_pe,1,NULLIP,NULLVP,y->av_un.av_acl);
acl_decode (y->av_un.av_acl);
break;
case AV_DN:
(void) decode_IF_DistinguishedName(y->av_pe,1,NULLIP,NULLVP,&(y->av_un.av_dn));
dn_decode (y->av_un.av_dn);
break;
case AV_SCHEMA:
(void) decode_Quipu_TreeStructureSyntax(y->av_pe,1,NULLIP,NULLVP,&(y->av_un.av_tree));
break;
case AV_UPDATE:
y->av_un.av_update = edb_info_alloc ();
(void) decode_Quipu_EDBInfoSyntax(y->av_pe,1,NULLIP,NULLVP,y->av_un.av_update);
edb_info_decode (y->av_un.av_update);
break;
default:
y->av_syntax = AV_UNKNOWN;
LLOG(log_dsap, LLOG_EXCEPTIONS, ("Un decoded syntax %d",x->at_table->oa_syntax));
break;
}
}
#ifndef lint
void ds_advise (va_alist)
va_dcl
{
va_list ap;
va_start (ap);
(void) _ll_log (log_dsap, LLOG_EXCEPTIONS, ap);
va_end (ap);
}
#else
/* VARARGS */
void ds_advise (what, fmt)
char *what,
*fmt;
{
ds_advise (what, fmt);
}
#endif