const ribi::foam::Header ribi::foam::FacesFile::GetDefaultHeader() noexcept { return Header("faceList","constant/polyMesh","","faces"); }
Packet PacketFactory::RequestKey () { return HalfPacket { Header (Packets::GetMPOPSession), QByteArray () }; }
Packet PacketFactory::Ping () { return HalfPacket { Header (Packets::Ping, Seq_++), QByteArray () }; }
Packet PacketFactory::Microblog (BlogStatus st, const QString& text) { const QByteArray& data = ToMRIM (static_cast<quint32> (st), ToMRIM16 (text)); return HalfPacket { Header (Packets::MicroblogPost, Seq_++), data }; }
Packet PacketFactory::AddGroup (const QString& name, int numGroups) { const QByteArray& data = ToMRIM (static_cast<quint32> (ContactOpFlag::Group | (numGroups << 24)), 0, QString (), ToMRIM16 (name), QString (), 0, 0); return HalfPacket { Header (Packets::Contact, Seq_++), data }; }
bool HttpRequest::parse_body() { if(std::string::npos == m_body.find("\r\n\r\n")) return false; std::vector<std::string> lines; Splite(lines, m_body, "\r\n"); BOOST_ASSERT(false == lines.empty()); /* #ifdef WIN32 #pragma warning(disable:4129) #endif // check the method, path, protocol and version boost::regex reg("^([a-zA-Z]+) (/[^ ]*) ([a-zA-Z]+/[0-9\\.]+)"); #ifdef WIN32 #pragma warning(default:4129) #endif boost::smatch sm; if (false == boost::regex_match(lines[0], sm, reg)) { return false; } m_method = std::string(sm[1].first, sm[1].second); m_path = std::string(sm[2].first, sm[2].second); m_protocol_and_version = std::string(sm[3].first, sm[3].second); */ std::vector<std::string> sm; Splite(sm, lines[0], " "); if (sm.size() != 3) { return false; } m_method = sm[0]; m_path = sm[1]; m_protocol_and_version = sm[2]; // header fields for(int i = 1; i != lines.size(); ++i) { std::string line = lines[i]; boost::algorithm::trim(line); if( line.empty() ) continue; size_t colon_pos = line.find_first_of(":"); if( colon_pos == std::string::npos ) continue; std::string key = boost::algorithm::trim_copy(line.substr(0, colon_pos)); std::string val = boost::algorithm::trim_copy(line.substr(colon_pos+1)); m_headers.push_back(Header(key, val)); // 暂不解析pragma //if( boost::algorithm::to_lower_copy(key) != "pragma" ) { m_header_fields_map[key] = val; } } return true; }
Packet PacketFactory::MessageAck (const QString& from, quint32 msgId) { const QByteArray& data = ToMRIM (from, msgId); return HalfPacket { Header (Packets::MsgRecv, Seq_++), data }; }
long HttpTransaction::ContentLength() const { return atol(Header("content-length").c_str()); }
const std::string& HttpTransaction::Host() const { return Header("host"); }
const std::string& HttpTransaction::Connection() const { return Header("connection"); }
const std::string& HttpTransaction::ContentType() const { return Header("content-type"); }
const std::string& HttpTransaction::AcceptLanguage() const { return Header("accept-language"); }
const std::string& HttpTransaction::AcceptEncoding() const { return Header("accept-encoding"); }
/* * Show filelist from current area, called from the menu. */ void File_List() { int FileCount = 0; unsigned FileBytes = 0; _Tag T; struct _fdbarea *fdb_area = NULL; char temp[81]; iLineCount = 0; WhosDoingWhat(FILELIST, NULL); Syslog('+', "Listing File Area # %d", iAreaNumber); if (Access(exitinfo.Security, area.LTSec) == FALSE) { Enter(1); /* You don't have enough security to list this area */ pout(YELLOW, BLACK, (char *) Language(236)); Enter(2); Pause(); return; } InitTag(); if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) return; if (utf8) chartran_init((char *)"CP437", (char *)"UTF-8", 'b'); clear(); Header(); if (iLC(2) == 1) { mbsedb_CloseFDB(fdb_area); chartran_close(); return; } while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { memset(&T, 0, sizeof(T)); T.Area = iAreaNumber; T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); strncpy(T.LFile, chartran(fdb.LName), 80); SetTag(T); if (ShowOneFile() == 1) { mbsedb_CloseFDB(fdb_area); chartran_close(); return; } if (fdb.Deleted) { /* D E L E T E D */ /* Uploaded by: */ snprintf(temp, 81, " -- %-12s %s [%4d] %s%s\n", fdb.Name, (char *) Language(239), fdb.TimesDL, (char *) Language(238), fdb.Uploader); PUTSTR(temp); } FileCount++; /* Increase File Counter by 1 */ FileBytes += fdb.Size; /* Increase File Byte Count */ } Mark(); Enter(1); /* Total Files: */ snprintf(temp, 81, "%s%d / %d bytes", (char *) Language(242), FileCount, FileBytes); pout(LIGHTCYAN, BLACK, temp); Enter(2); chartran_close(); iLineCount = 0; mbsedb_CloseFDB(fdb_area); Pause(); }
ResultCodes WaitJobNotification(Socket& kd_sock, Socket& kp_sock, const std::string& job_id){ std::cout << "WaitJobNotification\n"; ResultCodes rlt = OK; std::stringstream ss; ss << g_home_job_dir << job_id ; std::string job_path = ss.str(); std::cout <<"job dir use to save file: " << job_path << std::endl; Message notify_msg_begin, notify_msg_end, change_state_msg(Header(MT_COMMAND, 0, 9999, 0, CMD_JOB_STATE), NULL), send_msg(Header(MT_COMMAND, 0, 9999, 0, CMD_JOB_STATE), NULL); std::vector<std::string> argv; std::string pjm_jobid, status, start_date, duration_time; // wait new status start running if(kd_sock.Recv(notify_msg_begin)){ if(notify_msg_begin.GetHeader()->GetCommand() == CMD_JOB_STATE){ argv = notify_msg_begin.GetCmdArgs(); if(argv.size() > 4){ pjm_jobid = argv[1]; status = argv[2]; start_date = argv[3]; duration_time = argv[4]; std::cout << pjm_jobid << " " << status << " " << start_date << " " << duration_time << std::endl; change_state_msg.AddArgv(job_id); change_state_msg.AddArgv(pjm_jobid); change_state_msg.AddArgv(status); change_state_msg.AddArgv(start_date); change_state_msg.AddArgv(duration_time); } std::cout << "submit job success\n"; } else { rlt = SLAVEDAEMON_SUBMITJOB_ERR; std::cout << "wait notification job\n"; return rlt; } } if(kp_sock.Send(change_state_msg)){ std::cout << " send event change status to kp_server sucesss\n"; } else { std::cout << " send event change status response to kp_server fail\n"; rlt = SLAVEDAEMON_SUBMITJOB_ERR; return rlt; } // wait file while(true){ int status = kd_sock.RecvListFile(job_path); std::cout << "status = " << status << std::endl; if(status > 0){ std::cout << "Receieve new files success;\n"; //Message req(Header(MT_COMMAND, 0, 0, 0, CMD_INITJOB), NULL), res; // /notify_msg.AddArgv(job_id); break; } sleep(3); } // wait last notify if(kd_sock.Recv(notify_msg_end)){ if(notify_msg_end.GetHeader()->GetCommand() == CMD_JOB_STATE){ argv = notify_msg_end.GetCmdArgs(); if(argv.size() > 3){ pjm_jobid = argv[1]; status = argv[2]; start_date = argv[3]; duration_time = argv[4]; std::cout << pjm_jobid << " " << status << " " << start_date << " " << duration_time << std::endl; send_msg.AddArgv(job_id); send_msg.AddArgv(pjm_jobid); send_msg.AddArgv(status); send_msg.AddArgv(start_date); send_msg.AddArgv(duration_time); } std::cout << "submit job success\n"; } else { rlt = SLAVEDAEMON_SUBMITJOB_ERR; std::cout << "wait notification job\n"; } } if(kp_sock.Send(send_msg)){ std::cout << " send response to kp_server sucesss\n"; } else { std::cout << " send response to kp_server fail\n"; rlt = SLAVEDAEMON_SUBMITJOB_ERR; } return rlt; }
const std::string& HttpTransaction::Pragma() const { return Header("pragma"); }
// // Main function // int main (int argc, char **argv) { if (argc < 6) { std::cout << "Usage: slavedaemon \n argc = " << argc << " is missing arg\n"; return 0; } g_home_job_dir = argv[1]; std::string job_id = argv[2]; std::string kp_host = argv[3]; int kd_port = atoi(argv[4]); int kp_port = atoi(argv[5]); std::string exe_path = argv[6]; std::vector<std::string> stgindirs; for(int i = 7; i < argc; i ++){ stgindirs.push_back(argv[i]); } std::cout <<"home job: " << g_home_job_dir << ", job id: " << job_id << ", kp_host: " << kp_host << ", kd_port: "<< kd_port << ", kp_port: " << kp_port << ", exe_path: " << exe_path << std::endl; // Connect kdeskdaemon Socket kdesk_socket; try { if ( ! kdesk_socket.Create() ) { throw SocketException ( "Could not create client socket." ); } for(int i = 0 ; i < MAX_NUM_OF_RETRY ; i ++ ){ if ( ! kdesk_socket.Connect( kp_host, kd_port)) { if( i == MAX_NUM_OF_RETRY - 1) throw SocketException ( "Could not connect to server." ); else{ std::cout << "Retry connect " << i << std::endl; sleep(3); } } else { std::cout <<"connect success\n"; break; } } } catch ( SocketException& e ) { std::cout << "Exception was caught:" << e.description() << "\n";; Message err_msg(Header(MT_COMMAND, 0, 0, 0, CMD_ACK_ERR), NULL); err_msg.AddArgv(job_id); err_msg.AddArgv("Can not connect to k-computer via tunnel."); if(SendMsgToKpServer(err_msg)){ std::cout << " send error ack success\n"; } else { std::cout << " send error ack fail\n"; } std::cout << "Exiting\n"; return -1; } // Copy exe service file if(CopyExeFile(job_id, exe_path) == OK){ std::cout << "copy exe file in dirs successfull\n"; } else { std::cout << "copy exe file in dirs fail\n"; } // Copy Stage-in std::cout << "CMD_COPY_STAGIN_DIR <dir01> <dir02>...." << std::endl; if(stgindirs.size() > 0){ if(Stagein(job_id, stgindirs) == OK){ std::cout << "copy stage in dirs successfull\n"; } else { std::cout << "copy stage in dirs fail\n"; } } else { std::cout << "Stage-in nothing\n" << std::endl; } // Connect to kp_server job_handler std::cout << "Connect to kp_server job_handler: " << kp_host << ":" << kp_port << std::endl; g_kpserver_host = kp_host; g_kpserver_port = kp_port; /*Socket kpserver_socket; try { if ( ! kpserver_socket.Create() ) { throw SocketException ( "Could not create client socket." ); } if ( ! kpserver_socket.Connect(kp_host, kp_port)) { throw SocketException ( "Could not connect to server." ); } } catch ( SocketException& e ) { std::cout << "Exception was caught:" << e.description() << "\n"; std::cout << "Exiting\n"; return -1; }*/ // Submit job std::cout << "SubmitJob\n"; ResultCodes rlt = OK; //rlt = SendInitJobCommand(&kdesk_socket, job_id); rlt = SendSubmitJobCommand(&kdesk_socket, job_id, exe_path); if(rlt == OK){ rlt = SendDataToKdeskDaemon(&kdesk_socket, job_id); if(rlt == OK){ //rlt = WaitKdeskSubmitResult(&kpserver_socket, &kdesk_socket, job_id); rlt = WaitKdeskSubmitResult(&kdesk_socket, job_id); // if(rlt == OK){ // rlt = WaitJobNotification(kdesk_socket, kpserver_socket, job_id); // } else { // std::cout << "wait kdesk submijob response & send result to kp_server fail.\n"; // } } else { std::cout << "send data fail.\n"; } } else { std::cout << "send submit job fail\n"; } if(rlt != OK){ Message err_msg(Header(MT_COMMAND, 0, 0, 0, CMD_ACK_ERR), NULL); err_msg.AddArgv(job_id); //if(kpserver_socket.Send(err_msg)){ if(SendMsgToKpServer(err_msg)){ std::cout << " send error ack success\n"; } else { std::cout << " send error ack fail\n"; } return 1; } std::cout << "submit job success\n"; return 0; }
const std::string& HttpTransaction::Referer() const { return Header("referer"); }
Packet PacketFactory::Message (MsgFlags flags, const QString& to, const QString& msg) { const QByteArray& data = ToMRIM (static_cast<quint32> (flags), to, ToMRIM16 (msg), ToMRIM1251 (" ")); return HalfPacket { Header (Packets::Msg, Seq_++), data }; }
const std::string& HttpTransaction::UserAgent() const { return Header("user-agent"); }
Packet PacketFactory::OfflineMessageAck (const UIDL& id) { const QByteArray& data = ToMRIM (id); return HalfPacket { Header (Packets::DeleteOfflineMsg, Seq_++), data }; }
const std::string& HttpTransaction::AcceptCharset() const { return Header("accept-charset"); }
Packet PacketFactory::SMS (const QString& to, const QString& text) { const QByteArray& data = ToMRIM (0, to, ToMRIM16 (text)); return HalfPacket { Header (Packets::SMS, Seq_++), data }; }
uint8_t LoaderCurrent::GetHeader() { return Header(); }
Packet PacketFactory::Authorize (const QString& email) { const QByteArray& data = ToMRIM (email); return HalfPacket { Header (Packets::Authorize), data }; }
void MainObject::DispatchCommand(QString cmd) { bool processed=false; int line; QTime time; bool ok=false; bool overwrite=!edit_modified; QStringList cmds; QString verb; cmd=cmd.stripWhiteSpace(); if(cmd.right(1)=="!") { overwrite=true; cmd=cmd.left(cmd.length()-1).stripWhiteSpace(); } cmds=cmds.split(" ",cmd); verb=cmds[0].lower(); // // No loaded log needed for these // if(verb=="deletelog") { if(rda->user()->deleteLog()) { if(cmds.size()==2) { Deletelog(cmds[1]); } else { fprintf(stderr,"deletelog: invalid command arguments\n"); } } else { fprintf(stderr,"deletelog: insufficient privileges [Delete Log]\n"); } processed=true; } if((verb=="exit")||(verb=="quit")||(verb=="bye")) { if(overwrite) { exit(0); } else { OverwriteError(verb); } processed=true; } if((verb=="help")||(verb=="?")) { Help(cmds); processed=true; } if(verb=="listlogs") { ListLogs(); processed=true; } if(verb=="listservices") { Listservices(); processed=true; } if(verb=="load") { if(overwrite) { if(cmds.size()==2) { Load(cmds[1]); } else { fprintf(stderr,"load: invalid command arguments\n"); } } else { OverwriteError("load"); } processed=true; } if(verb=="new") { if(overwrite) { if(cmds.size()==2) { New(cmds[1]); } else { fprintf(stderr,"new: invalid command arguments\n"); } } else { OverwriteError("new"); } processed=true; } // // These need a log loaded // if((processed)||(edit_log_event!=NULL)) { if(verb=="addcart") { if(rda->user()->addtoLog()) { if(cmds.size()==3) { line=cmds[1].toInt(&ok); if(ok&&(line>=0)) { unsigned cartnum=cmds[2].toUInt(&ok); if(ok&&(cartnum<=RD_MAX_CART_NUMBER)) { Addcart(line,cartnum); } else { fprintf(stderr,"addcart: invalid cart number\n"); } } else { fprintf(stderr,"addcart: invalid line number\n"); } } else { fprintf(stderr,"addcart: invalid command arguments\n"); } } else { fprintf(stderr,"addcart: insufficient privileges [Add Log Items]\n"); } processed=true; } if(verb=="addchain") { if(rda->user()->addtoLog()) { if(cmds.size()==3) { line=cmds[1].toInt(&ok); if(ok&&(line>=0)) { Addchain(line,cmds[2]); } else { fprintf(stderr,"addchain: invalid line number\n"); } } else { fprintf(stderr,"addchain: invalid command arguments\n"); } } else { fprintf(stderr,"addchain: insufficient privileges [Add Log Items]\n"); } processed=true; } if(verb=="addmarker") { if(rda->user()->addtoLog()) { if(cmds.size()==2) { line=cmds[1].toInt(&ok); if(ok&&(line>=0)) { Addmarker(line); } else { fprintf(stderr,"addmarker: invalid line number\n"); } } else { fprintf(stderr,"addmarker: invalid command arguments\n"); } } else { fprintf(stderr,"addmarker: insufficient privileges [Add Log Items]\n"); } processed=true; } if(verb=="addtrack") { if(rda->user()->addtoLog()) { if(cmds.size()==2) { line=cmds[1].toInt(&ok); if(ok&&(line>=0)) { Addtrack(line); } else { fprintf(stderr,"addtrack: invalid line number\n"); } } else { fprintf(stderr,"addtrack: invalid command arguments\n"); } } else { fprintf(stderr,"addtrack: insufficient privileges [Add Log Items]\n"); } processed=true; } if(verb=="header") { Header(); processed=true; } if(verb=="list") { List(); processed=true; } if(verb=="remove") { if(rda->user()->removefromLog()) { if(cmds.size()==2) { line=cmds[1].toInt(&ok); if(ok&&(line>=0)&&(line<edit_log_event->size())) { Remove(line); } else { fprintf(stderr,"remove: invalid line number\n"); } } else { fprintf(stderr,"remove: invalid command arguments\n"); } } else { fprintf(stderr,"remove: insufficient privileges [Delete Log Items]\n"); } processed=true; } if(verb=="save") { if(rda->user()->arrangeLog()) { Save(); } else { fprintf(stderr,"save: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="saveas") { if(rda->user()->arrangeLog()) { if(cmds.size()==2) { if(cmds[1].length()>64) { fprintf(stderr,"saveas: log name too long\n"); } Saveas(cmds[1]); } else { fprintf(stderr,"saveas: invalid command arguments\n"); } } else { fprintf(stderr, "saveas: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="setautorefresh") { if(rda->user()->arrangeLog()) { if(cmds.size()==2) { QString arg=cmds[1].lower(); if((arg=="yes")||(arg=="true")||(arg=="y")) { Setautorefresh(true); processed=true; } if((arg=="no")||(arg=="false")||(arg=="n")) { Setautorefresh(false); processed=true; } if(!processed) { fprintf(stderr,"setautorefresh: invalid command argument\n"); } } else { fprintf(stderr,"setautorefresh: invalid command arguments\n"); } } else { fprintf(stderr, "setautorefresh: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="setcart") { if(rda->user()->arrangeLog()) { if(cmds.size()==3) { line=cmds[1].toInt(&ok); if(ok&&(line>=0)&&(line<edit_log_event->size())) { unsigned cartnum=cmds[2].toUInt(&ok); if(ok&&(cartnum<=RD_MAX_CART_NUMBER)) { Setcart(line,cartnum); } else { fprintf(stderr,"setcart: invalid cart number\n"); } } else { fprintf(stderr,"setcart: invalid line number\n"); } } else { fprintf(stderr,"setcart: invalid command arguments\n"); } } else { fprintf(stderr, "setcart: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="setcomment") { if(rda->user()->arrangeLog()) { if(cmds.size()>=3) { line=cmds[1].toInt(&ok); if(ok&&(line>=0)&&(line<edit_log_event->size())) { cmds.remove(cmds.begin()); cmds.remove(cmds.begin()); Setcomment(line,cmds.join(" ")); } else { fprintf(stderr,"setcomment: invalid line number\n"); } } else { fprintf(stderr,"setcomment: invalid command arguments\n"); } } else { fprintf(stderr, "setcomment: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="setdesc") { if(rda->user()->arrangeLog()) { if(cmds.size()>=2) { cmds.erase(cmds.begin()); Setdesc(cmds.join(" ")); } else { fprintf(stderr,"setdesc: invalid command arguments\n"); } } else { fprintf(stderr, "setdesc: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="setenddate") { if(rda->user()->arrangeLog()) { if(cmds.size()==1) { Setenddate(QDate()); } else { if(cmds.size()==2) { QDate date=QDate::fromString(cmds[1],Qt::ISODate); if(date.isValid()) { Setenddate(date); } else { fprintf(stderr,"setenddate: invalid date format\n"); } } else { fprintf(stderr,"setenddate: invalid command arguments\n"); } } } else { fprintf(stderr, "setenddate: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="setlabel") { if(rda->user()->arrangeLog()) { if(cmds.size()==3) { line=cmds[1].toInt(&ok); if(ok&&(line>=0)&&(line<edit_log_event->size())) { Setlabel(line,cmds[2]); } else { fprintf(stderr,"setlabel: invalid line number\n"); } } else { fprintf(stderr,"setlabel: invalid command arguments\n"); } } else { fprintf(stderr, "setlabel: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="setpurgedate") { if(rda->user()->arrangeLog()) { if(cmds.size()==1) { Setpurgedate(QDate()); } else { if(cmds.size()==2) { QDate date=QDate::fromString(cmds[1],Qt::ISODate); if(date.isValid()) { Setpurgedate(date); } else { fprintf(stderr,"setpurgedate: invalid date format\n"); } } else { fprintf(stderr,"setpurgedate: invalid command arguments\n"); } } } else { fprintf(stderr, "setpurgedate: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="setservice") { if(rda->user()->arrangeLog()) { if(cmds.size()==2) { Setservice(cmds[1]); } else { fprintf(stderr,"setservice: invalid command arguments\n"); } } else { fprintf(stderr, "setservice: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="setstartdate") { if(rda->user()->arrangeLog()) { if(cmds.size()==1) { Setstartdate(QDate()); } else { if(cmds.size()==2) { QDate date=QDate::fromString(cmds[1],Qt::ISODate); if(date.isValid()) { Setstartdate(date); } else { fprintf(stderr,"setstartdate: invalid date format\n"); } } else { fprintf(stderr,"setstartdate: invalid command arguments\n"); } } } else { fprintf(stderr, "setstartdate: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="settime") { if(rda->user()->arrangeLog()) { if(cmds.size()>=3) { line=cmds[1].toInt(&ok); if(ok&&(line>=0)&&(line<edit_log_event->size())) { RDLogLine::TimeType ttype=RDLogLine::NoTime; if(cmds[2].lower()=="hard") { ttype=RDLogLine::Hard; } if(cmds[2].lower()=="none") { ttype=RDLogLine::Relative; } switch(ttype) { case RDLogLine::Hard: if(cmds.size()>=4) { time=RDGetWebTime(cmds[3],&ok); if(ok) { Settime(line,ttype,time); } else { fprintf(stderr,"settime: invalid time value\n"); } } else { fprintf(stderr,"settime: missing time value\n"); } break; case RDLogLine::Relative: Settime(line,ttype); break; case RDLogLine::NoTime: fprintf(stderr,"settime: invalid time type\n"); break; } } else { fprintf(stderr,"settime: invalid line number\n"); } } else { fprintf(stderr,"settime: invalid command arguments\n"); } } else { fprintf(stderr, "settime: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="settrans") { if(rda->user()->arrangeLog()) { if(cmds.size()==3) { line=cmds[1].toInt(&ok); if(ok&&(line>=0)&&(line<edit_log_event->size())) { RDLogLine::TransType trans=RDLogLine::NoTrans; if(cmds[2].lower()=="play") { trans=RDLogLine::Play; } if(cmds[2].lower()=="segue") { trans=RDLogLine::Segue; } if(cmds[2].lower()=="stop") { trans=RDLogLine::Stop; } if(trans!=RDLogLine::NoTrans) { Settrans(line,trans); } else { fprintf(stderr,"settrans: invalid transition type\n"); } } else { fprintf(stderr,"settrans: invalid line number\n"); } } else { fprintf(stderr,"settrans: invalid command arguments\n"); } } else { fprintf(stderr, "settrans: insufficient privileges [Rearrange Log Items]\n"); } processed=true; } if(verb=="unload") { if(overwrite) { Unload(); } else { OverwriteError("unload"); } processed=true; } } else { fprintf(stderr,"%s: no log loaded\n",(const char *)verb); processed=true; } if(!processed) { fprintf(stderr,"invalid command\n"); } PrintPrompt(); }
Packet PacketFactory::Hello () { return HalfPacket { Header (Packets::Hello, Seq_++), QByteArray () }; }
ResultCodes WaitKdeskSubmitResult(Socket* kd_sock, const std::string& job_id){ std::cout << "WaitKdeskSubmitResult\n"; ResultCodes rlt = OK; Header err_hdr(MT_COMMAND, 9001, 9008, 0, CMD_ACK_ERR); std::vector<std::string> argv; std::string pjm_jobid, status, start_date, duration_time; bool isFinish = false; while(rlt == OK && !isFinish){ std::cout << "Wait new message from kdeskdaemon\n"; Message recv_msg, err_msg; Message send_msg(Header(MT_COMMAND, 9001, 9008, 0, CMD_JOB_STATE), NULL); if(kd_sock->Recv(recv_msg) > 0){ if(recv_msg.GetHeader()->GetCommand() == CMD_JOB_STATE){ std::cout << "CMD_JOB_STATE <kdesk job id> <state>\n"; argv = recv_msg.GetCmdArgs(); if(argv.size() > 4){ pjm_jobid = argv[1]; status = argv[2]; start_date = argv[3]; duration_time = argv[4]; send_msg.AddArgv(job_id); send_msg.AddArgv(pjm_jobid); send_msg.AddArgv(status); send_msg.AddArgv(start_date); send_msg.AddArgv(duration_time); std::cout <<" job_id = " << job_id << " " << pjm_jobid << " " << status << " " << start_date << " " << duration_time << std::endl; if(status == "RJT" || status == "EXT" || status == "CCL" || status == "ERR"){ isFinish = true; } } } else { std::cout << "kdesk response submitjob fail\n"; err_msg.SetHeader(err_hdr); err_msg.AddArgv(job_id); rlt = KDESK_SUBMITJOB_ERR; } } else { std::cout << "wait response submit job status from kdesk fail\n"; rlt = KDESK_SUBMITJOB_ERR; err_msg.SetHeader(err_hdr); err_msg.AddArgv(job_id); } if(SendMsgToKpServer( rlt == OK ? send_msg : err_msg) == OK){ //if(kp_sock->Send(*send_msg)){ std::cout << " send response to kp_server sucesss\n"; } else { std::cout << " send response to kp_server fail\n"; rlt = SLAVEDAEMON_SUBMITJOB_ERR; } } // wait file std::cout << "Wait output file\n"; std::string job_path = std::string(g_home_job_dir) + job_id; std::cout <<"job dir use to save file: " << job_path << std::endl; if(rlt == OK){ int status = kd_sock->RecvListFile(job_path); std::cout << "status = " << status << std::endl; if(status > 0){ std::cout << "Receieve new files success;\n"; } else { std::cout << "Receieve new files fail"; rlt = KDESK_SUBMITJOB_ERR; } } return rlt; }
// ----------------------------------------------------------------------------- // CSIPMessage::From // ----------------------------------------------------------------------------- // EXPORT_C CSIPFromHeader* CSIPMessage::From () { CSIPHeaderBase* from = Header(SIPStrings::StringF(SipStrConsts::EFromHeader),0); return static_cast<CSIPFromHeader*>(from); }
Packet::Packet() { getMutableHeader() = Header(); }