Line | |
---|
1 | #ifndef CIDEV_H |
---|
2 | #define CIDEV_H |
---|
3 | |
---|
4 | struct dvbdev* ciopen(struct dvbdev* node) |
---|
5 | { |
---|
6 | debug(1000, "in"); |
---|
7 | int fd = -1; |
---|
8 | |
---|
9 | if(node != NULL) |
---|
10 | { |
---|
11 | if((fd = open(node->dev, O_RDWR | O_NONBLOCK)) < 0) |
---|
12 | { |
---|
13 | debug(200, "open ci failed %s", node->dev); |
---|
14 | node = NULL; |
---|
15 | } |
---|
16 | else |
---|
17 | { |
---|
18 | node->fd = fd; |
---|
19 | closeonexec(fd); |
---|
20 | } |
---|
21 | } |
---|
22 | |
---|
23 | debug(1000, "out"); |
---|
24 | return node; |
---|
25 | } |
---|
26 | |
---|
27 | int ciopendirect(char *cidev) |
---|
28 | { |
---|
29 | debug(1000, "in"); |
---|
30 | int fd = -1; |
---|
31 | |
---|
32 | if((fd = open(cidev, O_RDWR | O_NONBLOCK)) < 0) |
---|
33 | { |
---|
34 | debug(200, "open ci failed %s", cidev); |
---|
35 | } |
---|
36 | |
---|
37 | closeonexec(fd); |
---|
38 | debug(1000, "out"); |
---|
39 | return fd; |
---|
40 | } |
---|
41 | |
---|
42 | void ciclose(struct dvbdev* node, int fd) |
---|
43 | { |
---|
44 | if(node != NULL) |
---|
45 | { |
---|
46 | close(node->fd); |
---|
47 | node->fd = -1; |
---|
48 | } |
---|
49 | else |
---|
50 | close(fd); |
---|
51 | } |
---|
52 | |
---|
53 | int cigetdev() |
---|
54 | { |
---|
55 | debug(1000, "in"); |
---|
56 | int i, y, fd = -1, count = 0; |
---|
57 | char *buf = NULL, *cidev = NULL; |
---|
58 | |
---|
59 | cidev = getconfig("cidev", NULL); |
---|
60 | if(cidev == NULL) |
---|
61 | { |
---|
62 | debug(1000, "out -> NULL detect"); |
---|
63 | return count; |
---|
64 | } |
---|
65 | |
---|
66 | buf = malloc(MINMALLOC); |
---|
67 | if(buf == NULL) |
---|
68 | { |
---|
69 | err("no memory"); |
---|
70 | return count; |
---|
71 | } |
---|
72 | |
---|
73 | for(i = 0; i < MAXDVBADAPTER; i++) |
---|
74 | { |
---|
75 | for(y = 0; y < MAXCIDEV; y++) |
---|
76 | { |
---|
77 | sprintf(buf, cidev, i, y); |
---|
78 | fd = ciopendirect(buf); |
---|
79 | if(fd >= 0) |
---|
80 | { |
---|
81 | count++; |
---|
82 | adddvbdev(buf, i, y, fd, CIDEV, NULL, NULL); |
---|
83 | } |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | free(buf); |
---|
88 | debug(1000, "out"); |
---|
89 | return count; |
---|
90 | } |
---|
91 | |
---|
92 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.