OUTPUT_SCREEN and OUTPUT_LOG are done.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5703 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2011-10-19 21:48:09 +00:00
parent fbaa4906ff
commit efe04692ff
5 changed files with 103 additions and 95 deletions

View File

@ -45,8 +45,6 @@ warning_msg(const std::string & stdstr)
{ {
if (this->io) if (this->io)
{ {
//this->io->phreeqc_handler(PHRQ_io::ACTION_OUTPUT, PHRQ_io::OUTPUT_WARNING, stdstr.c_str(), false, "", NULL);
//this->io->output_string(PHRQ_io::OUTPUT_WARNING, stdstr);
this->io->warning_msg(stdstr.c_str()); this->io->warning_msg(stdstr.c_str());
} }
else else

View File

@ -13,7 +13,7 @@ PHRQ_io(void)
input_file = NULL; input_file = NULL;
database_file = NULL; database_file = NULL;
output_file = NULL; /* OUTPUT_MESSAGE */ output_file = NULL; /* OUTPUT_MESSAGE */
log_file = NULL; /* OUTPUT_LOG */ log_file = NULL;
punch_file = NULL; /* OUTPUT_PUNCH */ punch_file = NULL; /* OUTPUT_PUNCH */
error_file = NULL; error_file = NULL;
dump_file = NULL; dump_file = NULL;
@ -85,9 +85,9 @@ output_open_temp(const char *file_name)
safe_close(output_file); safe_close(output_file);
if ((output_file = fopen(file_name, "w")) == NULL) if ((output_file = fopen(file_name, "w")) == NULL)
{ {
return true; // error return false; // error
} }
return false; return true;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PHRQ_io:: void PHRQ_io::
@ -147,9 +147,9 @@ log_open(const char *file_name)
safe_close(log_file); safe_close(log_file);
if ((log_file = fopen(file_name, "w")) == NULL) if ((log_file = fopen(file_name, "w")) == NULL)
{ {
return true; // error return false; // error
} }
return false; return true;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PHRQ_io:: void PHRQ_io::
@ -209,9 +209,9 @@ punch_open(const char *file_name)
safe_close(punch_file); safe_close(punch_file);
if ((punch_file = fopen(file_name, "w")) == NULL) if ((punch_file = fopen(file_name, "w")) == NULL)
{ {
return true; // error return false; // error
} }
return false; return true;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PHRQ_io:: void PHRQ_io::
@ -375,9 +375,9 @@ dump_open(const char *file_name)
safe_close(dump_file); safe_close(dump_file);
if ((dump_file = fopen(file_name, "w")) == NULL) if ((dump_file = fopen(file_name, "w")) == NULL)
{ {
return true; // error return false; // error
} }
return false; return true;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PHRQ_io:: void PHRQ_io::
@ -569,22 +569,22 @@ output_msg(int type, const char *format, va_list args)
} }
} }
break; break;
case OUTPUT_LOG: //case OUTPUT_LOG:
if (log_file != NULL && log_file_on) // if (log_file != NULL && log_file_on)
{ // {
vfprintf(log_file, format, args); // vfprintf(log_file, format, args);
if (flush) // if (flush)
fflush(log_file); // fflush(log_file);
} // }
break; // break;
case OUTPUT_SCREEN: //case OUTPUT_SCREEN:
if (error_file != NULL && error_file_on) // if (error_file != NULL && error_file_on)
{ // {
vfprintf(error_file, format, args); // vfprintf(error_file, format, args);
if (flush) // if (flush)
fflush(error_file); // fflush(error_file);
} // }
break; // break;
//case OUTPUT_DUMP: //case OUTPUT_DUMP:
// if (dump_file != NULL && dump_file_on) // if (dump_file != NULL && dump_file_on)
@ -661,19 +661,19 @@ output_string(const int type, std::string str)
fprintf(punch_file, "%s", str.c_str()); fprintf(punch_file, "%s", str.c_str());
} }
break; break;
case OUTPUT_LOG: //case OUTPUT_LOG:
if (log_file != NULL && log_file_on) // if (log_file != NULL && log_file_on)
{ // {
fprintf(log_file, "%s", str.c_str()); // fprintf(log_file, "%s", str.c_str());
} // }
break; // break;
case OUTPUT_SCREEN: //case OUTPUT_SCREEN:
if (error_file != NULL && error_file_on) // if (error_file != NULL && error_file_on)
{ // {
fprintf(error_file, "%s", str.c_str()); // fprintf(error_file, "%s", str.c_str());
fflush(error_file); // fflush(error_file);
} // }
break; // break;
//case OUTPUT_DUMP: //case OUTPUT_DUMP:
// if (dump_file != NULL && dump_file_on) // if (dump_file != NULL && dump_file_on)
@ -772,17 +772,17 @@ output_open(int type, const char *file_name)
// error_file = stderr; // error_file = stderr;
// } // }
// break; // break;
case OUTPUT_LOG: //case OUTPUT_LOG:
if (log_file != NULL) // if (log_file != NULL)
{ // {
safe_close(log_file); // safe_close(log_file);
log_file = NULL; // log_file = NULL;
} // }
if ((log_file = fopen(file_name, "w")) == NULL) // if ((log_file = fopen(file_name, "w")) == NULL)
{ // {
return 0; // return 0;
} // }
break; // break;
default: default:
assert(false); assert(false);
} }
@ -808,12 +808,12 @@ output_isopen(const int type)
case OUTPUT_PUNCH: case OUTPUT_PUNCH:
return (punch_file != NULL); return (punch_file != NULL);
break; break;
case OUTPUT_SCREEN: //case OUTPUT_SCREEN:
return (error_file != NULL); // return (error_file != NULL);
break; // break;
case OUTPUT_LOG: //case OUTPUT_LOG:
return (log_file != NULL); // return (log_file != NULL);
break; // break;
//case OUTPUT_DUMP: //case OUTPUT_DUMP:
// return (dump_file != NULL); // return (dump_file != NULL);
// break; // break;
@ -855,15 +855,15 @@ output_fflush(const int type)
fflush(punch_file); fflush(punch_file);
break; break;
case OUTPUT_SCREEN: //case OUTPUT_SCREEN:
if (error_file) // if (error_file)
fflush(error_file); // fflush(error_file);
break; // break;
case OUTPUT_LOG: //case OUTPUT_LOG:
if (log_file) // if (log_file)
fflush(log_file); // fflush(log_file);
break; // break;
//case OUTPUT_DUMP: //case OUTPUT_DUMP:
// if (dump_file) // if (dump_file)
@ -904,15 +904,15 @@ output_rewind(const int type)
rewind(punch_file); rewind(punch_file);
break; break;
case OUTPUT_SCREEN: //case OUTPUT_SCREEN:
if (error_file) // if (error_file)
rewind(error_file); // rewind(error_file);
break; // break;
case OUTPUT_LOG: //case OUTPUT_LOG:
if (log_file) // if (log_file)
rewind(log_file); // rewind(log_file);
break; // break;
//case OUTPUT_DUMP: //case OUTPUT_DUMP:
// if (dump_file) // if (dump_file)
@ -948,13 +948,13 @@ output_close(const int type)
safe_close(punch_file); safe_close(punch_file);
break; break;
case OUTPUT_SCREEN: //case OUTPUT_SCREEN:
safe_close(error_file); // safe_close(error_file);
break; // break;
case OUTPUT_LOG: //case OUTPUT_LOG:
safe_close(log_file); // safe_close(log_file);
break; // break;
//case OUTPUT_DUMP: //case OUTPUT_DUMP:
// safe_close(dump_file); // safe_close(dump_file);

View File

@ -14,8 +14,8 @@ typedef enum
//OUTPUT_WARNING, //OUTPUT_WARNING,
OUTPUT_MESSAGE, OUTPUT_MESSAGE,
OUTPUT_PUNCH, OUTPUT_PUNCH,
OUTPUT_SCREEN, //OUTPUT_SCREEN,
OUTPUT_LOG, //OUTPUT_LOG,
OUTPUT_CHECKLINE, OUTPUT_CHECKLINE,
OUTPUT_GUI_ERROR, OUTPUT_GUI_ERROR,
//OUTPUT_DUMP, //OUTPUT_DUMP,
@ -123,7 +123,7 @@ protected:
FILE *input_file; FILE *input_file;
FILE *database_file; FILE *database_file;
FILE *output_file; /* OUTPUT_MESSAGE */ FILE *output_file; /* OUTPUT_MESSAGE */
FILE *log_file; /* OUTPUT_LOG */ FILE *log_file;
FILE *punch_file; /* OUTPUT_PUNCH */ FILE *punch_file; /* OUTPUT_PUNCH */
FILE *error_file; FILE *error_file;
FILE *dump_file; FILE *dump_file;

View File

@ -281,6 +281,8 @@ int process_file_names(int argc, char *argv[], void **db_cookie,
void **input_cookie, int log); void **input_cookie, int log);
/* PHRQ_io_output.cpp */ /* PHRQ_io_output.cpp */
void screen_msg(const char *err_str);
// dump_file // dump_file
bool dump_open(const char *file_name); bool dump_open(const char *file_name);
void dump_fflush(void); void dump_fflush(void);
@ -289,6 +291,14 @@ void dump_rewind(void);
bool dump_isopen(void); bool dump_isopen(void);
void dump_msg(const char * str); void dump_msg(const char * str);
// log_file
bool log_open(const char *file_name);
void log_fflush(void);
void log_close(void);
void log_rewind(void);
bool log_isopen(void);
void log_msg(const char * str);
// error_file // error_file
bool error_open(const char *file_name); bool error_open(const char *file_name);
void error_fflush(void); void error_fflush(void);

View File

@ -186,38 +186,38 @@ write_banner(void)
{ {
char buffer[80]; char buffer[80];
int len, indent; int len, indent;
output_msg(OUTPUT_SCREEN, screen_msg(
" ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ\n"); " ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ\n");
output_msg(OUTPUT_SCREEN, screen_msg(
" º º\n"); " º º\n");
/* version */ /* version */
len = sprintf(buffer, "* PHREEQC-%s *", "@VERSION@"); len = sprintf(buffer, "* PHREEQC-%s *", "@VERSION@");
indent = (44 - len) / 2; indent = (44 - len) / 2;
output_msg(OUTPUT_SCREEN, "%14cº%*c%s%*cº\n", ' ', indent, ' ', buffer, screen_msg(sformatf("%14cº%*c%s%*cº\n", ' ', indent, ' ', buffer,
44 - indent - len, ' '); 44 - indent - len, ' ').c_str());
output_msg(OUTPUT_SCREEN, screen_msg(
" º º\n"); " º º\n");
output_msg(OUTPUT_SCREEN, screen_msg(
" º A hydrogeochemical transport model º\n"); " º A hydrogeochemical transport model º\n");
output_msg(OUTPUT_SCREEN, screen_msg(
" º º\n"); " º º\n");
output_msg(OUTPUT_SCREEN, screen_msg(
" º by º\n"); " º by º\n");
output_msg(OUTPUT_SCREEN, screen_msg(
" º D.L. Parkhurst and C.A.J. Appelo º\n"); " º D.L. Parkhurst and C.A.J. Appelo º\n");
output_msg(OUTPUT_SCREEN, screen_msg(
" º º\n"); " º º\n");
/* date */ /* date */
len = sprintf(buffer, "%s", "@VER_DATE@"); len = sprintf(buffer, "%s", "@VER_DATE@");
indent = (44 - len) / 2; indent = (44 - len) / 2;
output_msg(OUTPUT_SCREEN, "%14cº%*c%s%*cº\n", ' ', indent, ' ', buffer, screen_msg(sformatf("%14cº%*c%s%*cº\n", ' ', indent, ' ', buffer,
44 - indent - len, ' '); 44 - indent - len, ' ').c_str());
output_msg(OUTPUT_SCREEN, screen_msg(
" ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ\n\n"); " ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ\n\n");
return 0; return 0;