How to get the "presence" statement when deciding if a container is a presence container?

Hi,
I need to implement a function to decide if a container is a presence container as below:

func (node *Node) IsPresenceContainer() 

Node is confd_cs_node as below:

 221 type _Ctype_struct_confd_cs_node struct {
 222     tag     _Ctype_u_int32_t
 223     ns      _Ctype_u_int32_t
 224     info        _Ctype_struct_confd_cs_node_info
 225     parent      *_Ctype_struct_confd_cs_node
 226     children    *_Ctype_struct_confd_cs_node
 227     next        *_Ctype_struct_confd_cs_node
 228     opaque      unsafe.Pointer
 229 }
 230
 231 type _Ctype_struct_confd_cs_node_info struct {
 232     keys        *_Ctype_u_int32_t
 233     minOccurs   _Ctype_int
 234     maxOccurs   _Ctype_int
 235     shallow_type    uint32
 236     _type       *_Ctype_struct_confd_type
 237     defval      *_Ctype_struct_confd_value
 238     choices     *_Ctype_struct_confd_cs_choice
 239     flags       _Ctype_int
 240     cmp     _Ctype_u_int8_t
 241     meta_data   *_Ctype_struct_confd_cs_meta_data
 242 }

And here is the corresponding schema:

                container school {
                    presence "edu";
                    leaf key {type string;}
                    leaf schoolname {
                        type string;
                        description "Name of the school";
                    }
                    leaf school-rating {
                        type string;
                        yexte:is-passphrase;
                        description "choice case leaf encrypted value";
                    }
                }

I can get children: key, schoolname, and school-rating by the next point. But I cannot get the statement of “presence” by meta-data. Would you please give me some guide how to get the “presence” statement?

You may try something like this (check minOccurs for 0) :

static inline int container_is_p(struct confd_cs_node *cs) {
    return cs->info.minOccurs == 0;
}

(taken from examples.confd/netconf_yang_push/example-dp.c)

1 Like

Hi mnovak,
Thank you very much for the reply.
The file example-dp.c is not found in confd-basic 7.5. Would you please share the version which includes this file?
BRs
Michael

Can you try latest confd-basic? I think it was added recently to confd-basic as well.

Do you need the example? The function is pasted into the chat. All you need is to check minOccurs == 0.