NEW FILE HEADER / COPYRIGHT FORMAT
[senf.git] / Socket / FileHandle.cc
index 4865ae6..97e554c 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
-// Copyright (C) 2006 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Copyright (C) 2006
+// Fraunhofer Institute for Open Communication Systems (FOKUS) 
+// Competence Center NETwork research (NET), St. Augustin, GERMANY 
+//     Stefan Bund <g0dil@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
@@ -20,7 +20,9 @@
 // Free Software Foundation, Inc.,
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-// Definition of non-inline non-template functions
+/** \file
+    \brief FileHandle non-inline non-template implementation
+ */
 
 #include "FileHandle.hh"
 //#include "FileHandle.ih"
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>
-#include "Utils/Exception.hh"
+#include "../Utils/Exception.hh"
 
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
 
-prefix_ void satcom::lib::FileBody::v_close()
+prefix_ void senf::FileBody::v_close()
 {
     if (::close(fd_) != 0)
-        throw SystemException(errno);
+        throwErrno();
 }
 
-prefix_ void satcom::lib::FileBody::v_terminate()
+prefix_ void senf::FileBody::v_terminate()
 {
     ::close(fd_);
 }
 
-prefix_ bool satcom::lib::FileBody::v_eof()
+prefix_ bool senf::FileBody::v_eof()
     const
 {
     return false;
 }
 
-prefix_ bool satcom::lib::FileBody::v_valid()
+prefix_ bool senf::FileBody::v_valid()
     const
 {
     return true;
 }
 
-prefix_ bool satcom::lib::FileBody::blocking()
+prefix_ bool senf::FileBody::blocking()
     const
 {
     int flags = ::fcntl(fd(),F_GETFL);
-    if (flags < 0) throw SystemException(errno);
+    if (flags < 0) throwErrno();
     return ! (flags & O_NONBLOCK);
 }
 
-prefix_ void satcom::lib::FileBody::blocking(bool status)
+prefix_ void senf::FileBody::blocking(bool status)
 {
     int flags = ::fcntl(fd(),F_GETFL);
-    if (flags < 0) throw SystemException(errno);
+    if (flags < 0) throwErrno();
     if (status) flags &= ~O_NONBLOCK;
     else        flags |= O_NONBLOCK;
-    if (::fcntl(fd(), F_SETFL, flags) < 0) throw SystemException(errno);
+    if (::fcntl(fd(), F_SETFL, flags) < 0) throwErrno();
 }
 
-prefix_ bool satcom::lib::FileBody::pollCheck(int fd, bool incoming, bool block)
+/* We don't take POLLIN/POLLOUT as argument to avoid having to include
+   sys/poll.h in the .cci file (and therefore indirectly into the .hh
+   and then every file which uses FileHandle) */
+prefix_ bool senf::FileBody::pollCheck(int fd, bool incoming, bool block)
     const
 {
     struct ::pollfd pfd;
@@ -91,7 +96,7 @@ prefix_ bool satcom::lib::FileBody::pollCheck(int fd, bool incoming, bool block)
             case EINTR:
                 break;
             default:
-                throw SystemException(errno);
+                throwErrno();
             }
     } while (rv<0);
     return rv>0;
@@ -103,5 +108,10 @@ prefix_ bool satcom::lib::FileBody::pollCheck(int fd, bool incoming, bool block)
 \f
 // Local Variables:
 // mode: c++
-// c-file-style: "satcom"
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
 // End: