コード例 #1
0
ファイル: node.cpp プロジェクト: Zhang-Yi/tornet
 void node::start_service( uint16_t cn, const fc::string& name, const node::new_channel_handler& cb ) {
   if( !my->_thread.is_current() ) {
     my->_thread.async( [&,this](){ return start_service( cn, name, cb ); } ).wait();
     return;
   }
   if( !my->_services.insert( service( cn, name, cb ) ).second )
     FC_THROW_MSG( "Unable to start service '%s' on channel '%s' because channel '%s' is in use.", name.c_str(), cn, cn );
   slog( "Starting service '%s' on channel %d", name.c_str(), cn );
 }
コード例 #2
0
ファイル: cli.cpp プロジェクト: FollowMyVote/fc
/***
 * @brief Read input from the user
 * @param prompt the prompt to display
 * @param line what the user typed
 */
void cli::getline( const fc::string& prompt, fc::string& line)
{
   // getting file descriptor for C++ streams is near impossible
   // so we just assume it's the same as the C stream...
#ifdef HAVE_EDITLINE
#ifndef WIN32   
   if( isatty( fileno( stdin ) ) )
#else
   // it's implied by
   // https://msdn.microsoft.com/en-us/library/f4s0ddew.aspx
   // that this is the proper way to do this on Windows, but I have
   // no access to a Windows compiler and thus,
   // no idea if this actually works
   if( _isatty( _fileno( stdin ) ) )
#endif
   {
      rl_set_complete_func(my_rl_complete);
      rl_set_list_possib_func(cli_completion);
      rl_set_check_secret_func(cli_check_secret);

      static fc::thread getline_thread("getline");
      getline_thread.async( [&](){
         char* line_read = nullptr;
         std::cout.flush(); //readline doesn't use cin, so we must manually flush _out
         line_read = readline(prompt.c_str());
         if( line_read == nullptr )
            FC_THROW_EXCEPTION( fc::eof_exception, "" );
         line = line_read;
         // we don't need here to add line in editline's history, cause it will be doubled
         free(line_read);
      }).wait();
   }
   else
#endif
   {
      std::cout << prompt;
      // sync_call( cin_thread, [&](){ std::getline( *input_stream, line ); }, "getline");
      fc::getline( fc::cin, line );
      return;
   }
}
コード例 #3
0
ファイル: ip.cpp プロジェクト: BrownBear2/fc
 address::address( const fc::string& s ) {
   _ip = boost::asio::ip::address_v4::from_string(s.c_str()).to_ulong();
 }