*** empty log message ***

svn path=/trunk/boinc/; revision=4295
This commit is contained in:
David Anderson 2004-10-06 19:09:37 +00:00
parent 596e9b768c
commit 12887b134d
16 changed files with 251 additions and 166 deletions

View File

@ -18053,3 +18053,35 @@ Lana 4 Oct 2004
validator.C
wu_check.C
David 6 Oct 2004
- Added some new items to the APP_INIT_DATA struct
(and to the init_data.xml file):
- global preferences
- user/team/host IDs
- proxy info
This is for the benefit of Folding@home,
whose application does some core-client-type stuff
(e.g. network communication) and therefore needs this info
- changed GLOBAL_PREFS::source_project and source_scheduler
from std::string to char[256]
- factored out PROXY_INFO code into lib/proxy_info.C,h
- moved GLOBAL_PREFS code from client/ to lib/
client/
app_start.C
client_state.C
cs_prefs.C
cs_scheduler.C
prefs.C,h (moved to lib)
proxy.C,h
lib/
app_ipc.C,h
prefs.C,h (moved from client)
proxy_info.C,h (new)
win_build/
boinc_cli.vcproj
boinc_gui.vcproj
upper_case.vcproj

View File

@ -143,7 +143,7 @@ int ACTIVE_TASK::write_app_init_file() {
safe_strcpy(aid.user_name, wup->project->user_name);
safe_strcpy(aid.team_name, wup->project->team_name);
if (wup->project->project_specific_prefs.length()) {
strcpy(aid.project_preferences, wup->project->project_specific_prefs.c_str());
aid.project_preferences = (char*)wup->project->project_specific_prefs.c_str();
}
get_project_dir(wup->project, project_dir);
relative_to_absolute(project_dir, project_path);
@ -182,6 +182,7 @@ int ACTIVE_TASK::write_app_init_file() {
}
aid.host_info = gstate.host_info;
aid.global_prefs = gstate.global_prefs;
retval = write_init_data_file(f, aid);
fclose(f);
return retval;

View File

@ -1200,7 +1200,7 @@ int CLIENT_STATE::detach_project(PROJECT* project) {
// if global prefs came from this project, delete file and reinit
//
p = lookup_project(global_prefs.source_project.c_str());
p = lookup_project(global_prefs.source_project);
if (p == project) {
boinc_delete_file(GLOBAL_PREFS_FILE_NAME);
global_prefs.init();

View File

@ -235,7 +235,7 @@ int CLIENT_STATE::resume_network() {
// call this only after parsing global prefs
//
PROJECT* CLIENT_STATE::global_prefs_source_project() {
return lookup_project(global_prefs.source_project.c_str());
return lookup_project(global_prefs.source_project);
}
void CLIENT_STATE::show_global_prefs_source(bool found_venue) {
@ -248,7 +248,7 @@ void CLIENT_STATE::show_global_prefs_source(bool found_venue) {
} else {
msg_printf(NULL, MSG_INFO,
"General prefs: from unknown project %s (last modified %s)\n",
global_prefs.source_project.c_str(),
global_prefs.source_project,
time_to_string(global_prefs.mod_time)
);
}

View File

@ -222,7 +222,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
copy_stream(fprefs, f);
fclose(fprefs);
}
PROJECT* pp = lookup_project(global_prefs.source_project.c_str());
PROJECT* pp = lookup_project(global_prefs.source_project);
if (pp && strlen(pp->email_hash)) {
fprintf(f,
"<global_prefs_source_email_hash>%s</global_prefs_source_email_hash>\n",

View File

@ -84,77 +84,6 @@ void print_buf( char *buf, int n ) {
printf( "\n" );
}
int PROXY_INFO::parse(MIOFILE& in) {
char buf[256];
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
memset(this, 0, sizeof(PROXY_INFO));
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</proxy_info>")) return 0;
else if (match_tag(buf, "<use_http_proxy/>")) use_http_proxy = true;
else if (match_tag(buf, "<use_socks_proxy/>")) use_socks_proxy = true;
else if (match_tag(buf, "<use_http_auth/>")) use_http_auth = true;
else if (parse_int(buf, "<socks_version>", socks_version)) continue;
else if (parse_str(buf, "<socks_server_name>", socks_server_name, sizeof(socks_server_name))) continue;
else if (parse_int(buf, "<socks_server_port>", socks_server_port)) continue;
else if (parse_str(buf, "<http_server_name>", http_server_name, sizeof(http_server_name))) continue;
else if (parse_int(buf, "<http_server_port>", http_server_port)) continue;
else if (parse_str(buf, "<socks5_user_name>", socks5_user_name, sizeof(socks5_user_name))) continue;
else if (parse_str(buf, "<socks5_user_passwd>", socks5_user_passwd, sizeof(socks5_user_passwd))) continue;
else if (parse_str(buf, "<http_user_name>", http_user_name, sizeof(http_user_name))) continue;
else if (parse_str(buf, "<http_user_passwd>", http_user_passwd, sizeof(http_user_passwd))) continue;
else scope_messages.printf("PROXY_INFO::parse(): unrecognized: %s\n", buf);
}
return 0;
}
int PROXY_INFO::write(MIOFILE& out) {
out.printf(
"<proxy_info>\n"
"%s"
"%s"
"%s"
" <socks_version>%d</socks_version>\n"
" <socks_server_name>%s</socks_server_name>\n"
" <socks_server_port>%d</socks_server_port>\n"
" <http_server_name>%s</http_server_name>\n"
" <http_server_port>%d</http_server_port>\n"
" <socks5_user_name>%s</socks5_user_name>\n"
" <socks5_user_passwd>%s</socks5_user_passwd>\n"
" <http_user_name>%s</http_user_name>\n"
" <http_user_passwd>%s</http_user_passwd>\n"
"</proxy_info>\n",
use_http_proxy?" <use_http_proxy/>\n":"",
use_socks_proxy?" <use_socks_proxy/>\n":"",
use_http_auth?" <use_http_auth/>\n":"",
socks_version,
socks_server_name,
socks_server_port,
http_server_name,
http_server_port,
socks5_user_name,
socks5_user_passwd,
http_user_name,
http_user_passwd
);
return 0;
}
void PROXY_INFO::clear() {
use_http_proxy = false;
use_socks_proxy = false;
use_http_auth = false;
strcpy(socks_server_name, "");
strcpy(http_server_name, "");
socks_server_port = 80;
http_server_port = 80;
strcpy(socks5_user_name, "");
strcpy(socks5_user_passwd, "");
strcpy(http_user_name, "");
strcpy(http_user_passwd, "");
socks_version = 0;
}
PROXY::PROXY() {
strcpy(proxy_data,"");

View File

@ -21,26 +21,7 @@
#define _PROXY_
#include "net_xfer.h"
#include "miofile.h"
struct PROXY_INFO {
bool use_http_proxy;
bool use_socks_proxy;
bool use_http_auth;
int socks_version;
char socks_server_name[256];
char http_server_name[256];
int socks_server_port;
int http_server_port;
char http_user_name[256];
char http_user_passwd[256];
char socks5_user_name[256];
char socks5_user_passwd[256];
int parse(MIOFILE&);
int write(MIOFILE&);
void clear();
};
#include "proxy_info.h"
class PROXY : public NET_XFER {
public:

View File

@ -51,7 +51,7 @@ int write_init_data_file(FILE* f, APP_INIT_DATA& ai) {
if (strlen(ai.app_name)) {
fprintf(f, "<app_name>%s</app_name>\n", ai.app_name);
}
if (strlen(ai.project_preferences)) {
if (ai.project_preferences && strlen(ai.project_preferences)) {
fprintf(f, "<project_preferences>\n%s</project_preferences>\n", ai.project_preferences);
}
if (strlen(ai.team_name)) {
@ -105,25 +105,32 @@ int write_init_data_file(FILE* f, APP_INIT_DATA& ai) {
ai.fraction_done_start,
ai.fraction_done_end
);
fprintf(f, "</app_init_data>\n");
MIOFILE mf;
mf.init_file(f);
ai.host_info.write(mf);
ai.proxy_info.write(mf);
ai.global_prefs.write(f);
fprintf(f, "</app_init_data>\n");
return 0;
}
int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) {
char buf[256];
int retval;
bool flag;
memset(&ai, 0, sizeof(ai));
ai.fraction_done_start = 0;
ai.fraction_done_end = 1;
while (fgets(buf, 256, f)) {
if (match_tag(buf, "<project_preferences>")) {
safe_strncpy(ai.project_preferences, "", sizeof(ai.project_preferences));
while (fgets(buf, 256, f)) {
if (match_tag(buf, "</project_preferences>")) break;
safe_strcat(ai.project_preferences, buf);
}
retval = dup_element_contents(f, "</project_preferences>", &ai.project_preferences);
if (retval) return retval;
continue;
}
if (match_tag(buf, "<global_preferences>")) {
retval = ai.global_prefs.parse(f, "", flag);
if (retval) return retval;
continue;
}
else if (match_tag(buf, "<host_info>")) {

View File

@ -24,6 +24,8 @@
#include <string>
#include "hostinfo.h"
#include "proxy_info.h"
#include "prefs.h"
// Communication between the core client and the BOINC app library.
// This code is linked into both core client and app lib.
@ -142,7 +144,10 @@ public:
struct APP_INIT_DATA {
int core_version;
char app_name[256];
char project_preferences[65536];
char* project_preferences;
int userid;
int teamid;
int hostid;
char user_name[256];
char team_name[256];
char project_dir[256];
@ -155,6 +160,8 @@ struct APP_INIT_DATA {
double host_total_credit;
double host_expavg_credit;
HOST_INFO host_info;
PROXY_INFO proxy_info;
GLOBAL_PREFS global_prefs;
// Items below here are for implementation only
// (not used by app developers)

View File

@ -32,7 +32,6 @@
#include "parse.h"
#include "error_numbers.h"
#include "client_msgs.h"
#include "file_names.h"
#include "client_state.h"
@ -65,9 +64,11 @@ void GLOBAL_PREFS::init() {
idle_time_to_run = 3;
max_bytes_sec_up = 1e9;
max_bytes_sec_down = 1e9;
max_memory_mbytes = 128;
//max_memory_mbytes = 128;
proc_priority = 1;
cpu_affinity = -1;
strcpy(source_project, "");
strcpy(source_scheduler, "");
};
GLOBAL_PREFS::GLOBAL_PREFS() {
@ -86,11 +87,7 @@ int GLOBAL_PREFS::parse(FILE* in, char* host_venue, bool& found_venue) {
char buf[256], buf2[256];
bool in_venue = false, in_correct_venue=false;
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
init();
source_project = "";
source_scheduler = "";
// set all booleans to false here
run_on_batteries = false;
@ -130,9 +127,9 @@ int GLOBAL_PREFS::parse(FILE* in, char* host_venue, bool& found_venue) {
}
if (match_tag(buf, "<global_preferences>")) {
continue;
} else if (parse_str(buf, "<source_project>", source_project)) {
} else if (parse_str(buf, "<source_project>", source_project, sizeof(source_project))) {
continue;
} else if (parse_str(buf, "<source_scheduler>", source_scheduler)) {
} else if (parse_str(buf, "<source_scheduler>", source_scheduler, sizeof(source_scheduler))) {
continue;
} else if (parse_int(buf, "<mod_time>", mod_time)) {
continue;
@ -192,12 +189,12 @@ int GLOBAL_PREFS::parse(FILE* in, char* host_venue, bool& found_venue) {
} else if (parse_double(buf, "<max_bytes_sec_down>", max_bytes_sec_down)) {
if (max_bytes_sec_down <= 0) max_bytes_sec_down = 1e12;
continue;
#if 0
} else if (parse_int(buf, "<max_memory_mbytes>", max_memory_mbytes)) {
continue;
#endif
} else if (parse_int(buf, "<cpu_affinity>", cpu_affinity)) {
continue;
} else {
scope_messages.printf("GLOBAL_PREFS::parse: unrecognized: %s\n", buf);
}
}
return 0;
@ -217,3 +214,50 @@ int GLOBAL_PREFS::parse_file(
fclose(f);
return retval;
}
// this is used only to write the app init data file
//
int GLOBAL_PREFS::write(FILE* f) {
fprintf(f,
"<global_preferences>\n"
" <mod_time>%d</mod_time>\n"
"%s%s"
" <start_hour>%d</start_hour>\n"
" <end_hour>%d</end_hour>\n"
"%s%s%s%s%s"
" <work_buf_min_days>%f</work_buf_min_days>\n"
" <max_cpus>%d</max_cpus>\n"
" <cpu_sched_period>%d</cpu_sched_period>\n"
" <disk_interval>%f</disk_interval>\n"
" <disk_max_used_gb>%f</disk_max_used_gb>\n"
" <disk_max_used_pct>%f</disk_max_used_pct>\n"
" <disk_min_free_gb>%f</disk_min_free_gb>\n"
" <vm_max_used_pct>%f</vm_max_used_pct>\n"
" <idle_time_to_run>%f</idle_time_to_run>\n"
" <max_bytes_sec_up>%f</max_bytes_sec_up>\n"
" <max_bytes_sec_down>%f</max_bytes_sec_down>\n"
"</global_preferences>\n",
mod_time,
run_on_batteries?" <run_on_batteries/>\n":"",
run_if_user_active?" <run_if_user_active/>\n":"",
start_hour,
end_hour,
leave_apps_in_memory?" <leave_apps_in_memory/>\n":"",
confirm_before_connecting?" <confirm_before_connecting/>\n":"",
run_minimized?" <run_minimized/>\n":"",
run_on_startup?" <run_on_startup/>\n":"",
hangup_if_dialed?" <hangup_if_dialed/>\n":"",
work_buf_min_days,
max_cpus,
cpu_sched_period,
disk_interval,
disk_max_used_gb,
disk_max_used_pct,
disk_min_free_gb,
vm_max_used_pct,
idle_time_to_run,
max_bytes_sec_up,
max_bytes_sec_down
);
return 0;
}

View File

@ -43,7 +43,6 @@ struct GLOBAL_PREFS {
bool run_minimized;
bool run_on_startup;
bool hangup_if_dialed;
//double work_buf_max_days;
double work_buf_min_days;
int max_cpus;
int cpu_sched_period;
@ -55,16 +54,17 @@ struct GLOBAL_PREFS {
double idle_time_to_run;
double max_bytes_sec_up;
double max_bytes_sec_down;
int max_memory_mbytes;
//int max_memory_mbytes;
int proc_priority;
int cpu_affinity;
std::string source_project;
std::string source_scheduler;
char source_project[256];
char source_scheduler[256];
GLOBAL_PREFS();
void init();
int parse(FILE*, char* venue, bool& found_venue);
int parse_file(char* filename, char* venue, bool& found_venue);
int write(FILE*);
};
#endif

75
lib/proxy_info.C Normal file
View File

@ -0,0 +1,75 @@
#ifdef _WIN32
#include "boinc_win.h"
#endif
#include "parse.h"
#include "proxy_info.h"
int PROXY_INFO::parse(MIOFILE& in) {
char buf[256];
memset(this, 0, sizeof(PROXY_INFO));
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</proxy_info>")) return 0;
else if (match_tag(buf, "<use_http_proxy/>")) use_http_proxy = true;
else if (match_tag(buf, "<use_socks_proxy/>")) use_socks_proxy = true;
else if (match_tag(buf, "<use_http_auth/>")) use_http_auth = true;
else if (parse_int(buf, "<socks_version>", socks_version)) continue;
else if (parse_str(buf, "<socks_server_name>", socks_server_name, sizeof(socks_server_name))) continue;
else if (parse_int(buf, "<socks_server_port>", socks_server_port)) continue;
else if (parse_str(buf, "<http_server_name>", http_server_name, sizeof(http_server_name))) continue;
else if (parse_int(buf, "<http_server_port>", http_server_port)) continue;
else if (parse_str(buf, "<socks5_user_name>", socks5_user_name, sizeof(socks5_user_name))) continue;
else if (parse_str(buf, "<socks5_user_passwd>", socks5_user_passwd, sizeof(socks5_user_passwd))) continue;
else if (parse_str(buf, "<http_user_name>", http_user_name, sizeof(http_user_name))) continue;
else if (parse_str(buf, "<http_user_passwd>", http_user_passwd, sizeof(http_user_passwd))) continue;
}
return 0;
}
int PROXY_INFO::write(MIOFILE& out) {
out.printf(
"<proxy_info>\n"
"%s"
"%s"
"%s"
" <socks_version>%d</socks_version>\n"
" <socks_server_name>%s</socks_server_name>\n"
" <socks_server_port>%d</socks_server_port>\n"
" <http_server_name>%s</http_server_name>\n"
" <http_server_port>%d</http_server_port>\n"
" <socks5_user_name>%s</socks5_user_name>\n"
" <socks5_user_passwd>%s</socks5_user_passwd>\n"
" <http_user_name>%s</http_user_name>\n"
" <http_user_passwd>%s</http_user_passwd>\n"
"</proxy_info>\n",
use_http_proxy?" <use_http_proxy/>\n":"",
use_socks_proxy?" <use_socks_proxy/>\n":"",
use_http_auth?" <use_http_auth/>\n":"",
socks_version,
socks_server_name,
socks_server_port,
http_server_name,
http_server_port,
socks5_user_name,
socks5_user_passwd,
http_user_name,
http_user_passwd
);
return 0;
}
void PROXY_INFO::clear() {
use_http_proxy = false;
use_socks_proxy = false;
use_http_auth = false;
strcpy(socks_server_name, "");
strcpy(http_server_name, "");
socks_server_port = 80;
http_server_port = 80;
strcpy(socks5_user_name, "");
strcpy(socks5_user_passwd, "");
strcpy(http_user_name, "");
strcpy(http_user_passwd, "");
socks_version = 0;
}

25
lib/proxy_info.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef _PROXY_INFO_
#define _PROXY_INFO_
#include "miofile.h"
struct PROXY_INFO {
bool use_http_proxy;
bool use_socks_proxy;
bool use_http_auth;
int socks_version;
char socks_server_name[256];
char http_server_name[256];
int socks_server_port;
int http_server_port;
char http_user_name[256];
char http_user_passwd[256];
char socks5_user_name[256];
char socks5_user_passwd[256];
int parse(MIOFILE&);
int write(MIOFILE&);
void clear();
};
#endif

View File

@ -855,31 +855,14 @@
</FileConfiguration>
</File>
<File
RelativePath="..\Client\Prefs.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
BrowseInformation="1"
CompileAs="2"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"/>
</FileConfiguration>
RelativePath="..\lib\prefs.C">
</File>
<File
RelativePath="..\client\proxy.C">
</File>
<File
RelativePath="..\lib\proxy_info.C">
</File>
<File
RelativePath="..\Client\scheduler_op.C">
<FileConfiguration
@ -1122,11 +1105,14 @@
RelativePath="..\Client\pers_file_xfer.h">
</File>
<File
RelativePath="..\client\prefs.h">
RelativePath="..\lib\prefs.h">
</File>
<File
RelativePath="..\client\proxy.h">
</File>
<File
RelativePath="..\lib\proxy_info.h">
</File>
<File
RelativePath="..\client\scheduler_op.h">
</File>

View File

@ -870,31 +870,14 @@
</FileConfiguration>
</File>
<File
RelativePath="..\Client\Prefs.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
BrowseInformation="1"
CompileAs="2"/>
</FileConfiguration>
RelativePath="..\lib\prefs.C">
</File>
<File
RelativePath="..\client\proxy.C">
</File>
<File
RelativePath="..\lib\proxy_info.C">
</File>
<File
RelativePath="..\Client\scheduler_op.C">
<FileConfiguration
@ -1304,11 +1287,14 @@
RelativePath="..\Client\pers_file_xfer.h">
</File>
<File
RelativePath="..\client\prefs.h">
RelativePath="..\lib\prefs.h">
</File>
<File
RelativePath="..\client\proxy.h">
</File>
<File
RelativePath="..\lib\proxy_info.h">
</File>
<File
RelativePath="..\client\scheduler_op.h">
</File>
@ -1362,10 +1348,10 @@
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
<File
RelativePath="..\client\win\boinc.bmp">
RelativePath="..\client\win\res\boinc.bmp">
</File>
<File
RelativePath="..\client\win\res\boinc.bmp">
RelativePath="..\client\win\boinc.bmp">
</File>
<File
RelativePath="..\client\win\boinc_gui.rc">
@ -1385,10 +1371,10 @@
</FileConfiguration>
</File>
<File
RelativePath="..\client\win\res\boincsm.bmp">
RelativePath="..\client\win\boincsm.bmp">
</File>
<File
RelativePath="..\client\win\boincsm.bmp">
RelativePath="..\client\win\res\boincsm.bmp">
</File>
<File
RelativePath="..\res\CoreClient.ico">

View File

@ -263,6 +263,12 @@
CompileAs="2"/>
</FileConfiguration>
</File>
<File
RelativePath="..\lib\prefs.C">
</File>
<File
RelativePath="..\lib\proxy_info.C">
</File>
<File
RelativePath="..\lib\shmem.C">
<FileConfiguration
@ -352,6 +358,12 @@
<File
RelativePath="..\lib\parse.h">
</File>
<File
RelativePath="..\lib\prefs.h">
</File>
<File
RelativePath="..\lib\proxy_info.h">
</File>
<File
RelativePath="..\lib\shmem.h">
</File>