| #include <fcntl.h> |
| #include <stdio.h> |
| #include <sys/stat.h> |
| #include <unistd.h> |
| |
| int main(int argc, char **argv) { |
| int outfd, infd, len, wrote; |
| char data[131072]; |
| |
| infd = open("out", O_RDONLY); |
| if (infd < 0) { |
| perror("open ./out"); |
| return 1; |
| } |
| |
| read(infd, &data, 131072); |
| |
| int offset = 0; |
| while (1) { |
| outfd = open("/tmp/Fifo_bdt_tiaudio", O_WRONLY); |
| if (outfd < 0) { |
| perror("open /tmp/Fifo_bdt_tiaudio"); |
| return 1; |
| } |
| |
| len = data[offset]; |
| printf("%d data bytes to write\n", len); |
| if (len == 0) { |
| return 0; |
| } |
| |
| wrote = write(outfd, &data[offset], len + 1); |
| offset += len + 1; |
| if (wrote != len + 1) { |
| printf("only wrote %d/%d bytes. skipping.\n", wrote, len + 1); |
| } |
| |
| close(outfd); |
| usleep(1000); |
| } |
| } |