37 typedef std::map<unsigned char, SWBuf>
DataMap;
42 for (
unsigned short int c = 32; c <= 255; ++c) {
43 if ( (c >=
'A' && c <=
'Z') || (c >=
'a' && c <=
'z') || (c >=
'0' && c <=
'9') || strchr(
"-_.!~*'()", c)) {
67 if (url && strlen(url)) {
99 static SWBuf emptyStr(
"");
101 ParameterMap::const_iterator it =
parameterMap.find(name);
105 retVal = it->second.
c_str();
107 retVal = emptyStr.
c_str();
109 return retVal.
c_str();
132 const char *end = strchr( urlPtr,
':' );
138 for (; (*urlPtr ==
':') || (*urlPtr ==
'/'); urlPtr++);
142 bool checkPath =
true;
143 bool checkParams =
true;
144 bool checkAnchor =
true;
146 end = strchr(urlPtr,
'/');
149 end = strchr(urlPtr,
'?');
153 end = strchr(urlPtr,
'#');
157 end = urlPtr+strlen(urlPtr);
162 urlPtr = end + ((*end)? 1 : 0);
165 end = strchr(urlPtr,
'?');
168 end = strchr(urlPtr,
'#');
172 end = urlPtr+strlen(urlPtr);
177 urlPtr = end + ((*end)? 1 : 0);
185 if (checkAnchor) checkAnchor =
false;
200 const char *valueStart = strchr(end,
'=');
202 const char* valueEnd = strstr(valueStart,
"&") ? strstr(valueStart,
"&") : strstr(valueStart,
"&");
205 paramName.
append(end, valueStart-end);
206 paramValue.
append(valueStart+1, valueEnd-(valueStart+1));
209 paramName.
append(end, valueStart-end);
210 paramValue.
append(valueStart+1);
215 paramValue =
decode(paramValue.c_str());
224 const char *start = end+1;
225 end = strstr(start,
"&") ? strstr(start,
"&")+5 : (strstr(start,
"&") ? strstr(start,
"&")+1 : 0);
237 for (
long i = 0; i <
length; i++) {
238 const char& c = url[i];
261 else if ( (a ==
'%') && (i+2 < length)) {
262 const char b = toupper( text[i+1] );
263 const char c = toupper( text[i+2] );
265 if (isxdigit(b) && isxdigit(c)) {
266 unsigned int dec = 16 * ((b >=
'A' && b <=
'F') ? (b -
'A' + 10) : (b -
'0'));
267 dec += (c >=
'A' && c <=
'F') ? (c -
'A' + 10) : (c -
'0');
269 decoded.
append((
char)dec);
#define SWORD_NAMESPACE_START
unsigned long length() const
static class SWORD_NAMESPACE_START::__init ___init
std::map< SWBuf, SWBuf > ParameterMap
const char * getParameterValue(const char *name) const
const char * c_str() const
SWBuf & append(const char *str, long max=-1)
const char * getPath() const
const char * getProtocol() const
std::map< unsigned char, SWBuf > DataMap
const ParameterMap & getParameters() const
#define SWORD_NAMESPACE_END
const char * getHostName() const
SWBuf & setFormatted(const char *format,...)
ParameterMap parameterMap
static const SWBuf decode(const char *encodedText)
static const SWBuf encode(const char *urlText)