Пример #1
0
		void import(const base_url &n) {

			if (protocol.empty() && !n.protocol.empty())
				protocol = n.protocol;
			if (host.empty() && !n.host.empty())
				host = n.host;
			if (port == 0 && n.port != 0)
				port = n.port;
			if (path.empty() && !n.path.empty())
				path = n.path;
			if (query.empty() && !n.query.empty())
				query = n.query;
		}
Пример #2
0
 static bool equals(const string_type& str1, const string_type& str2) {
     if(str1.size() != str2.size()) {
         return false;
     } else if(str1.empty() && str2.empty()) {
         return true;
     } else {
         return std::equal(
             str1.begin(),
             str1.end(),
             str2.begin()
         );
     }
     
 }
Пример #3
0
BOOST_LOG_EXPORT void basic_event_log_backend< CharT >::construct(
    boost::log::aux::universal_path const& message_file_name,
    string_type const& target,
    string_type const& log_name,
    string_type const& source_name,
    event_log::registration_mode reg_mode)
{
    if (reg_mode != event_log::never)
    {
        aux::registry_params< char_type > reg_params;
        string_type file_name;
        log::aux::code_convert(message_file_name.string(), file_name);
        reg_params.event_message_file = file_name;
        reg_params.types_supported = DWORD(
            EVENTLOG_SUCCESS |
            EVENTLOG_INFORMATION_TYPE |
            EVENTLOG_WARNING_TYPE |
            EVENTLOG_ERROR_TYPE);
        aux::init_event_log_registry(log_name, source_name, reg_mode == event_log::forced, reg_params);
    }

    std::auto_ptr< implementation > p(new implementation());

    const char_type* target_unc = NULL;
    if (!target.empty())
        target_unc = target.c_str();

    HANDLE hSource = register_event_source(target_unc, source_name.c_str());
    if (!hSource)
        BOOST_LOG_THROW_DESCR(system_error, "Could not register event source");

    p->m_SourceHandle = hSource;

    m_pImpl = p.release();
}
Пример #4
0
 void operator()(const Char* data)
 {
     if (exe.empty())
         exe = data;
     else
         args.push_back(data);
 }
Пример #5
0
 void operator()(const string_type & data)
 {
     if (exe.empty())
         exe = data;
     else
         args.push_back(data);
 }
Пример #6
0
 void operator()(const boost::filesystem::path & data)
 {
     not_cmd = true;
     if (exe.empty())
         exe = data.native();
     else
         args.push_back(data.native());
 }
Пример #7
0
 void get_name_(FwdIter &begin, FwdIter end, string_type &name)
 {
     this->eat_ws_(begin, end);
     for(name.clear(); begin != end && this->is_alnum_(*begin); ++begin)
     {
         name.push_back(*begin);
     }
     this->eat_ws_(begin, end);
     detail::ensure(!name.empty(), regex_constants::error_paren, "incomplete extension");
 }
Пример #8
0
 void comment(const string_type& s) {
   adaptor_statistics.comment(s);
   if (s.empty())
     out << "c";
   else
     if (boost::algorithm::is_space()(s[0]))
       out << "c" << s;
     else
       out << "c " << s;
   out << "\n";
 }
Пример #9
0
 void start(basic_session<T>& sesh, string_type const& ssid = "")
 {
   if (!sesh.loaded() && sesh.id().empty())
   {
     if (!ssid.empty()) {
       sesh.id(ssid);
       load(sesh);
     } else {
       sesh.id(make_session_id());
       sesh.loaded(true);
     }
   }  
 }
Пример #10
0
    void operator()(std::vector<string_type> && data)
    {
        if (data.empty())
            return;

        auto itr = std::make_move_iterator(data.begin());
        auto end = std::make_move_iterator(data.end());

        if (exe.empty())
        {
            exe = *itr;
            itr++;
        }
        args.insert(args.end(), itr, end);
    }
Пример #11
0
    void operator()(const std::vector<string_type> & data)
    {
        if (data.empty())
            return;

        auto itr = data.begin();
        auto end = data.end();

        if (exe.empty())
        {
            exe = *itr;
            itr++;
        }
        args.insert(args.end(), itr, end);
    }
Пример #12
0
// Close tag (may be with closing all of its children)
void XmlStream::endTag(const string_type& tag)
{
	bool	brk = false;

	while (tags.size() > 0 && !brk) {
		if (stateNone == state) {
			startTagging();
			s << "</" << tags.top() << '>';
			endTagging();
		}
		else {
			closeTagStart(true);
			state = stateNone;
		}
		brk = tag.empty() || tag == tags.top();
		tags.pop();
	}
}
Пример #13
0
				void raw_request( const string_type& method, const string_type& name, const string_type& ext, const string_type& body, Handler& handler )
				{
					if ( !body.empty() ) {
						//内容を分解する
						const param_type param = parse_parameter_helper( body );

//						if ( !param.empty() ) {
							//
							raw_request( method, name, ext, param, handler );
//						} else {
//							//
//							boost::bind( handler, _1, _2 )( "", error::value( error::critical, "bad parameter." ) );
//						}
					} else {
						//
						return raw_request( method, name, ext, param_type(), handler );
					}
				}
Пример #14
0
            void extract( string_type const & data, string_type & name, string_type & value, basic_cookie<Tag> & c )
            {
                std::size_t pos = data.find( string_traits_type::convert('=') );
                name = data.substr( 0,pos );
                if ( pos != string_type::npos )
                {
                    value = data.substr( pos+1 );
                }

                if ( !value.empty() )
                {
                    if ( *value.begin() == '"' && *value.rbegin() != '"' )
                    {
                        value = name + string_traits_type::convert("=") + value;
                        return;
                    }
                    boost::trim_if( value, boost::is_any_of( string_traits_type::convert("\"") ) );
                }
                set_value( name, value, c );
                name.clear();
                value.clear();
            }
Пример #15
0
		inline std::string get_host(std::string default_host = "127.0.0.1") const {
			if (!host.empty())
				return utf8::cvt<std::string>(host);
			return default_host;
		}
Пример #16
0
//Based on the example at https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx.
Process::id_type Process::open(const string_type &command, const string_type &path) {
  if(open_stdin)
    stdin_fd=std::unique_ptr<fd_type>(new fd_type(NULL));
  if(read_stdout)
    stdout_fd=std::unique_ptr<fd_type>(new fd_type(NULL));
  if(read_stderr)
    stderr_fd=std::unique_ptr<fd_type>(new fd_type(NULL));

  Handle stdin_rd_p;
  Handle stdin_wr_p;
  Handle stdout_rd_p;
  Handle stdout_wr_p;
  Handle stderr_rd_p;
  Handle stderr_wr_p;

  SECURITY_ATTRIBUTES security_attributes;

  security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
  security_attributes.bInheritHandle = TRUE;
  security_attributes.lpSecurityDescriptor = nullptr;

  std::lock_guard<std::mutex> lock(create_process_mutex);
  if(stdin_fd) {
    if (!CreatePipe(&stdin_rd_p, &stdin_wr_p, &security_attributes, 0) ||
        !SetHandleInformation(stdin_wr_p, HANDLE_FLAG_INHERIT, 0))
      return 0;
  }
  if(stdout_fd) {
    if (!CreatePipe(&stdout_rd_p, &stdout_wr_p, &security_attributes, 0) ||
        !SetHandleInformation(stdout_rd_p, HANDLE_FLAG_INHERIT, 0)) {
      return 0;
    }
  }
  if(stderr_fd) {
    if (!CreatePipe(&stderr_rd_p, &stderr_wr_p, &security_attributes, 0) ||
        !SetHandleInformation(stderr_rd_p, HANDLE_FLAG_INHERIT, 0)) {
      return 0;
    }
  }

  PROCESS_INFORMATION process_info;
  STARTUPINFO startup_info;

  ZeroMemory(&process_info, sizeof(PROCESS_INFORMATION));

  ZeroMemory(&startup_info, sizeof(STARTUPINFO));
  startup_info.cb = sizeof(STARTUPINFO);
  startup_info.hStdInput = stdin_rd_p;
  startup_info.hStdOutput = stdout_wr_p;
  startup_info.hStdError = stderr_wr_p;
  if(stdin_fd || stdout_fd || stderr_fd)
    startup_info.dwFlags |= STARTF_USESTDHANDLES;

  string_type process_command=command;
#ifdef MSYS_PROCESS_USE_SH
  size_t pos=0;
  while((pos=process_command.find('\\', pos))!=string_type::npos) {
    process_command.replace(pos, 1, "\\\\\\\\");
    pos+=4;
  }
  pos=0;
  while((pos=process_command.find('\"', pos))!=string_type::npos) {
    process_command.replace(pos, 1, "\\\"");
    pos+=2;
  }
  process_command.insert(0, "sh -c \"");
  process_command+="\"";
#endif

  BOOL bSuccess = CreateProcess(nullptr, process_command.empty()?nullptr:&process_command[0], nullptr, nullptr, TRUE, 0,
                                nullptr, path.empty()?nullptr:path.c_str(), &startup_info, &process_info);

  if(!bSuccess) {
    CloseHandle(process_info.hProcess);
    CloseHandle(process_info.hThread);
    return 0;
  }
  else {
    CloseHandle(process_info.hThread);
  }

  if(stdin_fd) *stdin_fd=stdin_wr_p.detach();
  if(stdout_fd) *stdout_fd=stdout_rd_p.detach();
  if(stderr_fd) *stderr_fd=stderr_rd_p.detach();

  closed=false;
  data.id=process_info.dwProcessId;
  data.handle=process_info.hProcess;
  return process_info.dwProcessId;
}
Пример #17
0
 /// TODO: Check that the uploaded file isn't empty too.
 bool empty() const { return value.empty(); }