summaryrefslogtreecommitdiffabout
path: root/lib/discovery.cc
Unidiff
Diffstat (limited to 'lib/discovery.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/discovery.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc
index b7f2db6..5913ad4 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -6,6 +6,7 @@
6#include <opkele/exception.h> 6#include <opkele/exception.h>
7#include <opkele/util.h> 7#include <opkele/util.h>
8#include <opkele/tidy.h> 8#include <opkele/tidy.h>
9#include <opkele/data.h>
9#include <opkele/debug.h> 10#include <opkele/debug.h>
10 11
11#include "config.h" 12#include "config.h"
@@ -21,8 +22,6 @@ namespace opkele {
21 /* TODO: the whole discovery thing needs cleanup and optimization due to 22 /* TODO: the whole discovery thing needs cleanup and optimization due to
22 * many changes of concept. */ 23 * many changes of concept. */
23 24
24 static const char *whitespace = " \t\r\n";
25 static const char *i_leaders = "=@+$!(";
26 static const size_t max_html = 16384; 25 static const size_t max_html = 16384;
27 26
28 static const struct service_type_t { 27 static const struct service_type_t {
@@ -128,10 +127,10 @@ namespace opkele {
128 string discover(endpoint_discovery_iterator& oi,const string& identity) { 127 string discover(endpoint_discovery_iterator& oi,const string& identity) {
129 string rv; 128 string rv;
130 idiscovery_t idis; 129 idiscovery_t idis;
131 string::size_type fsc = identity.find_first_not_of(whitespace); 130 string::size_type fsc = identity.find_first_not_of(data::_whitespace_chars);
132 if(fsc==string::npos) 131 if(fsc==string::npos)
133 throw bad_input(OPKELE_CP_ "whitespace-only identity"); 132 throw bad_input(OPKELE_CP_ "whitespace-only identity");
134 string::size_type lsc = identity.find_last_not_of(whitespace); 133 string::size_type lsc = identity.find_last_not_of(data::_whitespace_chars);
135 assert(lsc!=string::npos); 134 assert(lsc!=string::npos);
136 if(!strncasecmp(identity.c_str()+fsc,"xri://",sizeof("xri://")-1)) 135 if(!strncasecmp(identity.c_str()+fsc,"xri://",sizeof("xri://")-1))
137 fsc += sizeof("xri://")-1; 136 fsc += sizeof("xri://")-1;
@@ -139,7 +138,7 @@ namespace opkele {
139 throw bad_input(OPKELE_CP_ "not a character of importance in identity"); 138 throw bad_input(OPKELE_CP_ "not a character of importance in identity");
140 string id(identity,fsc,lsc-fsc+1); 139 string id(identity,fsc,lsc-fsc+1);
141 idis.clear(); 140 idis.clear();
142 if(strchr(i_leaders,id[0])) { 141 if(strchr(data::_iname_leaders,id[0])) {
143 /* TODO: further normalize xri identity? Like folding case 142 /* TODO: further normalize xri identity? Like folding case
144 * or whatever... */ 143 * or whatever... */
145 rv = id; 144 rv = id;
@@ -495,13 +494,13 @@ namespace opkele {
495 const char *ns = a[1]; 494 const char *ns = a[1];
496 for(;*ns && isspace(*ns);++ns); 495 for(;*ns && isspace(*ns);++ns);
497 href.assign(ns); 496 href.assign(ns);
498 string::size_type lns=href.find_last_not_of(whitespace); 497 string::size_type lns=href.find_last_not_of(data::_whitespace_chars);
499 href.erase(lns+1); 498 href.erase(lns+1);
500 } 499 }
501 } 500 }
502 for(string::size_type ns=rels.find_first_not_of(whitespace); 501 for(string::size_type ns=rels.find_first_not_of(data::_whitespace_chars);
503 ns!=string::npos; ns=rels.find_first_not_of(whitespace,ns)) { 502 ns!=string::npos; ns=rels.find_first_not_of(data::_whitespace_chars,ns)) {
504 string::size_type s = rels.find_first_of(whitespace,ns); 503 string::size_type s = rels.find_first_of(data::_whitespace_chars,ns);
505 string rel; 504 string rel;
506 if(s==string::npos) { 505 if(s==string::npos) {
507 rel.assign(rels,ns,string::npos); 506 rel.assign(rels,ns,string::npos);