stdin goes to the client, stdout goes to lightningd */
| 314 | |
| 315 | /* stdin goes to the client, stdout goes to lightningd */ |
| 316 | int main(int argc, char *argv[]) |
| 317 | { |
| 318 | struct pollfd pfds[2]; |
| 319 | |
| 320 | common_setup(argv[0]); |
| 321 | |
| 322 | if (argc != 1) |
| 323 | errx(1, "Usage: %s", argv[0]); |
| 324 | |
| 325 | /* Do HTTP-style negotiation to get into websocket frames. */ |
| 326 | io_fd_block(STDIN_FILENO, true); |
| 327 | http_upgrade(STDIN_FILENO); |
| 328 | |
| 329 | pfds[0].fd = STDIN_FILENO; |
| 330 | pfds[0].events = POLLIN; |
| 331 | pfds[1].fd = STDOUT_FILENO; |
| 332 | pfds[1].events = POLLIN; |
| 333 | |
| 334 | for (;;) { |
| 335 | poll(pfds, 2, -1); |
| 336 | |
| 337 | if (pfds[1].revents & POLLIN) |
| 338 | lightningd_to_websocket(STDOUT_FILENO, STDIN_FILENO); |
| 339 | if (pfds[0].revents & POLLIN) |
| 340 | websocket_to_lightningd(STDIN_FILENO, STDOUT_FILENO); |
| 341 | } |
| 342 | |
| 343 | common_shutdown(); |
| 344 | exit(0); |
| 345 | } |
nothing calls this directly
no test coverage detected