r587 - in /branches/experimental/boinc: client/
client/client_state.h debian/changelog lib/ lib/boinc_cmd.C
fst-guest at users.alioth.debian.org
fst-guest at users.alioth.debian.org
Fri Mar 9 23:37:12 CET 2007
Author: fst-guest
Date: Fri Mar 9 22:37:11 2007
New Revision: 587
URL: http://svn.debian.org/wsvn/pkg-boinc/?sc=1&rev=587
Log:
Fixed the FTBFS with GCC 4.3 bug.
Added:
branches/experimental/boinc/client/
branches/experimental/boinc/client/client_state.h
branches/experimental/boinc/lib/
branches/experimental/boinc/lib/boinc_cmd.C
Modified:
branches/experimental/boinc/debian/changelog
Added: branches/experimental/boinc/client/client_state.h
URL: http://svn.debian.org/wsvn/pkg-boinc/branches/experimental/boinc/client/client_state.h?rev=587&op=file
==============================================================================
--- branches/experimental/boinc/client/client_state.h (added)
+++ branches/experimental/boinc/client/client_state.h Fri Mar 9 22:37:11 2007
@@ -1,0 +1,463 @@
+// Berkeley Open Infrastructure for Network Computing
+// http://boinc.berkeley.edu
+// Copyright (C) 2005 University of California
+//
+// This is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation;
+// either version 2.1 of the License, or (at your option) any later version.
+//
+// This software is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU Lesser General Public License for more details.
+//
+// To view the GNU Lesser General Public License visit
+// http://www.gnu.org/copyleft/lesser.html
+// or write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#ifndef _CLIENT_STATE_
+#define _CLIENT_STATE_
+
+#ifndef _WIN32
+#include <string>
+#include <vector>
+#include <ctime>
+#endif
+
+using std::string;
+using std::vector;
+
+#include "acct_mgr.h"
+#include "acct_setup.h"
+#include "app.h"
+#include "client_types.h"
+#include "file_xfer.h"
+#include "gui_rpc_server.h"
+#include "gui_http.h"
+#include "hostinfo.h"
+#include "miofile.h"
+#include "net_stats.h"
+#include "pers_file_xfer.h"
+#include "prefs.h"
+#include "scheduler_op.h"
+#include "ss_logic.h"
+#include "time_stats.h"
+#include "http_curl.h"
+
+#define WORK_FETCH_DONT_NEED 0
+ // project: suspended, deferred, or no new work (can't ask for more work)
+ // overall: not work_fetch_ok (from CPU policy)
+#define WORK_FETCH_OK 1
+ // project: has more than min queue * share, not suspended/def/nonewwork
+ // overall: at least min queue, work fetch OK
+#define WORK_FETCH_NEED 2
+ // project: less than min queue * resource share of DL/runnable results
+ // overall: less than min queue
+#define WORK_FETCH_NEED_IMMEDIATELY 3
+ // project: no downloading or runnable results
+ // overall: at least one idle CPU
+
+// CLIENT_STATE encapsulates the global variables of the core client.
+// If you add anything here, initialize it in the constructor
+//
+class CLIENT_STATE {
+public:
+ vector<PROJECT*> projects;
+ vector<APP*> apps;
+ vector<FILE_INFO*> file_infos;
+ vector<APP_VERSION*> app_versions;
+ vector<WORKUNIT*> workunits;
+ vector<RESULT*> results;
+
+ PERS_FILE_XFER_SET* pers_file_xfers;
+ HTTP_OP_SET* http_ops;
+ FILE_XFER_SET* file_xfers;
+ ACTIVE_TASK_SET active_tasks;
+ HOST_INFO host_info;
+ GLOBAL_PREFS global_prefs;
+ NET_STATS net_stats;
+ SS_LOGIC ss_logic;
+ GUI_RPC_CONN_SET gui_rpcs;
+ TIME_STATS time_stats;
+ PROXY_INFO proxy_info;
+ GUI_HTTP gui_http;
+
+ VERSION_INFO core_client_version;
+ string statefile_platform_name;
+ int file_xfer_giveup_period;
+ MODE run_mode;
+ MODE network_mode;
+ bool started_by_screensaver;
+ bool exit_when_idle;
+ bool check_all_logins;
+ bool user_active; // there has been recent mouse/kbd input
+ bool return_results_immediately;
+ bool allow_remote_gui_rpc;
+ int cmdline_gui_rpc_port;
+ bool show_projects;
+ bool requested_exit;
+ char detach_project_url[256];
+ // stores URL for -detach_project option
+ char reset_project_url[256];
+ // stores URL for -reset_project option
+ char update_prefs_url[256];
+ // stores URL for -update_prefs option
+ char main_host_venue[256];
+ // venue from project that gave us general prefs
+ // or from account manager
+ char attach_project_url[256];
+ char attach_project_auth[256];
+ bool exit_before_upload;
+ // exit when about to upload a file
+#ifndef _WIN32
+ gid_t boinc_project_gid;
+#endif
+
+ // backoff-related variables
+ //
+ int master_fetch_period;
+ // fetch project's master URL (and stop doing scheduler RPCs)
+ // if get this many successive RPC failures (default 10)
+ int retry_cap;
+ // cap project->nrpc_failures at this number
+ int master_fetch_retry_cap;
+ // after this many master-fetch failures,
+ // move into a state in which we retry master fetch
+ // at the frequency below
+ int master_fetch_interval;
+ // see above
+
+ int sched_retry_delay_min;
+ int sched_retry_delay_max;
+ int pers_retry_delay_min;
+ int pers_retry_delay_max;
+ int pers_giveup;
+
+ bool tasks_suspended;
+ // Don't do CPU. See check_suspend_activities for logic
+ bool network_suspended;
+ // Don't do network. See check_suspend_network for logic
+ int suspend_reason;
+ int network_suspend_reason;
+ bool executing_as_daemon;
+ // true if --daemon is on the commandline
+ // this means we are running as a daemon on unix,
+ // or as a service on Windows
+ bool redirect_io;
+ // redirect stdout, stderr to log files
+ bool disable_graphics;
+ // a condition has occurred in which we know graphics will
+ // not be displayable.
+ // So GUIs shouldn't offer graphics.
+ bool detach_console;
+ bool launched_by_manager;
+ // this affects auto-update
+ double now;
+ const char* platform_name;
+ bool initialized;
+
+private:
+ bool client_state_dirty;
+ int old_major_version;
+ int old_minor_version;
+ int old_release;
+ bool skip_cpu_benchmarks;
+ // if set, use hardwired numbers rather than running benchmarks
+ bool run_cpu_benchmarks;
+ // if set, run benchmarks on client startup
+ bool cpu_benchmarks_pending;
+ // set if a benchmark fails to start because of a process that doesn't stop.
+ // Persists so that the next start of BOINC runs the benchmarks.
+
+ int exit_after_app_start_secs;
+ // if nonzero, exit this many seconds after starting an app
+ double app_started;
+ // when the most recent app was started
+
+// --------------- acct_mgr.C:
+public:
+ ACCT_MGR_OP acct_mgr_op;
+ ACCT_MGR_INFO acct_mgr_info;
+
+// --------------- acct_setup.C:
+public:
+ PROJECT_INIT project_init;
+ GET_PROJECT_CONFIG_OP get_project_config_op;
+ LOOKUP_ACCOUNT_OP lookup_account_op;
+ CREATE_ACCOUNT_OP create_account_op;
+ LOOKUP_WEBSITE_OP lookup_website_op;
+ PROJECT_ATTACH project_attach;
+ GET_CURRENT_VERSION_OP get_current_version_op;
+ void new_version_check();
+ double new_version_check_time;
+ string newer_version;
+
+// --------------- app_graphics.C:
+public:
+ ACTIVE_TASK* get_next_graphics_capable_app();
+
+// --------------- auto_update.C:
+public:
+ AUTO_UPDATE auto_update;
+
+// --------------- client_state.C:
+public:
+ CLIENT_STATE();
+ void show_host_info();
+ int init();
+ bool poll_slow_events();
+ // Never blocks.
+ // Returns true if it actually did something,
+ // in which case it should be called again immediately.
+ void do_io_or_sleep(double dt);
+ bool time_to_exit();
+ PROJECT* lookup_project(const char*);
+ APP* lookup_app(PROJECT*, const char*);
+ FILE_INFO* lookup_file_info(PROJECT*, const char* name);
+ RESULT* lookup_result(PROJECT*, const char*);
+ WORKUNIT* lookup_workunit(PROJECT*, const char*);
+ APP_VERSION* lookup_app_version(APP*, int);
+ int detach_project(PROJECT*);
+ int report_result_error(RESULT&, const char *format, ...);
+ int reset_project(PROJECT*);
+ bool have_tentative_project();
+ bool have_nontentative_project();
+ bool no_gui_rpc;
+private:
+ int link_app(PROJECT*, APP*);
+ int link_file_info(PROJECT*, FILE_INFO*);
+ int link_file_ref(PROJECT*, FILE_REF*);
+ int link_app_version(PROJECT*, APP_VERSION*);
+ int link_workunit(PROJECT*, WORKUNIT*);
+ int link_result(PROJECT*, RESULT*);
+ void print_summary();
+ bool garbage_collect();
+ bool garbage_collect_always();
+ bool update_results();
+ int nresults_for_project(PROJECT*);
+
+// --------------- cpu_sched.C:
+private:
+ double debt_interval_start;
+ double total_wall_cpu_time_this_debt_interval;
+ // "wall CPU time" accumulated since last adjust_debts()
+ double total_cpu_time_this_debt_interval;
+ double cpu_shortfall;
+ bool work_fetch_no_new_work;
+ bool must_enforce_cpu_schedule;
+ bool must_schedule_cpus;
+ bool must_check_work_fetch;
+ std::vector <RESULT*> ordered_scheduled_results;
+ void assign_results_to_projects();
+ RESULT* largest_debt_project_best_result();
+ RESULT* earliest_deadline_result();
+ void adjust_debts();
+ bool possibly_schedule_cpus();
+ void schedule_cpus();
+ bool enforce_schedule();
+ bool no_work_for_a_cpu();
+ void rr_simulation();
+ void make_running_task_heap(vector<ACTIVE_TASK*>&);
+ void print_deadline_misses();
+ inline double work_buf_min() {
+ return global_prefs.work_buf_min_days * 86400;
+ }
+public:
+ void request_enforce_schedule(const char*);
+ void request_schedule_cpus(const char*);
+ // Check for reschedule CPUs ASAP. Called when:
+ // - core client starts (CS::init())
+ // - an app exits (ATS::check_app_exited())
+ // - Tasks are killed (ATS::exit_tasks())
+ // - a result's input files finish downloading (CS::update_results())
+ // - an app fails to start (CS::schedule_cpus())
+ // - any project op is done via RPC (suspend/resume)
+ // - any result op is done via RPC (suspend/resume)
+
+// --------------- cs_account.C:
+public:
+ int add_project(
+ const char* master_url, const char* authenticator,
+ const char* project_name, bool attached_via_acct_mgr
+ );
+private:
+ int parse_account_files();
+ int parse_account_files_venue();
+ int parse_preferences_for_user_files();
+ int parse_statistics_files();
+ // should be move to a new file, but this will do it for testing
+
+// --------------- cs_apps.C:
+private:
+ double total_resource_share();
+ double potentially_runnable_resource_share();
+ double nearly_runnable_resource_share();
+public:
+ double runnable_resource_share();
+ void request_work_fetch(const char*);
+ // Check if work fetch needed. Called when:
+ // - core client starts (CS::init())
+ // - task is completed or fails
+ // - tasks are killed
+ // - an RPC completes
+ // - project suspend/detch/attach/reset GUI RPC
+ // - result suspend/abort GUI RPC
+ int quit_activities();
+ void set_ncpus();
+ double estimate_cpu_time(WORKUNIT&);
+ double get_fraction_done(RESULT* result);
+ int input_files_available(RESULT*, bool);
+ ACTIVE_TASK* lookup_active_task_by_result(RESULT*);
+ int ncpus;
+ // number of usable cpus
+private:
+ int nslots;
+
+ int choose_version_num(WORKUNIT*, SCHEDULER_REPLY&);
+ int app_finished(ACTIVE_TASK&);
+ bool start_apps();
+ bool handle_finished_apps();
+public:
+ ACTIVE_TASK* get_task(RESULT*);
+
+// --------------- cs_benchmark.C:
+public:
+ bool should_run_cpu_benchmarks();
+ void start_cpu_benchmarks();
+ bool cpu_benchmarks_poll();
+ void abort_cpu_benchmarks();
+ bool are_cpu_benchmarks_running();
+ bool cpu_benchmarks_done();
+ void cpu_benchmarks_set_defaults();
+ void print_benchmark_results();
+
+// --------------- cs_cmdline.C:
+public:
+ void parse_cmdline(int argc, char** argv);
+ void parse_env_vars();
+ void do_cmdline_actions();
+
+// --------------- cs_files.C:
+public:
+ void check_file_existence();
+ bool start_new_file_xfer(PERS_FILE_XFER&);
+private:
+ int make_project_dirs();
+ bool handle_pers_file_xfers();
+
+// --------------- cs_prefs.C:
+public:
+ int project_disk_usage(PROJECT*, double&);
+ int total_disk_usage(double&);
+ // returns the total disk usage of BOINC on this host
+ int allowed_disk_usage(double&);
+ int allowed_project_disk_usage(double&);
+ int suspend_tasks(int reason);
+ int resume_tasks(int reason=0);
+ int suspend_network(int reason);
+ int resume_network();
+ void read_global_prefs();
+ int save_global_prefs(char* prefs, char* url, char* sched);
+ double available_ram();
+ double max_available_ram();
+private:
+ void check_suspend_activities(int&);
+ void check_suspend_network(int&);
+ void install_global_prefs();
+ PROJECT* global_prefs_source_project();
+ void show_global_prefs_source(bool);
+
+// --------------- cs_scheduler.C:
+public:
+ int make_scheduler_request(PROJECT*);
+ int handle_scheduler_reply(PROJECT*, char* scheduler_url, int& nresults);
+ SCHEDULER_OP* scheduler_op;
+private:
+ bool contacted_sched_server;
+ int overall_work_fetch_urgency;
+
+ bool scheduler_rpc_poll();
+ double avg_proc_rate();
+ bool should_get_work();
+
+// --------------- cs_statefile.C:
+public:
+ void set_client_state_dirty(const char*);
+ int parse_state_file();
+ int write_state(MIOFILE&);
+ int write_state_file();
+ int write_state_file_if_needed();
+ void check_anonymous();
+ int parse_app_info(PROJECT*, FILE*);
+ int write_state_gui(MIOFILE&);
+ int write_file_transfers_gui(MIOFILE&);
+ int write_tasks_gui(MIOFILE&);
+
+// --------------- cs_trickle.C:
+private:
+ int read_trickle_files(PROJECT*, FILE*);
+ int remove_trickle_files(PROJECT*);
+public:
+ int handle_trickle_down(PROJECT*, FILE*);
+
+// --------------- check_state.C:
+// stuff related to data-structure integrity checking
+//
+public:
+ void check_project_pointer(PROJECT*);
+ void check_app_pointer(APP*);
+ void check_file_info_pointer(FILE_INFO*);
+ void check_app_version_pointer(APP_VERSION*);
+ void check_workunit_pointer(WORKUNIT*);
+ void check_result_pointer(RESULT*);
+ void check_pers_file_xfer_pointer(PERS_FILE_XFER*);
+ void check_file_xfer_pointer(FILE_XFER*);
+
+ void check_app(APP&);
+ void check_file_info(FILE_INFO&);
+ void check_file_ref(FILE_REF&);
+ void check_app_version(APP_VERSION&);
+ void check_workunit(WORKUNIT&);
+ void check_result(RESULT&);
+ void check_active_task(ACTIVE_TASK&);
+ void check_pers_file_xfer(PERS_FILE_XFER&);
+ void check_file_xfer(FILE_XFER&);
+
+ void check_all();
+ void free_mem();
+
+// --------------- work_fetch.C:
+public:
+ int proj_min_results(PROJECT*, double);
+ void check_project_timeout();
+ PROJECT* next_project_master_pending();
+ PROJECT* next_project_sched_rpc_pending();
+ PROJECT* next_project_trickle_up_pending();
+ PROJECT* next_project_need_work();
+ PROJECT* find_project_with_overdue_results();
+ double overall_cpu_frac();
+ double time_until_work_done(PROJECT*, int, double);
+ bool compute_work_requests();
+ double work_needed_secs();
+ void scale_duration_correction_factors(double);
+ void generate_new_host_cpid();
+ void compute_nuploading_results();
+
+};
+
+extern CLIENT_STATE gstate;
+
+#ifdef SANDBOX
+#define BOINC_PROJECT_GROUP_NAME "boinc_project"
+#endif
+
+// return a random double in the range [MIN,min(e^n,MAX))
+//
+extern double calculate_exponential_backoff(
+ int n, double MIN, double MAX
+);
+
+#define POLL_INTERVAL 1.0
+#endif
Modified: branches/experimental/boinc/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-boinc/branches/experimental/boinc/debian/changelog?rev=587&op=diff
==============================================================================
--- branches/experimental/boinc/debian/changelog (original)
+++ branches/experimental/boinc/debian/changelog Fri Mar 9 22:37:11 2007
@@ -42,6 +42,8 @@
* Added ca-certificates to boinc-client's Depends field and create the
ca-bundle.crt symlink (which points to /etc/ssl/certs/ca-certificates) in
the BOINC data directory in boinc-client.postinst.
+ * Fixed FTBFS with GCC 4.3, thanks to Martin Michlmayr <tbm at cyrius.com>.
+ (closes: #413307)
[ Debconf translations ]
* Added Galician (gl.po) by Jacobo Tarrio <jtarrio at trasno.net>.
@@ -57,7 +59,7 @@
* debian/control: Added "csh | c-shell" to boinc-server's Depends field
since tools/db_query and tools/watch_tcp use /bin/csh as interpreter.
- -- Frank S. Thomas <frank at thomas-alfeld.de> Fri, 9 Mar 2007 20:28:53 +0100
+ -- Frank S. Thomas <frank at thomas-alfeld.de> Fri, 9 Mar 2007 23:35:19 +0100
boinc (5.4.11-4) unstable; urgency=low
Added: branches/experimental/boinc/lib/boinc_cmd.C
URL: http://svn.debian.org/wsvn/pkg-boinc/branches/experimental/boinc/lib/boinc_cmd.C?rev=587&op=file
==============================================================================
--- branches/experimental/boinc/lib/boinc_cmd.C (added)
+++ branches/experimental/boinc/lib/boinc_cmd.C Fri Mar 9 22:37:11 2007
@@ -1,0 +1,499 @@
+// Berkeley Open Infrastructure for Network Computing
+// http://boinc.berkeley.edu
+// Copyright (C) 2005 University of California
+//
+// This is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation;
+// either version 2.1 of the License, or (at your option) any later version.
+//
+// This software is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU Lesser General Public License for more details.
+//
+// To view the GNU Lesser General Public License visit
+// http://www.gnu.org/copyleft/lesser.html
+// or write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+// boinc_cmd: command-line interface to a BOINC core client,
+// using GUI RPCs.
+//
+// usage: boinc_cmd [--host hostname] [--passwd passwd] command
+//
+// See help() below for a list of commands.
+
+#if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_)
+#include "boinc_win.h"
+#endif
+
+#ifndef _WIN32
+#include "config.h"
+#include <cstdio>
+#include <unistd.h>
+#endif
+
+#include <vector>
+#include <string>
+using std::vector;
+using std::string;
+
+#include "gui_rpc_client.h"
+#include "error_numbers.h"
+#include "util.h"
+#include "version.h"
+#include "common_defs.h"
+
+
+void usage() {
+ fprintf(stderr, "\
+Usage: boinc_cmd [--host hostname] [--passwd passwd] command\n\
+Give --help as a command for a list of commands\n\
+");
+ exit(1);
+}
+
+void version(){
+ printf("boinc_cmd, built from %s \n", PACKAGE_STRING );
+ exit(0);
+}
+
+void help() {
+ fprintf(stderr, "\n\n\
+ usage: boinc_cmd [--host hostname] [--passwd passwd] command\n\n\
+Commands:\n\
+ --get_state show entire state\n\
+ --get_results show results\n\
+ --get_file_transfers show file transfers\n\
+ --get_project_status show status of all attached projects\n\
+ --get_simple_gui_info show status of projects and active results\n\
+ --get_disk_usage\n\
+ --result url result_name {suspend | resume | abort | graphics_window | graphics_fullscreen}\n\
+ --project url {reset | detach | update | suspend | resume | nomorework | allowmorework}\n\
+ --project_attach url auth\n\
+ --file_transfer url filename {retry | abort}\n\
+ --set_run_mode {always | auto | never} duration\n\
+ --set_network_mode {always | auto | never} duration\n\
+ --get_proxy_settings\n\
+ --set_proxy_settings\n\
+ --get_messages seqno show messages > seqno\n\
+ --get_host_info\n\
+ --acct_mgr_rpc url name password\n\
+ --run_benchmarks\n\
+ --get_screensaver_mode\n\
+ --set_screensaver_mode on|off blank_time {desktop window_station}\n\
+ --get_project_config url\n\
+ --get_project_config_poll\n\
+ --lookup_account url email passwd\n\
+ --create_account url email passwd name\n\
+ --quit\n\
+ ");
+ exit(1);
+}
+
+void parse_display_args(char** argv, int& i, DISPLAY_INFO& di) {
+ strcpy(di.window_station, "winsta0");
+ strcpy(di.desktop, "default");
+ strcpy(di.display, "");
+ while (argv[i]) {
+ if (!strcmp(argv[i], "--window_station")) {
+ strcpy(di.window_station, argv[++i]);
+ } else if (!strcpy(argv[i], "--desktop")) {
+ strcpy(di.desktop, argv[++i]);
+ } else if (!strcpy(argv[i], "--display")) {
+ strcpy(di.display, argv[++i]);
+ }
+ i++;
+ }
+}
+
+void show_error(int retval) {
+ fprintf(stderr, "Error %d: %s\n", retval, boincerror(retval));
+}
+
+char* next_arg(int argc, char** argv, int& i) {
+ if (i >= argc) {
+ fprintf(stderr, "Missing command-line argument\n");
+ help();
+ exit(1);
+ }
+ return argv[i++];
+}
+
+
+// If there's a password file, read it
+//
+void read_password_from_file(char* buf) {
+ FILE* f = fopen("gui_rpc_auth.cfg", "r");
+ if (!f) return;
+ fgets(buf, 256, f);
+ int n = (int)strlen(buf);
+
+ // trim CR
+ //
+ if (n && buf[n-1]=='\n') {
+ buf[n-1] = 0;
+ }
+ fclose(f);
+}
+
+int main(int argc, char** argv) {
+ RPC_CLIENT rpc;
+ int i, retval, port=0;
+ MESSAGES messages;
+ char passwd_buf[256], hostname_buf[256], *hostname=0;
+ char* passwd = passwd_buf, *p;
+
+ g_use_sandbox = false;
+
+ strcpy(passwd_buf, "");
+ read_password_from_file(passwd_buf);
+
+#if defined(_WIN32) && defined(USE_WINSOCK)
+ WSADATA wsdata;
+ retval = WSAStartup( MAKEWORD( 1, 1 ), &wsdata);
+ if (retval) {
+ fprintf(stderr, "WinsockInitialize: %d\n", retval);
+ exit(1);
+ }
+#endif
+ if (argc < 2) usage();
+ i = 1;
+ if (!strcmp(argv[i], "--help")) help();
+ if (!strcmp(argv[i], "-h")) help();
+ if (!strcmp(argv[i], "--version")) version();
+ if (!strcmp(argv[i], "-V")) version();
+
+ if (!strcmp(argv[i], "--host")) {
+ if (++i == argc) usage();
+ strcpy(hostname_buf, argv[i]);
+ hostname = hostname_buf;
+ p = strchr(hostname, ':');
+ if (p) {
+ port = atoi(p+1);
+ *p=0;
+ }
+ i++;
+ }
+ if ((i<argc)&& !strcmp(argv[i], "--passwd")) {
+ if (++i == argc) usage();
+ passwd = argv[i];
+ i++;
+ }
+
+ // change the following to debug GUI RPC's asynchronous connection mechanism
+ //
+#if 1
+ retval = rpc.init(hostname, port);
+ if (retval) {
+ fprintf(stderr, "can't connect to %s\n", hostname?hostname:"local host");
+ exit(1);
+ }
+#else
+ retval = rpc.init_asynch(hostname, 60., false);
+ while (1) {
+ retval = rpc.init_poll();
+ if (!retval) break;
+ if (retval == ERR_RETRY) {
+ printf("sleeping\n");
+ sleep(1);
+ continue;
+ }
+ fprintf(stderr, "can't connect: %d\n", retval);
+ exit(1);
+ }
+ printf("connected\n");
+#endif
+
+ if (passwd) {
+ retval = rpc.authorize(passwd);
+ if (retval) {
+ fprintf(stderr, "Authorization failure: %d\n", retval);
+ exit(1);
+ }
+ }
+
+ char* cmd = next_arg(argc, argv, i);
+ if (!strcmp(cmd, "--get_state")) {
+ CC_STATE state;
+ retval = rpc.get_state(state);
+ if (!retval) state.print();
+ } else if (!strcmp(cmd, "--get_results")) {
+ RESULTS results;
+ retval = rpc.get_results(results);
+ if (!retval) results.print();
+ } else if (!strcmp(cmd, "--get_file_transfers")) {
+ FILE_TRANSFERS ft;
+ retval = rpc.get_file_transfers(ft);
+ if (!retval) ft.print();
+ } else if (!strcmp(cmd, "--get_project_status")) {
+ PROJECTS ps;
+ retval = rpc.get_project_status(ps);
+ if (!retval) ps.print();
+ } else if (!strcmp(cmd, "--get_simple_gui_info")) {
+ SIMPLE_GUI_INFO sgi;
+ retval = rpc.get_simple_gui_info(sgi);
+ if (!retval) sgi.print();
+ } else if (!strcmp(cmd, "--get_disk_usage")) {
+ DISK_USAGE du;
+ retval = rpc.get_disk_usage(du);
+ if (!retval) du.print();
+ } else if (!strcmp(cmd, "--result")) {
+ RESULT result;
+ char* project_url = next_arg(argc, argv, i);
+ result.project_url = project_url;
+ char* name = next_arg(argc, argv, i);
+ result.name = name;
+ char* op = next_arg(argc, argv, i);
+ if (!strcmp(op, "suspend")) {
+ retval = rpc.result_op(result, "suspend");
+ } else if (!strcmp(op, "resume")) {
+ retval = rpc.result_op(result, "resume");
+ } else if (!strcmp(op, "abort")) {
+ retval = rpc.result_op(result, "abort");
+ } else if (!strcmp(op, "graphics_window")) {
+ DISPLAY_INFO di;
+ parse_display_args(argv, i, di);
+ retval = rpc.show_graphics(project_url, name, MODE_WINDOW, di);
+ } else if (!strcmp(op, "graphics_fullscreen")) {
+ DISPLAY_INFO di;
+ parse_display_args(argv, i, di);
+ retval = rpc.show_graphics(project_url, name, MODE_FULLSCREEN, di);
+ } else {
+ fprintf(stderr, "Unknown op %s\n", op);
+ }
+ } else if (!strcmp(cmd, "--project")) {
+ PROJECT project;
+ project.master_url = next_arg(argc, argv, i);
+ char* op = next_arg(argc, argv, i);
+ if (!strcmp(op, "reset")) {
+ retval = rpc.project_op(project, "reset");
+ } else if (!strcmp(op, "suspend")) {
+ retval = rpc.project_op(project, "suspend");
+ } else if (!strcmp(op, "resume")) {
+ retval = rpc.project_op(project, "resume");
+ } else if (!strcmp(op, "detach")) {
+ retval = rpc.project_op(project, "detach");
+ } else if (!strcmp(op, "update")) {
+ retval = rpc.project_op(project, "update");
+ } else if (!strcmp(op, "suspend")) {
+ retval = rpc.project_op(project, "suspend");
+ } else if (!strcmp(op, "resume")) {
+ retval = rpc.project_op(project, "resume");
+ } else if (!strcmp(op, "nomorework")) {
+ retval = rpc.project_op(project, "nomorework");
+ } else if (!strcmp(op, "allowmorework")) {
+ retval = rpc.project_op(project, "allowmorework");
+ } else {
+ fprintf(stderr, "Unknown op %s\n", op);
+ }
+ } else if (!strcmp(cmd, "--project_attach")) {
+ char* url = next_arg(argc, argv, i);
+ char* auth = next_arg(argc, argv, i);
+ retval = rpc.project_attach(url, auth, "");
+ } else if (!strcmp(cmd, "--file_transfer")) {
+ FILE_TRANSFER ft;
+
+ ft.project_url = next_arg(argc, argv, i);
+ ft.name = next_arg(argc, argv, i);
+ char* op = next_arg(argc, argv, i);
+ if (!strcmp(op, "retry")) {
+ retval = rpc.file_transfer_op(ft, "retry");
+ } else if (!strcmp(op, "abort")) {
+ retval = rpc.file_transfer_op(ft, "abort");
+ } else {
+ fprintf(stderr, "Unknown op %s\n", op);
+ }
+ } else if (!strcmp(cmd, "--set_run_mode")) {
+ char* op = next_arg(argc, argv, i);
+ double duration;
+ if (i >= argc || (argv[i][0] == '-')) {
+ duration = 0;
+ } else {
+ duration = atof(next_arg(argc, argv, i));
+ }
+ if (!strcmp(op, "always")) {
+ retval = rpc.set_run_mode(RUN_MODE_ALWAYS, duration);
+ } else if (!strcmp(op, "auto")) {
+ retval = rpc.set_run_mode(RUN_MODE_AUTO, duration);
+ } else if (!strcmp(op, "never")) {
+ retval = rpc.set_run_mode(RUN_MODE_NEVER, duration);
+ } else {
+ fprintf(stderr, "Unknown op %s\n", op);
+ }
+ } else if (!strcmp(cmd, "--set_network_mode")) {
+ char* op = next_arg(argc, argv, i);
+ double duration;
+ if (i >= argc || (argv[i][0] == '-')) {
+ duration = 0;
+ } else {
+ duration = atof(next_arg(argc, argv, i));
+ }
+ if (!strcmp(op, "always")) {
+ retval = rpc.set_network_mode(RUN_MODE_ALWAYS, duration);
+ } else if (!strcmp(op, "auto")) {
+ retval = rpc.set_network_mode(RUN_MODE_AUTO, duration);
+ } else if (!strcmp(op, "never")) {
+ retval = rpc.set_network_mode(RUN_MODE_NEVER, duration);
+ } else {
+ fprintf(stderr, "Unknown op %s\n", op);
+ }
+ } else if (!strcmp(cmd, "--get_proxy_settings")) {
+ GR_PROXY_INFO pi;
+ retval = rpc.get_proxy_settings(pi);
+ if (!retval) pi.print();
+ } else if (!strcmp(cmd, "--set_proxy_settings")) {
+ GR_PROXY_INFO pi;
+ pi.http_server_name = next_arg(argc, argv, i);
+ pi.http_server_port = atoi(next_arg(argc, argv, i));
+ pi.http_user_name = next_arg(argc, argv, i);
+ pi.http_user_passwd = next_arg(argc, argv, i);
+ pi.socks_server_name = next_arg(argc, argv, i);
+ pi.socks_server_port = atoi(next_arg(argc, argv, i));
+ pi.socks_version = atoi(next_arg(argc, argv, i));
+ pi.socks5_user_name = next_arg(argc, argv, i);
+ pi.socks5_user_passwd = next_arg(argc, argv, i);
+ retval = rpc.set_proxy_settings(pi);
+ } else if (!strcmp(cmd, "--get_messages")) {
+ int seqno = atoi(next_arg(argc, argv, i));
+ retval = rpc.get_messages(seqno, messages);
+ if (!retval) {
+ unsigned int j;
+ for (j=0; j<messages.messages.size(); j++) {
+ MESSAGE& md = *messages.messages[j];
+ printf("%s %d %d %s\n",
+ md.project.c_str(), md.priority,
+ md.timestamp, md.body.c_str()
+ );
+ }
+ }
+ } else if (!strcmp(cmd, "--get_host_info")) {
+ HOST_INFO hi;
+ retval = rpc.get_host_info(hi);
+ if (!retval) hi.print();
+ } else if (!strcmp(cmd, "--acct_mgr_rpc")) {
+ char* am_url = next_arg(argc, argv, i);
+ char* am_name = next_arg(argc, argv, i);
+ char* am_passwd = next_arg(argc, argv, i);
+ retval = rpc.acct_mgr_rpc(am_url, am_name, am_passwd);
+ } else if (!strcmp(cmd, "--run_benchmarks")) {
+ retval = rpc.run_benchmarks();
+ } else if (!strcmp(cmd, "--get_screensaver_mode")) {
+ int status;
+ retval = rpc.get_screensaver_mode(status);
+ if (!retval) printf("screensaver mode: %d\n", status);
+ } else if (!strcmp(cmd, "--set_screensaver_mode")) {
+ double blank_time;
+ bool enabled = false;
+ DISPLAY_INFO di;
+
+ char* op = next_arg(argc, argv, i);
+ if (!strcmp(op, "on")) enabled = true;
+ blank_time = atof(next_arg(argc, argv, i));
+ parse_display_args(argv, i, di);
+ retval = rpc.set_screensaver_mode(enabled, blank_time, di);
+ } else if (!strcmp(cmd, "--get_project_config")) {
+ char* gpc_url = next_arg(argc, argv,i);
+ retval = rpc.get_project_config(string(gpc_url));
+ } else if (!strcmp(cmd, "--get_project_config_poll")) {
+ PROJECT_CONFIG pc;
+ retval = rpc.get_project_config_poll(pc);
+ if (retval) {
+ printf("retval: %d\n", retval);
+ } else {
+ pc.print();
+ }
+ } else if (!strcmp(cmd, "--lookup_account")) {
+ ACCOUNT_IN lai;
+ lai.url = next_arg(argc, argv, i);
+ lai.email_addr = next_arg(argc, argv, i);
+ lai.passwd = next_arg(argc, argv, i);
+ retval = rpc.lookup_account(lai);
+ printf("status: %s\n", boincerror(retval));
+ if (!retval) {
+ ACCOUNT_OUT lao;
+ while (1) {
+ retval = rpc.lookup_account_poll(lao);
+ if (retval) {
+ printf("poll status: %s\n", boincerror(retval));
+ } else {
+ if (lao.error_num) {
+ printf("poll status: %s\n", boincerror(lao.error_num));
+ if (lao.error_num != ERR_IN_PROGRESS) break;
+ boinc_sleep(1);
+ } else {
+ lao.print();
+ break;
+ }
+ }
+ }
+ }
+ } else if (!strcmp(cmd, "--create_account")) {
+ ACCOUNT_IN cai;
+ cai.url = next_arg(argc, argv, i);
+ cai.email_addr = next_arg(argc, argv, i);
+ cai.passwd = next_arg(argc, argv, i);
+ cai.user_name = next_arg(argc, argv, i);
+ retval = rpc.create_account(cai);
+ printf("status: %s\n", boincerror(retval));
+ if (!retval) {
+ ACCOUNT_OUT lao;
+ while (1) {
+ retval = rpc.create_account_poll(lao);
+ if (retval) {
+ printf("poll status: %s\n", boincerror(retval));
+ } else {
+ if (lao.error_num) {
+ printf("poll status: %s\n", boincerror(lao.error_num));
+ if (lao.error_num != ERR_IN_PROGRESS) break;
+ boinc_sleep(1);
+ } else {
+ lao.print();
+ break;
+ }
+ }
+ }
+ }
+ } else if (!strcmp(cmd, "--read_global_prefs_override")) {
+ retval = rpc.read_global_prefs_override();
+ } else if (!strcmp(cmd, "--read_cc_config")) {
+ retval = rpc.read_cc_config();
+ } else if (!strcmp(cmd, "--test1")) {
+ string s;
+ retval = rpc.get_global_prefs_override(s);
+ printf("retval: %d\nprefs:\n%s\n", retval, s.c_str());
+ } else if (!strcmp(cmd, "--test2")) {
+ string s = "foobar";
+ retval = rpc.set_global_prefs_override(s);
+ printf("retval: %d\n", retval);
+ } else if (!strcmp(cmd, "--test3")) {
+ GLOBAL_PREFS gp;
+ GLOBAL_PREFS_MASK mask;
+ memset(&gp, 0, sizeof(gp));
+ mask.clear();
+ retval = rpc.get_global_prefs_override_struct(gp, mask);
+ printf("retval %d max %d\n", retval, gp.max_cpus);
+ } else if (!strcmp(cmd, "--test4")) {
+ GLOBAL_PREFS gp;
+ GLOBAL_PREFS_MASK m;
+ gp.max_cpus = 2;
+ m.max_cpus = true;
+ retval = rpc.set_global_prefs_override_struct(gp, m);
+ printf("retval %d\n", retval);
+ } else if (!strcmp(cmd, "--quit")) {
+ retval = rpc.quit();
+ } else {
+ fprintf(stderr, "unrecognized command %s\n", cmd);
+ }
+ if (retval) {
+ show_error(retval);
+ }
+
+#if defined(_WIN32) && defined(USE_WINSOCK)
+ WSACleanup();
+#endif
+ return 0;
+}
+
+const char *BOINC_RCSID_77f00010ab = "$Id: boinc_cmd.C,v 1.46.2.1 2007/03/01 16:10:11 rwalton Exp $";
More information about the pkg-boinc-commits
mailing list