Api to get Tagpath from confd_hkeypath_t

Hi,

Could you please help me with an api to get the Tagpath from a confd_hkeypath_t?

Eg:
If below is the confd_hkeypath
“/hosts/host{buzz}/interfaces/interface{1/1/1}”;

I need the output of the api as below without the keys
“/hosts/host/interfaces/interface”;

Thanks in advance.
Ramishet

Hello,

i believe there is no explicit API/procedure to do it “automatically”.

You can easily get it by iterating the input keypath, and copying only the C_XMLTAG elements to the output…

pseudo code:

int output_len = 0;
for (i = 0; i < input->len; i++) {
    if (C_XMLTAG == input->v[i][0].type) {
        confd_value_dup_to(&input->v[i][0], &output->v[output_len++][0]);
    }
}
output->len = output_len;

in addition, whenever working with artificial keypaths created in custom code, for safety reasons it might be a good idea to set/add a border values not occupied by keypath “tags” to C_NOEXISTS… (e.g. setting CONFD_SET_NOEXISTS(&output->v[output->len][0]) etc.

(depending on what you do with the output keypath, for the output key to be a “proper one” that can be safely passed to e.g. confd_free_hkeypath(), confd_hkeypath_dup(), etc.)

Thanks a lot Joseph for your quick support