/* inherit.c - inherit attribute */
static char *rcsid
= "$Header: /f/osi/dsap/common/RCS/inherit.c,v 7.2 91/02/22 09:19:24 mrose Interim $";
* $Header: /f/osi/dsap/common/RCS/inherit.c,v 7.2 91/02/22 09:19:24 mrose Interim $
* Revision 7.2 91/02/22 09:19:24 mrose
* Revision 7.1 90/10/17 11:42:04 mrose
* Revision 7.0 90/08/08 08:34:04 mrose
* *** empty log message ***
* 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
inherit ::= [<objectclass> '$'] ["ALWAYS $"] <attribute>
#include "quipu/attrvalue.h"
#include "quipu/syntaxes.h"
static inherit_free (ptr
)
as_free (ptr
->i_default
);
static InheritAttr
inherit_cpy (a
)
result
= (InheritAttr
) smalloc (sizeof (*result
));
result
->i_always
= as_cpy (a
->i_always
);
result
->i_default
= as_cpy (a
->i_default
);
result
->i_oid
= oid_cpy (a
->i_oid
);
if ( (res
= oid_cmp (a
->i_oid
,b
->i_oid
)) != 0)
if ( (res
= as_cmp (a
->i_always
,b
->i_always
)) != 0)
return (as_cmp (a
->i_default
,b
->i_default
));
static inherit_print (ps
,inherit
,format
)
ps_printf (ps
,"Object class %s, ",oid2name(inherit
->i_oid
, OIDPART
));
ps_print (ps
,"ALWAYS:\n");
as_print (ps
,inherit
->i_always
,READOUT
);
if (inherit
->i_default
) {
ps_print (ps
,"--------\t\t");
ps_printf (ps
,"Object class %s, ",oid2name(inherit
->i_oid
, OIDPART
));
ps_print (ps
,"DEFAULT:\n");
as_print (ps
,inherit
->i_default
,READOUT
);
ps_print (ps
,"ALWAYS inherit:\n");
as_print (ps
,inherit
->i_always
,READOUT
);
if (inherit
->i_default
) {
ps_print (ps
,"--------\t\t");
ps_print (ps
,"DEFAULT inheritance:\n");
as_print (ps
,inherit
->i_default
,READOUT
);
ps_print (ps
,"--------");
ps_printf (ps
,"%s $ ",oid2name(inherit
->i_oid
, OIDPART
));
ps_print (ps
,"ALWAYS (\n");
as_print (ps
,inherit
->i_always
,EDBOUT
);
if (inherit
->i_default
) {
ps_print (ps
,"DEFAULT (\n");
as_print (ps
,inherit
->i_default
,EDBOUT
);
static char * getInheritAttrs (asptr
, needsoc
)
Attr_Sequence as
= NULLATTR
;
Attr_Sequence
as_combine ();
Attr_Sequence
as_find_type();
static AttributeType octype
= NULLAttrT
;
char * ptr
, * getnextline();
if ((ptr
= getnextline ()) == NULLCP
) {
parse_error ("Inherit: EOF unexpected",NULLCP
);
parse_error ("Attributes missing",NULLCP
);
as
= as_combine (as
,ptr
,TRUE
);
if ((ptr
= getnextline ()) == NULLCP
)
if (needsoc
&& octype
== NULLAttrT
)
octype
= str2AttrT("objectClass");
if (needsoc
&& as_find_type(as
, octype
) == NULLATTR
) {
parse_error("Required inherited attribute objectClass missing",NULLCP
);
parse_error ("Inherit: EOF unexpected (2)",NULLCP
);
static InheritAttr
str2inherit (str
)
result
= (InheritAttr
) smalloc (sizeof *result
);
result
->i_always
= NULLATTR
;
result
->i_default
= NULLATTR
;
if ( (ptr
=index (str
,'$')) != NULLCP
) {
if ((result
->i_oid
= name2oid (str
)) == NULLOID
)
if (lexnequ (ptr
,"ALWAYS",strlen("ALWAYS")) == 0) {
ptr
= SkipSpace (ptr
+strlen("ALWAYS"));
parse_error ("Inherit: open bracket missing",NULLCP
);
parse_error ("Inherit: extra data '%s'",ptr
);
ptr
= getInheritAttrs(&result
->i_always
, FALSE
);
if (lexnequ (ptr
,"DEFAULT",strlen("DEFAULT")) == 0) {
ptr
= SkipSpace (ptr
+strlen("DEFAULT"));
parse_error ("Inherit: open bracket missing",NULLCP
);
parse_error ("Inherit: extra data '%s'",ptr
);
ptr
= getInheritAttrs(&result
->i_default
, needsoc
);
if ((result
->i_always
== NULLATTR
)
&& (result
->i_default
== NULLATTR
)) {
parse_error ("Inherited Attribute syntax incorrect",NULLCP
);
parse_error ("Inherit: extra data '%s'",ptr
);
static PE
inherit_enc (m
)
(void) encode_Quipu_InheritedAttribute (&ret_pe
,0,0,NULLCP
,m
);
static InheritAttr
inherit_dec (pe
)
if (decode_Quipu_InheritedAttribute (pe
,1,NULLIP
,NULLVP
,&m
) == NOTOK
)
extern short inherit_sntx
;
inherit_sntx
= add_attribute_syntax ("InheritedAttribute",
(IFP
) inherit_enc
, (IFP
) inherit_dec
,
(IFP
) str2inherit
, inherit_print
,
(IFP
) inherit_cpy
, inherit_cmp
,