Utils: Removed ErrnoException and implemented generic Exception base-class
[senf.git] / Socket / Protocols / DVB / DVBFrontendHandle.cc
index b56fb84..96ff4f2 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
 // Copyright (C) 2007
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Thorsten Horstmann <tho@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 /** \file
-    \brief xxx
- */
+    \brief DVBFrontendHandle non-inline non-template implementation */
 
 #include "DVBFrontendHandle.hh"
 //#include "DVBFrontendHandle.ih"
 
 // Custom includes
-#include <sys/types.h>
+#include <boost/format.hpp>
 #include <sys/socket.h>
-#include <iostream>
-#include <string>
 #include <sys/ioctl.h>
-#include <linux/sockios.h>
-#include <stdio.h>
 #include <fcntl.h>
-#include "Socket/SocketHandle.hh"
-
-#include "Utils/Exception.hh"
+#include "../../../Utils/Exception.hh"
 
 //#include "DVBFrontendHandle.mpp"
 #define prefix_
 ///////////////////////////////////////////////////////////////////////////
 // senf::DVBFrontendHandle
 
-prefix_ void senf::DVBFrontendProtocol::init_client()
+prefix_ void senf::DVBFrontendProtocol::init_client(uint8_t adapter, boost::uint8_t device)
     const
 {
-    int fd = open("/dev/dvb/adapter0/frontend0", O_RDONLY | O_NONBLOCK);
-    if (fd < 0)
-        throw SystemException(errno);
-    body().fd(fd);
+    std::string devFrontend = str( boost::format(
+            "/dev/dvb/adapter%d/frontend%d") % adapter % device);
+    int f = open(devFrontend.c_str(), O_RDONLY | O_NONBLOCK);
+    if (f < 0)
+        throw SystemException();
+    fd(f);
 }
 
 prefix_ unsigned senf::DVBFrontendProtocol::available()
@@ -68,18 +63,11 @@ prefix_ bool senf::DVBFrontendProtocol::eof()
     return false;
 }
 
-prefix_ std::auto_ptr<senf::SocketProtocol> senf::DVBFrontendProtocol::clone()
-    const
-{
-    return std::auto_ptr<SocketProtocol>(new DVBFrontendProtocol());
-}
-
-
 prefix_ void senf::DVBFrontendProtocol::signalStrength(int16_t *strength)
     const
 {
-    if (::ioctl(body().fd(), FE_READ_SIGNAL_STRENGTH, strength) < 0)
-        throw SystemException(errno);
+    if (::ioctl(fd(), FE_READ_SIGNAL_STRENGTH, strength) < 0)
+        throw SystemException();
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////