11 #if defined(HAVE_ASSERT_H) && !defined(assert)
36 static inline unsigned char *
37 strnchr(
unsigned char *s,
size_t len,
unsigned char c) {
38 while (len && *s++ != c)
41 return len ? s : NULL;
47 int secure = 0, res = 0;
63 while (len && *q && tolower(*p) == *q) {
75 if (len && (secure = tolower(*p) ==
's')) {
79 q = (
unsigned char *)
"://";
80 while (len && *q && tolower(*p) == *q) {
91 if (len && *p ==
'[') {
94 while (len && *q !=
']') {
98 if (!len || *q !=
']' || p == q) {
106 while (len && *q !=
':' && *q !=
'/' && *q !=
'?') {
121 if (len && *q ==
':') {
125 while (len && isdigit(*q)) {
134 uri_port = uri_port * 10 + (*p++ -
'0');
136 uri->
port = uri_port;
149 while (len && *q !=
'?') {
161 if (len && *p ==
'?') {
182 #define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F))
204 seg += 2; length -= 2;
225 if (length < 2 || !(isxdigit(s[1]) && isxdigit(s[2])))
259 unsigned char *buf,
size_t buflen) {
264 debug(
"make_decoded_option(): buflen is 0!\n");
275 assert(written <= buflen);
283 if (buflen < (
size_t)res) {
284 debug(
"buffer too small for option\n");
290 return written + res;
295 #define min(a,b) ((a) < (b) ? (a) : (b))
319 length = parse_iter->
n;
342 if (memcmp(s,
"..",
min(len,2)) == 0)
355 unsigned char *
buf,
size_t *buflen) {
356 struct cnt_str tmp = { { *buflen, buf }, 0 };
360 '/', (
unsigned char *)
"?#", 2, &pi);
369 unsigned char *
buf,
size_t *buflen) {
370 struct cnt_str tmp = { { *buflen, buf }, 0 };
374 '&', (
unsigned char *)
"#", 1, &pi);
382 #define URI_DATA(uriobj) ((unsigned char *)(uriobj) + sizeof(coap_uri_t))
386 unsigned char *result;
393 memcpy(
URI_DATA(result), uri, length);
463 '/', (
unsigned char *)
"?#", 2, &pi);
473 unsigned char separator,
474 unsigned char *delim,
size_t dlen,