I try to run a Linux command and read the output from it by using C/C++ code. I search for exec but this don't deal with input/output.
What I am trying to achieve is to get information about wireless LAN by using this command iwconfig
, invoking it from C/C++ code.
also i need a suitable code to use it as lib for android using NDK.
i see in android open source they called this function
what do you think about this code ?
int wpa_ctrl_request(struct wpa_ctrl *ctrl, const char *cmd, size_t cmd_len,
char *reply, size_t *reply_len,
void (*msg_cb)(char *msg, size_t len))
{
DWORD written;
DWORD readlen = *reply_len;
if (!WriteFile(ctrl->pipe, cmd, cmd_len, &written, NULL))
return -1;
if (!ReadFile(ctrl->pipe, reply, *reply_len, &readlen, NULL))
return -1;
*reply_len = readlen;
return 0;
}
this is the link