osdep.h File Reference


Detailed Description

Various os/compiler specific stuff.

Definition in file osdep.h.

#include <boost/format.hpp>
#include <stdint.h>

Include dependency graph for osdep.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


Defines

#define EXPORT
#define IMPORT
#define DLLEXPORT
#define DLLIMPORT
#define O_BINARY   0
#define __PRETTY_FUNCTION__   __FUNCTION__
#define CHECK(Cond)
 Debugging macro which logs an error if condition fails.
#define CHECK_MSG(Cond, Message)
 Debugging macro which logs an error and message if condition fails.
#define CHECK_FAIL(Cond)
 Aborts the application with message if condition fails.
#define CHECK_THROW_MSG(Cond, Message)
 Throws std::runtime_error if condition is true This is our replacement for assert() for situations where assert() is not appropriate.
#define CHECK_THROW(Cond)
#define CHECK_RET(Cond)
 Checks condition and logs and error + returns from function if it fails.
#define CHECK_RETVAL(Cond, RetVal)
#define COL_NONE
 Ansi color codes.
#define COL_BLACK
#define COL_RED
#define COL_BRED
#define COL_GREEN
#define COL_BGREEN
#define COL_YELLOW
#define COL_BYELLOW
#define COL_BLUE
#define COL_BBLUE
#define COL_MAGENTA
#define COL_BMAGENTA
#define COL_CYAN
#define COL_BCYAN
#define COL_WHITE
#define COL_BWHITE
#define GCC_ONLY(x)
 Compile code only when compiling with GNU GCC.
#define MSVC_ONLY(x)
 Compile code only when compiling with Microsoft Visual C++.

Enumerations

enum  VersionInfo { APPVER_MAJOR = 0, APPVER_MINOR = 1, APPVER_PATCH = 0 }
 Client version information. More...

Define Documentation

#define __PRETTY_FUNCTION__   __FUNCTION__
 

Definition at line 105 of file osdep.h.

#define CHECK Cond   ) 
 

Value:

if (!(Cond)) {                                                    \
                logError(                                                 \
                        boost::format("%1%:%2%: Check `%3%' failed.")     \
                        % __FILE__ % __LINE__ % #Cond                     \
                );                                                        \
        }
Debugging macro which logs an error if condition fails.

Definition at line 110 of file osdep.h.

Referenced by clearAndNotify(), Md4Transform::getHash(), Log::getLast(), ModManager::load(), UDPSocket::recv(), Md4Transform::sumUp(), and Md4Transform::~Md4Transform().

#define CHECK_FAIL Cond   ) 
 

Value:

if (!(Cond)) {                                                    \
                logFatalError(                                            \
                        boost::format("\n"                                \
                                "where(): %1%:%2%\n"                      \
                                "what():  Check `%3%' failed."            \
                        )                                                 \
                        % __FILE__ % __LINE__ % #Cond                     \
                );                                                        \
        }
Aborts the application with message if condition fails.

Definition at line 144 of file osdep.h.

Referenced by Scheduler< Impl, ImplPtr >::accept(), Scheduler< Impl, ImplPtr >::AcceptReq::AcceptReq(), Scheduler< Impl, ImplPtr >::connect(), Scheduler< Impl, ImplPtr >::ConnReq::ConnReq(), Scheduler< Impl, ImplPtr >::delSocket(), Scheduler< Impl, ImplPtr >::disconnect(), Scheduler< Impl, ImplPtr >::DownloadReq::DownloadReq(), Scheduler< Impl, ImplPtr >::getData(), SchedEventHandler::ClientEventHandler< Source, Scheduler >::handleConnected(), SchedEventHandler::ClientEventHandler< Source, Scheduler >::handleErr(), SchedEventHandler::ClientEventHandler< Source, Scheduler >::handleRead(), SchedEventHandler::ClientEventHandler< Source, Scheduler >::handleWrite(), SchedEventHandler::ServerEventHandler< Source, Scheduler >::onEvent(), Scheduler< Impl, ImplPtr >::read(), Scheduler< Impl, ImplPtr >::UploadReq::UploadReq(), and Scheduler< Impl, ImplPtr >::write().

#define CHECK_MSG Cond,
Message   ) 
 

Value:

if (!(Cond)) {                                                    \
                logError(                                                 \
                        boost::format("%1%:%2%: Check `%3%' failed: %4%") \
                        % __FILE__ % __LINE__ % #Cond % Message           \
                );                                                        \
        }
Debugging macro which logs an error and message if condition fails.

Definition at line 118 of file osdep.h.

#define CHECK_RET Cond   ) 
 

Value:

if (!(Cond)) {                                                   \
                logError(                                                \
                        boost::format("%1%:%2%: Check `%3%' failed")     \
                        % __FILE__ % __LINE__ % #Cond                    \
                );                                                       \
                return;                                                  \
        }
Checks condition and logs and error + returns from function if it fails.

Second version of this macro returns a specific value from the function (for usage in functions that need to return a value)

Definition at line 179 of file osdep.h.

Referenced by FilesList::addTempDir(), FilesList::remSharedDir(), and FilesList::remTempDir().

#define CHECK_RETVAL Cond,
RetVal   ) 
 

Value:

if (!(Cond)) {                                                   \
                logError(                                                \
                        boost::format("%1%:%2%: Check `%3%' failed")     \
                        % __FILE__ % __LINE__ % #Cond                    \
                );                                                       \
                return (RetVal);                                         \
        }

Definition at line 187 of file osdep.h.

#define CHECK_THROW Cond   ) 
 

Value:

if (!(Cond)) {                                                   \
                throw std::runtime_error(                                \
                        (boost::format("%1%:%2%: Check `%3%' failed")    \
                        % __FILE__ % __LINE__ % #Cond).str()             \
                );                                                       \
        }

Definition at line 167 of file osdep.h.

Referenced by Scheduler< Impl, ImplPtr >::accept(), PartData::addHashSet(), FilesList::addSharedDir(), PartData::addSourceMask(), RangeList< Range32 >::back(), Range< uint64_t >::begin(), SharedFile::checkFileSize(), Utils::decode(), PartData::delFullSource(), PartData::delSourceMask(), SocketWatcher::doAddSocket(), PartData::doComplete(), SocketWatcher::doRemoveSocket(), PartData::doWrite(), Utils::encode(), Range< uint64_t >::end(), HashWork::finish(), PartData::flushBuffer(), RangeList< Range32 >::front(), MD4HashMaker::getHashSet(), SHA1HashMaker::getHashSet(), MD5HashMaker::getHashSet(), BTHashMaker::getHashSet(), ED2KHashMaker::getHashSet(), ModManager::getList(), PartData::getLock(), PartData::getPartStatus(), HashWork::getType(), HashWork::HashWork(), ModManager::initialize(), HashWork::initState(), SharedFile::isDuplicate(), MetaDb::load(), Config::load(), Detail::LockedRange::LockedRange(), SSocket< Module, Type, Protocol >::onEvent(), SharedFile::onHashEvent(), PartData::onHashEvent(), MetaDb::onMetaDataEvent(), SharedFile::onPartEvent(), operator<<(), PartData::PartData(), HashWork::process(), MetaDb::push(), FilesList::push(), Utils::putVal(), Range< uint64_t >::Range(), RangeList< Range32 >::RangeList(), SharedFile::read(), Config::read(), PartData::save(), Config::save(), SharedFile::setMetaData(), PartData::setMetaData(), SharedFile::setPartData(), Config::setPath(), SharedFile::SharedFile(), BTHashMaker::sumUp(), ED2KHashMaker::sumUp(), MetaDb::tryAddFileName(), MetaDb::tryAddHashSet(), Detail::UsedRange::UsedRange(), PartData::verifyHashSet(), PartData::write(), and Config::write().

#define CHECK_THROW_MSG Cond,
Message   ) 
 

Value:

if (!(Cond)) {                                                   \
                throw std::runtime_error(                                \
                        (boost::format("%1%:%2%: %3%")                   \
                        % __FILE__ % __LINE__ % (Message)).str()         \
                );                                                       \
        }
Throws std::runtime_error if condition is true This is our replacement for assert() for situations where assert() is not appropriate.

Definition at line 159 of file osdep.h.

Referenced by UDPSocket::listen(), UDPSocket::recv(), and UDPSocket::send().

#define COL_BBLUE
 

Definition at line 235 of file osdep.h.

Referenced by SharedFile::onMoveEvent().

#define COL_BCYAN
 

Definition at line 239 of file osdep.h.

#define COL_BGREEN
 

Definition at line 231 of file osdep.h.

#define COL_BLACK
 

Definition at line 227 of file osdep.h.

#define COL_BLUE
 

Definition at line 234 of file osdep.h.

#define COL_BMAGENTA
 

Definition at line 237 of file osdep.h.

#define COL_BRED
 

Definition at line 229 of file osdep.h.

#define COL_BWHITE
 

Definition at line 241 of file osdep.h.

#define COL_BYELLOW
 

Definition at line 233 of file osdep.h.

Referenced by SharedFile::onMoveEvent().

#define COL_CYAN
 

Definition at line 238 of file osdep.h.

Referenced by SchedBase::handleEvents().

#define COL_GREEN
 

Definition at line 230 of file osdep.h.

Referenced by SchedBase::handleEvents(), and PartData::printCompleted().

#define COL_MAGENTA
 

Definition at line 236 of file osdep.h.

#define COL_NONE
 

Ansi color codes.

These can be used to colourize text output to terminal or socket. However, since not all platforms, shells and so on support these, they are currently disabled when NDEBUG is defined. In the future, the check's whether to enable colors or not should be done on runtime (perhaps using a commandline argument?).

Definition at line 226 of file osdep.h.

Referenced by SchedBase::handleEvents(), logError(), logWarning(), SharedFile::onMoveEvent(), and PartData::printCompleted().

#define COL_RED
 

Definition at line 228 of file osdep.h.

Referenced by logError().

#define COL_WHITE
 

Definition at line 240 of file osdep.h.

#define COL_YELLOW
 

Definition at line 232 of file osdep.h.

Referenced by SchedBase::handleEvents(), and logWarning().

#define DLLEXPORT
 

Definition at line 59 of file osdep.h.

#define DLLIMPORT
 

Definition at line 60 of file osdep.h.

#define EXPORT
 

Definition at line 57 of file osdep.h.

#define GCC_ONLY  ) 
 

Compile code only when compiling with GNU GCC.

Definition at line 248 of file osdep.h.

#define IMPORT
 

Definition at line 58 of file osdep.h.

#define MSVC_ONLY  ) 
 

Compile code only when compiling with Microsoft Visual C++.

Definition at line 255 of file osdep.h.

#define O_BINARY   0
 

Definition at line 101 of file osdep.h.

Referenced by PartData::flushBuffer(), HashWork::initState(), and SharedFile::read().


Enumeration Type Documentation

enum VersionInfo
 

Client version information.

Enumeration values:
APPVER_MAJOR 
APPVER_MINOR 
APPVER_PATCH 

Definition at line 39 of file osdep.h.