Filter by bo:
typedef bool (*FNC_FOUNDMAIL)(char *);
bool IsAlowedMailChar(char chr) {
/*
According to RFC 2822, the local-part of the email may use any of these ASCII characters:
Uppercase and lowercase letters
The digits 0 through 9
The characters "! # $ % & ' * + - / = ? ^ _ ` { | } ~"
The character "." provided that it is not the first or last character in the local-part.
*/
const char *SpecialChar = "*+-=^_`| ~.";
char c[2] = {chr, 0};
return ((chr >= 'a') && (chr <= 'z')) || ((chr >= 'A') && (chr <= 'Z')) || ((chr >= '0') && (chr <= '9')) || (strpbrk(c, SpecialChar)) && !(chr == ' ');
}
void SearchEMail(char *html_source, FNC_FOUNDMAIL found) {
const char *EMAIL_AT[] = {"@", "[at]", "@@"};
if (!html_source || !found)
return;
char *runptr;
const unsigned int len = sizeof(EMAIL_AT) / sizeof(char *);
// Plain Search
for (unsigned int idx = 0; idx < len; ++idx) {
runptr = strstr(html_source, EMAIL_AT[idx]);
while (runptr) {
char *begin = runptr - 1;
char *end = runptr + strlen(EMAIL_AT[idx]);
while ((begin > html_source) && IsAlowedMailChar(*begin))
begin--;
begin++;
while ((*end) && IsAlowedMailChar(*end))
end++;
if (*end)
runptr = strstr(runptr + 1, EMAIL_AT[idx]);
else
runptr = NULL;
char Backup = *end;
*end = 0;
bool bContinue = found(begin);
*end = Backup;
if (!bContinue)
return;
}
}
Filter by aw:
void SearchEMail(const char* cDomain, char nextEmail[MAX_PATH])
{
const char symbolCha[3][5] = { "@","@@","[AT]" };
const char* notCh = "!§$%&/()=?`´+#~*_<>|:;^°}{³² ";
const char* buffCh = cDomain;
char cpyConst[1024] = { 0 };
unsigned int eCount = 0;
for (int i = 0; i < sizeof(symbolCha); i++)
{
startTheScan:
if (const char* chUpaDow = strstr(buffCh, symbolCha[i]))
{
while (chUpaDow)
{
if (strcspn(chUpaDow, notCh))
{
chUpaDow--;
}
else
{
chUpaDow++;
for (int i = 0; i < strlen(chUpaDow); i++)
{
cpyConst[i] = (int)chUpaDow[i];
unsigned int pos = strlen(cpyConst);
chUpaDow++;
for (int i = 0; i < strlen(notCh); i++)
{
if (cpyConst[pos] == notCh[i])
{
pos--;
nextEmail[eCount++] = cpyConst[pos];
buffCh = chUpaDow;
goto startTheScan;
}
}
}
}
}
}
}
}
Zuletzt bearbeitet: