summaryrefslogtreecommitdiffabout
path: root/test
Side-by-side diff
Diffstat (limited to 'test') (more/less context) (ignore whitespace changes)
-rw-r--r--test/.gitignore1
-rw-r--r--test/Makefile.am6
-rw-r--r--test/idiscover.cc54
3 files changed, 60 insertions, 1 deletions
diff --git a/test/.gitignore b/test/.gitignore
index 918b3c9..31ae686 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -4 +4,2 @@
*.o
+/idiscover
diff --git a/test/Makefile.am b/test/Makefile.am
index 0d1c0ef..b573d55 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,3 +1,4 @@
-noinst_PROGRAMS = test
+noinst_PROGRAMS = test idiscover
+AM_CPPFLAGS=${CPPFLAGS_DEBUG}
DEFAULT_INCLUDES = -I${top_builddir}
@@ -12 +13,4 @@ EXTRA_DIST=$(addsuffix .html,$(addprefix html/, \
))
+
+idiscover_SOURCES = idiscover.cc
+idiscover_LDADD = ${top_builddir}/lib/libopkele.la
diff --git a/test/idiscover.cc b/test/idiscover.cc
new file mode 100644
index 0000000..d9a7c62
--- a/dev/null
+++ b/test/idiscover.cc
@@ -0,0 +1,54 @@
+#include <iostream>
+#include <stdexcept>
+#include <iterator>
+#include <algorithm>
+using namespace std;
+#include <opkele/exception.h>
+#include <opkele/discovery.h>
+
+template<typename _PDT>
+ ostream& operator<<(ostream& o,const opkele::xrd::priority_map<_PDT>& pm) {
+ for(typename opkele::xrd::priority_map<_PDT>::const_iterator i=pm.begin();
+ i!=pm.end();++i)
+ o << ' ' << i->second << '[' << i->first << ']';
+ return o;
+ }
+
+ostream& operator<<(ostream& o,const opkele::xrd::service_t s) {
+ o << "{" << endl
+ << " Type: ";
+ copy(s.types.begin(),s.types.end(),
+ ostream_iterator<string>(o," "));
+ o << endl
+ << " URI: " << s.uris << endl
+ << " LocalID: " << s.local_ids << endl
+ << " ProviderID: " << s.provider_id << endl;
+ o << "}";
+}
+
+int main(int argc,char **argv) {
+ try {
+ if(argc<2)
+ throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve");
+ for(int a=1;a<argc;++a) {
+ opkele::idiscovery_t discovery(argv[a]);
+ clog
+ << "===============================================================" << endl
+ << "User-supplied ID: " << argv[a] << endl
+ << "Normalized ID: " << discovery.normalized_id << endl
+ << "Canonicalized ID: " << discovery.canonicalized_id << endl
+ << "The identity is " << (discovery.xri_identity?"":"not ") << "an i-name" << endl;
+ if(discovery.xrd.expires)
+ clog << "Information expires in " << discovery.xrd.expires-time(0) << " seconds" << endl;
+ clog << endl
+ << "CanonicalID: " << discovery.xrd.canonical_ids << endl
+ << "LocalID: " << discovery.xrd.local_ids << endl
+ << "ProviderID: " << discovery.xrd.provider_id << endl
+ << "Services: " << discovery.xrd.services << endl;
+ }
+ }catch(exception& e) {
+ cerr << "oops: " << e.what() << endl;
+ _exit(1);
+ }
+ _exit(0);
+}