2004-06-10 07:49:50 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2004-06-10 07:49:50 +00:00
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
2004-07-13 13:54:09 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2004-06-10 07:49:50 +00:00
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
2004-07-13 13:54:09 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2004-06-10 07:49:50 +00:00
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2004-06-10 07:49:50 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
2004-06-12 04:45:36 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstdio>
|
2004-01-21 07:07:16 +00:00
|
|
|
#include <unistd.h>
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
2004-04-15 20:42:15 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/tcp.h>
|
2004-06-12 04:45:36 +00:00
|
|
|
#include <arpa/inet.h>
|
2004-07-10 07:27:00 +00:00
|
|
|
#include <netdb.h>
|
2004-06-10 07:49:50 +00:00
|
|
|
#endif
|
2004-01-21 07:07:16 +00:00
|
|
|
|
|
|
|
#include "parse.h"
|
|
|
|
#include "error_numbers.h"
|
2004-06-12 04:45:36 +00:00
|
|
|
#include "miofile.h"
|
2004-01-21 07:07:16 +00:00
|
|
|
#include "gui_rpc_client.h"
|
|
|
|
|
2004-07-02 03:20:17 +00:00
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
|
2004-07-10 07:27:00 +00:00
|
|
|
int RPC_CLIENT::init(char* host) {
|
2004-06-12 04:45:36 +00:00
|
|
|
int retval;
|
2004-04-15 20:42:15 +00:00
|
|
|
sockaddr_in addr;
|
|
|
|
addr.sin_family = AF_INET;
|
|
|
|
addr.sin_port = htons(GUI_RPC_PORT);
|
2004-07-10 07:27:00 +00:00
|
|
|
|
|
|
|
if (host) {
|
|
|
|
hostent* hep = gethostbyname(host);
|
|
|
|
if (!hep) {
|
|
|
|
perror("gethostbyname");
|
|
|
|
return ERR_GETHOSTBYNAME;
|
|
|
|
}
|
|
|
|
addr.sin_addr.s_addr = *(int*)hep->h_addr_list[0];
|
|
|
|
} else {
|
2004-06-14 17:58:37 +00:00
|
|
|
#ifdef _WIN32
|
2004-07-10 07:27:00 +00:00
|
|
|
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
|
2004-06-14 17:58:37 +00:00
|
|
|
#else
|
2004-07-10 07:27:00 +00:00
|
|
|
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
2004-06-14 17:58:37 +00:00
|
|
|
#endif
|
2004-07-10 07:27:00 +00:00
|
|
|
}
|
2004-04-15 20:42:15 +00:00
|
|
|
|
|
|
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
2004-06-12 04:45:36 +00:00
|
|
|
if (sock <= 0) {
|
|
|
|
perror("socket");
|
2004-07-10 07:27:00 +00:00
|
|
|
return ERR_SOCKET;
|
2004-06-12 04:45:36 +00:00
|
|
|
}
|
2004-01-21 07:07:16 +00:00
|
|
|
retval = connect(sock, (const sockaddr*)(&addr), sizeof(addr));
|
|
|
|
if (retval) {
|
2004-06-12 04:45:36 +00:00
|
|
|
#ifdef _WIN32
|
2004-06-10 21:58:57 +00:00
|
|
|
printf( "Windows Socket Error '%d'\n", WSAGetLastError() );
|
2004-06-12 04:45:36 +00:00
|
|
|
#endif
|
2004-01-21 07:07:16 +00:00
|
|
|
perror("connect");
|
2004-07-10 07:27:00 +00:00
|
|
|
return ERR_CONNECT;
|
2004-01-21 07:07:16 +00:00
|
|
|
}
|
2004-06-10 07:49:50 +00:00
|
|
|
return 0;
|
2004-01-21 07:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RPC_CLIENT::~RPC_CLIENT() {
|
2004-06-12 04:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int RPC_CLIENT::send_request(char* p) {
|
2004-07-10 07:27:00 +00:00
|
|
|
int n = send(sock, p, strlen(p), 0);
|
|
|
|
if (n < 0) return ERR_WRITE;
|
2004-06-12 18:44:53 +00:00
|
|
|
return 0;
|
2004-06-12 04:45:36 +00:00
|
|
|
}
|
|
|
|
|
2004-06-17 21:37:59 +00:00
|
|
|
// get reply from server. Caller must free buf
|
|
|
|
//
|
2004-06-12 04:45:36 +00:00
|
|
|
int RPC_CLIENT::get_reply(char*& mbuf) {
|
|
|
|
char buf[1025];
|
|
|
|
MFILE mf;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
n = recv(sock, buf, 1024, 0);
|
2004-07-10 07:27:00 +00:00
|
|
|
if (n <= 0) return ERR_READ;
|
2004-06-12 04:45:36 +00:00
|
|
|
buf[n]=0;
|
|
|
|
mf.puts(buf);
|
|
|
|
if (strchr(buf, '\003')) break;
|
|
|
|
}
|
|
|
|
mf.get_buf(mbuf, n);
|
2004-06-12 18:44:53 +00:00
|
|
|
return 0;
|
2004-01-21 07:07:16 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
int RPC_CLIENT::get_state(CC_STATE& state) {
|
2004-01-21 07:07:16 +00:00
|
|
|
char buf[256];
|
2004-01-23 21:57:47 +00:00
|
|
|
PROJECT* project;
|
2004-07-09 20:14:33 +00:00
|
|
|
char* mbuf=0;
|
2004-07-10 07:27:00 +00:00
|
|
|
int retval;
|
2004-06-12 04:45:36 +00:00
|
|
|
|
2004-07-10 07:27:00 +00:00
|
|
|
retval = send_request("<get_state/>\n");
|
|
|
|
if (retval) return retval;
|
|
|
|
retval = get_reply(mbuf);
|
|
|
|
if (retval) return retval;
|
2004-06-12 04:45:36 +00:00
|
|
|
MIOFILE fin;
|
|
|
|
fin.init_buf(mbuf);
|
2004-01-21 07:07:16 +00:00
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
while (fin.fgets(buf, 256)) {
|
2004-01-22 19:30:42 +00:00
|
|
|
if (match_tag(buf, "</client_state>")) break;
|
2004-01-23 21:57:47 +00:00
|
|
|
else if (match_tag(buf, "<project>")) {
|
|
|
|
project = new PROJECT;
|
|
|
|
project->parse(fin);
|
2004-07-13 23:51:09 +00:00
|
|
|
state.projects.push_back(project);
|
2004-01-23 21:57:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<app>")) {
|
|
|
|
APP* app = new APP;
|
|
|
|
app->parse(fin);
|
|
|
|
app->project = project;
|
2004-07-13 23:51:09 +00:00
|
|
|
state.apps.push_back(app);
|
2004-01-23 21:57:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<app_version>")) {
|
|
|
|
APP_VERSION* app_version = new APP_VERSION;
|
|
|
|
app_version->parse(fin);
|
|
|
|
app_version->project = project;
|
2004-07-13 23:51:09 +00:00
|
|
|
app_version->app = state.lookup_app(app_version->app_name);
|
|
|
|
state.app_versions.push_back(app_version);
|
2004-01-23 21:57:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<workunit>")) {
|
|
|
|
WORKUNIT* wu = new WORKUNIT;
|
|
|
|
wu->parse(fin);
|
|
|
|
wu->project = project;
|
2004-07-13 23:51:09 +00:00
|
|
|
wu->app = state.lookup_app(wu->app_name);
|
|
|
|
wu->avp = state.lookup_app_version(wu->app_name, wu->version_num);
|
|
|
|
state.wus.push_back(wu);
|
2004-01-23 21:57:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<result>")) {
|
|
|
|
RESULT* result = new RESULT;
|
|
|
|
result->parse(fin);
|
|
|
|
result->project = project;
|
2004-07-13 23:51:09 +00:00
|
|
|
result->wup = state.lookup_wu(result->wu_name);
|
2004-01-23 21:57:47 +00:00
|
|
|
result->app = result->wup->app;
|
2004-07-13 23:51:09 +00:00
|
|
|
state.results.push_back(result);
|
2004-01-23 21:57:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
2004-07-13 23:51:09 +00:00
|
|
|
}
|
|
|
|
if (mbuf) free(mbuf);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RPC_CLIENT::get_file_transfers(FILE_TRANSFERS& t) {
|
|
|
|
char buf[256];
|
|
|
|
char* mbuf=0;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
retval = send_request("<get_file_transfers/>\n");
|
|
|
|
if (retval) return retval;
|
|
|
|
retval = get_reply(mbuf);
|
|
|
|
if (retval) return retval;
|
|
|
|
MIOFILE fin;
|
|
|
|
fin.init_buf(mbuf);
|
|
|
|
|
|
|
|
while (fin.fgets(buf, 256)) {
|
|
|
|
if (match_tag(buf, "</file_transfers>")) break;
|
|
|
|
else if (match_tag(buf, "<file_transfer>")) {
|
|
|
|
FILE_TRANSFER* fip = new FILE_TRANSFER;
|
2004-01-23 21:57:47 +00:00
|
|
|
fip->parse(fin);
|
2004-07-13 23:51:09 +00:00
|
|
|
t.file_transfers.push_back(fip);
|
2004-01-23 21:57:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
2004-07-13 23:51:09 +00:00
|
|
|
}
|
|
|
|
if (mbuf) free(mbuf);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RPC_CLIENT::get_results(RESULTS& t) {
|
|
|
|
char buf[256];
|
|
|
|
char* mbuf=0;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
retval = send_request("<get_results/>\n");
|
|
|
|
if (retval) return retval;
|
|
|
|
retval = get_reply(mbuf);
|
|
|
|
if (retval) return retval;
|
|
|
|
MIOFILE fin;
|
|
|
|
fin.init_buf(mbuf);
|
|
|
|
|
|
|
|
while (fin.fgets(buf, 256)) {
|
|
|
|
if (match_tag(buf, "</results>")) break;
|
|
|
|
else if (match_tag(buf, "<result>")) {
|
|
|
|
RESULT* rp = new RESULT;
|
|
|
|
rp->parse(fin);
|
|
|
|
t.results.push_back(rp);
|
2004-01-31 23:21:07 +00:00
|
|
|
continue;
|
|
|
|
}
|
2004-01-23 21:57:47 +00:00
|
|
|
}
|
2004-06-17 21:37:59 +00:00
|
|
|
if (mbuf) free(mbuf);
|
2004-01-23 21:57:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-19 19:40:06 +00:00
|
|
|
int RPC_CLIENT::show_graphics(char* project, char* result_name, bool full_screen) {
|
2004-07-09 20:14:33 +00:00
|
|
|
char buf[256];
|
|
|
|
char* mbuf=0;
|
2004-07-10 07:27:00 +00:00
|
|
|
int retval;
|
|
|
|
|
2004-07-19 19:40:06 +00:00
|
|
|
if (project) {
|
2004-07-09 20:14:33 +00:00
|
|
|
sprintf(buf, "<result_show_graphics>\n"
|
2004-07-19 19:40:06 +00:00
|
|
|
"<project_url>%s</project_url>\n"
|
2004-07-09 20:14:33 +00:00
|
|
|
"<result_name>%s</result_name>\n"
|
|
|
|
"%s"
|
|
|
|
"</result_show_graphics>\n",
|
|
|
|
result_name,
|
|
|
|
full_screen?"<full_screen/>\n":""
|
|
|
|
);
|
|
|
|
} else {
|
2004-08-03 14:02:13 +00:00
|
|
|
sprintf(buf,
|
|
|
|
"<result_show_graphics>\n%s</result_show_graphics>\n",
|
|
|
|
full_screen?"<full_screen/>\n":""
|
|
|
|
);
|
2004-07-09 20:14:33 +00:00
|
|
|
}
|
2004-07-10 07:27:00 +00:00
|
|
|
retval = send_request(buf);
|
|
|
|
if (retval) return retval;
|
|
|
|
retval = get_reply(mbuf);
|
|
|
|
if (retval) return retval;
|
2004-07-09 20:14:33 +00:00
|
|
|
if (mbuf) free(mbuf);
|
2004-04-02 00:19:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-09 20:14:33 +00:00
|
|
|
int RPC_CLIENT::project_reset(char* url) {
|
|
|
|
char buf[256];
|
|
|
|
char* mbuf=0;
|
2004-07-10 07:27:00 +00:00
|
|
|
int retval;
|
|
|
|
|
2004-07-09 20:14:33 +00:00
|
|
|
sprintf(buf,
|
|
|
|
"<project_reset>\n"
|
|
|
|
" <project_url>%s</project_url>\n"
|
|
|
|
"</project_reset>\n",
|
|
|
|
url
|
|
|
|
);
|
2004-07-10 07:27:00 +00:00
|
|
|
retval = send_request(buf);
|
|
|
|
if (retval) return retval;
|
|
|
|
retval = get_reply(mbuf);
|
|
|
|
if (retval) return retval;
|
2004-07-09 20:14:33 +00:00
|
|
|
if (mbuf) free(mbuf);
|
2004-04-02 00:19:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RPC_CLIENT::project_attach(char* url, char* auth) {
|
2004-07-09 20:14:33 +00:00
|
|
|
char buf[256];
|
|
|
|
char* mbuf=0;
|
2004-07-10 07:27:00 +00:00
|
|
|
int retval;
|
|
|
|
|
2004-07-09 20:14:33 +00:00
|
|
|
sprintf(buf,
|
|
|
|
"<project_attach>\n"
|
|
|
|
" <project_url>%s</project_url>\n"
|
|
|
|
" <authenticator>%s</authenticator>\n"
|
|
|
|
"</project_attach>\n",
|
|
|
|
url, auth
|
|
|
|
);
|
2004-07-10 07:27:00 +00:00
|
|
|
retval = send_request(buf);
|
|
|
|
if (retval) return retval;
|
|
|
|
retval = get_reply(mbuf);
|
|
|
|
if (retval) return retval;
|
2004-07-09 20:14:33 +00:00
|
|
|
if (mbuf) free(mbuf);
|
2004-04-02 00:19:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-09 20:14:33 +00:00
|
|
|
int RPC_CLIENT::project_detach(char* url) {
|
|
|
|
char buf[256];
|
|
|
|
char* mbuf=0;
|
2004-07-10 07:27:00 +00:00
|
|
|
int retval;
|
|
|
|
|
2004-07-09 20:14:33 +00:00
|
|
|
sprintf(buf,
|
|
|
|
"<project_detach>\n"
|
|
|
|
" <project_url>%s</project_url>\n"
|
|
|
|
"</project_detach>\n",
|
|
|
|
url
|
|
|
|
);
|
2004-07-10 07:27:00 +00:00
|
|
|
retval = send_request(buf);
|
|
|
|
if (retval) return retval;
|
|
|
|
retval = get_reply(mbuf);
|
|
|
|
if (retval) return retval;
|
2004-07-09 20:14:33 +00:00
|
|
|
if (mbuf) free(mbuf);
|
2004-04-02 00:19:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-09 20:14:33 +00:00
|
|
|
int RPC_CLIENT::project_update(char* url) {
|
|
|
|
char buf[256];
|
|
|
|
char* mbuf=0;
|
2004-07-10 07:27:00 +00:00
|
|
|
int retval;
|
|
|
|
|
2004-07-09 20:14:33 +00:00
|
|
|
sprintf(buf,
|
|
|
|
"<project_update>\n"
|
|
|
|
" <project_url>%s</project_url>\n"
|
|
|
|
"</project_update>\n",
|
|
|
|
url
|
|
|
|
);
|
2004-07-10 07:27:00 +00:00
|
|
|
retval = send_request(buf);
|
|
|
|
if (retval) return retval;
|
|
|
|
retval = get_reply(mbuf);
|
|
|
|
if (retval) return retval;
|
2004-07-09 20:14:33 +00:00
|
|
|
if (mbuf) free(mbuf);
|
2004-04-02 00:19:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RPC_CLIENT::set_run_mode(int mode) {
|
2004-07-08 17:59:46 +00:00
|
|
|
char *p, buf[256];
|
2004-07-09 20:14:33 +00:00
|
|
|
char* mbuf=0;
|
2004-07-10 07:27:00 +00:00
|
|
|
int retval;
|
|
|
|
|
2004-07-08 17:59:46 +00:00
|
|
|
switch (mode) {
|
|
|
|
case RUN_MODE_ALWAYS: p="<always/>"; break;
|
|
|
|
case RUN_MODE_NEVER: p="<never/>"; break;
|
|
|
|
case RUN_MODE_AUTO: p="<auto/>"; break;
|
|
|
|
}
|
|
|
|
sprintf(buf, "<set_run_mode>\n%s\n</set_run_mode>\n", p);
|
2004-07-10 07:27:00 +00:00
|
|
|
retval = send_request(buf);
|
|
|
|
if (retval) return retval;
|
|
|
|
retval = get_reply(mbuf);
|
|
|
|
if (retval) return retval;
|
2004-07-08 17:59:46 +00:00
|
|
|
if (mbuf) free(mbuf);
|
2004-04-02 00:19:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RPC_CLIENT::run_benchmarks() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RPC_CLIENT::set_proxy_settings(PROXY_INFO& pi) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RPC_CLIENT::get_messages(
|
2004-07-02 03:20:17 +00:00
|
|
|
int nmessages, int seqno, vector<MESSAGE_DESC>& msgs
|
2004-04-02 00:19:22 +00:00
|
|
|
) {
|
|
|
|
char buf[256];
|
2004-06-12 04:45:36 +00:00
|
|
|
char* mbuf;
|
2004-07-10 07:27:00 +00:00
|
|
|
int retval;
|
2004-06-12 04:45:36 +00:00
|
|
|
|
|
|
|
sprintf(buf,
|
2004-04-02 00:19:22 +00:00
|
|
|
"<get_messages>\n"
|
|
|
|
" <nmessages>%d</nmessages>\n"
|
2004-06-17 05:08:31 +00:00
|
|
|
" <seqno>%d</seqno>\n"
|
2004-04-02 00:19:22 +00:00
|
|
|
"</get_messages>\n",
|
2004-06-17 05:08:31 +00:00
|
|
|
nmessages, seqno
|
2004-04-02 00:19:22 +00:00
|
|
|
);
|
2004-07-10 07:27:00 +00:00
|
|
|
retval = send_request(buf);
|
|
|
|
if (retval) return retval;
|
|
|
|
|
|
|
|
retval = get_reply(mbuf);
|
|
|
|
if (retval) return retval;
|
2004-06-12 04:45:36 +00:00
|
|
|
MIOFILE fin;
|
|
|
|
fin.init_buf(mbuf);
|
|
|
|
|
|
|
|
while (fin.fgets(buf, 256)) {
|
2004-04-02 00:32:10 +00:00
|
|
|
puts(buf);
|
2004-04-02 00:19:22 +00:00
|
|
|
if (match_tag(buf, "<msgs>")) continue;
|
|
|
|
if (match_tag(buf, "</msgs>")) break;
|
|
|
|
if (match_tag(buf, "<msg>")) {
|
|
|
|
MESSAGE_DESC md;
|
2004-06-12 04:45:36 +00:00
|
|
|
while (fin.fgets(buf, 256)) {
|
2004-04-02 00:32:10 +00:00
|
|
|
puts(buf);
|
2004-04-02 00:19:22 +00:00
|
|
|
if (match_tag(buf, "</msg>")) break;
|
|
|
|
if (parse_str(buf, "<project>", md.project)) continue;
|
2004-06-12 05:44:28 +00:00
|
|
|
if (match_tag(buf, "<body>" )) {
|
|
|
|
copy_element_contents(fin, "</body>", md.body);
|
|
|
|
continue;
|
|
|
|
}
|
2004-04-02 00:19:22 +00:00
|
|
|
if (parse_int(buf, "<pri>", md.priority)) continue;
|
|
|
|
if (parse_int(buf, "<time>", md.timestamp)) continue;
|
|
|
|
}
|
|
|
|
msgs.push_back(md);
|
|
|
|
}
|
|
|
|
}
|
2004-06-17 21:37:59 +00:00
|
|
|
if (mbuf) free(mbuf);
|
2004-04-02 00:19:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
void CC_STATE::print() {
|
2004-01-23 21:57:47 +00:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
printf("======== Projects ========\n");
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
|
|
|
printf("%d) -----------\n", i+1);
|
|
|
|
projects[i]->print();
|
|
|
|
}
|
|
|
|
printf("\n======== Applications ========\n");
|
|
|
|
for (i=0; i<apps.size(); i++) {
|
|
|
|
printf("%d) -----------\n", i+1);
|
|
|
|
apps[i]->print();
|
|
|
|
}
|
|
|
|
printf("\n======== Application versions ========\n");
|
|
|
|
for (i=0; i<app_versions.size(); i++) {
|
|
|
|
printf("%d) -----------\n", i+1);
|
|
|
|
app_versions[i]->print();
|
|
|
|
}
|
|
|
|
printf("\n======== Workunits ========\n");
|
|
|
|
for (i=0; i<wus.size(); i++) {
|
|
|
|
printf("%d) -----------\n", i+1);
|
|
|
|
wus[i]->print();
|
|
|
|
}
|
|
|
|
printf("\n======== Results ========\n");
|
|
|
|
for (i=0; i<results.size(); i++) {
|
|
|
|
printf("%d) -----------\n", i+1);
|
|
|
|
results[i]->print();
|
|
|
|
}
|
2004-07-13 23:51:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RESULTS::print() {
|
|
|
|
unsigned int i;
|
|
|
|
printf("\n======== Results ========\n");
|
|
|
|
for (i=0; i<results.size(); i++) {
|
|
|
|
printf("%d) -----------\n", i+1);
|
|
|
|
results[i]->print();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FILE_TRANSFERS::print() {
|
|
|
|
unsigned int i;
|
|
|
|
printf("\n======== Files ========\n");
|
|
|
|
for (i=0; i<file_transfers.size(); i++) {
|
2004-01-31 23:21:07 +00:00
|
|
|
printf("%d) -----------\n", i+1);
|
2004-07-13 23:51:09 +00:00
|
|
|
file_transfers[i]->print();
|
2004-01-31 23:21:07 +00:00
|
|
|
}
|
2004-01-23 21:57:47 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
int FILE_TRANSFER::parse(MIOFILE& in) {
|
2004-01-23 21:57:47 +00:00
|
|
|
char buf[256];
|
2004-07-19 19:40:06 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2004-06-12 04:45:36 +00:00
|
|
|
while (in.fgets(buf, 256)) {
|
2004-07-13 23:51:09 +00:00
|
|
|
if (match_tag(buf, "</file_transfer>")) return 0;
|
2004-01-23 21:57:47 +00:00
|
|
|
else if (parse_str(buf, "<name>", name)) continue;
|
|
|
|
else if (match_tag(buf, "<generated_locally/>")) {
|
|
|
|
generated_locally = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<uploaded/>")) {
|
|
|
|
uploaded = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<upload_when_present/>")) {
|
|
|
|
upload_when_present = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<sticky/>")) {
|
|
|
|
sticky = true;
|
|
|
|
continue;
|
|
|
|
}
|
2004-01-31 23:21:07 +00:00
|
|
|
else if (match_tag(buf, "<persistent_file_xfer>")) {
|
|
|
|
pers_xfer_active = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<file_xfer>")) {
|
|
|
|
xfer_active = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (parse_int(buf, "<num_retries>", num_retries)) continue;
|
|
|
|
else if (parse_double(buf, "<bytes_xferred>", bytes_xferred)) continue;
|
|
|
|
else if (parse_double(buf, "<file_offset>", file_offset)) continue;
|
|
|
|
else if (parse_double(buf, "<xfer_speed>", xfer_speed)) continue;
|
|
|
|
else if (parse_str(buf, "<hostname>", hostname)) continue;
|
2004-01-23 21:57:47 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
void FILE_TRANSFER::print() {
|
2004-01-23 21:57:47 +00:00
|
|
|
printf(" name: %s\n", name.c_str());
|
|
|
|
printf(" generated locally: %s\n", generated_locally?"yes":"no");
|
|
|
|
printf(" uploaded: %s\n", uploaded?"yes":"no");
|
|
|
|
printf(" upload when present: %s\n", upload_when_present?"yes":"no");
|
|
|
|
printf(" sticky: %s\n", sticky?"yes":"no");
|
|
|
|
printf(" generated locally: %s\n", generated_locally?"yes":"no");
|
|
|
|
}
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int PROJECT::parse(MIOFILE& in) {
|
2004-01-23 21:57:47 +00:00
|
|
|
char buf[256];
|
2004-07-19 19:40:06 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2004-06-12 04:45:36 +00:00
|
|
|
while (in.fgets(buf, 256)) {
|
2004-01-23 21:57:47 +00:00
|
|
|
if (match_tag(buf, "</project>")) return 0;
|
2004-07-19 19:40:06 +00:00
|
|
|
else if (parse_str(buf, "<master_url>", master_url)) continue;
|
|
|
|
else if (parse_double(buf, "<resource_share>", resource_share)) continue;
|
2004-01-23 21:57:47 +00:00
|
|
|
else if (parse_str(buf, "<project_name>", project_name)) continue;
|
|
|
|
else if (parse_str(buf, "<user_name>", user_name)) continue;
|
|
|
|
else if (parse_str(buf, "<team_name>", team_name)) continue;
|
|
|
|
else if (parse_double(buf, "<user_total_credit>", user_total_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<user_expavg_credit>", user_expavg_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<host_total_credit>", host_total_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<host_expavg_credit>", host_expavg_credit)) continue;
|
|
|
|
else if (parse_int(buf, "<nrpc_failures>", nrpc_failures)) continue;
|
|
|
|
else if (parse_int(buf, "<master_fetch_failures>", master_fetch_failures)) continue;
|
|
|
|
else if (parse_int(buf, "<min_rpc_time>", min_rpc_time)) continue;
|
|
|
|
else if (match_tag(buf, "<master_url_fetch_pending>")) {
|
|
|
|
master_url_fetch_pending = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<sched_rpc_pending>")) {
|
|
|
|
sched_rpc_pending = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<tentative>")) {
|
|
|
|
tentative = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PROJECT::print() {
|
|
|
|
printf(" name: %s\n", project_name.c_str());
|
|
|
|
printf(" master URL: %s\n", master_url.c_str());
|
|
|
|
printf(" user_name: %s\n", user_name.c_str());
|
|
|
|
printf(" team_name: %s\n", team_name.c_str());
|
|
|
|
printf(" resource share: %f\n", resource_share);
|
|
|
|
printf(" user_total_credit: %f\n", user_total_credit);
|
|
|
|
printf(" user_expavg_credit: %f\n", user_expavg_credit);
|
|
|
|
printf(" host_total_credit: %f\n", host_total_credit);
|
|
|
|
printf(" host_expavg_credit: %f\n", host_expavg_credit);
|
|
|
|
printf(" nrpc_failures: %d\n", nrpc_failures);
|
|
|
|
printf(" master_fetch_failures: %d\n", master_fetch_failures);
|
|
|
|
printf(" master fetch pending: %s\n", master_url_fetch_pending?"yes":"no");
|
|
|
|
printf(" scheduler RPC pending: %s\n", sched_rpc_pending?"yes":"no");
|
|
|
|
printf(" tentative: %s\n", tentative?"yes":"no");
|
|
|
|
}
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int APP::parse(MIOFILE& in) {
|
2004-01-23 21:57:47 +00:00
|
|
|
char buf[256];
|
2004-07-19 19:40:06 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2004-06-12 04:45:36 +00:00
|
|
|
while (in.fgets(buf, 256)) {
|
2004-01-23 21:57:47 +00:00
|
|
|
if (match_tag(buf, "</app>")) return 0;
|
|
|
|
else if (parse_str(buf, "<name>", name)) continue;
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void APP::print() {
|
|
|
|
printf(" name: %s\n", name.c_str());
|
|
|
|
printf(" Project: %s\n", project->project_name.c_str());
|
|
|
|
}
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int APP_VERSION::parse(MIOFILE& in) {
|
2004-01-23 21:57:47 +00:00
|
|
|
char buf[256];
|
2004-07-19 19:40:06 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2004-06-12 04:45:36 +00:00
|
|
|
while (in.fgets(buf, 256)) {
|
2004-01-23 21:57:47 +00:00
|
|
|
if (match_tag(buf, "</app_version>")) return 0;
|
|
|
|
else if (parse_str(buf, "<app_name>", app_name)) continue;
|
|
|
|
else if (parse_int(buf, "<version_num>", version_num)) continue;
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void APP_VERSION::print() {
|
|
|
|
printf(" application: %s\n", app->name.c_str());
|
|
|
|
printf(" version: %.2f\n", version_num/100.0);
|
|
|
|
printf(" project: %s\n", project->project_name.c_str());
|
|
|
|
}
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int WORKUNIT::parse(MIOFILE& in) {
|
2004-01-23 21:57:47 +00:00
|
|
|
char buf[256];
|
2004-07-19 19:40:06 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2004-06-12 04:45:36 +00:00
|
|
|
while (in.fgets(buf, 256)) {
|
2004-01-23 21:57:47 +00:00
|
|
|
if (match_tag(buf, "</workunit>")) return 0;
|
|
|
|
else if (parse_str(buf, "<name>", name)) continue;
|
|
|
|
else if (parse_str(buf, "<app_name>", app_name)) continue;
|
|
|
|
else if (parse_int(buf, "<version_num>", version_num)) continue;
|
|
|
|
else if (parse_double(buf, "<rsc_fpops_est>", rsc_fpops_est)) continue;
|
|
|
|
else if (parse_double(buf, "<rsc_fpops_bound>", rsc_fpops_bound)) continue;
|
|
|
|
else if (parse_double(buf, "<rsc_memory_bound>", rsc_memory_bound)) continue;
|
|
|
|
else if (parse_double(buf, "<rsc_disk_bound>", rsc_disk_bound)) continue;
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WORKUNIT::print() {
|
|
|
|
printf(" name: %s\n", name.c_str());
|
|
|
|
printf(" FP estimate: %f\n", rsc_fpops_est);
|
|
|
|
printf(" FP bound: %f\n", rsc_fpops_bound);
|
|
|
|
printf(" memory bound: %f\n", rsc_memory_bound);
|
|
|
|
printf(" disk bound: %f\n", rsc_disk_bound);
|
|
|
|
}
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int RESULT::parse(MIOFILE& in) {
|
2004-01-23 21:57:47 +00:00
|
|
|
char buf[256];
|
2004-07-19 19:40:06 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2004-06-12 04:45:36 +00:00
|
|
|
while (in.fgets(buf, 256)) {
|
2004-01-23 21:57:47 +00:00
|
|
|
if (match_tag(buf, "</result>")) return 0;
|
|
|
|
else if (parse_str(buf, "<name>", name)) continue;
|
|
|
|
else if (parse_str(buf, "<wu_name>", wu_name)) continue;
|
|
|
|
else if (parse_int(buf, "<report_deadline>", report_deadline)) continue;
|
|
|
|
else if (match_tag(buf, "<ready_to_report>")) {
|
|
|
|
ready_to_report = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (match_tag(buf, "<got_server_ack>")) {
|
|
|
|
got_server_ack = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (parse_double(buf, "<final_cpu_time>", final_cpu_time)) continue;
|
|
|
|
else if (parse_int(buf, "<state>", state)) continue;
|
|
|
|
else if (parse_int(buf, "<exit_status>", exit_status)) continue;
|
|
|
|
else if (parse_int(buf, "<signal>", signal)) continue;
|
|
|
|
else if (parse_int(buf, "<active_task_state>", active_task_state)) continue;
|
|
|
|
else if (match_tag(buf, "<stderr_out>")) {
|
|
|
|
copy_element_contents(in, "</stderr_out>", stderr_out);
|
|
|
|
}
|
2004-07-14 00:53:12 +00:00
|
|
|
else if (parse_int(buf, "<app_version_num>", app_version_num)) continue;
|
|
|
|
else if (parse_double(buf, "<checkpoint_cpu_time>", checkpoint_cpu_time)) continue;
|
|
|
|
else if (parse_double(buf, "<current_cpu_time>", current_cpu_time)) continue;
|
|
|
|
else if (parse_double(buf, "<fraction_done>", fraction_done)) continue;
|
2004-01-23 21:57:47 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RESULT::print() {
|
|
|
|
printf(" name: %s\n", name.c_str());
|
|
|
|
printf(" WU name: %s\n", wup->name.c_str());
|
|
|
|
printf(" ready to report: %s\n", ready_to_report?"yes":"no");
|
|
|
|
printf(" got server ack: %s\n", got_server_ack?"yes":"no");
|
|
|
|
printf(" final CPU time: %f\n", final_cpu_time);
|
|
|
|
printf(" state: %d\n", state);
|
|
|
|
printf(" exit_status: %d\n", exit_status);
|
|
|
|
printf(" signal: %d\n", signal);
|
|
|
|
printf(" active_task_state: %d\n", active_task_state);
|
|
|
|
printf(" stderr_out: %s\n", stderr_out.c_str());
|
2004-01-31 23:21:07 +00:00
|
|
|
printf(" app version num: %d\n", app_version_num);
|
|
|
|
printf(" checkpoint CPU time: %f\n", checkpoint_cpu_time);
|
|
|
|
printf(" current CPU time: %f\n", current_cpu_time);
|
|
|
|
printf(" fraction done: %f\n", fraction_done);
|
|
|
|
}
|
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
APP* CC_STATE::lookup_app(string& str) {
|
2004-01-23 21:57:47 +00:00
|
|
|
unsigned int i;
|
|
|
|
for (i=0; i<apps.size(); i++) {
|
|
|
|
if (apps[i]->name == str) return apps[i];
|
|
|
|
}
|
|
|
|
printf("CAN'T FIND APP %s\n", str.c_str());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
WORKUNIT* CC_STATE::lookup_wu(string& str) {
|
2004-01-23 21:57:47 +00:00
|
|
|
unsigned int i;
|
|
|
|
for (i=0; i<wus.size(); i++) {
|
|
|
|
if (wus[i]->name == str) return wus[i];
|
|
|
|
}
|
|
|
|
printf("CAN'T FIND WU %s\n", str.c_str());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
RESULT* CC_STATE::lookup_result(string& str) {
|
2004-01-31 23:21:07 +00:00
|
|
|
unsigned int i;
|
|
|
|
for (i=0; i<results.size(); i++) {
|
|
|
|
if (results[i]->name == str) return results[i];
|
|
|
|
}
|
|
|
|
printf("CAN'T FIND RESULT %s\n", str.c_str());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
APP_VERSION* CC_STATE::lookup_app_version(string& str, int version_num) {
|
2004-01-23 21:57:47 +00:00
|
|
|
unsigned int i;
|
|
|
|
for (i=0; i<app_versions.size(); i++) {
|
|
|
|
if (app_versions[i]->app_name == str && app_versions[i]->version_num == version_num) return app_versions[i];
|
2004-01-21 07:07:16 +00:00
|
|
|
}
|
2004-01-22 19:30:42 +00:00
|
|
|
return 0;
|
2004-01-21 07:07:16 +00:00
|
|
|
}
|
2004-06-10 07:49:50 +00:00
|
|
|
|