Ejemplo n.º 1
0
/* Check if the provided flags suffice for this command/trigger.
 *
 * Note: This is INLINE code for check_tcl_bind().
 */
static inline int check_bind_flags(struct flag_record *flags,
                                   struct flag_record *atr, int match_type)
{
  if (match_type & BIND_USE_ATTR) {
    if (match_type & BIND_HAS_BUILTINS)
      return (flagrec_ok(flags, atr));
    else
      return (flagrec_eq(flags, atr));
  } else
    return 1;
  return 0;
}
Ejemplo n.º 2
0
/* Returns 1 if flags match, 0 if they don't. */
int
flagrec_ok(struct flag_record *req, struct flag_record *have)
{
  if (req->match & FR_AND) {
    return flagrec_eq(req, have);
  } else if (req->match & FR_OR) {
    int hav = have->global;

    /* no flags, is a match */
    if (!req->chan && !req->global)
      return 1;
    if (hav & req->global)
      return 1;
    if (have->chan & req->chan)
      return 1;
    return 0;
  }
  return 0;
}
Ejemplo n.º 3
0
int flagrec_ok(struct flag_record *req, struct flag_record *have)
{
  /* FIXME: flag masks with '&' in them won't be subject to
   *        further tests below. Example: 'o&j'
   */
  if (req->match & FR_AND)
    return flagrec_eq(req, have);
  else if (req->match & FR_OR) {
    int hav = have->global;

    /* Exception 1 - global +d/+k cant use -|-, unless they are +p */
    if (!req->chan && !req->global && !req->udef_global && !req->udef_chan) {
      if (!allow_dk_cmds) {
        if (glob_party(*have))
          return 1;
        if (glob_kick(*have) || chan_kick(*have))
          return 0;             /* +k cant use -|- commands */
        if (glob_deop(*have) || chan_deop(*have))
          return 0;             /* neither can +d's */
      }
      return 1;
    }
    /* The +n/+m checks aren't needed anymore because +n/+m
     * automatically adds lower flags
     */
    if (!require_p && ((hav & USER_OP) || (have->chan & USER_OWNER)))
      hav |= USER_PARTY;
    if (hav & req->global)
      return 1;
    if (have->chan & req->chan)
      return 1;
    if (have->udef_global & req->udef_global)
      return 1;
    if (have->udef_chan & req->udef_chan)
      return 1;
    return 0;
  }
  return 0;                     /* fr0k3 binding, dont pass it */
}
Ejemplo n.º 4
0
int flagrec_ok(struct flag_record *req,
	       struct flag_record *have)
{
  if (req->match & FR_AND) {
    return flagrec_eq(req, have);
  } else if (req->match & FR_OR) {
    int hav = have->global;

    /* exception 1 - global +d/+k cant use -|-, unless they are +p */
    if (!req->chan && !req->global && !req->udef_global &&
	!req->udef_chan) {
      if (!allow_dk_cmds) {
	if (glob_party(*have))
	  return 1;
	if (glob_kick(*have) || chan_kick(*have))
	  return 0;		/* +k cant use -|- commands */
	if (glob_deop(*have) || chan_deop(*have))
	  return 0;		/* neither can +d's */
      }
      return 1;
    }
    /* the +n/+m checks arent needed anymore since +n/+m
     * automatically add lower flags */
    if (!require_p && ((hav & USER_OP) || (have->chan & USER_OWNER)))
      hav |= USER_PARTY;
    if (hav & req->global)
      return 1;
    if (have->chan & req->chan)
      return 1;
    if (have->udef_global & req->udef_global)
      return 1;
    if (have->udef_chan & req->udef_chan)
      return 1;
    return 0;
  }
  return 0;			/* fr0k3 binding, dont pass it */
}