text
stringlengths
0
14.1k
if (!(s = memmem(p, e-p, t, strlen(t))))
continue;
ue_add(ue_h, p, s-p);
p = s;
}
return M_OK;
}
/**
* Default plaintext parser
**/
M_CODE
lm_parser_text(worker_t *w, iobuf_t *buf,
uehandle_t *ue_h, url_t *url,
attr_list_t *al)
{
return lm_extract_text_urls(ue_h, buf->ptr, buf->sz);
}
M_CODE
lm_extract_text_urls(uehandle_t *ue_h, char *p, size_t sz)
{
int x;
char *s, *e = p+sz;
for (p = strstr(p, ""://""); p && p<e; p = strstr(p+1, ""://"")) {
for (x=0;x<2;x++) {
if (p-e >= protocols[x].len
&& strncmp(p-protocols[x].len, protocols[x].name, protocols[x].len) == 0) {
for (s=p+3; s < e; s++) {
if (!isalnum(*s) && *s != '%' && *s != '?'
&& *s != '=' && *s != '&' && *s != '/'
&& *s != '.') {
ue_add(ue_h, p-protocols[x].len, (s-p)+protocols[x].len);
break;
}
}
p = s;
}
}
}
return M_OK;
}
/**
* Default FTP parser. Expects data returned from the default
* FTP handler.
**/
M_CODE
lm_parser_ftp(worker_t *w, iobuf_t *buf,
uehandle_t *ue_h, url_t *url,
attr_list_t *al)
{
char *p, *prev;
struct ftpparse info;
char name[128]; /* i'm pretty sure no filename will be longer than 127 chars... */
int len;
for (prev = p = buf->ptr; p<buf->ptr+buf->sz; p++) {
if (*p == '\n') {
if (p-prev) {
if (ftpparse(&info, prev, p-prev)) {
if (info.namelen >= 126) {
LM_WARNING(w->m, ""file name too long"");
continue;
}
if (info.flagtrycwd) {
memcpy(name, info.name, info.namelen);
name[info.namelen] = '/';
name[info.namelen+1] = '\0';
len = info.namelen+1;
} else {
strncpy(name, info.name, info.namelen);
len = info.namelen;
}
ue_add(ue_h, name, len);
}
prev = p+1;
} else
prev = p+1;
}
}
return M_OK;
}
" isc
dennis95/dennix libc/src/stdio/__file_write.c 1293 "/* Copyright (c) 2019, 2022 Dennis Wölfing
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED ""AS IS"" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR