author | Michael Krelin <hacker@klever.net> | 2009-03-11 20:18:56 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2009-03-11 20:18:56 (UTC) |
commit | e9a08ddbc451de3725293bf27ea90f579809af23 (patch) (unidiff) | |
tree | 2795b8b8e7a4415621b7601d49fe10e755de8321 | |
parent | dc10624546cc63fef3e633e493535698d3cc6998 (diff) | |
download | libopkele-e9a08ddbc451de3725293bf27ea90f579809af23.zip libopkele-e9a08ddbc451de3725293bf27ea90f579809af23.tar.gz libopkele-e9a08ddbc451de3725293bf27ea90f579809af23.tar.bz2 |
missing include for gcc 4.3
-rw-r--r-- | test/RP.cc | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -1,99 +1,100 @@ | |||
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 | }; |
52 | 53 | ||
53 | class example_rp_t : public opkele::prequeue_RP { | 54 | class example_rp_t : public opkele::prequeue_RP { |
54 | public: | 55 | public: |
55 | mutable rpdb_t db; | 56 | mutable rpdb_t db; |
56 | kingate::cookie htc; | 57 | kingate::cookie htc; |
57 | long as_id; | 58 | long as_id; |
58 | int ordinal; | 59 | int ordinal; |
59 | kingate::cgi_gateway& gw; | 60 | kingate::cgi_gateway& gw; |
60 | 61 | ||
61 | example_rp_t(kingate::cgi_gateway& g) | 62 | example_rp_t(kingate::cgi_gateway& g) |
62 | : as_id(-1), ordinal(0), gw(g), have_eqtop(false) { | 63 | : as_id(-1), ordinal(0), gw(g), have_eqtop(false) { |
63 | try { | 64 | try { |
64 | htc = gw.cookies.get_cookie("ht_session"); | 65 | htc = gw.cookies.get_cookie("ht_session"); |
65 | as_id = opkele::util::string_to_long(gw.get_param("asid")); | 66 | as_id = opkele::util::string_to_long(gw.get_param("asid")); |
66 | }catch(kingate::exception_notfound& kenf) { | 67 | }catch(kingate::exception_notfound& kenf) { |
67 | uuid_t uuid; uuid_generate(uuid); | 68 | uuid_t uuid; uuid_generate(uuid); |
68 | htc = kingate::cookie("ht_session",util::encode_base64(uuid,sizeof(uuid))); | 69 | htc = kingate::cookie("ht_session",util::encode_base64(uuid,sizeof(uuid))); |
69 | sqlite3_mem_t<char*> S = sqlite3_mprintf( | 70 | sqlite3_mem_t<char*> S = sqlite3_mprintf( |
70 | "INSERT INTO ht_sessions (hts_id) VALUES (%Q)", | 71 | "INSERT INTO ht_sessions (hts_id) VALUES (%Q)", |
71 | htc.get_value().c_str()); | 72 | htc.get_value().c_str()); |
72 | db.exec(S); | 73 | db.exec(S); |
73 | } | 74 | } |
74 | } | 75 | } |
75 | 76 | ||
76 | /* Global persistent store */ | 77 | /* Global persistent store */ |
77 | 78 | ||
78 | opkele::assoc_t store_assoc( | 79 | opkele::assoc_t store_assoc( |
79 | const string& OP,const string& handle, | 80 | const string& OP,const string& handle, |
80 | const string& type,const secret_t& secret, | 81 | const string& type,const secret_t& secret, |
81 | int expires_in) { | 82 | int expires_in) { |
82 | DUMBTHROW; | 83 | DUMBTHROW; |
83 | DOUT_("Storing '" << handle << "' assoc with '" << OP << "'"); | 84 | DOUT_("Storing '" << handle << "' assoc with '" << OP << "'"); |
84 | time_t exp = time(0)+expires_in; | 85 | time_t exp = time(0)+expires_in; |
85 | sqlite3_mem_t<char*> | 86 | sqlite3_mem_t<char*> |
86 | S = sqlite3_mprintf( | 87 | S = sqlite3_mprintf( |
87 | "INSERT INTO assoc" | 88 | "INSERT INTO assoc" |
88 | " (a_op,a_handle,a_type,a_ctime,a_etime,a_secret)" | 89 | " (a_op,a_handle,a_type,a_ctime,a_etime,a_secret)" |
89 | " VALUES (" | 90 | " VALUES (" |
90 | " %Q,%Q,%Q," | 91 | " %Q,%Q,%Q," |
91 | " datetime('now'), datetime('now','+%d seconds')," | 92 | " datetime('now'), datetime('now','+%d seconds')," |
92 | " %Q" | 93 | " %Q" |
93 | " );", OP.c_str(), handle.c_str(), type.c_str(), | 94 | " );", OP.c_str(), handle.c_str(), type.c_str(), |
94 | expires_in, | 95 | expires_in, |
95 | util::encode_base64(&(secret.front()),secret.size()).c_str() ); | 96 | util::encode_base64(&(secret.front()),secret.size()).c_str() ); |
96 | db.exec(S); | 97 | db.exec(S); |
97 | return opkele::assoc_t(new opkele::association( | 98 | return opkele::assoc_t(new opkele::association( |
98 | OP, handle, type, secret, exp, false )); | 99 | OP, handle, type, secret, exp, false )); |
99 | } | 100 | } |