author | Michael Krelin <hacker@klever.net> | 2007-12-13 18:33:20 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-12-13 18:37:33 (UTC) |
commit | 58383f07af80dfd5b5c18e5158291c3d8caefbe7 (patch) (unidiff) | |
tree | fe7b9bc8da74bce0dcc6d8a033b8a8073f81ad14 | |
parent | 54f9cf0424f47ef6384bc55904097dc4ecb5fc78 (diff) | |
download | libopkele-58383f07af80dfd5b5c18e5158291c3d8caefbe7.zip libopkele-58383f07af80dfd5b5c18e5158291c3d8caefbe7.tar.gz libopkele-58383f07af80dfd5b5c18e5158291c3d8caefbe7.tar.bz2 |
keep track of whether the identity being discovered is XRI
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | include/opkele/discovery.h | 1 | ||||
-rw-r--r-- | lib/discovery.cc | 2 | ||||
-rw-r--r-- | test/idiscover.cc | 1 |
3 files changed, 4 insertions, 0 deletions
diff --git a/include/opkele/discovery.h b/include/opkele/discovery.h index 5d7129b..7865fb2 100644 --- a/include/opkele/discovery.h +++ b/include/opkele/discovery.h | |||
@@ -11,8 +11,9 @@ namespace opkele { | |||
11 | 11 | ||
12 | void idiscover(idiscovery_t& result,const string& identity); | 12 | void idiscover(idiscovery_t& result,const string& identity); |
13 | 13 | ||
14 | struct idiscovery_t { | 14 | struct idiscovery_t { |
15 | bool xri_identity; | ||
15 | string normalized_id; | 16 | string normalized_id; |
16 | string canonicalized_id; | 17 | string canonicalized_id; |
17 | xrd::XRD_t xrd; | 18 | xrd::XRD_t xrd; |
18 | 19 | ||
diff --git a/lib/discovery.cc b/lib/discovery.cc index a35ce32..1f23ff1 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc | |||
@@ -94,8 +94,9 @@ namespace opkele { | |||
94 | throw bad_input(OPKELE_CP_ "not a character of importance in identity"); | 94 | throw bad_input(OPKELE_CP_ "not a character of importance in identity"); |
95 | string id(identity,fsc,lsc-fsc+1); | 95 | string id(identity,fsc,lsc-fsc+1); |
96 | if(strchr(i_leaders,id[0])) { | 96 | if(strchr(i_leaders,id[0])) { |
97 | result.normalized_id = id; | 97 | result.normalized_id = id; |
98 | result.xri_identity = true; | ||
98 | /* TODO: further canonicalize xri identity? Like folding case or whatever... */ | 99 | /* TODO: further canonicalize xri identity? Like folding case or whatever... */ |
99 | discover_at( | 100 | discover_at( |
100 | result, | 101 | result, |
101 | xri_proxy + util::url_encode(id)+ | 102 | xri_proxy + util::url_encode(id)+ |
@@ -105,8 +106,9 @@ namespace opkele { | |||
105 | "XRI resolution failed with '"+status_string+"' message",status_code); | 106 | "XRI resolution failed with '"+status_string+"' message",status_code); |
106 | if(result.xrd.canonical_ids.empty()) | 107 | if(result.xrd.canonical_ids.empty()) |
107 | throw opkele::failed_discovery(OPKELE_CP_ "No CanonicalID for XRI identity found"); | 108 | throw opkele::failed_discovery(OPKELE_CP_ "No CanonicalID for XRI identity found"); |
108 | }else{ | 109 | }else{ |
110 | result.xri_identity = false; | ||
109 | if(id.find("://")==string::npos) | 111 | if(id.find("://")==string::npos) |
110 | id.insert(0,"http://"); | 112 | id.insert(0,"http://"); |
111 | string::size_type fp = id.find('#'); | 113 | string::size_type fp = id.find('#'); |
112 | if(fp!=string::npos) { | 114 | if(fp!=string::npos) { |
diff --git a/test/idiscover.cc b/test/idiscover.cc index 2abedc9..05cbcae 100644 --- a/test/idiscover.cc +++ b/test/idiscover.cc | |||
@@ -35,8 +35,9 @@ int main(int argc,char **argv) { | |||
35 | << "===============================================================" << endl | 35 | << "===============================================================" << endl |
36 | << "User-supplied ID: " << argv[a] << endl | 36 | << "User-supplied ID: " << argv[a] << endl |
37 | << "Normalized ID: " << discovery.normalized_id << endl | 37 | << "Normalized ID: " << discovery.normalized_id << endl |
38 | << "Canonicalized ID: " << discovery.canonicalized_id << endl | 38 | << "Canonicalized ID: " << discovery.canonicalized_id << endl |
39 | << "The identity is " << (discovery.xri_identity?"":"not ") << "an i-name" << endl | ||
39 | << endl | 40 | << endl |
40 | << "CanonicalID: " << discovery.xrd.canonical_ids << endl | 41 | << "CanonicalID: " << discovery.xrd.canonical_ids << endl |
41 | << "LocalID: " << discovery.xrd.local_ids << endl | 42 | << "LocalID: " << discovery.xrd.local_ids << endl |
42 | << "Services: " << discovery.xrd.services << endl; | 43 | << "Services: " << discovery.xrd.services << endl; |