Maapi_cursor for multiple keys

Hi,

I am using maapi_cursor in my code for a list. The list has multiple keys. So, i am doing maapi_cd with %*x with mc.n,mc.keys but all the keys are coming as joined and there is no space between them and maapi_cd is failing. Can anyone help if you have tried it out

Regards,
Himani

all 3 keys are type string, if i take some other type like uint16 then this problem is not coming.

I will show a simple example here.

For the following YANG fragment:

  container root {
    container servers {
      list server {
        key “location name";
        leaf location {
          type string;
        }
        leaf name {
          type string;
        }
        leaf ip {
          type inet:ip-address;
          mandatory true;
        }
        leaf port {
          type inet:port-number;
          mandatory true;
        }
      }
    }
  }

The maapi_cd call can be invoked as follows:

maapi_cd(sock, tid,
         "/root/servers/server{%x %x}",
         &mc.keys[0], &mc.keys[1]);

True - but this hardwires the number of keys. Using the %*x modifier that @Himani mentions, an arbitrary number of keys can be handled:

maapi_cd(sock, tid,
         "/root/servers/server{%*x}",
         mc.n, mc.keys);

Or rather - it should be possible to do that - but there is indeed a bug with “adjacent” string keys getting joined together. Will be fixed…