0799ec3c2b02a1df85b99f869d0d88d0cbe0845f
[senf.git] / Socket / Protocols / DVB / DVBFrontendHandle.cc
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief DVBFrontendHandle non-inline non-template implementation */
25
26 #include "DVBFrontendHandle.hh"
27 //#include "DVBFrontendHandle.ih"
28
29 // Custom includes
30 #include <sys/types.h>
31 #include <sys/socket.h>
32 #include <iostream>
33 #include <string>
34 #include <sys/ioctl.h>
35 #include <linux/sockios.h>
36 #include <stdio.h>
37 #include <fcntl.h>
38 #include "Socket/SocketHandle.hh"
39
40 #include "Utils/Exception.hh"
41
42 //#include "DVBFrontendHandle.mpp"
43 #define prefix_
44 ///////////////////////////////cc.p////////////////////////////////////////
45
46 ///////////////////////////////////////////////////////////////////////////
47 // senf::DVBFrontendHandle
48
49 prefix_ void senf::DVBFrontendProtocol::init_client()
50     const
51 {
52     int fd = open("/dev/dvb/adapter0/frontend0", O_RDONLY | O_NONBLOCK);
53     if (fd < 0)
54         throw SystemException(errno);
55     body().fd(fd);
56 }
57
58 prefix_ unsigned senf::DVBFrontendProtocol::available()
59     const
60 {
61     return 0;
62 }
63
64 prefix_ bool senf::DVBFrontendProtocol::eof()
65     const
66 {
67     return false;
68 }
69
70 prefix_ std::auto_ptr<senf::SocketProtocol> senf::DVBFrontendProtocol::clone()
71     const
72 {
73     return std::auto_ptr<SocketProtocol>(new DVBFrontendProtocol());
74 }
75
76
77 prefix_ void senf::DVBFrontendProtocol::signalStrength(int16_t *strength)
78     const
79 {
80     if (::ioctl(body().fd(), FE_READ_SIGNAL_STRENGTH, strength) < 0)
81         throw SystemException(errno);
82 }
83
84 ///////////////////////////////cc.e////////////////////////////////////////
85 #undef prefix_
86 //#include "DVBFrontendHandle.mpp"
87
88 \f
89 // Local Variables:
90 // mode: c++
91 // fill-column: 100
92 // c-file-style: "senf"
93 // indent-tabs-mode: nil
94 // ispell-local-dictionary: "american"
95 // compile-command: "scons -u test"
96 // comment-column: 40
97 // End: