示例#1
0
void IRCSession::on_ctcp_privmsg_dcc(const IRCText &data, const IRCPrivateMessage &message)
{
	//uicore::Console::write_line(data.get_text());

	std::vector<std::string> tokens = split_command_line(data.get_text());
	if (tokens.size() >= 4 && tokens[0] == "SEND")
	{
		IRCFileOffer offer;
		offer.sender = message.get_prefix();

		unsigned int address = uicore::Text::parse_uint32(tokens[2]);
		std::string ip_address = uicore::string_format(
			"%1.%2.%3.%4",
			uicore::Text::to_string((address>>24)&0xff),
			uicore::Text::to_string((address>>16)&0xff),
			uicore::Text::to_string((address>>8)&0xff),
			uicore::Text::to_string(address&0xff));
		std::string port = tokens[3];
		offer.host = uicore::SocketName(ip_address, port);

		offer.size = 0;
		offer.size_provided = false;
		if (tokens.size() >= 5)
		{
			offer.size = uicore::Text::parse_uint32(tokens[4]);
			offer.size_provided = true;
		}

		offer.filename = uicore::PathHelp::get_filename(tokens[1]);
		cb_dcc_file_offer(offer);
	}
示例#2
0
int main (int argc, char *argv[]) {
	FILE *f;
	char name[255],*it;
	PROFILE_LoadMzRc();
	PROFILE_GetMzRcString("emulators","wine","wine",WinePath,sizeof(WinePath));
	PROFILE_GetMzRcString("emulators","dos","dos",DosEmuPath,sizeof(DosEmuPath));
	/* Get program name */
	it = strrchr(argv[0],'/');
	it = it ? (it+1) : argv[0];
	strcpy(name,it);
	it = strrchr(name, '.');
	if(it) *it= '\0';
	PROFILE_GetMzRcString(name,"command","",RcOptions,sizeof(RcOptions));
	if(RcOptions[0])
	{
		RcCommand = split_command_line(RcOptions);
		if(strcmp(RcCommand[0],"wine")==0)
			exec_wine(argc,argv);
		else
			exec_dosemu(argc,argv);
	}
	f=fopen(argv[0],"r");
	if(!f)
	{
		perror("mzloader");
		return 1;
	}
	if(is_nepe(f))
		exec_wine(argc,argv);
	else
		exec_dosemu(argc,argv);
	return 1;
}
 void handle_read_line(std::string line)
 {
   std::vector<std::string> args;
   
   // huu, ugly...
   args = split_command_line(std::string("--") + line); 
   
   try
   {
     boost::program_options::variables_map vm;
     boost::program_options::store(
       boost::program_options::command_line_parser(args).options(*m_desc).run(), 
       vm);
     boost::program_options::notify(vm);
   }
   catch (boost::program_options::unknown_option &e) 
   {
     std::cerr << "error: " << e.what() << std::endl;
   }
   catch (boost::program_options::invalid_command_line_syntax &e)
   {
     std::cerr << "error: " << e.what() << std::endl;
   }
   catch (boost::program_options::validation_error &e)
   {
     std::cerr << "error: " << e.what() << std::endl;
   }
 }
示例#4
0
int main(void)
{
 
  char *command_line;
  char **command_args;
  int status;

                                                          // Run loop.
  do {
    printf("<Zhang> ");
    command_line = read_command_line();
    command_args = split_command_line(command_line);
    status = execute_command(command_args);
                                                         //deallocate memory 
    free(command_line);
    free(command_args);
  } while (status);
  return 0;
}
示例#5
0
	void parse_backend_event(std::string const &line)
	{
		std::string command;
		params_t params;
		split_command_line(line, command, params);

		queue_by_uri_t &queue_by_uri = queue.template get < uri_tag > ();
		typename queue_by_uri_t::iterator resource_by_uri_iter = queue_by_uri.end();

		if (params.size() > 0)
			resource_by_uri_iter = queue_by_uri.find(params[0]);

		if (resource_by_uri_iter != queue_by_uri.end())
		{
			uri uri_ = resource_by_uri_iter->uri_;
			playlist_t *playlist_ = resource_by_uri_iter->playlist_;

			bool playlist_exists = has_playlist(playlists_, *playlist_);

			if (playlist_exists)
			{
				if ((command == "metadata") && (params.size() >= 2))
				{
					metadata_optional_t new_metadata = parse_metadata(params[1]);

					if (new_metadata)
					{
						long num_sub_resources = get_metadata_value < long > (*new_metadata, "num_sub_resources", 0);
						long min_sub_resource_index = get_metadata_value < long > (*new_metadata, "min_sub_resource_index", 0);
						uri::options_t::const_iterator uri_resource_index_iter = uri_.get_options().find("sub_resource_index");
						bool has_resource_index = (uri_resource_index_iter != uri_.get_options().end());

						if ((num_sub_resources > 1) && !has_resource_index)
						{
							for (int i = 0; i < num_sub_resources; ++i)
							{
								unsigned int sub_resource_index = min_sub_resource_index + i;
								uri sub_uri = uri_;
								sub_uri.get_options()["sub_resource_index"] = boost::lexical_cast < std::string > (sub_resource_index);

								//queue_sequence_t &queue_sequence = queue.template get < sequence_tag > ();
								typename queue_sequence_t::iterator seq_iter = queue.template project < sequence_tag > (resource_by_uri_iter);
								queue.insert(seq_iter, entry(sub_uri, playlist_));
							}
						}
						else
						{
							if (has_metadata_value(*new_metadata, "title") && has_resource_index)
							{
								std::string title = get_metadata_value < std::string > (*new_metadata, "title", "");
								std::stringstream sstr;
								std::string resource_index_str = uri_resource_index_iter->second;

								try
								{
									// This compensates for the 0-starting indices
									int resource_index = boost::lexical_cast < int > (resource_index_str);
									resource_index_str = boost::lexical_cast < std::string > (resource_index + 1 - min_sub_resource_index);
								}
								catch (boost::bad_lexical_cast const &)
								{
								}

								sstr << title << " (" << resource_index_str << "/" << num_sub_resources << ")";
								set_metadata_value(*new_metadata, "title", sstr.str());
							}

							get_derived().resource_successfully_scanned(uri_, *playlist_, *new_metadata);
						}
					}
					else
						get_derived().unrecognized_resource(uri_, *playlist_);
				}
				else if (command == "resource_corrupted")
				{
					get_derived().resource_corrupted(uri_, *playlist_);
				}
				else if (command == "unrecognized_resource")
				{
					get_derived().unrecognized_resource(uri_, *playlist_);
				}
				/*else if (command == "error")
				{
					get_derived().resource_scan_error(uri_, *playlist_, (params.size() >= 2) ? params[1] : boost::none);
				}*/
			}
			else
				std::cerr << "uri " << uri_.get_full() << " playlist is from a playlist that does not exist\n";

			{
				if (playlist_exists)
					get_derived().removing_queue_entry(uri_, *playlist_, true);

				queue_by_uri.erase(resource_by_uri_iter);

				if (playlist_exists)
					get_derived().removing_queue_entry(uri_, *playlist_, false);
			}

			if (queue.empty())
			{
				get_derived().stop_watchdog_timer();
				get_derived().scanning_in_progress(false);
			}
			else
			{
				get_derived().restart_watchdog_timer();
				request_next_metadata();
			}
		}
	}