chan.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /*
  2. * chan.h
  3. * stuff common to chan.c and mode.c
  4. * users.h needs to be loaded too
  5. *
  6. */
  7. #ifndef _EGG_CHAN_H
  8. #define _EGG_CHAN_H
  9. typedef struct memstruct {
  10. struct memstruct *next;
  11. struct userrec *user;
  12. time_t joined;
  13. time_t split; /* in case they were just netsplit */
  14. time_t last; /* for measuring idle time */
  15. time_t delay; /* for delayed autoop */
  16. int hops;
  17. int tried_getuser;
  18. unsigned short flags;
  19. char nick[NICKLEN];
  20. char userhost[UHOSTLEN];
  21. } memberlist;
  22. #define CHANMETA "#&!+"
  23. #define NICKVALID "[{}]^`|\\_-"
  24. #define CHANOP BIT0 /* channel +o */
  25. #define CHANVOICE BIT1 /* channel +v */
  26. #define FAKEOP BIT2 /* op'd by server */
  27. #define SENTOP BIT3 /* a mode +o was already sent out for this user */
  28. #define SENTDEOP BIT4 /* a mode -o was already sent out for this user */
  29. #define SENTKICK BIT5 /* a kick was already sent out for this user */
  30. #define SENTVOICE BIT6 /* a mode +v was already sent out for this user */
  31. #define SENTDEVOICE BIT7 /* a devoice has been sent */
  32. #define WASOP BIT8 /* was an op before a split */
  33. #define STOPWHO BIT9
  34. #define FULL_DELAY BIT10
  35. #define STOPCHECK BIT11
  36. #define EVOICE BIT12 /* keeps people -v */
  37. #define OPER BIT13
  38. #define chan_hasvoice(x) (x->flags & CHANVOICE)
  39. #define chan_hasop(x) (x->flags & CHANOP)
  40. #define chan_fakeop(x) (x->flags & FAKEOP)
  41. #define chan_sentop(x) (x->flags & SENTOP)
  42. #define chan_sentdeop(x) (x->flags & SENTDEOP)
  43. #define chan_sentkick(x) (x->flags & SENTKICK)
  44. #define chan_sentvoice(x) (x->flags & SENTVOICE)
  45. #define chan_sentdevoice(x) (x->flags & SENTDEVOICE)
  46. #define chan_issplit(x) (x->split > 0)
  47. #define chan_wasop(x) (x->flags & WASOP)
  48. #define chan_stopcheck(x) (x->flags & STOPCHECK)
  49. #define P_DEOP 1
  50. #define P_KICK 2
  51. #define P_DELETE 3
  52. /* Why duplicate this struct for exempts and invites only under another
  53. * name? <cybah>
  54. */
  55. typedef struct maskstruct {
  56. struct maskstruct *next;
  57. time_t timer;
  58. char *mask;
  59. char *who;
  60. } masklist;
  61. /* Used for temporary bans, exempts and invites */
  62. typedef struct maskrec {
  63. struct maskrec *next;
  64. time_t expire,
  65. added,
  66. lastactive;
  67. int flags;
  68. char *mask,
  69. *desc,
  70. *user;
  71. } maskrec;
  72. extern maskrec *global_bans, *global_exempts, *global_invites;
  73. #define MASKREC_STICKY 1
  74. #define MASKREC_PERM 2
  75. /* For every channel i join */
  76. struct chan_t {
  77. memberlist *member;
  78. masklist *ban;
  79. masklist *exempt;
  80. masklist *invite;
  81. time_t jointime;
  82. time_t parttime;
  83. time_t no_op;
  84. int fighting;
  85. #ifdef G_BACKUP
  86. int backup_time; /* If non-0, set +backup when now>backup_time */
  87. #endif /* G_BACKUP */
  88. int maxmembers;
  89. int members;
  90. int do_opreq;
  91. char *topic;
  92. char *key;
  93. unsigned short int mode;
  94. };
  95. #define CHANINV BIT0 /* +i */
  96. #define CHANPRIV BIT1 /* +p */
  97. #define CHANSEC BIT2 /* +s */
  98. #define CHANMODER BIT3 /* +m */
  99. #define CHANTOPIC BIT4 /* +t */
  100. #define CHANNOMSG BIT5 /* +n */
  101. #define CHANLIMIT BIT6 /* -l -- used only for protecting modes */
  102. #define CHANKEY BIT7 /* +k */
  103. #define CHANANON BIT8 /* +a -- ircd 2.9 */
  104. #define CHANQUIET BIT9 /* +q -- ircd 2.9 */
  105. #define CHANNOCLR BIT10 /* +c -- bahamut */
  106. #define CHANREGON BIT11 /* +R -- bahamut */
  107. #define CHANMODR BIT12 /* +M -- bahamut */
  108. #define CHANNOCTCP BIT13 /* +C -- QuakeNet's ircu 2.10 */
  109. #define CHANLONLY BIT14 /* +r -- ircu 2.10.11 */
  110. #define MODES_PER_LINE_MAX 6
  111. /* For every channel i'm supposed to be active on */
  112. struct chanset_t {
  113. struct chanset_t *next;
  114. struct chan_t channel; /* current information */
  115. maskrec *bans, /* temporary channel bans */
  116. *exempts, /* temporary channel exempts */
  117. *invites; /* temporary channel invites */
  118. time_t added_ts; /* ..and when? */
  119. struct {
  120. char *op;
  121. int type;
  122. } cmode[MODES_PER_LINE_MAX]; /* parameter-type mode changes - */
  123. struct {
  124. char *op;
  125. } ccmode[MODES_PER_LINE_MAX]; /* parameter-type mode changes - */
  126. /* detect floods */
  127. time_t floodtime[FLOOD_CHAN_MAX];
  128. uint32_t status;
  129. uint32_t ircnet_status;
  130. int flood_pub_thr;
  131. time_t flood_pub_time;
  132. int flood_join_thr;
  133. time_t flood_join_time;
  134. int flood_deop_thr;
  135. time_t flood_deop_time;
  136. int flood_kick_thr;
  137. time_t flood_kick_time;
  138. int flood_ctcp_thr;
  139. time_t flood_ctcp_time;
  140. int flood_nick_thr;
  141. time_t flood_nick_time;
  142. int limitraise;
  143. int closed_ban;
  144. int closed_private;
  145. int bad_cookie;
  146. time_t cookie_time_slack;
  147. int manop;
  148. int mdop;
  149. int mop;
  150. /* Chanint template
  151. *int temp;
  152. */
  153. int idle_kick;
  154. int stopnethack_mode;
  155. int revenge_mode;
  156. time_t ban_time;
  157. time_t invite_time;
  158. time_t exempt_time;
  159. /* desired channel modes: */
  160. int mode_pls_prot; /* modes to enforce */
  161. int mode_mns_prot; /* modes to reject */
  162. int limit_prot; /* desired limit */
  163. /* queued mode changes: */
  164. int limit; /* new limit to set */
  165. size_t bytes; /* total bytes so far */
  166. size_t cbytes;
  167. int compat; /* to prevent mixing old/new modes */
  168. int floodnum[FLOOD_CHAN_MAX];
  169. int opreqtime[5]; /* remember when ops was requested */
  170. char *key; /* new key to set */
  171. char *rmkey; /* old key to remove */
  172. char pls[21]; /* positive mode changes */
  173. char mns[21]; /* negative mode changes */
  174. char key_prot[121]; /* desired password */
  175. /* Chanchar template
  176. *char temp[121];
  177. */
  178. char topic[121];
  179. char added_by[NICKLEN]; /* who added the channel? */
  180. char floodwho[FLOOD_CHAN_MAX][128];
  181. char deopd[NICKLEN]; /* last person deop'd (must change */
  182. char dname[81]; /* what the users know the channel as like !eggdev */
  183. char name[81]; /* what the servers know the channel as, like !ABCDEeggdev */
  184. };
  185. /* behavior modes for the channel */
  186. /* Chanflag template
  187. * #define CHAN_TEMP 0x0000
  188. */
  189. #define CHAN_ENFORCEBANS BIT0 /* kick people who match channel bans */
  190. #define CHAN_DYNAMICBANS BIT1 /* only activate bans when needed */
  191. #define CHAN_NOUSERBANS BIT2 /* don't let non-bots place bans */
  192. #define CHAN_CLOSED BIT3 /* Only users +o can join */
  193. #define CHAN_BITCH BIT4 /* be a tightwad with ops */
  194. #define CHAN_TAKE BIT5 /* When a bot gets opped, take the chan */
  195. #define CHAN_PROTECTOPS BIT6 /* re-op any +o people who get deop'd */
  196. #define CHAN_NOMOP BIT7 /* If a bot sees a mass op, botnet mdops */
  197. #define CHAN_REVENGE BIT8 /* get revenge on bad people */
  198. #define CHAN_SECRET BIT9 /* don't advertise channel on botnet */
  199. #define CHAN_MANOP BIT10 /* manual opping allowed? */
  200. #define CHAN_CYCLE BIT11 /* cycle the channel if possible */
  201. #define CHAN_INACTIVE BIT12 /* no irc support for this channel */
  202. #define CHAN_VOICE BIT13 /* a bot +y|y will voice *, except +q */
  203. #define CHAN_REVENGEBOT BIT14 /* revenge on actions against the bot */
  204. #define CHAN_NODESYNCH BIT15
  205. #define CHAN_FASTOP BIT16 /* Bots will not use +o-b to op (no cookies) */
  206. #define CHAN_PRIVATE BIT17 /* users need |o to access chan */
  207. #define CHAN_ACTIVE BIT18 /* like i'm actually on the channel and stuff */
  208. #define CHAN_PEND BIT19 /* just joined; waiting for end of WHO list */
  209. #define CHAN_FLAGGED BIT20 /* flagged during rehash for delete */
  210. #define CHAN_ASKEDBANS BIT21
  211. #define CHAN_ASKEDMODES BIT22 /* find out key-info on IRCu */
  212. #define CHAN_JUPED BIT23 /* Is channel juped */
  213. #define CHAN_STOP_CYCLE BIT24 /* Some efnetservers have defined NO_CHANOPS_WHEN_SPLIT */
  214. #define CHAN_AUTOOP BIT25
  215. #define CHAN_ASKED_EXEMPTS BIT0
  216. #define CHAN_ASKED_INVITED BIT1
  217. #define CHAN_DYNAMICEXEMPTS BIT2
  218. #define CHAN_NOUSEREXEMPTS BIT3
  219. #define CHAN_DYNAMICINVITES BIT4
  220. #define CHAN_NOUSERINVITES BIT5
  221. /* prototypes */
  222. memberlist *ismember(struct chanset_t *, const char *);
  223. struct chanset_t *findchan(const char *name);
  224. struct chanset_t *findchan_by_dname(const char *name);
  225. /* is this channel +s/+p? */
  226. #define channel_hidden(chan) (chan->channel.mode & (CHANPRIV | CHANSEC))
  227. /* is this channel +t? */
  228. #define channel_optopic(chan) (chan->channel.mode & CHANTOPIC)
  229. #define channel_active(chan) (chan->status & CHAN_ACTIVE)
  230. #define channel_pending(chan) (chan->status & CHAN_PEND)
  231. #define channel_bitch(chan) (chan->status & CHAN_BITCH)
  232. #define channel_nodesynch(chan) (chan->status & CHAN_NODESYNCH)
  233. #define channel_enforcebans(chan) (chan->status & CHAN_ENFORCEBANS)
  234. #define channel_revenge(chan) (chan->status & CHAN_REVENGE)
  235. #define channel_dynamicbans(chan) (chan->status & CHAN_DYNAMICBANS)
  236. #define channel_nouserbans(chan) (chan->status & CHAN_NOUSERBANS)
  237. #define channel_protectops(chan) (chan->status & CHAN_PROTECTOPS)
  238. #define channel_secret(chan) (chan->status & CHAN_SECRET)
  239. #define channel_cycle(chan) (chan->status & CHAN_CYCLE)
  240. #define channel_inactive(chan) (chan->status & CHAN_INACTIVE)
  241. #define channel_revengebot(chan) (chan->status & CHAN_REVENGEBOT)
  242. #define channel_dynamicexempts(chan) (chan->ircnet_status & CHAN_DYNAMICEXEMPTS)
  243. #define channel_nouserexempts(chan) (chan->ircnet_status & CHAN_NOUSEREXEMPTS)
  244. #define channel_dynamicinvites(chan) (chan->ircnet_status & CHAN_DYNAMICINVITES)
  245. #define channel_nouserinvites(chan) (chan->ircnet_status & CHAN_NOUSERINVITES)
  246. #define channel_juped(chan) (chan->status & CHAN_JUPED)
  247. #define channel_stop_cycle(chan) (chan->status & CHAN_STOP_CYCLE)
  248. #define channel_closed(chan) (chan->status & CHAN_CLOSED)
  249. #define channel_take(chan) (chan->status & CHAN_TAKE)
  250. #define channel_nomop(chan) (chan->status & CHAN_NOMOP)
  251. #define channel_manop(chan) (chan->status & CHAN_MANOP)
  252. #define channel_voice(chan) (chan->status & CHAN_VOICE)
  253. #define channel_fastop(chan) (chan->status & CHAN_FASTOP)
  254. #define channel_privchan(chan) (chan->status & CHAN_PRIVATE)
  255. #define channel_autoop(chan) (chan->status & CHAN_AUTOOP)
  256. /* Chanflag template
  257. *#define channel_temp(chan) (chan->status & CHAN_PRIVATE)
  258. */
  259. struct msgq_head {
  260. struct msgq *head;
  261. struct msgq *last;
  262. int tot;
  263. int warned;
  264. };
  265. /* Used to queue a lot of things */
  266. struct msgq {
  267. struct msgq *next;
  268. size_t len;
  269. char *msg;
  270. };
  271. #endif /* _EGG_CHAN_H */