chan.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. #ifdef S_IRCNET
  75. extern maskrec *global_bans, *global_exempts, *global_invites;
  76. #else
  77. extern maskrec *global_bans;
  78. #endif
  79. #define MASKREC_STICKY 1
  80. #define MASKREC_PERM 2
  81. /* For every channel i join */
  82. struct chan_t {
  83. memberlist *member;
  84. masklist *ban;
  85. #ifdef S_IRCNET
  86. masklist *exempt;
  87. masklist *invite;
  88. #endif
  89. char *topic;
  90. char *key;
  91. unsigned short int mode;
  92. int maxmembers;
  93. int members;
  94. int do_opreq;
  95. };
  96. #define CHANINV 0x0001 /* +i */
  97. #define CHANPRIV 0x0002 /* +p */
  98. #define CHANSEC 0x0004 /* +s */
  99. #define CHANMODER 0x0008 /* +m */
  100. #define CHANTOPIC 0x0010 /* +t */
  101. #define CHANNOMSG 0x0020 /* +n */
  102. #define CHANLIMIT 0x0040 /* -l -- used only for protecting modes */
  103. #define CHANKEY 0x0080 /* +k */
  104. #define CHANANON 0x0100 /* +a -- ircd 2.9 */
  105. #define CHANQUIET 0x0200 /* +q -- ircd 2.9 */
  106. #define CHANNOCLR 0x0400 /* +c -- bahamut */
  107. #define CHANREGON 0x0800 /* +R -- bahamut */
  108. #define CHANMODR 0x1000 /* +M -- bahamut */
  109. #define CHANNOCTCP 0x2000 /* +C -- QuakeNet's ircu 2.10 */
  110. #define CHANLONLY 0x4000 /* +r -- ircu 2.10.11 */
  111. #define MODES_PER_LINE_MAX 6
  112. /* For every channel i'm supposed to be active on */
  113. struct chanset_t {
  114. struct chanset_t *next;
  115. struct chan_t channel; /* current information */
  116. char dname[81]; /* what the users know the channel as,
  117. like !eggdev */
  118. char name[81]; /* what the servers know the channel
  119. as, like !ABCDEeggdev */
  120. char need_op[121];
  121. char need_key[121];
  122. char need_limit[121];
  123. char need_unban[121];
  124. char need_invite[121];
  125. int flood_pub_thr;
  126. int flood_pub_time;
  127. int flood_join_thr;
  128. int flood_join_time;
  129. int flood_deop_thr;
  130. int flood_deop_time;
  131. int flood_kick_thr;
  132. int flood_kick_time;
  133. int flood_ctcp_thr;
  134. int flood_ctcp_time;
  135. int flood_nick_thr;
  136. int flood_nick_time;
  137. int status;
  138. int ircnet_status;
  139. int limitraise;
  140. /* Chanint template
  141. *int temp;
  142. */
  143. int jointime;
  144. int parttime;
  145. int idle_kick;
  146. int stopnethack_mode;
  147. int revenge_mode;
  148. int ban_time;
  149. #ifdef S_IRCNET
  150. int invite_time;
  151. int exempt_time;
  152. maskrec *bans, /* temporary channel bans */
  153. *exempts, /* temporary channel exempts */
  154. *invites; /* temporary channel invites */
  155. #else
  156. maskrec *bans;
  157. #endif
  158. /* desired channel modes: */
  159. int mode_pls_prot; /* modes to enforce */
  160. int mode_mns_prot; /* modes to reject */
  161. int limit_prot; /* desired limit */
  162. char key_prot[121]; /* desired password */
  163. /* Chanchar template
  164. *char temp[121];
  165. */
  166. /* queued mode changes: */
  167. char pls[21]; /* positive mode changes */
  168. char mns[21]; /* negative mode changes */
  169. char *key; /* new key to set */
  170. char *rmkey; /* old key to remove */
  171. int limit; /* new limit to set */
  172. int bytes; /* total bytes so far */
  173. int compat; /* to prevent mixing old/new modes */
  174. struct {
  175. char * target;
  176. } opqueue[24];
  177. struct {
  178. char * target;
  179. } deopqueue[24];
  180. struct {
  181. char *op;
  182. int type;
  183. } cmode[MODES_PER_LINE_MAX]; /* parameter-type mode changes - */
  184. /* detect floods */
  185. char floodwho[FLOOD_CHAN_MAX][81];
  186. time_t floodtime[FLOOD_CHAN_MAX];
  187. int floodnum[FLOOD_CHAN_MAX];
  188. char deopd[NICKLEN]; /* last person deop'd (must change */
  189. int opreqtime[5]; /* remember when ops was requested */
  190. #ifdef G_AUTOLOCK
  191. int fighting;
  192. #endif
  193. #ifdef G_BACKUP
  194. int backup_time; /* If non-0, set +backup when now>backup_time */
  195. #endif
  196. #ifdef HUB
  197. char topic[91];
  198. #endif
  199. };
  200. /* behavior modes for the channel */
  201. /* Chanflag template
  202. * #define CHAN_TEMP 0x0000
  203. */
  204. #define CHAN_ENFORCEBANS 0x0001 /* kick people who match channel bans */
  205. #define CHAN_DYNAMICBANS 0x0002 /* only activate bans when needed */
  206. #define CHAN_NOUSERBANS 0x0004 /* don't let non-bots place bans */
  207. #define CHAN_CLOSED 0x0008 /* Only users +o can join */
  208. #define CHAN_BITCH 0x0010 /* be a tightwad with ops */
  209. #define CHAN_TAKE 0x0020 /* When a bot gets opped, take the chan */
  210. #define CHAN_PROTECTOPS 0x0040 /* re-op any +o people who get deop'd */
  211. #define CHAN_NOMOP 0x0080 /* If a bot sees a mass op, botnet mdops */
  212. #define CHAN_REVENGE 0x0100 /* get revenge on bad people */
  213. #define CHAN_SECRET 0x0200 /* don't advertise channel on botnet */
  214. #define CHAN_MANOP 0x0400 /* manual opping allowed? */
  215. #define CHAN_CYCLE 0x0800 /* cycle the channel if possible */
  216. #define CHAN_DONTKICKOPS 0x1000 /* never kick +o flag people -arthur2 */
  217. #define CHAN_INACTIVE 0x2000 /* no irc support for this channel
  218. - drummer */
  219. //#define CHAN_ 0x4000 /* unused */
  220. #define CHAN_VOICE 0x8000 /* a bot +y|y will voice *, except +q */
  221. #define CHAN_SEEN 0x10000
  222. #define CHAN_REVENGEBOT 0x20000 /* revenge on actions against the bot */
  223. #define CHAN_NODESYNCH 0x40000
  224. #define CHAN_FASTOP 0x80000 /* Bots will not use +o-b to op (no cookies) */
  225. #define CHAN_PRIVATE 0x100000 /* users need |o to access chan */
  226. #define CHAN_ACTIVE 0x1000000 /* like i'm actually on the channel
  227. and stuff */
  228. #define CHAN_PEND 0x2000000 /* just joined; waiting for end of
  229. WHO list */
  230. #define CHAN_FLAGGED 0x4000000 /* flagged during rehash for delete */
  231. //#define CHAN_ 0x8000000 /* unused */
  232. #define CHAN_ASKEDBANS 0x10000000
  233. #define CHAN_ASKEDMODES 0x20000000 /* find out key-info on IRCu */
  234. #define CHAN_JUPED 0x40000000 /* Is channel juped */
  235. #define CHAN_STOP_CYCLE 0x80000000 /* Some efnetservers have defined
  236. NO_CHANOPS_WHEN_SPLIT */
  237. #ifdef S_IRCNET
  238. #define CHAN_ASKED_EXEMPTS 0x0001
  239. #define CHAN_ASKED_INVITED 0x0002
  240. #define CHAN_DYNAMICEXEMPTS 0x0004
  241. #define CHAN_NOUSEREXEMPTS 0x0008
  242. #define CHAN_DYNAMICINVITES 0x0010
  243. #define CHAN_NOUSERINVITES 0x0020
  244. #endif
  245. /* prototypes */
  246. memberlist *ismember(struct chanset_t *, char *);
  247. struct chanset_t *findchan(const char *name);
  248. struct chanset_t *findchan_by_dname(const char *name);
  249. /* is this channel +s/+p? */
  250. #define channel_hidden(chan) (chan->channel.mode & (CHANPRIV | CHANSEC))
  251. /* is this channel +t? */
  252. #define channel_optopic(chan) (chan->channel.mode & CHANTOPIC)
  253. #define channel_active(chan) (chan->status & CHAN_ACTIVE)
  254. #define channel_pending(chan) (chan->status & CHAN_PEND)
  255. #define channel_bitch(chan) (chan->status & CHAN_BITCH)
  256. #define channel_nodesynch(chan) (chan->status & CHAN_NODESYNCH)
  257. #define channel_enforcebans(chan) (chan->status & CHAN_ENFORCEBANS)
  258. #define channel_revenge(chan) (chan->status & CHAN_REVENGE)
  259. #define channel_dynamicbans(chan) (chan->status & CHAN_DYNAMICBANS)
  260. #define channel_nouserbans(chan) (chan->status & CHAN_NOUSERBANS)
  261. #define channel_protectops(chan) (chan->status & CHAN_PROTECTOPS)
  262. #define channel_autovoice(chan) (0)
  263. #define channel_dontkickops(chan) (chan->status & CHAN_DONTKICKOPS)
  264. #define channel_secret(chan) (chan->status & CHAN_SECRET)
  265. #define channel_shared(chan) (1)
  266. #define channel_cycle(chan) (chan->status & CHAN_CYCLE)
  267. #define channel_seen(chan) (1)
  268. #define channel_inactive(chan) (chan->status & CHAN_INACTIVE)
  269. #define channel_revengebot(chan) (chan->status & CHAN_REVENGEBOT)
  270. #ifdef S_IRCNET
  271. #define channel_dynamicexempts(chan) (chan->ircnet_status & CHAN_DYNAMICEXEMPTS)
  272. #define channel_nouserexempts(chan) (chan->ircnet_status & CHAN_NOUSEREXEMPTS)
  273. #define channel_dynamicinvites(chan) (chan->ircnet_status & CHAN_DYNAMICINVITES)
  274. #define channel_nouserinvites(chan) (chan->ircnet_status & CHAN_NOUSERINVITES)
  275. #endif
  276. #define channel_juped(chan) (chan->status & CHAN_JUPED)
  277. #define channel_stop_cycle(chan) (chan->status & CHAN_STOP_CYCLE)
  278. #define channel_closed(chan) (chan->status & CHAN_CLOSED)
  279. #define channel_take(chan) (chan->status & CHAN_TAKE)
  280. #define channel_nomop(chan) (chan->status & CHAN_NOMOP)
  281. #define channel_manop(chan) (chan->status & CHAN_MANOP)
  282. #define channel_voice(chan) (chan->status & CHAN_VOICE)
  283. #define channel_fastop(chan) (chan->status & CHAN_FASTOP)
  284. #define channel_private(chan) (chan->status & CHAN_PRIVATE)
  285. /* Chanflag template
  286. *#define channel_temp(chan) (chan->status & CHAN_PRIVATE)
  287. */
  288. struct msgq_head {
  289. struct msgq *head;
  290. struct msgq *last;
  291. int tot;
  292. int warned;
  293. };
  294. /* Used to queue a lot of things */
  295. struct msgq {
  296. struct msgq *next;
  297. int len;
  298. char *msg;
  299. };
  300. #endif /* _EGG_CHAN_H */