#undef COPY
#undef ADD_V
-#ifndef HAVE_MEMMEM
+#ifdef HAVE_MEMMEM
+
static void *
-memmem(const void *haystack, size_t haystacklen,
- const void *needle, size_t needlelen)
+dht_memmem(const void *haystack, size_t haystacklen,
+ const void *needle, size_t needlelen)
+{
+ return memmem(haystack, haystacklen, needle, needlelen);
+}
+
+#else
+
+static void *
+dht_memmem(const void *haystack, size_t haystacklen,
+ const void *needle, size_t needlelen)
{
const char *h = haystack;
const char *n = needle;
}
return NULL;
}
+
#endif
static int
if(((unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow;
if(tid_return) {
- p = memmem(buf, buflen, "1:t", 3);
+ p = dht_memmem(buf, buflen, "1:t", 3);
if(p) {
long l;
char *q;
}
}
if(id_return) {
- p = memmem(buf, buflen, "2:id20:", 7);
+ p = dht_memmem(buf, buflen, "2:id20:", 7);
if(p) {
CHECK(p + 7, 20);
memcpy(id_return, p + 7, 20);
}
}
if(info_hash_return) {
- p = memmem(buf, buflen, "9:info_hash20:", 14);
+ p = dht_memmem(buf, buflen, "9:info_hash20:", 14);
if(p) {
CHECK(p + 14, 20);
memcpy(info_hash_return, p + 14, 20);
}
}
if(port_return) {
- p = memmem(buf, buflen, "porti", 5);
+ p = dht_memmem(buf, buflen, "porti", 5);
if(p) {
long l;
char *q;
*port_return = 0;
}
if(target_return) {
- p = memmem(buf, buflen, "6:target20:", 11);
+ p = dht_memmem(buf, buflen, "6:target20:", 11);
if(p) {
CHECK(p + 11, 20);
memcpy(target_return, p + 11, 20);
}
}
if(token_return) {
- p = memmem(buf, buflen, "5:token", 7);
+ p = dht_memmem(buf, buflen, "5:token", 7);
if(p) {
long l;
char *q;
}
if(nodes_len) {
- p = memmem(buf, buflen, "5:nodes", 7);
+ p = dht_memmem(buf, buflen, "5:nodes", 7);
if(p) {
long l;
char *q;
}
if(nodes6_len) {
- p = memmem(buf, buflen, "6:nodes6", 8);
+ p = dht_memmem(buf, buflen, "6:nodes6", 8);
if(p) {
long l;
char *q;
}
if(values_len || values6_len) {
- p = memmem(buf, buflen, "6:valuesl", 9);
+ p = dht_memmem(buf, buflen, "6:valuesl", 9);
if(p) {
int i = p - buf + 9;
int j = 0, j6 = 0;
}
if(want_return) {
- p = memmem(buf, buflen, "4:wantl", 7);
+ p = dht_memmem(buf, buflen, "4:wantl", 7);
if(p) {
int i = p - buf + 7;
*want_return = 0;
#undef CHECK
- if(memmem(buf, buflen, "1:y1:r", 6))
+ if(dht_memmem(buf, buflen, "1:y1:r", 6))
return REPLY;
- if(memmem(buf, buflen, "1:y1:e", 6))
+ if(dht_memmem(buf, buflen, "1:y1:e", 6))
return ERROR;
- if(!memmem(buf, buflen, "1:y1:q", 6))
+ if(!dht_memmem(buf, buflen, "1:y1:q", 6))
return -1;
- if(memmem(buf, buflen, "1:q4:ping", 9))
+ if(dht_memmem(buf, buflen, "1:q4:ping", 9))
return PING;
- if(memmem(buf, buflen, "1:q9:find_node", 14))
+ if(dht_memmem(buf, buflen, "1:q9:find_node", 14))
return FIND_NODE;
- if(memmem(buf, buflen, "1:q9:get_peers", 14))
+ if(dht_memmem(buf, buflen, "1:q9:get_peers", 14))
return GET_PEERS;
- if(memmem(buf, buflen, "1:q13:announce_peer", 19))
+ if(dht_memmem(buf, buflen, "1:q13:announce_peer", 19))
return ANNOUNCE_PEER;
return -1;