Ver Fonte

Merge branch 'inline-flag-checking'

* inline-flag-checking:
  * Inline some flag checking functions
Bryan Drewery há 16 anos atrás
pai
commit
9a0dc420f6
2 ficheiros alterados com 11 adições e 61 exclusões
  1. 0 54
      src/flags.c
  2. 11 7
      src/flags.h

+ 0 - 54
src/flags.c

@@ -443,12 +443,6 @@ privchan(struct flag_record fr, struct chanset_t *chan, int type)
   return 1;                     /* user is restricted by +private */
 }
 
-int
-chk_op(struct flag_record fr, struct chanset_t *chan)
-{
-  return real_chk_op(fr, chan, 1);
-}
-
 int
 real_chk_op(struct flag_record fr, struct chanset_t *chan, bool botbitch)
 {
@@ -476,11 +470,6 @@ chk_autoop(struct flag_record fr, struct chanset_t *chan)
   return 0;
 }
 
-int chk_deop(struct flag_record fr, struct chanset_t *chan)
-{
-  return real_chk_deop(fr, chan, 1);
-}
-
 int
 real_chk_deop(struct flag_record fr, struct chanset_t *chan, bool botbitch)
 {
@@ -493,49 +482,6 @@ real_chk_deop(struct flag_record fr, struct chanset_t *chan, bool botbitch)
     return 0;
 }
 
-int
-chk_voice(struct flag_record fr, struct chanset_t *chan)
-{
-  if (!chan || (!privchan(fr, chan, PRIV_VOICE) && !chk_devoice(fr))) {
-    if (chan_voice(fr) || (glob_voice(fr) && !chan_quiet(fr)))
-      return 1;
-  }
-  return 0;
-}
-
-int
-chk_devoice(struct flag_record fr)
-{
-  if (chan_quiet(fr) || (glob_quiet(fr) && !chan_voice(fr)))
-    return 1;
-  else
-    return 0;
-}
-
-int
-chk_noflood(struct flag_record fr)
-{
-  return (chan_noflood(fr) || glob_noflood(fr));
-}
-
-int
-isupdatehub()
-{
-  if (conf.bot->hub && conf.bot->u && (conf.bot->u->flags & BOT_UPDATEHUB))
-    return 1;
-  else
-    return 0;
-}
-
-int
-ischanhub()
-{
-  if (!conf.bot->hub && conf.bot->u && (conf.bot->u->flags & BOT_CHANHUB))
-    return 1;
-  else
-    return 0;
-}
-
 int
 doresolv(struct chanset_t *chan)
 {

+ 11 - 7
src/flags.h

@@ -152,16 +152,20 @@ flag_t sanity_check(flag_t, int);
 flag_t chan_sanity_check(flag_t, int);
 char geticon(int);
 int privchan(struct flag_record, struct chanset_t *, int);
-int chk_op(struct flag_record, struct chanset_t *);
+#define chk_op(fr, chan) real_chk_op(fr, chan, 1)
 int real_chk_op(struct flag_record, struct chanset_t *, bool);
 int chk_autoop(struct flag_record, struct chanset_t *);
-int chk_deop(struct flag_record, struct chanset_t *);
+#define chk_deop(fr, chan) real_chk_deop(fr, chan, 1)
 int real_chk_deop(struct flag_record, struct chanset_t *, bool);
-int chk_voice(struct flag_record, struct chanset_t *);
-int chk_devoice(struct flag_record);
-int chk_noflood(struct flag_record);
-int ischanhub(void);
-int isupdatehub(void);
+#define chk_voice(fr, chan) (\
+    (\
+     (!chan || (!privchan(fr, chan, PRIV_VOICE) && !chk_devoice(fr))) \
+     && (chan_voice(fr) || (glob_voice(fr) && !chan_quiet(fr))) \
+    ) ? 1 : 0)
+#define chk_noflood(fr) (chan_noflood(fr) || glob_noflood(fr))
+#define chk_devoice(fr) ((chan_quiet(fr) || (glob_quiet(fr) && !chan_voice(fr))) ? 1 : 0)
+#define isupdatehub() ((conf.bot->hub && conf.bot->u && (conf.bot->u->flags & BOT_UPDATEHUB)) ? 1 : 0)
+#define ischanhub() ((!conf.bot->hub && conf.bot->u && (conf.bot->u->flags & BOT_CHANHUB)) ? 1 : 0)
 int doresolv(struct chanset_t *);
 int dovoice(struct chanset_t *);
 int doflood(struct chanset_t *);