2003-06-11 23:36:48 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2002-12-03 18:57:40 +00:00
|
|
|
// 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
|
2003-06-11 23:36:48 +00:00
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-07-08 21:30:47 +00:00
|
|
|
//
|
2002-12-03 18:57:40 +00:00
|
|
|
// 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
|
2003-07-08 21:30:47 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2002-12-03 18:57:40 +00:00
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
2003-07-08 21:30:47 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2002-12-03 18:57:40 +00:00
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
|
|
|
// Parse a server configuration file
|
|
|
|
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstring>
|
2003-10-03 06:46:22 +00:00
|
|
|
#include <string>
|
2004-08-03 21:51:30 +00:00
|
|
|
#include <unistd.h>
|
2002-10-03 18:33:46 +00:00
|
|
|
|
|
|
|
#include "parse.h"
|
|
|
|
#include "error_numbers.h"
|
|
|
|
|
2003-08-15 00:45:25 +00:00
|
|
|
#include "sched_config.h"
|
2002-10-03 18:33:46 +00:00
|
|
|
|
2004-07-03 21:38:22 +00:00
|
|
|
#ifdef _USING_FCGI_
|
|
|
|
#include "fcgi_stdio.h"
|
|
|
|
#endif
|
|
|
|
|
2003-09-02 21:16:55 +00:00
|
|
|
const char* CONFIG_FILE = "config.xml";
|
2003-07-08 21:30:47 +00:00
|
|
|
|
2004-04-30 23:18:56 +00:00
|
|
|
int SCHED_CONFIG::parse(char* buf) {
|
2004-02-03 21:48:49 +00:00
|
|
|
// fill in defaults
|
|
|
|
//
|
2003-09-02 21:16:55 +00:00
|
|
|
memset(this, 0, sizeof(SCHED_CONFIG));
|
2004-02-03 21:48:49 +00:00
|
|
|
max_wus_to_send = 10;
|
|
|
|
|
2004-05-02 15:55:17 +00:00
|
|
|
parse_str(buf, "<long_name>", long_name, sizeof(long_name));
|
2004-04-30 23:18:56 +00:00
|
|
|
parse_str(buf, "<db_name>", db_name, sizeof(db_name));
|
|
|
|
parse_str(buf, "<db_user>", db_user, sizeof(db_user));
|
|
|
|
parse_str(buf, "<db_passwd>", db_passwd, sizeof(db_passwd));
|
|
|
|
parse_str(buf, "<db_host>", db_host, sizeof(db_host));
|
|
|
|
parse_int(buf, "<shmem_key>", shmem_key);
|
|
|
|
parse_str(buf, "<key_dir>", key_dir, sizeof(key_dir));
|
|
|
|
parse_str(buf, "<download_url>", download_url, sizeof(download_url));
|
|
|
|
parse_str(buf, "<download_dir>", download_dir, sizeof(download_dir));
|
2004-08-06 11:42:41 +00:00
|
|
|
parse_str(buf, "<download_dir_alt>", download_dir_alt, sizeof(download_dir_alt));
|
2004-04-30 23:18:56 +00:00
|
|
|
parse_str(buf, "<upload_url>", upload_url, sizeof(upload_url));
|
|
|
|
parse_str(buf, "<upload_dir>", upload_dir, sizeof(upload_dir));
|
|
|
|
if (match_tag(buf, "<one_result_per_user_per_wu/>")) {
|
2003-10-16 19:03:49 +00:00
|
|
|
one_result_per_user_per_wu = true;
|
|
|
|
}
|
2004-04-30 23:18:56 +00:00
|
|
|
if (match_tag(buf, "<non_cpu_intensive/>")) {
|
2004-04-14 23:32:17 +00:00
|
|
|
non_cpu_intensive = true;
|
|
|
|
}
|
2004-05-18 18:33:01 +00:00
|
|
|
if (match_tag(buf, "<homogeneous_redundancy/>")) {
|
2004-08-05 22:02:33 +00:00
|
|
|
homogeneous_redundancy = true;
|
2004-05-18 18:33:01 +00:00
|
|
|
}
|
2004-09-10 21:02:11 +00:00
|
|
|
if (match_tag(buf, "<locality_scheduling/>")) {
|
|
|
|
locality_scheduling = true;
|
|
|
|
}
|
2004-06-24 21:00:13 +00:00
|
|
|
if (match_tag(buf, "<msg_to_host/>")) {
|
|
|
|
msg_to_host = true;
|
2004-03-17 01:26:44 +00:00
|
|
|
}
|
2004-06-07 03:34:07 +00:00
|
|
|
if (match_tag(buf, "<ignore_upload_certificates/>")) {
|
|
|
|
ignore_upload_certificates = true;
|
|
|
|
}
|
2004-09-24 21:28:12 +00:00
|
|
|
if (match_tag(buf, "<dont_generate_upload_certificates/>")) {
|
|
|
|
dont_generate_upload_certificates = true;
|
|
|
|
}
|
2004-09-24 20:17:52 +00:00
|
|
|
#if 0
|
2004-08-05 22:02:33 +00:00
|
|
|
if (match_tag(buf, "<deletion_policy_priority/>")) {
|
|
|
|
deletion_policy_priority = true;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<deletion_policy_expire/>")) {
|
|
|
|
deletion_policy_expire = true;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<delete_from_self/>")) {
|
|
|
|
delete_from_self = true;
|
|
|
|
}
|
2004-09-24 20:17:52 +00:00
|
|
|
#endif
|
2004-07-15 18:54:17 +00:00
|
|
|
if (match_tag(buf, "<enforce_delay_bound/>")) {
|
|
|
|
enforce_delay_bound = true;
|
|
|
|
}
|
2004-08-04 10:34:33 +00:00
|
|
|
if (match_tag(buf, "<use_transactions/>")) {
|
|
|
|
use_transactions = true;
|
|
|
|
}
|
2004-04-30 23:18:56 +00:00
|
|
|
parse_int(buf, "<min_sendwork_interval>", min_sendwork_interval);
|
|
|
|
parse_int(buf, "<max_wus_to_send>", max_wus_to_send);
|
2004-05-27 18:13:00 +00:00
|
|
|
parse_int(buf, "<daily_result_quota>", daily_result_quota);
|
2004-08-05 11:35:09 +00:00
|
|
|
parse_int(buf, "<uldl_dir_fanout>", uldl_dir_fanout);
|
2004-07-02 22:48:33 +00:00
|
|
|
if (match_tag(buf, "</config>")) {
|
|
|
|
char hostname[256];
|
|
|
|
gethostname(hostname, 256);
|
|
|
|
if (!strcmp(hostname, db_host)) strcpy(db_host, "localhost");
|
|
|
|
return 0;
|
|
|
|
}
|
2002-10-03 18:33:46 +00:00
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
2003-09-02 21:16:55 +00:00
|
|
|
int SCHED_CONFIG::parse_file(char* dir) {
|
2004-04-30 23:18:56 +00:00
|
|
|
char* p;
|
2003-09-02 21:16:55 +00:00
|
|
|
char path[256];
|
2004-04-30 23:18:56 +00:00
|
|
|
int retval;
|
2002-10-03 18:33:46 +00:00
|
|
|
|
2003-09-02 21:16:55 +00:00
|
|
|
sprintf(path, "%s/%s", dir, CONFIG_FILE);
|
2004-04-30 23:18:56 +00:00
|
|
|
retval = read_file_malloc(path, p);
|
|
|
|
if (retval) return retval;
|
2004-08-05 11:35:09 +00:00
|
|
|
retval = parse(p);
|
|
|
|
free(p);
|
|
|
|
return retval;
|
2002-10-03 18:33:46 +00:00
|
|
|
}
|
2004-04-04 02:59:42 +00:00
|
|
|
|
|
|
|
void get_project_dir(char* p, int len) {
|
|
|
|
getcwd(p, len);
|
|
|
|
char* q = strrchr(p, '/');
|
|
|
|
if (q) *q = 0;
|
|
|
|
}
|