mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 16:55:10 +00:00
[MOD/ADD] Use glob-like system for admins.
This commit is contained in:
parent
0fc0fdd6f4
commit
95aaa0dbc9
10 changed files with 154 additions and 13 deletions
51
src/Glob.c
Normal file
51
src/Glob.c
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include <Glob.h>
|
||||
|
||||
#include <Cytoplasm/Str.h>
|
||||
#include <string.h>
|
||||
|
||||
bool
|
||||
GlobMatches(char *rule, char *string)
|
||||
{
|
||||
char c1, c2;
|
||||
if (!rule || !string)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
while ((c1 = *rule))
|
||||
{
|
||||
char next = *(rule + 1);
|
||||
c2 = *string;
|
||||
switch (c1)
|
||||
{
|
||||
case '*':
|
||||
/* TODO */
|
||||
while ((c2 = *string) && (c2 != next))
|
||||
{
|
||||
string++;
|
||||
}
|
||||
if (next && !c2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
if (!c2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string++;
|
||||
break;
|
||||
default:
|
||||
if (c1 != c2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string++;
|
||||
break;
|
||||
}
|
||||
rule++;
|
||||
}
|
||||
|
||||
return !*string;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue