diff --git a/checkin_notes b/checkin_notes index 3e6a04f640..6d6fc65499 100755 --- a/checkin_notes +++ b/checkin_notes @@ -9149,3 +9149,17 @@ David 22 Aug 2006 client_types.C,h cpu_sched.C cs_apps.C + +David 22 Aug 2006 + - change XML_PARSER to take a MIOFILE* instead of a FILE*. + This allows it to be used anywhere in BOINC. + + client/ + log_flags.C + lib/ + miofile.C,h + parse.C,h + sched/ + sched_config.C + sea/ + insecure.sh diff --git a/client/log_flags.C b/client/log_flags.C index aa3f1a1331..618efb2a95 100644 --- a/client/log_flags.C +++ b/client/log_flags.C @@ -132,9 +132,11 @@ int CONFIG::parse_options(XML_PARSER& xp) { int CONFIG::parse(FILE* f) { char tag[256]; - XML_PARSER xp(f); + MIOFILE mf; + XML_PARSER xp(&mf); bool is_tag; + mf.init_file(f); if (!xp.parse_start("cc_config")) return ERR_XML_PARSE; while (!xp.get(tag, is_tag)) { if (!is_tag) { diff --git a/lib/miofile.C b/lib/miofile.C index afdf749da8..a14e35400d 100644 --- a/lib/miofile.C +++ b/lib/miofile.C @@ -87,6 +87,15 @@ char* MIOFILE::fgets(char* dst, int len) { return dst; } +int MIOFILE::ungetc(int c) { + if (f) { + return ::ungetc(c, f); + } + buf--; + *buf = c; + return c; +} + // copy from a file to static buffer // int copy_element_contents(MIOFILE& in, const char* end_tag, char* p, int len) { diff --git a/lib/miofile.h b/lib/miofile.h index ba54bd2866..b85bbad978 100644 --- a/lib/miofile.h +++ b/lib/miofile.h @@ -50,6 +50,11 @@ public: void init_buf(char*); int printf(const char* format, ...); char* fgets(char*, int); + int ungetc(int); + inline int getc() { + if (f) return ::getc(f); + return (*buf)?(*buf++):EOF; + } private: MFILE* mf; FILE* f; diff --git a/lib/parse.C b/lib/parse.C index 4bdbbaeb65..8ec8341f83 100644 --- a/lib/parse.C +++ b/lib/parse.C @@ -407,7 +407,7 @@ int skip_unrecognized(char* buf, FILE* in) { return ERR_XML_PARSE; } -XML_PARSER::XML_PARSER(FILE* _f) { +XML_PARSER::XML_PARSER(MIOFILE* _f) { f = _f; } @@ -418,7 +418,7 @@ XML_PARSER::XML_PARSER(FILE* _f) { bool XML_PARSER::scan_nonws(int& first_char) { int c; while (1) { - c = getc(f); + c = f->getc(); if (c == EOF) return true; if (isspace(c)) continue; first_char = c; @@ -433,7 +433,7 @@ bool XML_PARSER::scan_nonws(int& first_char) { bool XML_PARSER::scan_tag(char* buf) { int c; while (1) { - c = getc(f); + c = f->getc(); if (c == EOF) return true; if (c == '>') { *buf = 0; @@ -450,10 +450,10 @@ bool XML_PARSER::scan_tag(char* buf) { bool XML_PARSER::copy_until_tag(char* buf) { int c; while (1) { - c = getc(f); + c = f->getc(); if (c == EOF) return true; if (c == '<') { - ungetc(c, f); + f->ungetc(c); *buf = 0; return false; } diff --git a/lib/parse.h b/lib/parse.h index e86a21bc1f..f11d156067 100644 --- a/lib/parse.h +++ b/lib/parse.h @@ -33,13 +33,15 @@ #endif #endif +#include "miofile.h" + class XML_PARSER { - FILE* f; + MIOFILE* f; bool scan_nonws(int&); bool scan_tag(char*); bool copy_until_tag(char*); public: - XML_PARSER(FILE*); + XML_PARSER(MIOFILE*); bool get(char*, bool&); bool parse_start(char*); bool parse_str(char*, char*, char*); diff --git a/sched/sched_config.C b/sched/sched_config.C index daf7fc21df..bd43984ee4 100644 --- a/sched/sched_config.C +++ b/sched/sched_config.C @@ -37,9 +37,11 @@ const char* CONFIG_FILE = "config.xml"; int SCHED_CONFIG::parse(FILE* f) { char tag[1024], temp[1024]; - XML_PARSER xp(f); bool is_tag; + MIOFILE mf; + XML_PARSER xp(&mf); + mf.init_file(f); memset(this, 0, sizeof(SCHED_CONFIG)); max_wus_to_send = 10; default_disk_max_used_gb = 100.; diff --git a/sea/insecure.sh b/sea/insecure.sh index 434a1e9a16..6265e20d97 100755 --- a/sea/insecure.sh +++ b/sea/insecure.sh @@ -53,16 +53,17 @@ else exit fi -# If the user forgets to cd to the boinc data directory, this script can do serious damage +# If the user forgets to cd to the boinc data directory, +# this script can do serious damage # so show the directory we are about to modify -echo "Changing directory $(pwd) file ownership to user $user and group $group - OK? (y/n)" +echo "Changing directory $(pwd) ownership to user $user and group $group - OK? (y/n)" read line if [ "$line" != "y" ] then exit fi -# if the booinc client is not here, assume it is the wrong directory +# if the boinc client is not here, assume it is the wrong directory if [ ! -f "boinc_client" ] then echo "Can't find boinc_client in directory $(pwd); exiting"