|
|
|
@@ -1,51 +1,52 @@ |
1 | #include <uuid/uuid.h> |
1 | #include <uuid/uuid.h> |
2 | #include <iostream> |
2 | #include <iostream> |
3 | #include <cassert> |
3 | #include <cassert> |
| |
4 | #include <cstdlib> |
4 | #include <stdexcept> |
5 | #include <stdexcept> |
5 | #include <string> |
6 | #include <string> |
6 | #include <set> |
7 | #include <set> |
7 | #include <iterator> |
8 | #include <iterator> |
8 | using namespace std; |
9 | using namespace std; |
9 | #include <kingate/exception.h> |
10 | #include <kingate/exception.h> |
10 | #include <kingate/plaincgi.h> |
11 | #include <kingate/plaincgi.h> |
11 | #include <kingate/cgi_gateway.h> |
12 | #include <kingate/cgi_gateway.h> |
12 | #include <opkele/exception.h> |
13 | #include <opkele/exception.h> |
13 | #include <opkele/types.h> |
14 | #include <opkele/types.h> |
14 | #include <opkele/util.h> |
15 | #include <opkele/util.h> |
15 | #include <opkele/uris.h> |
16 | #include <opkele/uris.h> |
16 | #include <opkele/discovery.h> |
17 | #include <opkele/discovery.h> |
17 | #include <opkele/association.h> |
18 | #include <opkele/association.h> |
18 | #include <opkele/sreg.h> |
19 | #include <opkele/sreg.h> |
19 | using namespace opkele; |
20 | using namespace opkele; |
20 | #include <opkele/prequeue_rp.h> |
21 | #include <opkele/prequeue_rp.h> |
21 | #include <opkele/debug.h> |
22 | #include <opkele/debug.h> |
22 | |
23 | |
23 | #include "sqlite.h" |
24 | #include "sqlite.h" |
24 | #include "kingate_openid_message.h" |
25 | #include "kingate_openid_message.h" |
25 | |
26 | |
26 | #undef DUMB_RP |
27 | #undef DUMB_RP |
27 | |
28 | |
28 | #ifdef DUMB_RP |
29 | #ifdef DUMB_RP |
29 | # define DUMBTHROW throw opkele::dumb_RP(OPKELE_CP_ "This RP is dumb") |
30 | # define DUMBTHROW throw opkele::dumb_RP(OPKELE_CP_ "This RP is dumb") |
30 | #else |
31 | #else |
31 | # define DUMBTHROW (void)0 |
32 | # define DUMBTHROW (void)0 |
32 | #endif |
33 | #endif |
33 | |
34 | |
34 | class rpdb_t : public sqlite3_t { |
35 | class rpdb_t : public sqlite3_t { |
35 | public: |
36 | public: |
36 | rpdb_t() |
37 | rpdb_t() |
37 | : sqlite3_t("/tmp/RP.db") { |
38 | : sqlite3_t("/tmp/RP.db") { |
38 | assert(_D); |
39 | assert(_D); |
39 | char **resp; int nrow,ncol; char *errm; |
40 | char **resp; int nrow,ncol; char *errm; |
40 | if(sqlite3_get_table( |
41 | if(sqlite3_get_table( |
41 | _D,"SELECT a_op FROM assoc LIMIT 0", |
42 | _D,"SELECT a_op FROM assoc LIMIT 0", |
42 | &resp,&nrow,&ncol,&errm)!=SQLITE_OK) { |
43 | &resp,&nrow,&ncol,&errm)!=SQLITE_OK) { |
43 | extern const char *__RP_db_bootstrap; |
44 | extern const char *__RP_db_bootstrap; |
44 | DOUT_("Bootstrapping DB"); |
45 | DOUT_("Bootstrapping DB"); |
45 | if(sqlite3_exec(_D,__RP_db_bootstrap,NULL,NULL,&errm)!=SQLITE_OK) |
46 | if(sqlite3_exec(_D,__RP_db_bootstrap,NULL,NULL,&errm)!=SQLITE_OK) |
46 | throw opkele::exception(OPKELE_CP_ string("Failed to bootstrap SQLite database: ")+errm); |
47 | throw opkele::exception(OPKELE_CP_ string("Failed to bootstrap SQLite database: ")+errm); |
47 | }else |
48 | }else |
48 | sqlite3_free_table(resp); |
49 | sqlite3_free_table(resp); |
49 | |
50 | |
50 | } |
51 | } |
51 | }; |
52 | }; |
|