Line 1... |
Line 1... |
// $Id: RlinkPort.cpp 375 2011-04-02 07:56:47Z mueller $
|
// $Id: RlinkPort.cpp 466 2012-12-30 13:26:55Z mueller $
|
//
|
//
|
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
//
|
//
|
// This program is free software; you may redistribute and/or modify it under
|
// This program is free software; you may redistribute and/or modify it under
|
// the terms of the GNU General Public License as published by the Free
|
// the terms of the GNU General Public License as published by the Free
|
Line 11... |
Line 11... |
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for complete details.
|
// for complete details.
|
//
|
//
|
// Revision History:
|
// Revision History:
|
// Date Rev Version Comment
|
// Date Rev Version Comment
|
|
// 2012-12-28 466 1.0.2 allow Close() even when not open
|
|
// 2012-12-26 465 1.0.1 add CloseFd() method
|
// 2011-03-27 375 1.0 Initial version
|
// 2011-03-27 375 1.0 Initial version
|
// 2011-01-15 356 0.1 First draft
|
// 2011-01-15 356 0.1 First draft
|
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
|
|
/*!
|
/*!
|
\file
|
\file
|
\version $Id: RlinkPort.cpp 375 2011-04-02 07:56:47Z mueller $
|
\version $Id: RlinkPort.cpp 466 2012-12-30 13:26:55Z mueller $
|
\brief Implemenation of RlinkPort.
|
\brief Implemenation of RlinkPort.
|
*/
|
*/
|
|
|
#include <errno.h>
|
#include <errno.h>
|
#include <unistd.h>
|
#include <unistd.h>
|
Line 76... |
Line 78... |
//------------------------------------------+-----------------------------------
|
//------------------------------------------+-----------------------------------
|
//! FIXME_docs
|
//! FIXME_docs
|
|
|
void RlinkPort::Close()
|
void RlinkPort::Close()
|
{
|
{
|
if (! IsOpen())
|
if (!IsOpen()) return;
|
throw logic_error("RlinkPort::Close(): port not open");
|
|
|
|
close(fFdRead);
|
if (fFdWrite == fFdRead) fFdWrite = -1;
|
if (fFdWrite != fFdRead) close(fFdWrite);
|
CloseFd(fFdWrite);
|
|
CloseFd(fFdRead);
|
|
|
fFdRead = -1;
|
|
fFdWrite = -1;
|
|
fIsOpen = false;
|
fIsOpen = false;
|
fUrl.clear();
|
fUrl.clear();
|
fScheme.clear();
|
fScheme.clear();
|
fPath.clear();
|
fPath.clear();
|
fOptMap.clear();
|
fOptMap.clear();
|
Line 336... |
Line 336... |
}
|
}
|
}
|
}
|
|
|
return true;
|
return true;
|
}
|
}
|
|
//
|
//------------------------------------------+-----------------------------------
|
//------------------------------------------+-----------------------------------
|
//! FIXME_docs
|
//! FIXME_docs
|
|
|
bool RlinkPort::AddOpt(const std::string& key, const std::string& val,
|
bool RlinkPort::AddOpt(const std::string& key, const std::string& val,
|
bool hasval, const std::string& optlist, RerrMsg& emsg)
|
bool hasval, const std::string& optlist, RerrMsg& emsg)
|
Line 357... |
Line 357... |
fOptMap.insert(omap_val_t(key, hasval ? val : "1"));
|
fOptMap.insert(omap_val_t(key, hasval ? val : "1"));
|
return true;
|
return true;
|
}
|
}
|
|
|
//------------------------------------------+-----------------------------------
|
//------------------------------------------+-----------------------------------
|
|
//! FIXME_docs
|
|
|
|
void RlinkPort::CloseFd(int& fd)
|
|
{
|
|
if (fd >= 0) {
|
|
close(fd);
|
|
fd = -1;
|
|
}
|
|
return;
|
|
}
|
|
|
|
//------------------------------------------+-----------------------------------
|
#if (defined(Retro_NoInline) || defined(Retro_RlinkPort_NoInline))
|
#if (defined(Retro_NoInline) || defined(Retro_RlinkPort_NoInline))
|
#define inline
|
#define inline
|
#include "RlinkPort.ipp"
|
#include "RlinkPort.ipp"
|
#undef inline
|
#undef inline
|
#endif
|
#endif
|