2002-04-30 22:22:54 +00:00
|
|
|
// The contents of this file are subject to the Mozilla 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://www.mozilla.org/MPL/
|
|
|
|
//
|
|
|
|
// 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):
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2002-09-11 18:28:36 +00:00
|
|
|
#include "windows_cpp.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "error_numbers.h"
|
2002-08-12 23:18:47 +00:00
|
|
|
#include "file_names.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "parse.h"
|
|
|
|
|
|
|
|
#include "log_flags.h"
|
|
|
|
|
|
|
|
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;
|
|
|
|
time_debug = false;
|
|
|
|
net_xfer_debug = false;
|
2002-08-30 21:32:31 +00:00
|
|
|
measurement_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
|
|
|
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;
|
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;
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
else fprintf(stderr, "LOG_FLAGS::parse: unrecognized: %s\n", buf);
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
2002-08-12 23:18:47 +00:00
|
|
|
|
|
|
|
void read_log_flags() {
|
|
|
|
FILE* f;
|
|
|
|
|
|
|
|
f = fopen(LOG_FLAGS_FILE, "r");
|
|
|
|
if (f) {
|
|
|
|
log_flags.parse(f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
}
|