Currently the GroupServ flags parser is hardcoded for each flag. While this may
be faster than looping through ga_flags--debatable, as compilers can
probably optimize a loop over compile-time data--problems can arise from
adding a new GroupServ flag without also remembering to hardcode that
flag into the flags parser.
This patch replaces the hardcoded clauses in the flags parser switch
block with a loop across the elements of ga_flags to determine the
correct flag value for the specified flag character.
Permissions:
+f - Enables modification of group access list.
+F - Grants full founder access.
+ +A - Enables viewing of group access list.
+m - Read memos sent to the group.
+c - Have channel access in channels where the group has sufficient
privileges.
{
char *c;
unsigned int dir = 0;
+ unsigned int flag;
+ unsigned char n;
- /* XXX: this sucks. :< */
c = flagstring;
while (*c)
{
+ flag = 0;
+ n = 0;
switch(*c)
{
case '+':
else
flags = GA_ALL;
break;
- case 'F':
- if (dir)
- flags &= ~GA_FOUNDER;
- else
- flags |= GA_FOUNDER;
- break;
- case 'f':
- if (dir)
- flags &= ~GA_FLAGS;
- else
- flags |= GA_FLAGS;
- break;
- case 's':
- if (dir)
- flags &= ~GA_SET;
- else
- flags |= GA_SET;
- break;
- case 'v':
- if (dir)
- flags &= ~GA_VHOST;
- else
- flags |= GA_VHOST;
- break;
- case 'c':
- if (dir)
- flags &= ~GA_CHANACS;
- else
- flags |= GA_CHANACS;
- break;
- case 'm':
- if (dir)
- flags &= ~GA_MEMOS;
- else
- flags |= GA_MEMOS;
- break;
- case 'b':
- if (dir)
- flags &= ~GA_BAN;
- else
- flags |= GA_BAN;
- break;
- case 'i':
+ default:
+ while (ga_flags[n].ch != 0 && flag == 0)
+ {
+ if (ga_flags[n].ch == *c)
+ flag = ga_flags[n].value;
+ else
+ n++;
+ }
+ if (flag == 0)
+ break;
if (dir)
- flags &= ~GA_INVITE;
+ flags &= ~flag;
else
- flags |= GA_INVITE;
- break;
- default:
+ flags |= flag;
break;
}