2003-06-11 23:36:48 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2002-04-30 22:22:54 +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
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2002-04-30 22:22:54 +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
|
2004-07-13 13:54:09 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2002-04-30 22:22:54 +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
|
2004-07-13 13:54:09 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
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
|
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;
|
|
|
|
|
|
|
|
LOG_FLAGS::LOG_FLAGS() {
|
2003-03-13 21:49:52 +00:00
|
|
|
|
|
|
|
// informational output is on by default
|
|
|
|
//
|
|
|
|
task = true;
|
|
|
|
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;
|
2004-03-25 03:48:54 +00:00
|
|
|
dont_check_file_sizes = 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
|
|
|
fgets(buf, 256, in);
|
|
|
|
if (!match_tag(buf, "<log_flags>")) return ERR_XML_PARSE;
|
|
|
|
while (fgets(buf, 256, in)) {
|
|
|
|
if (match_tag(buf, "</log_flags>")) return 0;
|
|
|
|
else if (match_tag(buf, "<task/>")) {
|
|
|
|
task = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<file_xfer/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
file_xfer = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<sched_ops/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
sched_ops = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<state_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
state_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<task_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
task_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<file_xfer_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
file_xfer_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<sched_op_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
sched_op_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<http_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
http_debug = true;
|
|
|
|
continue;
|
2004-03-27 00:45:27 +00:00
|
|
|
} else if (match_tag(buf, "<proxy_debug/>")) {
|
|
|
|
proxy_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<time_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
time_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<net_xfer_debug/>")) {
|
2002-04-30 22:22:54 +00:00
|
|
|
net_xfer_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<measurement_debug/>")) {
|
2002-08-30 21:32:31 +00:00
|
|
|
measurement_debug = true;
|
|
|
|
continue;
|
2003-03-13 21:49:52 +00:00
|
|
|
} else if (match_tag(buf, "<poll_debug/>")) {
|
2002-08-28 21:50:51 +00:00
|
|
|
poll_debug = true;
|
|
|
|
continue;
|
2004-06-11 20:52:27 +00:00
|
|
|
} else if (match_tag(buf, "<guirpc_debug/>")) {
|
|
|
|
guirpc_debug = true;
|
|
|
|
continue;
|
2004-03-25 01:25:52 +00:00
|
|
|
} else if (match_tag(buf, "<dont_check_file_sizes/>")) {
|
|
|
|
dont_check_file_sizes = true;
|
|
|
|
continue;
|
2002-08-28 21:50:51 +00:00
|
|
|
}
|
2003-07-03 05:01:29 +00:00
|
|
|
else msg_printf(NULL, MSG_ERROR, "LOG_FLAGS::parse: unrecognized: %s\n", buf);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
2002-08-12 23:18:47 +00:00
|
|
|
|
|
|
|
void read_log_flags() {
|
|
|
|
FILE* f;
|
|
|
|
|
2004-03-01 19:11:12 +00:00
|
|
|
if (boinc_file_exists(LOG_FLAGS_FILE)) {
|
|
|
|
f = fopen(LOG_FLAGS_FILE, "r");
|
2002-08-12 23:18:47 +00:00
|
|
|
log_flags.parse(f);
|
|
|
|
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
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
static volatile const char __attribute__((unused)) *BOINCrcsid="$Id$";
|
|
|
|
#else
|
|
|
|
static volatile const char *BOINCrcsid="$Id$";
|
|
|
|
#endif
|