2

I'm trying to get a config using nc_recv_reply. So basically what I'm doing is:

struct nc_reply_data* reply = NULL;

std::cout << "======Calling nc_recv_reply======" << std::endl;
type = nc_recv_reply(session, rpc, msgid, 300, 0, (struct nc_reply**)&reply);
std::cout << "======Finished calling nc_recv_reply======" << std::endl;

if(reply && type == NC_MSG_REPLY)
  if(reply->type == NC_RPL_DATA)
  {
    if(reply->data)
      std::cout<< "======Got data======"<<std::endl;
    else
      std::cout<< "======Couldn't get data======"<<std::endl;
  }
  else
    std::cout<< "======Failure======"<<std::endl;

What get is

======Calling nc_recv_reply======

The message I'm supposed to receive

======Finished calling nc_recv_reply======

======Couldn't get data======

So my question is how do I get the lyd_node* I'm expecting?

Thanks in advance :)

Jim U
  • 3,318
  • 1
  • 14
  • 24
Prawky 77
  • 21
  • 2
  • Please do not tag as C and C++, these are different languages. Regardless, please indent your code, currently it's badly legible and hiding possible errors. – ljrk Mar 13 '20 at 13:35
  • 1
    I tagged this as C and C++ as it is both. Libnetconf2 is a C library and as such this issue required the C tag. However it is used in a C++ context therefore the C++ tag was needed too. In addition, the indentation is fine on my end so I'm not sure what you mean by that. – Prawky 77 Mar 13 '20 at 16:17
  • The language of the library doesn't matter -- in the end I could have written the library in Rust but still provide FFI for C++ and you'd be able to use it in C++. If you include a header in C++ this is *by definition* to be considered C++ code and does have different semantics. That's what `__cplusplus` is for. The indent was kindly fixed by someone editing your answer – ljrk Mar 13 '20 at 16:23
  • Oh okay sorry about that. – Prawky 77 Mar 13 '20 at 16:31
  • No problem! Most people get something wrong in their first questions :) – ljrk Mar 13 '20 at 16:39

0 Answers0