Exemplo n.º 1
0
void AgendaUI::deleteUser(void) {
    cout  << endl << "****************" << endl << "deleteUser"  << endl << "***************" << endl;
    if (agendaService_.deleteUser(userName_, userPassword_)) {
        os << "[delete agenda account] succeed!" << endl;
        os << "--------------------------------Agenda--------------------------------" << endl;
        os << "Action :" << endl;
        os << "l   - log in Agenda by user name and password" << endl;
        os << "r   - register an Agenda account" << endl;
        os << "q   - quit Agenda" << endl;
        os << "help- show the operation list" << endl;
        os << "----------------------------------------------------------------------" << endl;
        os << endl;
        os << "Agenda : ~$ ";
        res = os.str();
        strcpy(buffer, res.c_str());
        os.str("");
        __send();
        start_input();
    } else {
        os << "[error] delete agenda acount fail!" << endl;
        os << endl;
        os << "Agenda@" << userName_ << " : # ";
        res = os.str();
        strcpy(buffer, res.c_str());
        os.str("");
        __send();
        input();
    }
}
void 
MrsLog::mrsErr(const ostringstream& oss)
{
 
#ifdef MARSYAS_LOG_ERRORS 

#ifdef MARSYAS_LOG2STDOUT
	cout << "[MRSERR] " << oss.str() << endl;
#endif

#ifdef MARSYAS_LOG2STDERR
	cerr << "[MRSERR] " << oss.str() << endl;
#endif 

#ifdef MARSYAS_LOG2FILE
	ofstream ofs(fname_.c_str(), ios::out | ios::app);
	if (ofs.fail())
		return;
	if (!(ofs << "[MRSERR] " << oss.str() << endl))
	{
		ofs.close();
		return;
	}
	ofs.close();
	return;
#endif 

#else 
 
	return;
#endif 
}
Exemplo n.º 3
0
void compile(const std::vector<Sym>& syms, std::vector<single_function>& functions) {
    symc_init();
    
    static ostringstream os;
    os.str("");
    
    os << make_prototypes();
    HashMap map(Sym::get_dag().size());
    for (unsigned i = 0; i < syms.size(); ++i) {
	
	os << "double func" << i << "(const double* x) { return ";
	os << print_code(syms[i], map); //c_print(syms[i]);
	os << ";}\n";

	//symc_compile(os.str().c_str());
	//cout << "compiling " << os.str() << endl;	
    }

    os << ends;
#ifdef INTERVAL_DEBUG
    //cout << "Compiling " << os.str() << endl;
#endif
    
    symc_compile(os.str().c_str()); 
    symc_link();

    functions.resize(syms.size());
    for (unsigned i = 0; i < syms.size(); ++i) {
	ostringstream os2;
	os2 << "func" << i;
	
	functions[i] = (single_function) symc_get_fun(os2.str().c_str());
    }

}
void 
MrsLog::mrsDiagnostic(const ostringstream& oss)
{
#ifdef MARSYAS_LOG_DIAGNOSTICS

#ifdef MARSYAS_LOG2STDOUT
	cout << "[MRS_DIAG] " << oss.str() << endl;
#endif


#ifdef MARSYAS_LOG2STDERR
	cerr << "[MRS_DIAG] " << oss.str() << endl;
#endif

#ifdef MARSYAS_LOG2FILE
	ofstream ofs(fname_.c_str(), ios::out | ios::app);
	if (ofs.fail())
		return;
	if (!(ofs << "[MRS_DIAG] " <<  oss.str() << endl))
	{
		ofs.close();
		return;
	}
	ofs.close();
	return;
#endif

#else 
	(void) oss;
#endif


}
Exemplo n.º 5
0
void mutex_print(ostringstream& oss)
{
    pthread_mutex_lock(&mutex2);
    cerr << oss.str();
    oss.str("");
    pthread_mutex_unlock(&mutex2);
}
Exemplo n.º 6
0
/**
Sends messages to all clients or to all clients not in a game.
*/
void broadCast(bool global){
    verbose && cout << ticks() << ": server broadcasts: .:" << buffer.str() <<":." << endl;
    for (Clients::iterator it = clients.begin(); it != clients.end(); it++) if (it->second != 0){
        if (it->second && ((global) || (it->second->game == 0))) it->second->cast();
    }
    buffer.str("");
}
Exemplo n.º 7
0
void AgendaUI::listAllParticipateMeetings(void) {
    cout  << endl << "****************" << endl << "listAllParticipateMeetings"  << endl << "***************" << endl;
    os << endl;
    os << "[list all participator meetings]" << endl;
    os << endl;
    os << left << setw(17) << "title";
    os << left << setw(17) << "sponsor";
    os << left << setw(17) << "participator";
    os << left << setw(17) << "start time";
    os << left << setw(17) << "end time" << endl;
    list<Meeting> l = agendaService_.listAllParticipateMeetings(userName_);
    for (list<Meeting>::iterator it = l.begin(); it != l.end(); it++) {
        os << left << setw(17) << it->getTitle();
        os << left << setw(17) << it->getSponsor();
        os << left << setw(17) << it->getParticipator();
        os << left << setw(17) << Date::dateToString(it->getStartDate());
        os << left << setw(17) << Date::dateToString(it->getEndDate()) << endl;
    }
    os << endl;
    os << endl;
    os << "Agenda@" << userName_ << " : # ";
    res = os.str();
    strcpy(buffer, res.c_str());
    os.str("");
    __send();
    input();
}
Exemplo n.º 8
0
result_t Message::decode(SymbolString& masterData, SymbolString& slaveData,
		ostringstream& output, OutputFormat outputFormat,
		bool leadingSeparator)
{
	unsigned char offset = (unsigned char)(m_id.size() - 2);
	size_t startPos = output.str().length();
	result_t result = m_data->read(pt_masterData, masterData, offset, output, outputFormat, leadingSeparator, NULL, -1);
	if (result < RESULT_OK)
		return result;
	bool empty = result == RESULT_EMPTY;
	offset = 0;
	leadingSeparator |= output.str().length() > startPos;
	result = m_data->read(pt_slaveData, slaveData, offset, output, outputFormat, leadingSeparator, NULL, -1);
	if (result < RESULT_OK)
		return result;
	if (result == RESULT_EMPTY && !empty)
		result = RESULT_OK; // OK if at least one part was non-empty
	time(&m_lastUpdateTime);
	switch (masterData.compareMaster(m_lastMasterData)) {
	case 1: // completely different
		m_lastChangeTime = m_lastUpdateTime;
		m_lastMasterData = masterData;
		break;
	case 2: // only master address is different
		m_lastMasterData = masterData;
		break;
	}
	if (slaveData != m_lastSlaveData) {
		m_lastChangeTime = m_lastUpdateTime;
		m_lastSlaveData = slaveData;
	}
	return result;
}
Exemplo n.º 9
0
void AgendaUI::start_input() {
    cout  << endl << "****************" << endl << "start_input"  << endl << "***************" << endl;
    // os << endl;
    // os << "Agenda : ~$ ";
    // res = os.str(); strcpy(buffer, res.c_str()); os.str(""); __send();
    while(1) {
        string op = getOperation();
        if(op == "l" || op == "r" || op == "q" || op == "help") {
            if (op == "help") {
                executeOperation("help_start");
            } else {
                executeOperation(op);
            }
            break;
        } else {
            os << "your enter is wrong please enter again" << endl;
            os << endl;
            os << "Agenda : ~$ ";
            res = os.str();
            strcpy(buffer, res.c_str());
            os.str("");
            __send();
            start_input();
            break;
        }
    }
}
Exemplo n.º 10
0
string get_round(int i) {
  string ret =  NO_ROUND;
  char buff[100];
  sprintf(buff, "https://old.jutge.org/competitions/AlbertAtserias:BolaDeDrac2015/round/%d", i);
  string url = buff;
  request.setOpt(curlpp::options::Url(url));

  request.perform();
  string re = responseStream.str();
  size_t found = re.find("Player out:");

  if (found != string::npos) {
    size_t inici = re.find("<p class='indent'>",found+1);
    size_t fi =  re.find("(",found+1);
    cout << " --> ";
    if (inici != string::npos and fi != string::npos) {
      ret =  re.substr(inici+18, fi-(inici+18));
      cout << ret << endl;
    }
  } else if (re.find("Turn 1") != string::npos) {
    ret = ONGOING;
  }

  responseStream.str(string());
  return ret;
}
void 
MrsLog::mrsMessage(const ostringstream& oss)
{
#ifdef MARSYAS_LOG_MESSAGES
	if (!messages_off_) 
    {
#ifdef MARSYAS_LOG2STDOUT
		cout << "[MRS_MESSAGE] " << oss.str() << endl;
#endif

#ifdef MARSYAS_LOG2STDERR
		cerr << "[MRS_MESSAGE] " << oss.str() << endl;
#endif      

#ifdef MARSYAS_LOG2FILE
		ofstream ofs(fname_.c_str(), ios::out | ios::app);
		if (ofs.fail())
			return;
		if (!(ofs << "[MRS_MESSAGE] " <<  oss.str() << endl))
		{
			ofs.close();
			return;
		}
		ofs.close();
		return;

#endif
	}
	

#else 
	; 
#endif 
	
}
Exemplo n.º 12
0
void AgendaUI::quitAgenda(void) {
    os << "quit";
    res = os.str();
    strcpy(buffer, res.c_str());
    os.str("");
    __send();
    agendaService_.quitAgenda();
}
Exemplo n.º 13
0
int main(int argc, char *argv[])
{
    if(argc < 3) {
        cerr << "Usage: " << argv[0] << " <collection.db> <boffin.db>" << endl;
        return 1;
    }

    try {
        BoffinDb db(argv[2], argv[1]);
            
        // build up the request:
        db.map_tracks_without_tags(track_out);
        ossreq.flush();
        issreq = new istringstream(ossreq.str());

        // setup curl:
        CURL* curl = curl_easy_init();
        CurlChecker cc;

        // io options:
        cc("WRITEFUNCTION") = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writer);  
        cc("READFUNCTION") = curl_easy_setopt(curl, CURLOPT_READFUNCTION, curl_reader);

        // http options:
        cc("URL") = curl_easy_setopt(curl, CURLOPT_URL, MUSICLOOKUP_URL);  
        cc("HEADER") = curl_easy_setopt(curl, CURLOPT_HEADER, 0);                           // don't include header in response

        cc("FOLLOWLOCATION") = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);           // follow http redirects
        // leave this to the defaults with older versions of curl
#if defined(CURLOPT_POSTREDIR) && defined(CURL_REDIR_POST_ALL)
        cc("POSTREDIR") = curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL );  // keep on posting when redir'd (301 or 302)
#endif
        cc("POST") = curl_easy_setopt(curl, CURLOPT_POST, 1);
        cc("POSTFIELDSIZE") = curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, issreq->rdbuf()->in_avail());
        cc("USERAGENT") = curl_easy_setopt(curl, CURLOPT_USERAGENT, "playdar boffin tagger");
        struct curl_slist *headers = 0;
        headers = curl_slist_append(headers, "content-type: text/plain; charset=utf-8");
        headers = curl_slist_append(headers, "expect:");
        cc("HTTPHEADER") = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        
        cc("easy_perform") = curl_easy_perform(curl);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);

        ossresp.flush();
        issresp = new istringstream(ossresp.str());
        db.update_tags( parse_line );
    } 
    catch (const std::exception& e) {
        cerr << "failed: " << e.what();
        return 1;
    } 
    //catch (...) {
    //    cerr << "failed with unhandled exception";
    //    return 1;
    //}

}
Exemplo n.º 14
0
/**
Sends a message to clients in the same game.
*/
void Client::broadCast(bool except){
    verbose && cout << ticks() << ": server broadcasts: .:" << buffer.str() << ":." << endl;
    Client* cl;
    for (Clients::iterator it = clients.begin(); it != clients.end(); it++) if (it->second != 0){
        cl = it->second;
        if ((cl->game == game) && ((!except) || (cl != this))) cl->cast();
    }
    buffer.str("");
}
Exemplo n.º 15
0
string Text::toString(int n)
{
	static ostringstream out;
	out.str("");
	out.clear();
	out << n;
	string newStr = out.str();
	return newStr;
}
Exemplo n.º 16
0
void
CSipResponse::BuildPacket() throw(CSipException *)
{
	if(GetCommand().length() == 0)
		throw(new CSipException(SipError::UNSUPPORTED_COMMAND));
	//
	static ostringstream response;
	response.clear();
	response.str("");
	//
	if(GetCSeqCommand().length() == 0)
		SetCSeqCommand(GetCommand());
	//
	response << "SIP/2.0" << GetStatusCode() << GetStatus() << " SIP/2.0\r\n"
			 << "Via: SIP/2.0/UDP " << GetCallerAddress() << ":" << GetCallerPort()
			 << ";branch=" << GetBranch() << "\r\n"
			 << "Contact: <sip:" << GetCallerId() << "@" << GetCallerAddress()
			 << ":" << GetCallerPort() << ">;expires=" << GetExpires() << "\r\n"
			 << "Call-ID: " << GetCallId() << "\r\n"
			 << "Cseq: " << GetCSeq() << " " << GetCSeqCommand() << "\r\n";
	//
	if(GetServer().length() > 0)
		response << "Server: " << GetServer() << "\r\n";
	//
	// To field:
	response << "To: ";
	if(GetCalleeScreenName().length() > 0)
		response << "\"" << GetCalleeScreenName() << "\"";
	//
	response << "<sip:" << GetCalleeId() << "@" << GetSipServerAddress() << ">";
	response << ";tag=" << GetCalleeTag() << "\r\n";
	//
	// From field:
	response << "From: ";
	if(GetCallerScreenName().length() > 0)
		response << "\"" << GetCallerScreenName() << "\"";
	//
	response << "<sip:" << GetCallerId() << "@" << GetCallerAddress() << ">"
			 << ";tag=" << GetCallerTag() << "\r\n";
	//
	response << "Allow: REGISTER, INVITE, ACK, CANCEL, BYE\r\n";
	//
	if(GetContent().length() > 0)
	{
		response << "Content-Length: " << GetContent().length() << "\r\n"
				 << "Content-Type: " << GetContentType() << "\r\n"
				 << "\r\n" << GetContent();
	}
	else
		response << "\r\n";
	//
	SetBuffer(response.str().c_str(), response.str().length());
}
Exemplo n.º 17
0
void draw_gameover()
{
    output_h(350,100,"G A M E    O V E R");
	output(400,200, "Your  Score ");
    temp1<<score;
	sscore=temp1.str();
	temp = new char [sscore.length()+1];
  	strcpy (temp, sscore.c_str());
	output(440, 250, temp);
	delete temp;
	temp1.str("");
}
Exemplo n.º 18
0
string header::double2str(const double in, const double missing_value)
{
	if (in == missing_value)
		return ".";
	else
	{
		static ostringstream out;
		out.str(""); out.clear();
		out << in;
		return out.str();
	}
}
void buildURLGoogle(const axutil_env_t* env,axis2_char_t* symbol,axutil_date_time_t* start, axutil_date_time_t* end,ostringstream& oss)
{
	int syear = axutil_date_time_get_year(start,env);
	int smonth = axutil_date_time_get_month(start,env);
	int sdate = axutil_date_time_get_date(start,env);
	int eyear = axutil_date_time_get_year(end,env);
	int emonth = axutil_date_time_get_month(end,env);
	int edate = axutil_date_time_get_date(end,env);
	oss.str("");
	oss<<"http://www.google.com/finance/historical?q=";
	oss<<symbol<<"&startdate=";
	oss<<GlobalVariables::m_months[smonth]<<"+"<<sdate<<"%2C+"<<syear<<"&enddate=";
	oss<<GlobalVariables::m_months[emonth]<<"+"<<edate<<"%2C+"<<eyear<<"&histperiod=weekly&num=30&output=csv";
	AXIS2_LOG_INFO(env->log,"build url google version [%s]",oss.str().c_str());
}
Exemplo n.º 20
0
void AgendaUI::deleteAllMeetings(void) {
    cout  << endl << "****************" << endl << "deleteAllMeetings"  << endl << "***************" << endl;
    if (agendaService_.deleteAllMeetings(userName_)) {
        os << "[delete all meetings] succeed!" << endl;
    } else {
        os << "[error] fail!" << endl;
    }
    res = os.str();
    strcpy(buffer, res.c_str());
    os.str("");
    __send();
    os << endl;
    os << "Agenda@" << userName_ << " : # ";
    input();
}
Exemplo n.º 21
0
Block* BlockBuilder::build(int sbid, const string& id_name, const string& micro_type, TKPTVCIT pBegin, int current_instruction)
{
    // demultiplexing
    if (micro_type == "moving_average")
	return new MovingAverage(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "sin")
	return new Sin(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "simple_scope")
	return new SimpleScope(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "sum")
	return new Sum(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "step")
	return new Step(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "ramp")
	return new Ramp(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "impulse")
	return new Impulse(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "integrator")
	return new Integrator(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "derivator")
	return new Derivator(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "genericT")
	return new genericT(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "genericNT")
	return new genericNT(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "twins")
	return new Twins(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else if (micro_type == "delay")
	return new Delay(id_counter++, sbid, id_name, micro_type, pBegin, current_instruction);
    else
    {
	oss << "You must add a row for type '" << micro_type << "' in the demultiplexing function BlockBuilder::build()";
	throw BlockError(oss.str());
    }
}
Exemplo n.º 22
0
/*
* finalizeOutput Default implementation just outputs the stream
*
*/
void NyxCmdOutput::finalizeOutput(ostringstream &output)
{
	if (printOutputEnabled)
	{
		cout << output.str();
	}
}
Exemplo n.º 23
0
void xml_formatter::output(ostream & out)
{
	xml_support->build_subclasses(out);

	xml_support->output_program_structure(out);
	output_symbol_data(out);
	if (need_details) {
		out << open_element(DETAIL_TABLE);
		for (size_t i = 0; i < symbol_details.size(); ++i) {
			int id = symbol_details[i].id;

			if (id >= 0) {
				out << open_element(SYMBOL_DETAILS, true);
				out << init_attr(TABLE_ID, (size_t)id);
				out << close_element(NONE, true);
				out << symbol_details[i].details;
				out << close_element(SYMBOL_DETAILS);
			}
		}
		out << close_element(DETAIL_TABLE);

		// output bytesTable
		out << open_element(BYTES_TABLE);
		out << bytes_out.str();
		out << close_element(BYTES_TABLE);
	}

	out << close_element(PROFILE);
}
Exemplo n.º 24
0
void xml_utils::output_xml_header(string const & command_options,
                       string const & cpu_info, string const & events)
{
	// The integer portion indicates the schema version and should change
	// both here and in the schema file when major changes are made to
	// the schema.  Changes to opreport, or minor changes to the schema
	// can be indicated by changes to the fraction part.
	string const schema_version = "3.1";

	// This is the XML version, not schema version.
	string const xml_header = "<?xml version=\"1.0\" ?>";

	cout << xml_header << endl;
	cout << open_element(PROFILE, true);
	cout << init_attr(SCHEMA_VERSION, schema_version);

	cout << cpu_info;
	cout << init_attr(TITLE, "opreport " + command_options);
	cout << close_element(NONE, true);

	cout << open_element(OPTIONS, true) << xml_options.str();
	cout << close_element();

	cout << open_element(SETUP) << events;
	cout << close_element(SETUP) << endl;
}
Exemplo n.º 25
0
bool MultiOutput::outCheckAndClear()
{
    if (yReg.size() == 0)
    {
	oss << "Output of block '" << name << "' is completely disconnected";
	throw SyxError(oss.str());
    }
    if (yReg.size() && !used.size()) throw SyxError("You can't call function outCheckAndClear() more than once");
    for (int j=0; j<yReg.size(); j++)
	if (!used[j])
	{
	    oss << "Output #" << j << " of multi-output block '" << getType() << "' not assigned";
	    throw SyxError(oss.str());
	}
    return true;
}
Exemplo n.º 26
0
/**
 * This method will add a new line of code to the main file.
 * @param str the new line of code to add
 */
void add_code(string str) {
  //Count the braces and keep track of how deeply they are nested.
  sBraceCount += count(str.begin(), str.end(), '{');
  sBraceCount -= count(str.begin(), str.end(), '}');
  if (sBraceCount < 0) sBraceCount = 0;

  //Force rollback defaults to false. It is only set by the '!' and '@' commands
  bool force_rollback = false;
  if (sBraceCount == 0) {
    if (str[str.length() - 1] == '!') {
      //The '!' command was used.  Replace it with a semi-colon and set the flag.
      str[str.length() - 1] = ';';
      force_rollback = true;
    } else if (str[str.length() - 1] == '@') {
      //The '@' command was used.  Wrap the code in the cpp_console_print() method.
      force_rollback = true;
      str[str.length() - 1] = ' ';
      str = string("cpp_console_print(") + str + string(");");
    }
  }

  //Add the code to the buffer.
  sCodeBuffer << str << "\n";

  //If the code is not nested in any braces, we can attempt to execute.
  if (sBraceCount == 0) {
    ostringstream merge;
    string dump_string = sCodeBuffer.str();
    insert_code(&merge,&sCodeBuffer);
    if (execute(&merge, force_rollback)==0) sDumpBuffer << dump_string;
  }
}
Exemplo n.º 27
0
bool MultiInput::inCheckAndClear()
{
    if (in.size() == 0)
    {
	oss << "Input of block '" << name << "' is completely disconnected";
	throw SyxError(oss.str());
    }
    if (in.size() && !used.size()) throw SyxError("You can't call function inCheckAndClear() more than once");
    for (int j=0; j<in.size(); j++)
	if (!used[j])
	{
	    oss << "Input #" << j << " of multi-input block '" << ID << "' not assigned"; // name
	    throw SyxError(oss.str());
	}
    return true;
}
Exemplo n.º 28
0
void desligaServidor(int sig){
	cout << endl << "DESLIGANDO SERVIDOR..." << endl << "ESSES PROCESSOS NAO SERAO EXECUTADOS";
	listaProcessos();
	cout << endl << "ESSES PROCESSOS FORAM EXECUTADOS" << endl << exec_log.str();
	msgctl(msgqid, IPC_RMID, NULL);
	exit(0);
}
Exemplo n.º 29
0
/**
Sends a message to the client.
*/
void Client::cast(){
    int msglen;
    string outdata = buffer.str() + "\n";
    verbose && cout << ticks() << ": server sends to #" << id << ": .:" << outdata << ":." << endl;
    msglen = outdata.length()+1;
    if (SDLNet_TCP_Send(sd, (void *)(outdata.c_str()), msglen) < msglen)
        cerr << "SDLNet_TCP_Send: " << SDLNet_GetError() << endl;
}
Exemplo n.º 30
0
const char *ServerInfo::print() const
{
    os << "addr:" << server_ip.c_str() << ":" << server_port.c_str() << ", server_id:"
        << server_id.c_str() << ", time_out:" << time_out << ", heart_beat_interval:"
        << heart_beat_interval << ", reconnected_interval:" << reconnect_interval
        << ", conn_time_out:" << conn_time_out;
    return os.str().c_str();
}