Socket/Protocols: Add SO_ERROR getsockopt (BSDSocketProtocol::error())
[senf.git] / Socket / Protocols / DVB / DVBFrontendHandle.cc
index a90eca4..db5be7e 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
 // Copyright (C) 2007
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Thorsten Horstmann <thorsten.horstmann@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
 ///////////////////////////////////////////////////////////////////////////
 // senf::DVBFrontendHandle
 
-prefix_ void senf::DVBFrontendProtocol::init_client(uint8_t adapter, boost::uint8_t device)
+prefix_ void senf::DVBFrontendSocketProtocol::init_client(uint8_t adapter, boost::uint8_t device)
     const
 {
     std::string devFrontend = str( boost::format(
             "/dev/dvb/adapter%d/frontend%d") % adapter % device);
-    int fd = open(devFrontend.c_str(), O_RDONLY | O_NONBLOCK);
-    if (fd < 0)
-        throw SystemException(errno);
-    body().fd(fd);
+    int f = open(devFrontend.c_str(), O_RDONLY | O_NONBLOCK);
+    if (f < 0)
+        SENF_THROW_SYSTEM_EXCEPTION("") << "Could not open frontend device of DVB adapter " << devFrontend << ".";
+    
+    fd(f);
 }
 
-prefix_ unsigned senf::DVBFrontendProtocol::available()
+prefix_ unsigned senf::DVBFrontendSocketProtocol::available()
     const
 {
     return 0;
 }
 
-prefix_ bool senf::DVBFrontendProtocol::eof()
+prefix_ bool senf::DVBFrontendSocketProtocol::eof()
     const
 {
     return false;
 }
 
-prefix_ std::auto_ptr<senf::SocketProtocol> senf::DVBFrontendProtocol::clone()
+prefix_ void senf::DVBFrontendSocketProtocol::signalStrength(int16_t *strength)
     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)
+        SENF_THROW_SYSTEM_EXCEPTION("Could not get signal strength of DVB adapter.");
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////