#include <XrdOucUri.hh>
|
static int | Decode (const char *src, int len, char *dst) |
|
static int | Encode (const char *src, int len, char **dst) |
|
static int | Encode (const char *src, int len, char *dst) |
|
static int | Encoded (const char *src, int len) |
|
Definition at line 44 of file XrdOucUri.hh.
◆ XrdOucUri()
◆ ~XrdOucUri()
XrdOucUri::~XrdOucUri |
( |
| ) |
|
|
inline |
◆ Decode()
int XrdOucUri::Decode |
( |
const char * | src, |
|
|
int | len, |
|
|
char * | dst ) |
|
static |
Decode a url encoded string
- Parameters
-
src | Pointer to the source string to decode |
len | The length of src (i.e. strlen(src)). |
dst | Pointer to the buffer where to put the result. The buffer should be at least as long as the src, including null byte. |
- Returns
- The index of the null byte (i.e. end of string) in dst.
Definition at line 116 of file XrdOucUri.cc.
117{
118 int i = 0, j = 0;
119 unsigned char v1, v2;
120
121
122
123 while(i < len)
124 {if(src[i] == '%' && i + 2 < len)
125 {v1 = hexval[ (unsigned char)src[i+1] ];
126 v2 = hexval[ (unsigned char)src[i+2] ];
127
128
129 if ((v1 | v2) == 0xFF) dst[j++] = src[i++];
130 else {dst[j++] = (v1 << 4) | v2;
131 i += 3;
132 }
133 } else dst[j++] = src[i++];
134 }
135
136
137
138 dst[j] = '\0';
139 return j;
140}
◆ Encode() [1/2]
int XrdOucUri::Encode |
( |
const char * | src, |
|
|
int | len, |
|
|
char ** | dst ) |
|
static |
Encode an ASCII text string
- Parameters
-
src | Pointer to the source string to encode |
len | The length of src (i.e. strlen(src)). |
dst | Pointer to where the allocated buffer pointer should be placed. This buffer holds the result and must be released using free() when no longer needed. |
- Returns
- The index of the null byte (i.e. end of string) in dst.
Definition at line 146 of file XrdOucUri.cc.
147{
148
149
150
152
153
154
155 if (!(*dst = (char *)malloc(n))) return 0;
156
157
158
159 return Encode(src, len, *dst);
160}
static int Encode(const char *src, int len, char **dst)
static int Encoded(const char *src, int len)
References Encode(), and Encoded().
Referenced by Encode().
◆ Encode() [2/2]
int XrdOucUri::Encode |
( |
const char * | src, |
|
|
int | len, |
|
|
char * | dst ) |
|
static |
Encode an ASCII text string
- Parameters
-
src | Pointer to the source string to encode |
len | The length of src (i.e. strlen(src)). |
dst | Pointer to the buffer where to put the result. The buffer should be long enough to hold the result. Use the Encoded() method to determine how many bytes will be needed. |
- Returns
- The index of the null byte (i.e. end of string) in dst.
Definition at line 164 of file XrdOucUri.cc.
165{
166 const unsigned char *code;
167 int j = 0;
168
169
170
171 for(int i = 0; i < len; i++)
172 {code = &uri_encode_tbl[((unsigned int)((unsigned char)src[i])) << 1];
173 if (*code)
174 {dst[j++] = '%';
175 memcpy(&dst[j], code, 2);
176 j += 2;
177 } else dst[j++] = src[i];
178 }
179
180
181
182 dst[j] = '\0';
183 return j;
184}
◆ Encoded()
int XrdOucUri::Encoded |
( |
const char * | src, |
|
|
int | len ) |
|
static |
Calculate the number of bytes an encoded string will occupy.
- Parameters
-
src | Pointer to the source string to encode |
len | The length of src (i.e. strlen(src)). |
- Returns
- The number of bytes needed, including the ending null byte.
Definition at line 190 of file XrdOucUri.cc.
191{
192 int totlen = 0;
193
194
195
196 for(int i = 0; i < len; i++)
197 {totlen += (uri_encode_tbl[((unsigned int)src[i]) << 1] ? 3 : 1);}
198
199
200
201 return totlen + 1;
202}
Referenced by Encode().
The documentation for this class was generated from the following files: