// 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 // // commands: // --get_state show entire state // --get_results show results // --get_file_transfers show file transfers // --get_project_status show status of all projects // --get_disk_usage // --result // {suspend | resume | abort | graphics_window | graphics_fullscreen} // url result_name // --project // {reset | detach | update | suspend | resume | nomorework | allowmorework} // url // --project_attach url auth // --file_transfer {retry | abort} url filename // --get_run_mode // --set_run_mode {always | auto | never} // --get_network_mode // --set_network_mode {always | auto | never} // --get_proxy_settings // --set_proxy_settings // --get_messages seqno show messages > seqno // --get_host_info // --acct_mgr_rpc url name password // --run_benchmarks // --get_screensaver_mode // --set_screensaver_mode on|off blank_time {desktop window_station} // --quit #ifdef _WIN32 #include "boinc_win.h" #else #include #include #endif #include using std::vector; #include "gui_rpc_client.h" #include "error_numbers.h" void usage() { fprintf(stderr, "bad usage\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) { switch(retval) { case ERR_AUTHENTICATOR: fprintf(stderr, "Authentication failure\n"); break; default: fprintf(stderr, "Error %d\n", retval); } } char* next_arg(int argc, char** argv, int& i) { if (i >= argc) { fprintf(stderr, "Missing command-line argument\n"); exit(1); } return argv[i++]; } int main(int argc, char** argv) { RPC_CLIENT rpc; int i; MESSAGES messages; int retval; char* hostname = NULL; char* passwd = NULL; #ifdef _WIN32 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], "--host")) { if (++i == argc) usage(); hostname = argv[i]; i++; } if ((i