imcplugin demo: Extend to support stat() call
[nativeclient.git] / imcplugin / tests / imc-read.c
blob3e5378f81a45e28efa9327cde0ab7f694de78df7
2 #include <stdio.h>
4 #include <sys/nacl_imc_api.h>
5 #include <sys/nacl_syscalls.h>
8 int read_message(int desc)
10 char buf[2000];
11 int fds[8];
12 struct NaClImcMsgIoVec iov;
13 struct NaClImcMsgHdr msg;
14 iov.base = buf;
15 iov.length = sizeof(buf);
16 msg.iov = &iov;
17 msg.iov_length = 1;
18 msg.descv = fds;
19 msg.desc_length = 8;
21 int result = imc_recvmsg(desc, &msg, 0);
22 if(result <= 0) {
23 printf("failed, result=%i\n", result);
24 return 0;
26 else {
27 int i;
28 printf("NaCl got message: ");
29 for(i = 0; i < result; i++)
30 printf("%c", buf[i]);
31 printf("NaCl received %i FDs\n", msg.desc_length);
32 return 1;
36 int main(int argc, char* argv[])
38 while(read_message(3))
40 return 0;