chan.h 11 KB

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