-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 = \ | |||
35 | model/state/zoom_info_init.c \ | 35 | model/state/zoom_info_init.c \ |
36 | util/ati_meminfo.c \ | 36 | util/ati_meminfo.c \ |
37 | util/check_error.c \ | 37 | util/check_error.c \ |
38 | util/check_error_db.c \ | ||
38 | util/pick_convert.c \ | 39 | util/pick_convert.c \ |
39 | util/sqlinfoprint.c \ | 40 | util/sqlinfoprint.c \ |
40 | view/geometry.c \ | 41 | view/geometry.c \ |
@@ -75,6 +76,7 @@ noinst_HEADERS = \ | |||
75 | model/state/zoom_info_init.h \ | 76 | model/state/zoom_info_init.h \ |
76 | util/ati_meminfo.h \ | 77 | util/ati_meminfo.h \ |
77 | util/check_error.h \ | 78 | util/check_error.h \ |
79 | util/check_error_db.h \ | ||
78 | util/pick_convert.h \ | 80 | util/pick_convert.h \ |
79 | util/sqlinfoprint.h \ | 81 | util/sqlinfoprint.h \ |
80 | view/geometry.h \ | 82 | 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 @@ | |||
1 | #include "dbconnect.h" | 1 | #include "dbconnect.h" |
2 | #include "../util/check_error.h" | 2 | #include "../util/check_error_db.h" |
3 | 3 | ||
4 | EXEC SQL INCLUDE sqlca; | 4 | EXEC SQL INCLUDE sqlca; |
5 | 5 | ||
@@ -7,5 +7,13 @@ void | |||
7 | dbconnect (void) | 7 | dbconnect (void) |
8 | { | 8 | { |
9 | EXEC SQL CONNECT TO exp004; | 9 | EXEC SQL CONNECT TO exp004; |
10 | check_error (__FILE__, __LINE__); | 10 | |
11 | /* | ||
12 | * Only check for a database error rather than using check_error to | ||
13 | * test for OpenGL and database errors. OpenGL may not yet be | ||
14 | * prepared and checking it prematurely could cause odd behavior. | ||
15 | */ | ||
16 | check_error_db (__FILE__, __LINE__); | ||
17 | |||
18 | return; | ||
11 | } | 19 | } |
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 @@ | |||
2 | #include <error.h> | 2 | #include <error.h> |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include "sqlinfoprint.h" | 5 | #include "check_error_db.h" |
6 | extern struct sqlca sqlca; | ||
7 | 6 | ||
8 | void | 7 | void |
9 | check_error (const char *filename, const unsigned int linenum) | 8 | check_error (const char *filename, const unsigned int linenum) |
@@ -23,8 +22,7 @@ check_error (const char *filename, const unsigned int linenum) | |||
23 | /* | 22 | /* |
24 | * Check for an error from the Database API. | 23 | * Check for an error from the Database API. |
25 | */ | 24 | */ |
26 | if (sqlinfoprint ("DB Error", &sqlca, filename, linenum) == 1) | 25 | check_error_db (filename, linenum); |
27 | exit (EXIT_FAILURE); | ||
28 | 26 | ||
29 | return; | 27 | return; |
30 | } | 28 | } |
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 @@ | |||
1 | #include "check_error_db.h" | ||
2 | #include "sqlinfoprint.h" | ||
3 | #include <stdlib.h> | ||
4 | extern struct sqlca sqlca; | ||
5 | |||
6 | void | ||
7 | check_error_db (const char *filename, const unsigned int linenum) | ||
8 | { | ||
9 | if (sqlinfoprint ("DB Error", &sqlca, filename, linenum) == 1) | ||
10 | exit (EXIT_FAILURE); | ||
11 | |||
12 | return; | ||
13 | } | ||
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 @@ | |||
1 | #ifndef CHECK_ERROR_H | ||
2 | #define CHECK_ERROR_H | ||
3 | |||
4 | /* | ||
5 | * Check the database library to see if an error has occurred. | ||
6 | */ | ||
7 | void check_error_db (const char* filename, unsigned int linenum); | ||
8 | |||
9 | #endif // CHECK_ERROR_H | ||