[MOD/ADD] Use glob-like system for admins.

This commit is contained in:
LDA 2024-07-06 02:16:52 +02:00
commit 95aaa0dbc9
10 changed files with 154 additions and 13 deletions

51
src/Glob.c Normal file
View 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;
}