📄 warsvrproperties.cpp
字号:
#include "StdAfx.h"#include "WarSvrProperties.h" // class implemented#ifndef WAR_SVR_PROTOCOL_FTP_H# include "WarSvrProtocolFtp.h"#endif #ifndef WAR_UNICODE_H# include "WarUnicode.h"#endif#ifndef WAR_LOG_H# include "WarLog.h"#endif#ifndef WAR_ALOGRITH_INCLUDED# define WAR_ALOGRITH_INCLUDED# include <algorithm>#endifusing namespace std;/////////////////////////////// PUBLIC /////////////////////////////////////////============================= LIFECYCLE ====================================WarSvrProperties::WarSvrProperties(){}// WarSvrPropertiesWarSvrProperties::WarSvrProperties(const WarSvrProperties& from){ operator = (from);}// WarSvrPropertiesWarSvrProperties::~WarSvrProperties(){}// ~WarSvrProperties//============================= OPERATORS ====================================WarSvrProperties& WarSvrProperties::operator=(const WarSvrProperties& from){ mPaths = from.mPaths; mOptions = from.mOptions; mIpAccessList = from.mIpAccessList; return *this;}WarSvrProperties& WarSvrProperties::operator += (const WarSvrProperties& from){ { for(path_set_t::const_iterator P = from.mPaths.begin() ; P != from.mPaths.end() ; P++) { mPaths.insert((*P)); } } { for(WarOptionList::const_iterator P = from.mOptions.begin() ; P != from.mOptions.end() ; P++) { mOptions.insert((*P)); } } if ((mIpAccessList.mMode == from.mIpAccessList.mMode) || (mIpAccessList.mIpList.empty() && !from.mIpAccessList.mIpList.empty())) { mIpAccessList.mMode = from.mIpAccessList.mMode; for(war_ip_mask_set_t::const_iterator P = from.mIpAccessList.mIpList.begin() ; P != from.mIpAccessList.mIpList.end() ; ++P) { mIpAccessList.mIpList.insert(*P); } } else if (!mIpAccessList.mIpList.empty() && !from.mIpAccessList.mIpList.empty()) { WarLog warn_log(WARLOG_WARNINGS, "WarSvrProperties::operator += (const WarSvrProperties&)"); warn_log << "Can not add new IP access-list definitions " "because the current mode differs from the " "mode of the new entries!" << war_endl; } return *this;}//============================= OPERATIONS ===================================//============================= ACCESS ===================================//============================= INQUIRY ===================================WarSvrPath WarSvrProperties::ResolvPath(const WarSvrPath::path_t srchPath) const throw(WarException){ // Do a search for an exact match. Saves time if it exist. path_set_t::const_iterator P = mPaths.find(WarSvrPath(srchPath)); if (P != mPaths.end()) return *P; // Search trough all paths. Keep the longest path with recursive // permissions found. path_set_t::const_iterator best_match = mPaths.end(); for(P = mPaths.begin() ; P != mPaths.end() ; P++) { if (P->IsInPath(srchPath) || P->GetAlias().IsRoot()) { if (P->GetPerms() & RECURSIVE) best_match = P; } } if (best_match == mPaths.end()) { // Will never happen if the system is properly // configured with a root directory! WarLog err_log(WARLOG_ERROR, "WarSvrProperties::ResolvPath()"); err_log << "Configuration error: There is no valid root-path defined." << war_endl; WarThrow(WarError(WAR_ERR_OBJECT_NOT_FOUND), NULL); } war_svrpath_t my_pad; war_svrpath_ccstr_t p = srchPath.GetPath() + best_match->GetAlias().GetLength(); while (*p && my_pad.IsSlash(*p)) ++p; my_pad = p; WarSvrPath return_path = *best_match; return_path << WAR_SLASH << my_pad; return return_path;}/////////////////////////////// PROTECTED ////////////////////////////////////////////////////////////////// PRIVATE ///////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -