2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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.
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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.
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2003-10-16 19:03:49 +00:00
|
|
|
#include "cpp.h"
|
2004-03-04 11:41:43 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
2005-11-21 18:34:44 +00:00
|
|
|
#include "config.h"
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
#include "error_numbers.h"
|
2002-08-12 23:18:47 +00:00
|
|
|
#include "file_names.h"
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "client_msgs.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "parse.h"
|
|
|
|
|
|
|
|
#include "log_flags.h"
|
2004-03-01 19:11:12 +00:00
|
|
|
#include "filesys.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
LOG_FLAGS log_flags;
|
2006-05-21 21:11:28 +00:00
|
|
|
CONFIG config;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
LOG_FLAGS::LOG_FLAGS() {
|
2003-03-13 21:49:52 +00:00
|
|
|
|
|
|
|
// informational output is on by default
|
|
|
|
//
|
2006-05-21 22:03:36 +00:00
|
|
|
task = false;
|
2003-03-13 21:49:52 +00:00
|
|
|
file_xfer = true;
|
|
|
|
sched_ops = true;
|
|
|
|
|
|
|
|
// debugging output is off by default
|
|
|
|
//
|
|
|
|
state_debug = false;
|
|
|
|
task_debug = false;
|
|
|
|
file_xfer_debug = false;
|
|
|
|
sched_op_debug = false;
|
|
|
|
http_debug = false;
|
2004-03-27 00:45:27 +00:00
|
|
|
proxy_debug = false;
|
2003-03-13 21:49:52 +00:00
|
|
|
time_debug = false;
|
|
|
|
net_xfer_debug = false;
|
2002-08-30 21:32:31 +00:00
|
|
|
measurement_debug = false;
|
2004-06-11 20:52:27 +00:00
|
|
|
guirpc_debug = false;
|
2005-05-10 03:42:01 +00:00
|
|
|
sched_cpu_debug = false;
|
2005-05-11 06:57:58 +00:00
|
|
|
scrsave_debug = false;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-07-15 23:21:20 +00:00
|
|
|
// Parse log flag preferences
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
int LOG_FLAGS::parse(FILE* in) {
|
|
|
|
char buf[256];
|
2002-08-15 22:03:41 +00:00
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
while (fgets(buf, 256, in)) {
|
2005-05-23 00:07:29 +00:00
|
|
|
if (strlen(buf) < 2) continue;
|
2002-04-30 22:22:54 +00:00
|
|
|
if (match_tag(buf, "</log_flags>")) return 0;
|
2005-08-12 18:31:47 +00:00
|
|
|
else if (parse_bool(buf, "task", task)) continue;
|
|
|
|
else if (parse_bool(buf, "file_xfer", file_xfer)) continue;
|
|
|
|
else if (parse_bool(buf, "sched_ops", sched_ops)) continue;
|
|
|
|
else if (parse_bool(buf, "state_debug", state_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "task_debug", task_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "file_xfer_debug", file_xfer_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "sched_op_debug", sched_op_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "http_debug", http_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "proxy_debug", proxy_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "time_debug", time_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "net_xfer_debug", net_xfer_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "measurement_debug", measurement_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "poll_debug", poll_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "guirpc_debug", guirpc_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "sched_cpu_debug", sched_cpu_debug)) continue;
|
|
|
|
else if (parse_bool(buf, "scrsave_debug", scrsave_debug)) continue;
|
2006-05-21 21:11:28 +00:00
|
|
|
msg_printf(NULL, MSG_ERROR, "Unparsed line in %s: %s\n",
|
|
|
|
CONFIG_FILE, buf
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CONFIG::CONFIG() {
|
2006-05-22 09:54:31 +00:00
|
|
|
dont_check_file_sizes = false;
|
2006-05-21 21:11:28 +00:00
|
|
|
save_stats_days = 30;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CONFIG::parse(FILE* in) {
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
while (fgets(buf, 256, in)) {
|
|
|
|
if (strlen(buf) < 2) continue;
|
|
|
|
if (match_tag(buf, "</cc_config>")) return 0;
|
|
|
|
if (match_tag(buf, "<log_flags>")) {
|
|
|
|
log_flags.parse(in);
|
|
|
|
continue;
|
|
|
|
}
|
2006-05-22 09:54:31 +00:00
|
|
|
if (parse_int(buf, "<save_stats_days>", save_stats_days)) continue;
|
|
|
|
if (parse_bool(buf, "dont_check_file_sizes", dont_check_file_sizes)) continue;
|
2006-05-21 21:11:28 +00:00
|
|
|
msg_printf(NULL, MSG_ERROR, "Unparsed line in %s: %s\n",
|
|
|
|
CONFIG_FILE, buf
|
|
|
|
);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
2002-08-12 23:18:47 +00:00
|
|
|
|
2006-05-21 21:11:28 +00:00
|
|
|
void read_config_file() {
|
2002-08-12 23:18:47 +00:00
|
|
|
FILE* f;
|
|
|
|
|
2006-05-21 21:11:28 +00:00
|
|
|
if (boinc_file_exists(CONFIG_FILE)) {
|
|
|
|
f = boinc_fopen(CONFIG_FILE, "r");
|
|
|
|
config.parse(f);
|
2002-08-12 23:18:47 +00:00
|
|
|
fclose(f);
|
|
|
|
}
|
2004-03-01 19:11:12 +00:00
|
|
|
|
2002-08-12 23:18:47 +00:00
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_5f23de6652 = "$Id$";
|