summaryrefslogtreecommitdiffabout
path: root/test/idiscover.cc
Unidiff
Diffstat (limited to 'test/idiscover.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--test/idiscover.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/idiscover.cc b/test/idiscover.cc
index 873da12..d9a7c62 100644
--- a/test/idiscover.cc
+++ b/test/idiscover.cc
@@ -1,52 +1,54 @@
1#include <iostream> 1#include <iostream>
2#include <stdexcept> 2#include <stdexcept>
3#include <iterator> 3#include <iterator>
4#include <algorithm> 4#include <algorithm>
5using namespace std; 5using namespace std;
6#include <opkele/exception.h> 6#include <opkele/exception.h>
7#include <opkele/discovery.h> 7#include <opkele/discovery.h>
8 8
9template<typename _PDT> 9template<typename _PDT>
10 ostream& operator<<(ostream& o,const opkele::xrd::priority_map<_PDT>& pm) { 10 ostream& operator<<(ostream& o,const opkele::xrd::priority_map<_PDT>& pm) {
11 for(typename opkele::xrd::priority_map<_PDT>::const_iterator i=pm.begin(); 11 for(typename opkele::xrd::priority_map<_PDT>::const_iterator i=pm.begin();
12 i!=pm.end();++i) 12 i!=pm.end();++i)
13 o << ' ' << i->second << '[' << i->first << ']'; 13 o << ' ' << i->second << '[' << i->first << ']';
14 return o; 14 return o;
15 } 15 }
16 16
17ostream& operator<<(ostream& o,const opkele::xrd::service_t s) { 17ostream& operator<<(ostream& o,const opkele::xrd::service_t s) {
18 o << "{" << endl 18 o << "{" << endl
19 << " Type: "; 19 << " Type: ";
20 copy(s.types.begin(),s.types.end(), 20 copy(s.types.begin(),s.types.end(),
21 ostream_iterator<string>(o," ")); 21 ostream_iterator<string>(o," "));
22 o << endl 22 o << endl
23 << " URI: " << s.uris << endl 23 << " URI: " << s.uris << endl
24 << " LocalID: " << s.local_ids << endl; 24 << " LocalID: " << s.local_ids << endl
25 << " ProviderID: " << s.provider_id << endl;
25 o << "}"; 26 o << "}";
26} 27}
27 28
28int main(int argc,char **argv) { 29int main(int argc,char **argv) {
29 try { 30 try {
30 if(argc<2) 31 if(argc<2)
31 throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve"); 32 throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve");
32 for(int a=1;a<argc;++a) { 33 for(int a=1;a<argc;++a) {
33 opkele::idiscovery_t discovery(argv[a]); 34 opkele::idiscovery_t discovery(argv[a]);
34 clog 35 clog
35 << "===============================================================" << endl 36 << "===============================================================" << endl
36 << "User-supplied ID: " << argv[a] << endl 37 << "User-supplied ID: " << argv[a] << endl
37 << "Normalized ID: " << discovery.normalized_id << endl 38 << "Normalized ID: " << discovery.normalized_id << endl
38 << "Canonicalized ID: " << discovery.canonicalized_id << endl 39 << "Canonicalized ID: " << discovery.canonicalized_id << endl
39 << "The identity is " << (discovery.xri_identity?"":"not ") << "an i-name" << endl; 40 << "The identity is " << (discovery.xri_identity?"":"not ") << "an i-name" << endl;
40 if(discovery.xrd.expires) 41 if(discovery.xrd.expires)
41 clog << "Information expires in " << discovery.xrd.expires-time(0) << " seconds" << endl; 42 clog << "Information expires in " << discovery.xrd.expires-time(0) << " seconds" << endl;
42 clog << endl 43 clog << endl
43 << "CanonicalID: " << discovery.xrd.canonical_ids << endl 44 << "CanonicalID: " << discovery.xrd.canonical_ids << endl
44 << "LocalID: " << discovery.xrd.local_ids << endl 45 << "LocalID: " << discovery.xrd.local_ids << endl
46 << "ProviderID: " << discovery.xrd.provider_id << endl
45 << "Services: " << discovery.xrd.services << endl; 47 << "Services: " << discovery.xrd.services << endl;
46 } 48 }
47 }catch(exception& e) { 49 }catch(exception& e) {
48 cerr << "oops: " << e.what() << endl; 50 cerr << "oops: " << e.what() << endl;
49 _exit(1); 51 _exit(1);
50 } 52 }
51 _exit(0); 53 _exit(0);
52} 54}