// 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 // // 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 // under the License. // // The Original Code is the Berkeley Open Infrastructure for Network Computing. // // The Initial Developer of the Original Code is the SETI@home project. // Portions created by the SETI@home project are Copyright (C) 2002 // University of California at Berkeley. All Rights Reserved. // // Contributor(s): // // command-line parsing, and handling of 1-time actions #ifdef _WIN32 #include "boinc_win.h" #endif #ifndef _WIN32 #include #endif #include "util.h" #include "client_msgs.h" #include "client_state.h" static void print_options(char* prog) { printf( "Usage: %s [options]\n" " -version show version info\n" #if defined(_WIN32) && defined(_CONSOLE) " -install install boinc as a Windows Service\n" " -uninstall uninstall boinc as a Windows Service\n" #endif " -exit_when_idle Get/process/report work, then exit\n" " -show_projects show attached projects\n" " -return_results_immediately contact server when have results\n" " -detach_project URL detach from a project\n" " -reset_project URL reset (clear) a project\n" " -attach_project attach to a project (will prompt for URL, account key)\n" " -update_prefs URL contact a project to update preferences\n" " -run_cpu_benchmarks run the CPU benchmarks\n" " -check_all_logins check input from remote users\n" " -allow_remote_gui_rpc allow remote GUI RPC connections\n", prog ); } // Parse the command line arguments passed to the client // NOTE: init() has not been called at this point // (i.e. client_state.xml has not been parsed) // #define ARGX2(s1,s2) (!strcmp(argv[i], s1)||!strcmp(argv[i], s2)) #define ARG(S) ARGX2("-"#S, "--"#S) void CLIENT_STATE::parse_cmdline(int argc, char** argv) { int i; bool show_options = false; for (i=1; i 0) { pi.use_http_proxy = true; parse_url(p, pi.http_server_name, pi.http_server_port, temp); } p = getenv("HTTP_USER_NAME"); if (p) { pi.use_http_auth = true; strcpy(pi.http_user_name, p); p = getenv("HTTP_USER_PASSWD"); if (p) { strcpy(pi.http_user_passwd, p); } } pi.socks_version = getenv("SOCKS5_SERVER")?SOCKS_VERSION_5: getenv("SOCKS4_SERVER")?SOCKS_VERSION_4: getenv("SOCKS_SERVER")?SOCKS_VERSION_5: SOCKS_VERSION_5; p = getenv("SOCKS4_SERVER"); if (p && strlen(p) > 0) { pi.use_socks_proxy = true; parse_url(p, pi.socks_server_name, pi.socks_server_port, temp); } if ((p = getenv("SOCKS_SERVER")) || (p = getenv("SOCKS5_SERVER"))) { if (strlen(p) > 0) { pi.use_socks_proxy = true; parse_url(p, pi.socks_server_name, pi.socks_server_port, temp); } } if ((p = getenv("SOCKS5_USER")) || (p = getenv("SOCKS_USER"))) { safe_strcpy(pi.socks5_user_name, p); } if ((p = getenv("SOCKS5_PASSWD"))) { safe_strcpy(pi.socks5_user_passwd, p); } } void CLIENT_STATE::do_cmdline_actions() { unsigned int i; if (show_projects) { printf("projects:\n"); for (i=0; imaster_url, projects[i]->project_name ); } exit(0); } if (strlen(detach_project_url)) { PROJECT* project = lookup_project(detach_project_url); if (project) { detach_project(project); msg_printf(project, MSG_INFO, "detached from %s\n", detach_project_url); } else { msg_printf(NULL, MSG_ERROR, "project %s not found\n", detach_project_url); } exit(0); } if (strlen(reset_project_url)) { PROJECT* project = lookup_project(reset_project_url); if (project) { reset_project(project); msg_printf(project, MSG_INFO, "Project %s has been reset", reset_project_url); } else { msg_printf(NULL, MSG_ERROR, "project %s not found\n", reset_project_url); } exit(0); } if (strlen(update_prefs_url)) { PROJECT* project = lookup_project(update_prefs_url); if (project) { project->sched_rpc_pending = true; } else { msg_printf(NULL, MSG_ERROR, "project %s not found\n", update_prefs_url); } } }