static char * unset_flags_to_string(struct Client *client_p) { /* Inverse of above */ /* XXX - list all flags that we do NOT have set on the client */ static char setflags[IRCD_BUFSIZE + 1]; int i, isoper; /* Clear it to begin with, we'll be doing a lot of ircsprintf's */ setflags[0] = '\0'; isoper = IsOper(client_p) != 0; for (i = 0; flag_table[i].name; i++) { if (!(client_p->umodes & flag_table[i].mode)) { if (!isoper && flag_table[i].oper) continue; ircsprintf(setflags, "%s %s", setflags, flag_table[i].name); } } if (IsOper(client_p) && IsOperN(client_p)) { if (!(client_p->umodes & UMODE_NCHANGE)) { ircsprintf(setflags, "%s %s", setflags, "NICKCHANGES"); } } return setflags; }
static char * set_flags_to_string(struct Client *client_p) { /* XXX - list all flags that we have set on the client */ static char setflags[BUFSIZE + 1]; int i; /* Clear it to begin with, we'll be doing a lot of rb_sprintf's */ setflags[0] = '\0'; /* Unlike unset_flags_to_string(), we don't have to care about oper ** flags and not showing them */ if(client_p->umodes & UMODE_OPERWALL) { rb_sprintf(setflags, "%s %s", setflags, "OWALLOPS"); } for(i = 0; flag_table[i].name; i++) { if(client_p->umodes & flag_table[i].mode) { rb_sprintf(setflags, "%s %s", setflags, flag_table[i].name); } } #if 0 if(IsOper(client_p) && IsOperN(client_p)) { #endif /* You can only be set +NICKCHANGES if you are an oper and ** IsOperN(client_p) is true */ if(client_p->umodes & UMODE_NCHANGE) { rb_sprintf(setflags, "%s %s", setflags, "NICKCHANGES"); } #if 0 } #endif return setflags; }
/* mo_flags() * * parv[0] = sender prefix * parv[1] = parameter */ static void mo_flags(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { int i,j; int isadd; int isgood; unsigned int setflags; char *p; char *flag; if (parc < 2) { /* Generate a list of what flags you have and what you are missing, ** and send it to the user */ sendto_one(source_p, ":%s NOTICE %s :Current flags:%s", me.name, parv[0], set_flags_to_string(source_p)); sendto_one(source_p, ":%s NOTICE %s :Current missing flags:%s", me.name, parv[0], unset_flags_to_string(source_p)); return; } /* Preserve the current flags */ setflags = source_p->umodes; /* XXX - change this to support a multiple last parameter like ISON */ for (i = 1; i < parc; i++) { for (flag = strtoken(&p, parv[i], " "); flag; flag = strtoken(&p, NULL, " ")) { /* We default to being in ADD mode */ isadd = 1; /* We default to being in BAD mode */ isgood = 0; if (!isalpha(*flag)) { if (*flag == '-') isadd = 0; else if (*flag == '+') isadd = 1; ++flag; } /* support ALL here */ if (!irccmp(flag, "ALL")) { if (isadd) source_p->umodes |= FL_ALL_OPER_FLAGS; else source_p->umodes &= ~FL_ALL_OPER_FLAGS; sendto_one(source_p, ":%s NOTICE %s :Current flags:%s", me.name, parv[0], set_flags_to_string(source_p)); sendto_one(source_p, ":%s NOTICE %s :Current missing flags:%s", me.name, parv[0], unset_flags_to_string(source_p)); send_umode_out(client_p, source_p, setflags); return; } if (!irccmp(flag, "NICKCHANGES")) { if (!IsOperN(source_p)) { sendto_one(source_p, ":%s NOTICE %s :*** You have no nick_changes flag;", me.name,parv[0]); continue; } if (isadd) source_p->umodes |= UMODE_NCHANGE; else source_p->umodes &= ~UMODE_NCHANGE; isgood = 1; continue; } for (j = 0; flag_table[j].name; j++) { if (!irccmp(flag, flag_table[j].name)) { if (isadd) source_p->umodes |= flag_table[j].mode; else source_p->umodes &= ~ (flag_table[j].mode); isgood = 1; continue; } } /* This for ended without matching a valid FLAG, here is where * I want to operate differently than ircd-comstud, and just ignore * the invalid flag, send a warning and go on. */ if (!isgood) sendto_one(source_p, ":%s NOTICE %s :Invalid FLAGS: %s (IGNORING)", me.name, parv[0], flag); } } /* All done setting the flags, print the notices out to the user ** telling what flags they have and what flags they are missing */ sendto_one(source_p, ":%s NOTICE %s :Current flags:%s", me.name, parv[0], set_flags_to_string(source_p)); sendto_one(source_p, ":%s NOTICE %s :Current missing flags:%s", me.name, parv[0], unset_flags_to_string(source_p)); send_umode_out(client_p, source_p, setflags); }