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