Added experimental hatch and magic regexp code
This commit is contained in:
parent
8d792f2e3b
commit
b1ba68ebac
@ -4758,6 +4758,8 @@ v0.33.20 10-Feb-2002
|
||||
Added more checks to processing of file_id.diz files. Also
|
||||
when it is illegal formatted the already processed lines are
|
||||
cleared to prevent later malformatted descriptions.
|
||||
Added experimental debugging only code in magic and hatch
|
||||
name testing.
|
||||
|
||||
mbmsg:
|
||||
When creating non-existend message bases, the path is created
|
||||
|
@ -108,6 +108,7 @@ int CheckHatch(char *temp)
|
||||
struct dirent *de;
|
||||
char *fn, tf[81], tmp[4], *temp2;
|
||||
int i, Match, hatched = FALSE;
|
||||
char *Temp, *p, *q, mask[256];
|
||||
FILE *Tf;
|
||||
|
||||
fn = xstrcpy(strrchr(temp, '/') + 1);
|
||||
@ -126,6 +127,29 @@ int CheckHatch(char *temp)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Temp = xstrcpy(temp);
|
||||
p = tl(Temp);
|
||||
q = mask;
|
||||
*q++ = '^';
|
||||
while ((*p) && (q < (mask + sizeof(mask) - 4))) {
|
||||
switch(*p) {
|
||||
case '\\': *q++ = '\\'; *q++ = '\\'; break;
|
||||
case '?': *q++ = '.'; break;
|
||||
case '.': *q++ = '\\'; *q++ = '.'; break;
|
||||
case '+': *q++ = '\\'; *q++ = '+'; break;
|
||||
case '*': *q++ = '.'; *q++ = '*'; break;
|
||||
default: *q++ = toupper(*p); break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
*q++ = '$';
|
||||
*q = '\0';
|
||||
Syslog('f', "Hatch mask \"%s\" -> \"%s\"", MBSE_SS(Temp), MBSE_SS(mask));
|
||||
if ((re_comp(mask)) != NULL)
|
||||
Syslog('f', "re_comp() accepted");
|
||||
else
|
||||
Syslog('f', "re_comp() returned NULL");
|
||||
|
||||
while ((de = readdir(dp))) {
|
||||
Match = FALSE;
|
||||
if (strlen(fn) == strlen(de->d_name)) {
|
||||
@ -144,6 +168,12 @@ int CheckHatch(char *temp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (re_exec(de->d_name))
|
||||
Syslog('f', "%s matched using regexp", de->d_name);
|
||||
else
|
||||
Syslog('f', "%s no match using regexp", de->d_name);
|
||||
|
||||
if (Match) {
|
||||
hatched = TRUE;
|
||||
Syslog('+', "Hatch %s in area %s", de->d_name, hatch.Name);
|
||||
|
@ -102,7 +102,7 @@ int GetMagicRec(int Typ, int First)
|
||||
{
|
||||
int Eof = FALSE, DoMagic = TRUE;
|
||||
int i;
|
||||
char *temp;
|
||||
char *temp, *Magic, *p, *q, mask[256];
|
||||
FILE *FeM;
|
||||
|
||||
if (First)
|
||||
@ -132,6 +132,35 @@ int GetMagicRec(int Typ, int First)
|
||||
|
||||
if ((magic.Active) && (magic.Attrib == Typ) && (strcasecmp(magic.From, TIC.TicIn.Area) == 0)) {
|
||||
|
||||
// p = tl(magic.Mask);
|
||||
Magic = xstrcpy(magic.Mask);
|
||||
p = tl(Magic);
|
||||
q = mask;
|
||||
*q++ = '^';
|
||||
while ((*p) && (q < (mask + sizeof(mask) - 4))) {
|
||||
switch(*p) {
|
||||
case '\\': *q++ = '\\'; *q++ = '\\'; break;
|
||||
case '?': *q++ = '.'; break;
|
||||
case '.': *q++ = '\\'; *q++ = '.'; break;
|
||||
case '+': *q++ = '\\'; *q++ = '+'; break;
|
||||
case '*': *q++ = '.'; *q++ = '*'; break;
|
||||
default: *q++ = toupper(*p); break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
*q++ = '$';
|
||||
*q = '\0';
|
||||
Syslog('f', "Magic mask \"%s\" -> \"%s\"", MBSE_SS(Magic), MBSE_SS(mask));
|
||||
if ((re_comp(mask)) != NULL) {
|
||||
if (re_exec(TIC.NewName))
|
||||
Syslog('f', "Should matched using regexp");
|
||||
else
|
||||
Syslog('f', "No match using regexp");
|
||||
} else {
|
||||
Syslog('f', "re_comp returned NULL");
|
||||
}
|
||||
free(Magic);
|
||||
|
||||
/*
|
||||
* Comparing of the filename must be done in
|
||||
* two parts, before and after the dot.
|
||||
@ -155,6 +184,8 @@ int GetMagicRec(int Typ, int First)
|
||||
DoMagic = FALSE;
|
||||
}
|
||||
|
||||
Syslog('f', "Old test, found %s", DoMagic ? "True":"False");
|
||||
|
||||
if (DoMagic) {
|
||||
fclose(FeM);
|
||||
free(temp);
|
||||
|
Reference in New Issue
Block a user