Finished fpunchf.

Old output_msg is commented.

Seems to work.

Ran all test cases.

Time to clean up and make class-only versions.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5709 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2011-10-20 19:02:39 +00:00
parent 6c2f0b5bf2
commit 53a00d4a98
3 changed files with 489 additions and 442 deletions

View File

@ -490,203 +490,239 @@ warning_msg(const char *err_str)
fflush(output_file);
}
}
///* ---------------------------------------------------------------------- */
//void PHRQ_io::
//output_msg(int type, const char *format, va_list args)
///* ---------------------------------------------------------------------- */
//{
// int flush = 1;
//
// switch (type)
// {
//
// //case OUTPUT_ERROR:
// // io_error_count++;
// // if (error_file != NULL && error_file_on)
// // {
// // fprintf(error_file, "\nERROR: ");
// // vfprintf(error_file, format, args);
// // fflush(error_file);
// // }
// // if (output_file != NULL && output_file_on)
// // {
// // fprintf(output_file, "\nERROR: ");
// // vfprintf(output_file, format, args);
// // fflush(output_file);
// // }
// // if (log_file != NULL && log_file_on)
// // {
// // fprintf(log_file, "\nERROR: ");
// // vfprintf(log_file, format, args);
// // fflush(log_file);
// // }
// // break;
// //case OUTPUT_WARNING:
// // if (error_file != NULL && error_file_on)
// // {
// // fprintf(error_file, "\nWARNING: ");
// // vfprintf(error_file, format, args);
// // fflush(error_file);
// // }
// // if (output_file != NULL && output_file_on)
// // {
// // fprintf(output_file, "\nWARNING: ");
// // vfprintf(output_file, format, args);
// // fflush(output_file);
// // }
// // if (log_file != NULL && log_file_on)
// // {
// // fprintf(log_file, "\nWARNING: ");
// // vfprintf(log_file, format, args);
// // fflush(log_file);
// // }
// // break;
// //case OUTPUT_CHECKLINE:
// // {
// // if (output_file != NULL && output_file_on)
// // {
// // vfprintf(output_file, format, args);
// // if (flush)
// // fflush(output_file);
// // }
// // }
// // break;
// //case OUTPUT_MESSAGE:
// // if (output_file != NULL && output_file_on)
// // {
// // vfprintf(output_file, format, args);
// // if (flush)
// // fflush(output_file);
// // }
// // break;
// //case OUTPUT_PUNCH:
// // if (punch_file != NULL && punch_file_on)
// // {
// // {
// // vfprintf(punch_file, format, args);
// // if (flush)
// // fflush(punch_file);
// // }
// // }
// // break;
// //case OUTPUT_LOG:
// // if (log_file != NULL && log_file_on)
// // {
// // vfprintf(log_file, format, args);
// // if (flush)
// // fflush(log_file);
// // }
// // break;
// //case OUTPUT_SCREEN:
// // if (error_file != NULL && error_file_on)
// // {
// // vfprintf(error_file, format, args);
// // if (flush)
// // fflush(error_file);
// // }
// // break;
//
// //case OUTPUT_DUMP:
// // if (dump_file != NULL && dump_file_on)
// // {
// // vfprintf(dump_file, format, args);
// // if (flush)
// // fflush(dump_file);
// // }
// // break;
// default:
// assert(false);
// break;
// }
//}
///* ---------------------------------------------------------------------- */
//void PHRQ_io::
//fpunchf(const char *name, const char *format, va_list args)
///* ---------------------------------------------------------------------- */
//{
// int flush = 1;
//
// if (punch_file != NULL && punch_file_on)
// {
// {
// vfprintf(punch_file, format, args);
// if (flush)
// fflush(punch_file);
// }
// }
//}
/* ---------------------------------------------------------------------- */
void PHRQ_io::
output_msg(int type, const char *format, va_list args)
fpunchf(const char *name, const char *format, double d)
/* ---------------------------------------------------------------------- */
{
int flush = 1;
switch (type)
{
//case OUTPUT_ERROR:
// io_error_count++;
// if (error_file != NULL && error_file_on)
// {
// fprintf(error_file, "\nERROR: ");
// vfprintf(error_file, format, args);
// fflush(error_file);
// }
// if (output_file != NULL && output_file_on)
// {
// fprintf(output_file, "\nERROR: ");
// vfprintf(output_file, format, args);
// fflush(output_file);
// }
// if (log_file != NULL && log_file_on)
// {
// fprintf(log_file, "\nERROR: ");
// vfprintf(log_file, format, args);
// fflush(log_file);
// }
// break;
//case OUTPUT_WARNING:
// if (error_file != NULL && error_file_on)
// {
// fprintf(error_file, "\nWARNING: ");
// vfprintf(error_file, format, args);
// fflush(error_file);
// }
// if (output_file != NULL && output_file_on)
// {
// fprintf(output_file, "\nWARNING: ");
// vfprintf(output_file, format, args);
// fflush(output_file);
// }
// if (log_file != NULL && log_file_on)
// {
// fprintf(log_file, "\nWARNING: ");
// vfprintf(log_file, format, args);
// fflush(log_file);
// }
// break;
//case OUTPUT_CHECKLINE:
// {
// if (output_file != NULL && output_file_on)
// {
// vfprintf(output_file, format, args);
// if (flush)
// fflush(output_file);
// }
// }
// break;
//case OUTPUT_MESSAGE:
// if (output_file != NULL && output_file_on)
// {
// vfprintf(output_file, format, args);
// if (flush)
// fflush(output_file);
// }
// break;
//case OUTPUT_PUNCH:
// if (punch_file != NULL && punch_file_on)
// {
// {
// vfprintf(punch_file, format, args);
// if (flush)
// fflush(punch_file);
// }
// }
// break;
//case OUTPUT_LOG:
// if (log_file != NULL && log_file_on)
// {
// vfprintf(log_file, format, args);
// if (flush)
// fflush(log_file);
// }
// break;
//case OUTPUT_SCREEN:
// if (error_file != NULL && error_file_on)
// {
// vfprintf(error_file, format, args);
// if (flush)
// fflush(error_file);
// }
// break;
//case OUTPUT_DUMP:
// if (dump_file != NULL && dump_file_on)
// {
// vfprintf(dump_file, format, args);
// if (flush)
// fflush(dump_file);
// }
// break;
default:
assert(false);
break;
}
}
/* ---------------------------------------------------------------------- */
void PHRQ_io::
fpunchf(const char *name, const char *format, va_list args)
/* ---------------------------------------------------------------------- */
{
int flush = 1;
if (punch_file != NULL && punch_file_on)
{
{
vfprintf(punch_file, format, args);
if (flush)
fflush(punch_file);
fprintf(punch_file, format, d);
}
}
}
/* ---------------------------------------------------------------------- */
void PHRQ_io::
output_string(const int type, std::string str)
fpunchf(const char *name, const char *format, char * s)
/* ---------------------------------------------------------------------- */
{
switch (type)
if (punch_file != NULL && punch_file_on)
{
//case OUTPUT_ERROR:
// //this->io_error_count++;
// if (error_file != NULL && error_file_on)
// {
// fprintf(error_file, "%s", str.c_str());
// }
// fflush(error_file);
// break;
//case OUTPUT_WARNING:
// if (log_file != NULL && log_file_on)
// {
// fprintf(log_file, "%s", str.c_str());
// }
// if (error_file != NULL && error_file_on)
// {
// fprintf(error_file, "%s", str.c_str());
// fflush(error_file);
// }
// if (output_file != NULL && output_file_on)
// {
// fprintf(output_file, "%s", str.c_str());
// }
// break;
//case OUTPUT_CHECKLINE:
//case OUTPUT_MESSAGE:
// if (output_file != NULL && output_file_on)
// {
// fprintf(output_file, "%s", str.c_str());
// }
// break;
//case OUTPUT_PUNCH:
// if (punch_file != NULL && punch_file_on)
// {
// fprintf(punch_file, "%s", str.c_str());
// }
// break;
//case OUTPUT_LOG:
// if (log_file != NULL && log_file_on)
// {
// fprintf(log_file, "%s", str.c_str());
// }
// break;
//case OUTPUT_SCREEN:
// if (error_file != NULL && error_file_on)
// {
// fprintf(error_file, "%s", str.c_str());
// fflush(error_file);
// }
// break;
//case OUTPUT_DUMP:
// if (dump_file != NULL && dump_file_on)
// {
// fprintf(dump_file, "%s", str.c_str());
// }
// break;
default:
assert(false);
{
fprintf(punch_file, format, s);
}
}
return;
}
/* ---------------------------------------------------------------------- */
void PHRQ_io::
fpunchf(const char *name, const char *format, int d)
/* ---------------------------------------------------------------------- */
{
if (punch_file != NULL && punch_file_on)
{
{
fprintf(punch_file, format, d);
}
}
}
///* ---------------------------------------------------------------------- */
//void PHRQ_io::
//output_string(const int type, std::string str)
///* ---------------------------------------------------------------------- */
//{
//
// switch (type)
// {
//
// //case OUTPUT_ERROR:
// // //this->io_error_count++;
// // if (error_file != NULL && error_file_on)
// // {
// // fprintf(error_file, "%s", str.c_str());
// // }
// // fflush(error_file);
// // break;
//
// //case OUTPUT_WARNING:
// // if (log_file != NULL && log_file_on)
// // {
// // fprintf(log_file, "%s", str.c_str());
// // }
// // if (error_file != NULL && error_file_on)
// // {
// // fprintf(error_file, "%s", str.c_str());
// // fflush(error_file);
// // }
// // if (output_file != NULL && output_file_on)
// // {
// // fprintf(output_file, "%s", str.c_str());
// // }
// // break;
// //case OUTPUT_CHECKLINE:
// //case OUTPUT_MESSAGE:
// // if (output_file != NULL && output_file_on)
// // {
// // fprintf(output_file, "%s", str.c_str());
// // }
// // break;
// //case OUTPUT_PUNCH:
// // if (punch_file != NULL && punch_file_on)
// // {
// // fprintf(punch_file, "%s", str.c_str());
// // }
// // break;
// //case OUTPUT_LOG:
// // if (log_file != NULL && log_file_on)
// // {
// // fprintf(log_file, "%s", str.c_str());
// // }
// // break;
// //case OUTPUT_SCREEN:
// // if (error_file != NULL && error_file_on)
// // {
// // fprintf(error_file, "%s", str.c_str());
// // fflush(error_file);
// // }
// // break;
//
// //case OUTPUT_DUMP:
// // if (dump_file != NULL && dump_file_on)
// // {
// // fprintf(dump_file, "%s", str.c_str());
// // }
// // break;
// default:
// assert(false);
// }
// return;
//}
/* ---------------------------------------------------------------------- */
int PHRQ_io::
close_output_files(void)
/* ---------------------------------------------------------------------- */
@ -708,263 +744,263 @@ close_output_files(void)
return ret;
}
/* ---------------------------------------------------------------------- */
int PHRQ_io::
output_open(int type, const char *file_name)
/* ---------------------------------------------------------------------- */
{
switch (type)
{
///* ---------------------------------------------------------------------- */
//int PHRQ_io::
//output_open(int type, const char *file_name)
///* ---------------------------------------------------------------------- */
//{
// switch (type)
// {
//
// //case OUTPUT_PUNCH:
// // if (punch_file != NULL)
// // {
// // fclose(punch_file);
// // punch_file = NULL;
// // }
// // if ((punch_file = fopen(file_name, "w")) == NULL)
// // {
// // //return ERROR;
// // return 0;
// // }
// // break;
// //case OUTPUT_MESSAGE:
// // if (output_file != NULL)
// // {
// // safe_close(output_file);
// // output_file = NULL;
// // }
// // if ((output_file = fopen(file_name, "w")) == NULL)
// // {
// // //return ERROR;
// // return 0;
// // }
// // break;
// //case OUTPUT_DUMP:
// // if (dump_file != NULL)
// // {
// // safe_close(dump_file);
// // dump_file = NULL;
// // }
// // if ((dump_file = fopen(file_name, "w")) == NULL)
// // {
// // //return ERROR;
// // return 0;
// // }
// // break;
// //case OUTPUT_ERROR:
// // if (error_file != NULL)
// // {
// // safe_close(error_file);
// // error_file = NULL;
// // }
//
// // if (file_name != NULL)
// // {
// // if ((error_file = fopen(file_name, "w")) == NULL)
// // {
// // error_file = stderr;
// // return 0;
// // }
// // }
// // else
// // {
// // error_file = stderr;
// // }
// // break;
// //case OUTPUT_LOG:
// // if (log_file != NULL)
// // {
// // safe_close(log_file);
// // log_file = NULL;
// // }
// // if ((log_file = fopen(file_name, "w")) == NULL)
// // {
// // return 0;
// // }
// // break;
// default:
// assert(false);
// }
// return 1;
//}
//case OUTPUT_PUNCH:
// if (punch_file != NULL)
// {
// fclose(punch_file);
// punch_file = NULL;
// }
// if ((punch_file = fopen(file_name, "w")) == NULL)
// {
// //return ERROR;
// return 0;
// }
// break;
//case OUTPUT_MESSAGE:
// if (output_file != NULL)
// {
// safe_close(output_file);
// output_file = NULL;
// }
// if ((output_file = fopen(file_name, "w")) == NULL)
// {
// //return ERROR;
// return 0;
// }
// break;
//case OUTPUT_DUMP:
// if (dump_file != NULL)
// {
// safe_close(dump_file);
// dump_file = NULL;
// }
// if ((dump_file = fopen(file_name, "w")) == NULL)
// {
// //return ERROR;
// return 0;
// }
// break;
//case OUTPUT_ERROR:
// if (error_file != NULL)
// {
// safe_close(error_file);
// error_file = NULL;
// }
///* ---------------------------------------------------------------------- */
//bool PHRQ_io::
//output_isopen(const int type)
///* ---------------------------------------------------------------------- */
//{
// switch (type)
// {
// //case OUTPUT_ERROR:
// // return (error_file != NULL);
// // break;
// //case OUTPUT_WARNING:
// // return (error_file != NULL || output_file != NULL);
// // break;
// //case OUTPUT_MESSAGE:
// // return (output_file != NULL);
// // break;
// //case OUTPUT_PUNCH:
// // return (punch_file != NULL);
// // break;
// //case OUTPUT_SCREEN:
// // return (error_file != NULL);
// // break;
// //case OUTPUT_LOG:
// // return (log_file != NULL);
// // break;
// //case OUTPUT_DUMP:
// // return (dump_file != NULL);
// // break;
// default:
// assert(false);
// return (output_file != NULL);
// break;
// }
// return false;
//}
// if (file_name != NULL)
// {
// if ((error_file = fopen(file_name, "w")) == NULL)
// {
// error_file = stderr;
// return 0;
// }
// }
// else
// {
// error_file = stderr;
// }
// break;
//case OUTPUT_LOG:
// if (log_file != NULL)
// {
// safe_close(log_file);
// log_file = NULL;
// }
// if ((log_file = fopen(file_name, "w")) == NULL)
// {
// return 0;
// }
// break;
default:
assert(false);
}
return 1;
}
/* ---------------------------------------------------------------------- */
bool PHRQ_io::
output_isopen(const int type)
/* ---------------------------------------------------------------------- */
{
switch (type)
{
//case OUTPUT_ERROR:
// return (error_file != NULL);
// break;
//case OUTPUT_WARNING:
// return (error_file != NULL || output_file != NULL);
// break;
//case OUTPUT_MESSAGE:
// return (output_file != NULL);
// break;
//case OUTPUT_PUNCH:
// return (punch_file != NULL);
// break;
//case OUTPUT_SCREEN:
// return (error_file != NULL);
// break;
//case OUTPUT_LOG:
// return (log_file != NULL);
// break;
//case OUTPUT_DUMP:
// return (dump_file != NULL);
// break;
default:
assert(false);
return (output_file != NULL);
break;
}
return false;
}
/* ---------------------------------------------------------------------- */
void PHRQ_io::
output_fflush(const int type)
/* ---------------------------------------------------------------------- */
{
switch (type)
{
//case OUTPUT_ERROR:
// if (error_file)
// fflush(error_file);
// break;
//case OUTPUT_WARNING:
// if (error_file)
// fflush(error_file);
// if (output_file)
// fflush(output_file);
// break;
//case OUTPUT_MESSAGE:
////case OUTPUT_CHECKLINE:
// if (output_file)
// fflush(output_file);
// break;
//case OUTPUT_PUNCH:
// if (punch_file)
// fflush(punch_file);
// break;
//case OUTPUT_SCREEN:
// if (error_file)
// fflush(error_file);
// break;
//case OUTPUT_LOG:
// if (log_file)
// fflush(log_file);
// break;
//case OUTPUT_DUMP:
// if (dump_file)
// fflush(dump_file);
// break;
default:
assert(false);
break;
}
}
/* ---------------------------------------------------------------------- */
void PHRQ_io::
output_rewind(const int type)
/* ---------------------------------------------------------------------- */
{
switch (type)
{
//case OUTPUT_ERROR:
// if (error_file)
// rewind(error_file);
// break;
//case OUTPUT_WARNING:
// if (error_file)
// rewind(error_file);
// if (output_file)
// rewind(output_file);
// break;
//case OUTPUT_MESSAGE:
////case OUTPUT_CHECKLINE:
// if (output_file)
// rewind(output_file);
// break;
//case OUTPUT_PUNCH:
// if (punch_file)
// rewind(punch_file);
// break;
//case OUTPUT_SCREEN:
// if (error_file)
// rewind(error_file);
// break;
//case OUTPUT_LOG:
// if (log_file)
// rewind(log_file);
// break;
//case OUTPUT_DUMP:
// if (dump_file)
// rewind(dump_file);
// break;
default:
assert(false);
break;
}
}
/* ---------------------------------------------------------------------- */
void PHRQ_io::
output_close(const int type)
/* ---------------------------------------------------------------------- */
{
switch (type)
{
//case OUTPUT_ERROR:
// safe_close(error_file);
// break;
//case OUTPUT_WARNING:
// safe_close(error_file);
// safe_close(output_file);
// break;
//case OUTPUT_MESSAGE:
////case OUTPUT_CHECKLINE:
// safe_close(output_file);
// break;
//case OUTPUT_PUNCH:
// safe_close(punch_file);
// break;
//case OUTPUT_SCREEN:
// safe_close(error_file);
// break;
//case OUTPUT_LOG:
// safe_close(log_file);
// break;
//case OUTPUT_DUMP:
// safe_close(dump_file);
// break;
default:
assert(false);
break;
}
}
///* ---------------------------------------------------------------------- */
//void PHRQ_io::
//output_fflush(const int type)
///* ---------------------------------------------------------------------- */
//{
// switch (type)
// {
// //case OUTPUT_ERROR:
// // if (error_file)
// // fflush(error_file);
// // break;
//
// //case OUTPUT_WARNING:
// // if (error_file)
// // fflush(error_file);
// // if (output_file)
// // fflush(output_file);
// // break;
//
// //case OUTPUT_MESSAGE:
// ////case OUTPUT_CHECKLINE:
// // if (output_file)
// // fflush(output_file);
// // break;
//
// //case OUTPUT_PUNCH:
// // if (punch_file)
// // fflush(punch_file);
// // break;
//
// //case OUTPUT_SCREEN:
// // if (error_file)
// // fflush(error_file);
// // break;
//
// //case OUTPUT_LOG:
// // if (log_file)
// // fflush(log_file);
// // break;
//
// //case OUTPUT_DUMP:
// // if (dump_file)
// // fflush(dump_file);
// // break;
// default:
// assert(false);
// break;
// }
//}
///* ---------------------------------------------------------------------- */
//void PHRQ_io::
//output_rewind(const int type)
///* ---------------------------------------------------------------------- */
//{
// switch (type)
// {
// //case OUTPUT_ERROR:
// // if (error_file)
// // rewind(error_file);
// // break;
//
// //case OUTPUT_WARNING:
// // if (error_file)
// // rewind(error_file);
// // if (output_file)
// // rewind(output_file);
// // break;
//
// //case OUTPUT_MESSAGE:
// ////case OUTPUT_CHECKLINE:
// // if (output_file)
// // rewind(output_file);
// // break;
//
// //case OUTPUT_PUNCH:
// // if (punch_file)
// // rewind(punch_file);
// // break;
//
// //case OUTPUT_SCREEN:
// // if (error_file)
// // rewind(error_file);
// // break;
//
// //case OUTPUT_LOG:
// // if (log_file)
// // rewind(log_file);
// // break;
//
// //case OUTPUT_DUMP:
// // if (dump_file)
// // rewind(dump_file);
// // break;
// default:
// assert(false);
// break;
// }
//}
///* ---------------------------------------------------------------------- */
//void PHRQ_io::
//output_close(const int type)
///* ---------------------------------------------------------------------- */
//{
// switch (type)
// {
// //case OUTPUT_ERROR:
// // safe_close(error_file);
// // break;
//
// //case OUTPUT_WARNING:
// // safe_close(error_file);
// // safe_close(output_file);
// // break;
//
// //case OUTPUT_MESSAGE:
// ////case OUTPUT_CHECKLINE:
// // safe_close(output_file);
// // break;
//
// //case OUTPUT_PUNCH:
// // safe_close(punch_file);
// // break;
//
// //case OUTPUT_SCREEN:
// // safe_close(error_file);
// // break;
//
// //case OUTPUT_LOG:
// // safe_close(log_file);
// // break;
//
// //case OUTPUT_DUMP:
// // safe_close(dump_file);
// // break;
//
// default:
// assert(false);
// break;
// }
//}
//safe_close is static method
/* ---------------------------------------------------------------------- */

View File

@ -84,15 +84,18 @@ typedef enum
bool dump_isopen(void);
void dump_msg(const char * str);
int output_open(int type, const char *file_name);
//int output_open(int type, const char *file_name);
void warning_msg(const char *err_str);
void output_string(const int type, std::string str);
void output_fflush(int type);
void output_rewind(int type);
void output_close(int type);
bool output_isopen(int type);
void output_msg(int type, const char *format, va_list args);
void fpunchf(const char *name, const char *format, va_list args);
//void output_string(const int type, std::string str);
//void output_fflush(int type);
//void output_rewind(int type);
//void output_close(int type);
//bool output_isopen(int type);
//void output_msg(int type, const char *format, va_list args);
//void fpunchf(const char *name, const char *format, va_list args);
void fpunchf(const char *name, const char *format, double d);
void fpunchf(const char *name, const char *format, char * d);
void fpunchf(const char *name, const char *format, int d);
void Set_io_error_count(int i) {this->io_error_count = i;};
int Get_io_error_count(void) {return this->io_error_count;};

View File

@ -283,6 +283,7 @@ int process_file_names(int argc, char *argv[], void **db_cookie,
/* PHRQ_io_output.cpp */
void screen_msg(const char *err_str);
void echo_msg(const char *err_str);
int warning_msg(const char *err_str);
// dump_file
bool dump_open(const char *file_name);
@ -325,6 +326,13 @@ bool punch_isopen(void);
void punch_msg(const char * str);
void fpunchf_heading(const char *name);
void fpunchf(const char *name, const char *format, double d);
void fpunchf(const char *name, const char *format, char * d);
void fpunchf(const char *name, const char *format, int d);
void fpunchf_user(int user_index, const char *format, double d);
void fpunchf_user(int user_index, const char *format, char * d);
int fpunchf_end_row(const char *format);
// dw.c -------------------------------
int BB(LDBLE T);
LDBLE PS(LDBLE T);