char* mem_logger_read_line() { static char buff[256]; buff[0] = 0; if (oss.rdbuf()->in_avail()) oss.getline(buff, 256); return buff; }
void InterpreterDBG::sendData(stringstream& s) { if(clientsock < 0) return; string str = s.str(); s.rdbuf()->str(""); s << str.length() << '\0' << str; if(send(clientsock, s.str().c_str(), sizeof(char)* (s.str().length()+1), 0) < 0) {//error if(clientsock > 0) { //cerr << PACKAGE << ": erro ao enviar dados." << endl; } //else, server closed con } }
bool treeTrace( stringstream &ss, vector<int> &T, int currSum ) { if( ss.rdbuf()->in_avail() == 0 ) return false; char leftBracket; ss >> leftBracket; int integer; ss >> integer; bool leftTree; if( ss.fail() ) { ss.clear(); char otherBracket; ss >> otherBracket; return false; }
static pfi::lang::shared_ptr<http::response> gen_resp(stringstream &ss) { http::header head(ss); string content_type="text/html; charset=utf-8"; int code=200; string reason="OK"; if (head.has_key("content-type")){ content_type=head["content-type"]; head.erase("content-type"); } if (head.has_key("location")){ code=302; reason="Found"; } if (head.has_key("status")){ const char *p=head["status"].c_str(); char *q=NULL; code=strtol(p, &q, 10); while(*q && isspace(*q)) q++; reason=q; head.erase("status"); } pfi::lang::shared_ptr<http::response> resp(new http::response(code, reason)); head["Content-Type"]=content_type; for (http::header::iterator p=head.begin(); p!=head.end(); p++) resp->head()[p->first]=p->second; resp->body()<<ss.rdbuf(); return resp; }