]> git.zerfleddert.de Git - record-dvb/blob - dump-stream.c
1cbaad260854656b6aedc32699b8d476e28e411a
[record-dvb] / dump-stream.c
1 #include <features.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <sys/time.h>
5 #include <time.h>
6 #include <sys/socket.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <fcntl.h>
10 #include <unistd.h>
11 #include <strings.h>
12
13 #include "mcast.h"
14
15 #define CHUNKSIZE 1500
16
17 int main(int argc, char **argv)
18 {
19 char *url;
20 int bytes, written, i;
21 int in;
22 char buffer[CHUNKSIZE];
23
24 if (argc == 2) {
25 url = argv[1];
26 } else {
27 fprintf(stderr,"Syntax: %s URL\n", argv[0]);
28 exit(EXIT_FAILURE);
29 }
30
31 if ((in = open_mcast(url)) < 0) {
32 fprintf(stderr,"Can't open url %s!\n",url);
33 exit(EXIT_FAILURE);
34 }
35
36 while(1) {
37 if ((bytes = recv(in, buffer, CHUNKSIZE, 0)) < 1) {
38 perror("recv");
39 exit(EXIT_FAILURE);
40 }
41
42 written = 0;
43 do {
44 if ((i = write(STDOUT_FILENO, buffer, bytes-written)) < 0) {
45 perror("write");
46 exit(EXIT_FAILURE);
47 }
48 written += i;
49 } while(written < bytes);
50 }
51
52 close(in);
53
54 return EXIT_SUCCESS;
55 }
Impressum, Datenschutz