author | Don Pellegrino <don@drexel.edu> | 2009-10-01 20:18:18 (GMT) |
---|---|---|
committer | Don Pellegrino <don@drexel.edu> | 2009-10-01 20:18:18 (GMT) |
commit | 3ca9bb7c3c90a8e7da3e2e440a72cdb11b3e66b0 (patch) (side-by-side diff) | |
tree | 2ae180bb0c0c9c68c8b806edaf41b8a086b80d25 | |
parent | aeaf641df8c44c7fa415abd325233fe739bf5b1d (diff) | |
download | exp005-3ca9bb7c3c90a8e7da3e2e440a72cdb11b3e66b0.zip exp005-3ca9bb7c3c90a8e7da3e2e440a72cdb11b3e66b0.tar.gz exp005-3ca9bb7c3c90a8e7da3e2e440a72cdb11b3e66b0.tar.bz2 |
Separated checking for an error in the database library from checking
for an error in the OpenGL library. The check_error function still
checks for both however the check_error_db function can now be used to
check only the database. This is used at connect time as the OpenGL
library may not yet be fully initialized and running the error
checking could be premature.
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/db/dbconnect.sqc | 12 | ||||
-rw-r--r-- | src/util/check_error.c | 6 | ||||
-rw-r--r-- | src/util/check_error_db.c | 13 | ||||
-rw-r--r-- | src/util/check_error_db.h | 9 |
5 files changed, 36 insertions, 6 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 4938ed4..d6253b8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,6 +35,7 @@ flumap_SOURCES = \ model/state/zoom_info_init.c \ util/ati_meminfo.c \ util/check_error.c \ + util/check_error_db.c \ util/pick_convert.c \ util/sqlinfoprint.c \ view/geometry.c \ @@ -75,6 +76,7 @@ noinst_HEADERS = \ model/state/zoom_info_init.h \ util/ati_meminfo.h \ util/check_error.h \ + util/check_error_db.h \ util/pick_convert.h \ util/sqlinfoprint.h \ view/geometry.h \ diff --git a/src/db/dbconnect.sqc b/src/db/dbconnect.sqc index 1e41a12..aab7bcb 100644 --- a/src/db/dbconnect.sqc +++ b/src/db/dbconnect.sqc @@ -1,5 +1,5 @@ #include "dbconnect.h" -#include "../util/check_error.h" +#include "../util/check_error_db.h" EXEC SQL INCLUDE sqlca; @@ -7,5 +7,13 @@ void dbconnect (void) { EXEC SQL CONNECT TO exp004; - check_error (__FILE__, __LINE__); + + /* + * Only check for a database error rather than using check_error to + * test for OpenGL and database errors. OpenGL may not yet be + * prepared and checking it prematurely could cause odd behavior. + */ + check_error_db (__FILE__, __LINE__); + + return; } diff --git a/src/util/check_error.c b/src/util/check_error.c index c47ca43..7d116e9 100644 --- a/src/util/check_error.c +++ b/src/util/check_error.c @@ -2,8 +2,7 @@ #include <error.h> #include <errno.h> #include <stdlib.h> -#include "sqlinfoprint.h" -extern struct sqlca sqlca; +#include "check_error_db.h" void check_error (const char *filename, const unsigned int linenum) @@ -23,8 +22,7 @@ check_error (const char *filename, const unsigned int linenum) /* * Check for an error from the Database API. */ - if (sqlinfoprint ("DB Error", &sqlca, filename, linenum) == 1) - exit (EXIT_FAILURE); + check_error_db (filename, linenum); return; } diff --git a/src/util/check_error_db.c b/src/util/check_error_db.c new file mode 100644 index 0000000..a6b7f51 --- a/dev/null +++ b/src/util/check_error_db.c @@ -0,0 +1,13 @@ +#include "check_error_db.h" +#include "sqlinfoprint.h" +#include <stdlib.h> +extern struct sqlca sqlca; + +void +check_error_db (const char *filename, const unsigned int linenum) +{ + if (sqlinfoprint ("DB Error", &sqlca, filename, linenum) == 1) + exit (EXIT_FAILURE); + + return; +} diff --git a/src/util/check_error_db.h b/src/util/check_error_db.h new file mode 100644 index 0000000..cc8467b --- a/dev/null +++ b/src/util/check_error_db.h @@ -0,0 +1,9 @@ +#ifndef CHECK_ERROR_H +#define CHECK_ERROR_H + +/* + * Check the database library to see if an error has occurred. + */ +void check_error_db (const char* filename, unsigned int linenum); + +#endif // CHECK_ERROR_H |