// 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 #include #endif #include using std::vector; #include "gui_rpc_client.h" #include "error_numbers.h" #include "util.h" #include "version.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() { printf("\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 projects\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 {retry | abort} url filename\n\ --get_run_mode\n\ --set_run_mode {always | auto | never}\n\ --get_network_mode\n\ --set_network_mode {always | auto | never}\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\ --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"); 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], "--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(); hostname = argv[i]; i++; } if ((i