Esempio n. 1
0
/* 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);
}
Esempio n. 2
0
/*
** m_flags
**      parv[0] = sender prefix
**      parv[1] = parameter
*/
static int
m_flags(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	int i, j;
	int isadd;
	int setflags;
	int isgood;
	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 1;
	}

	/* 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++)
	{
		char *s = LOCAL_COPY(parv[i]);
		for(flag = strtok_r(s, " ", &p); flag; flag = strtok_r(NULL, " ", &p))
		{
			/* We default to being in ADD mode */
			isadd = 1;

			/* We default to being in BAD mode */
			isgood = 0;

			if(!isalpha(flag[0]))
			{
				if(flag[0] == '-')
					isadd = 0;
				else if(flag[0] == '+')
					isadd = 1;
				flag++;
			}

			/* support ALL here */
			if(!irccmp(flag, "ALL"))
			{
				if(isadd)
					source_p->umodes |= FL_ALL_USER_FLAGS;
				else
					source_p->umodes &= ~FL_ALL_USER_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 1;
			}

			for(j = 0; flag_table[j].name; j++)
			{
				if(!flag_table[j].oper && !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);
	return 0;
}