00001 #ifndef _STR_FDUtil_H_ // -*-c++-*- 00002 00003 /* 00004 * Copyright (C) 1991-9 Eric M. Hopper <hopper@omnifarious.mn.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published 00008 * by the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 #ifdef __GNUG__ 00022 # pragma interface 00023 #endif 00024 00025 /* $Header: /home/hopper/src/cvs/C++/StrMod/StrMod/FDUtil.h,v 1.4 2002/04/01 13:39:48 hopper Exp $ */ 00026 00027 // For a log, see ../ChangeLog 00028 00029 // $Revision: 1.4 $ 00030 00031 #define _STR_FDUtil_H_ 00032 00033 namespace strmod { 00034 namespace strmod { 00035 00036 /** \class FDUtil FDUtil.h StrMod/FDUtil.h 00037 * \brief A class utility library for file descriptor operations. 00038 * 00039 * This should probably be changed to a namespace. It, perhaps, shouldn't exist 00040 * at all. :-) 00041 */ 00042 class FDUtil { 00043 public: 00044 /** Set a file descriptor to POSIX non-blocking. 00045 * This will turn off \c O_NDELAY and turn on \c O_NONBLOCK. 00046 * 00047 * Returns true on success, false on failure. If there's a failure, myerrno 00048 * will be set to the errno result that precipitated the failure, otherwise, 00049 * it will not be touched. 00050 * 00051 * @param fd The file descriptor to set to non-blocking. 00052 * @param myerrno An OUT parameter, will be set to errno if there's an error. 00053 */ 00054 static bool setNonBlock(int fd, int &myerrno); 00055 00056 /** Set a file descriptor to blocking. 00057 * Removes \c O_NDELAY and \c O_NONBLOCK. 00058 * 00059 * Returns true on success, false on failure. If there's a failure, myerrno 00060 * will be set to the errno result that precipitated the failure, otherwise, 00061 * it will not be touched. 00062 * 00063 * @param fd The file descriptor to set to non-blocking. 00064 * @param myerrno An OUT parameter, will be set to errno if there's an error. 00065 */ 00066 static bool setBlock(int fd, int &myerrno); 00067 }; 00068 00069 }; // namespace strmod 00070 }; // namespace strmod 00071 00072 #endif
1.3-rc1