1 /* hash.c - IRC network state database
2 * Copyright 2000-2004 srvx Development Team
4 * This file is part of x3.
6 * x3 is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 #if defined(HAVE_LIBGEOIP)&&defined(HAVE_GEOIP_H)&&defined(HAVE_GEOIPCITY_H)
28 #include <GeoIPCity.h>
38 unsigned int max_clients
, invis_clients
;
39 time_t max_clients_time
;
40 struct userList curr_opers
;
42 static void hash_cleanup(void);
44 void init_structs(void)
46 channels
= dict_new();
49 userList_init(&curr_opers
);
50 reg_exit_func(hash_cleanup
);
53 server_link_func_t
*slf_list
;
54 unsigned int slf_size
= 0, slf_used
= 0;
57 reg_server_link_func(server_link_func_t handler
)
59 if (slf_used
== slf_size
) {
62 slf_list
= realloc(slf_list
, slf_size
*sizeof(server_link_func_t
));
65 slf_list
= malloc(slf_size
*sizeof(server_link_func_t
));
68 slf_list
[slf_used
++] = handler
;
72 GetServerH(const char *name
)
74 return dict_find(servers
, name
, NULL
);
77 new_user_func_t
*nuf_list
;
78 unsigned int nuf_size
= 0, nuf_used
= 0;
81 reg_new_user_func(new_user_func_t handler
)
83 if (nuf_used
== nuf_size
) {
86 nuf_list
= realloc(nuf_list
, nuf_size
*sizeof(new_user_func_t
));
89 nuf_list
= malloc(nuf_size
*sizeof(new_user_func_t
));
92 nuf_list
[nuf_used
++] = handler
;
95 static nick_change_func_t
*ncf2_list
;
96 static unsigned int ncf2_size
= 0, ncf2_used
= 0;
99 reg_nick_change_func(nick_change_func_t handler
)
101 if (ncf2_used
== ncf2_size
) {
104 ncf2_list
= realloc(ncf2_list
, ncf2_size
*sizeof(nick_change_func_t
));
107 ncf2_list
= malloc(ncf2_size
*sizeof(nick_change_func_t
));
110 ncf2_list
[ncf2_used
++] = handler
;
114 del_user_func_t
*duf_list
;
115 unsigned int duf_size
= 0, duf_used
= 0;
118 reg_del_user_func(del_user_func_t handler
)
120 if (duf_used
== duf_size
) {
123 duf_list
= realloc(duf_list
, duf_size
*sizeof(del_user_func_t
));
126 duf_list
= malloc(duf_size
*sizeof(del_user_func_t
));
129 duf_list
[duf_used
++] = handler
;
133 unreg_del_user_func(del_user_func_t handler
)
136 for (i
=0; i
<duf_used
; i
++) {
137 if (duf_list
[i
] == handler
) break;
139 if (i
== duf_used
) return;
140 memmove(duf_list
+i
, duf_list
+i
+1, (duf_used
-i
-1)*sizeof(duf_list
[0]));
144 /* reintroduces a user after it has been killed. */
146 ReintroduceUser(struct userNode
*user
)
148 struct mod_chanmode change
;
152 mod_chanmode_init(&change
);
154 for (n
= 0; n
< user
->channels
.used
; n
++) {
155 struct modeNode
*mn
= user
->channels
.list
[n
];
156 irc_join(user
, mn
->channel
);
158 change
.args
[0].mode
= mn
->modes
;
159 change
.args
[0].u
.member
= mn
;
160 mod_chanmode_announce(user
, mn
->channel
, &change
);
166 NickChange(struct userNode
* user
, const char *new_nick
, int no_announce
)
171 /* don't do anything if there's no change */
172 old_nick
= user
->nick
;
173 if (!strncmp(new_nick
, old_nick
, NICKLEN
))
176 /* remove old entry from clients dictionary */
177 dict_remove(clients
, old_nick
);
178 #if !defined(WITH_PROTOCOL_P10)
179 /* Remove from uplink's clients dict */
180 dict_remove(user
->uplink
->users
, old_nick
);
183 user
->nick
= strdup(new_nick
);
184 dict_insert(clients
, user
->nick
, user
);
185 #if !defined(WITH_PROTOCOL_P10)
186 dict_insert(user
->uplink
->users
, user
->nick
, user
);
189 /* Make callbacks for nick changes. Do this with new nick in
190 * place because that is slightly more useful.
192 for (nn
=0; nn
<ncf2_used
; nn
++)
193 ncf2_list
[nn
](user
, old_nick
);
194 user
->timestamp
= now
;
195 if (IsLocal(user
) && !no_announce
)
196 irc_nick(user
, old_nick
);
201 SVSNickChange(struct userNode
* user
, const char *new_nick
)
206 /* don't do anything if there's no change */
207 old_nick
= user
->nick
;
208 if (!strncmp(new_nick
, old_nick
, NICKLEN
))
211 /* remove old entry from clients dictionary */
212 dict_remove(clients
, old_nick
);
213 #if !defined(WITH_PROTOCOL_P10)
214 /* Remove from uplink's clients dict */
215 dict_remove(user
->uplink
->users
, old_nick
);
218 user
->nick
= strdup(new_nick
);
219 dict_insert(clients
, user
->nick
, user
);
220 #if !defined(WITH_PROTOCOL_P10)
221 dict_insert(user
->uplink
->users
, user
->nick
, user
);
224 /* Make callbacks for nick changes. Do this with new nick in
225 * place because that is slightly more useful.
227 for (nn
=0; nn
<ncf2_used
; nn
++)
228 ncf2_list
[nn
](user
, old_nick
);
229 user
->timestamp
= now
;
235 GetUserH(const char *nick
)
237 return dict_find(clients
, nick
, NULL
);
240 static account_func_t account_func
;
243 reg_account_func(account_func_t handler
)
246 log_module(MAIN_LOG
, LOG_WARNING
, "Reregistering ACCOUNT handler.");
248 account_func
= handler
;
252 call_account_func(struct userNode
*user
, const char *stamp
)
254 /* We've received an account stamp for a user; notify
255 NickServ, which registers the sole account_func
258 P10 Protocol violation if (user->modes & FLAGS_STAMPED) here.
261 account_func(user
, stamp
);
263 #ifdef WITH_PROTOCOL_P10
264 /* Mark the user so we don't stamp it again. */
265 user
->modes
|= FLAGS_STAMPED
;
270 StampUser(struct userNode
*user
, const char *stamp
, time_t timestamp
)
272 #ifdef WITH_PROTOCOL_P10
273 /* The P10 protocol says we can't stamp users who already
279 irc_account(user
, stamp
, timestamp
);
280 user
->modes
|= FLAGS_STAMPED
;
284 assign_fakehost(struct userNode
*user
, const char *host
, int announce
)
286 safestrncpy(user
->fakehost
, host
, sizeof(user
->fakehost
));
288 irc_fakehost(user
, host
);
292 set_geoip_info(struct userNode
*user
)
296 /* Need the libs and the headers if this is going to compile properly */
297 #if defined(HAVE_LIBGEOIP)&&defined(HAVE_GEOIP_H)&&defined(HAVE_GEOIPCITY_H)
299 const char *geoip_data_file
= NULL
;
300 const char *geoip_city_file
= NULL
;
302 geoip_data_file
= conf_get_data("services/opserv/geoip_data_file", RECDB_QSTRING
);
303 geoip_city_file
= conf_get_data("services/opserv/geoip_city_data_file", RECDB_QSTRING
);
305 if ((!geoip_data_file
&& !geoip_city_file
))
306 return; /* Admin doesnt want to use geoip functions */
308 if (geoip_data_file
&& !gi
)
309 gi
= GeoIP_open(geoip_data_file
, GEOIP_MEMORY_CACHE
| GEOIP_CHECK_CACHE
);
311 if (geoip_city_file
&& !cgi
)
312 cgi
= GeoIP_open(geoip_city_file
, GEOIP_MEMORY_CACHE
| GEOIP_CHECK_CACHE
);
315 gir
= GeoIP_record_by_name(cgi
, user
->hostname
);
317 user
->country_name
= strdup(gir
->country_name
? gir
->country_name
: "");
318 user
->country_code
= strdup(gir
->country_code
? gir
->country_code
: "");
319 user
->city
= strdup(gir
->city
? gir
->city
: "");
320 user
->region
= strdup(gir
->region
? gir
->region
: "");
321 user
->postal_code
= strdup(gir
->postal_code
? gir
->postal_code
: "");
323 user
->latitude
= gir
->latitude
? gir
->latitude
: 0;
324 user
->longitude
= gir
->longitude
? gir
->longitude
: 0;
325 user
->dma_code
= gir
->dma_code
? gir
->dma_code
: 0;
326 user
->area_code
= gir
->area_code
? gir
->area_code
: 0;
328 GeoIPRecord_delete(gir
);
333 const char *country
= GeoIP_country_name_by_name(gi
, user
->hostname
);
334 user
->country_name
= strdup(country
? country
: "");
342 static new_channel_func_t
*ncf_list
;
343 static unsigned int ncf_size
= 0, ncf_used
= 0;
346 reg_new_channel_func(new_channel_func_t handler
)
348 if (ncf_used
== ncf_size
) {
351 ncf_list
= realloc(ncf_list
, ncf_size
*sizeof(ncf_list
[0]));
354 ncf_list
= malloc(ncf_size
*sizeof(ncf_list
[0]));
357 ncf_list
[ncf_used
++] = handler
;
360 static join_func_t
*jf_list
;
361 static unsigned int jf_size
= 0, jf_used
= 0;
364 reg_join_func(join_func_t handler
)
366 if (jf_used
== jf_size
) {
369 jf_list
= realloc(jf_list
, jf_size
*sizeof(join_func_t
));
372 jf_list
= malloc(jf_size
*sizeof(join_func_t
));
375 jf_list
[jf_used
++] = handler
;
381 wipeout_channel(struct chanNode
*cNode
, time_t new_time
, char **modes
, unsigned int modec
) {
382 unsigned int orig_limit
;
383 chan_mode_t orig_modes
;
384 char orig_key
[KEYLEN
+1];
385 char orig_apass
[KEYLEN
+1];
386 char orig_upass
[KEYLEN
+1];
387 unsigned int nn
, argc
;
390 cNode
->topic
[0] = '\0';
391 cNode
->topic_nick
[0] = '\0';
392 cNode
->topic_time
= 0;
394 /* remember the old modes, and update them with the new */
395 orig_modes
= cNode
->modes
;
396 orig_limit
= cNode
->limit
;
397 strcpy(orig_key
, cNode
->key
);
398 strcpy(orig_upass
, cNode
->upass
);
399 strcpy(orig_apass
, cNode
->apass
);
401 mod_chanmode(NULL
, cNode
, modes
, modec
, 0);
402 cNode
->timestamp
= new_time
;
404 /* remove our old ban list, replace it with the new one */
405 for (nn
=0; nn
<cNode
->banlist
.used
; nn
++)
406 free(cNode
->banlist
.list
[nn
]);
407 cNode
->banlist
.used
= 0;
409 /* remove our old exe,[t list, replace it with the new one */
410 for (nn
=0; nn
<cNode
->exemptlist
.used
; nn
++)
411 free(cNode
->exemptlist
.list
[nn
]);
412 cNode
->exemptlist
.used
= 0;
414 /* deop anybody in the channel now, but count services to reop */
415 for (nn
=argc
=0; nn
<cNode
->members
.used
; nn
++) {
416 struct modeNode
*mn
= cNode
->members
.list
[nn
];
417 if ((mn
->modes
& MODE_CHANOP
) && IsService(mn
->user
) && IsLocal(mn
->user
))
422 struct mod_chanmode
*change
;
424 change
= mod_chanmode_alloc(argc
);
425 change
->modes_clear
= 0;
426 change
->modes_set
= orig_modes
;
427 change
->new_limit
= orig_limit
;
428 strcpy(change
->new_key
, orig_key
);
429 strcpy(change
->new_upass
, orig_upass
);
430 strcpy(change
->new_apass
, orig_apass
);
431 for (nn
= argc
= 0; nn
< cNode
->members
.used
; ++nn
) {
432 struct modeNode
*mn
= cNode
->members
.list
[nn
];
433 if ((mn
->modes
& MODE_CHANOP
) && IsService(mn
->user
) && IsLocal(mn
->user
)) {
434 change
->args
[argc
].mode
= MODE_CHANOP
;
435 change
->args
[argc
].u
.member
= mn
;
439 assert(argc
== change
->argc
);
440 change
->args
[0].u
.member
->modes
&= ~MODE_CHANOP
;
441 mod_chanmode_announce(change
->args
[0].u
.member
->user
, cNode
, change
);
442 mod_chanmode_free(change
);
447 AddChannel(const char *name
, time_t time_
, const char *modes
, char *banlist
, char *exemptlist
)
449 struct chanNode
*cNode
;
450 char new_modes
[MAXLEN
], *argv
[MAXNUMPARAMS
];
453 if (!IsChannelName(name
)) {
454 log_module(MAIN_LOG
, LOG_ERROR
, "Somebody asked to add channel '%s', which isn't a channel name!", name
);
460 safestrncpy(new_modes
, modes
, sizeof(new_modes
));
461 nn
= split_line(new_modes
, 0, ArrayLength(argv
), argv
);
462 if (!(cNode
= GetChannel(name
))) {
463 cNode
= calloc(1, sizeof(*cNode
) + strlen(name
));
464 strcpy(cNode
->name
, name
);
465 banList_init(&cNode
->banlist
);
466 exemptList_init(&cNode
->exemptlist
);
467 modeList_init(&cNode
->members
);
468 mod_chanmode(NULL
, cNode
, argv
, nn
, MCP_FROM_SERVER
);
469 dict_insert(channels
, cNode
->name
, cNode
);
470 cNode
->timestamp
= time_
;
472 } else if (cNode
->timestamp
> time_
) {
473 wipeout_channel(cNode
, time_
, argv
, nn
);
475 } else if (cNode
->timestamp
== time_
) {
476 mod_chanmode(NULL
, cNode
, argv
, nn
, MCP_FROM_SERVER
);
482 /* rel_age is the relative ages of our channel data versus what is
483 * in a BURST command. 1 means ours is younger, 0 means both are
484 * the same age, -1 means ours is older. */
486 /* if it's a new or updated channel, make callbacks */
488 for (nn
=0; nn
<ncf_used
; nn
++)
491 /* go through list of bans and add each one */
492 if (banlist
&& (rel_age
>= 0)) {
493 for (nn
=0; banlist
[nn
];) {
494 char *ban
= banlist
+ nn
;
496 while (banlist
[nn
] != ' ' && banlist
[nn
])
498 while (banlist
[nn
] == ' ')
500 bn
= calloc(1, sizeof(*bn
));
501 safestrncpy(bn
->ban
, ban
, sizeof(bn
->ban
));
502 safestrncpy(bn
->who
, "<unknown>", sizeof(bn
->who
));
504 banList_append(&cNode
->banlist
, bn
);
508 /* go through list of exempts and add each one */
509 if (exemptlist
&& (rel_age
>= 0)) {
510 for (nn
=0; exemptlist
[nn
];) {
511 char *exempt
= exemptlist
+ nn
;
512 struct exemptNode
*en
;
513 while (exemptlist
[nn
] != ' ' && exemptlist
[nn
])
515 while (exemptlist
[nn
] == ' ')
516 exemptlist
[nn
++] = 0;
517 en
= calloc(1, sizeof(*en
));
518 safestrncpy(en
->exempt
, exempt
, sizeof(en
->exempt
));
519 safestrncpy(en
->who
, "<unknown>", sizeof(en
->who
));
521 exemptList_append(&cNode
->exemptlist
, en
);
528 static del_channel_func_t
*dcf_list
;
529 static unsigned int dcf_size
= 0, dcf_used
= 0;
532 reg_del_channel_func(del_channel_func_t handler
)
534 if (dcf_used
== dcf_size
) {
537 dcf_list
= realloc(dcf_list
, dcf_size
*sizeof(dcf_list
[0]));
540 dcf_list
= malloc(dcf_size
*sizeof(dcf_list
[0]));
543 dcf_list
[dcf_used
++] = handler
;
547 DelChannel(struct chanNode
*channel
)
551 dict_remove(channels
, channel
->name
);
553 if (channel
->members
.used
|| channel
->locks
) {
554 log_module(MAIN_LOG
, LOG_ERROR
, "Warning: deleting channel %s with %d users and %d locks remaining.", channel
->name
, channel
->members
.used
, channel
->locks
);
557 /* go through all channel members and delete them from the channel */
558 for (n
=channel
->members
.used
; n
>0; )
559 DelChannelUser(channel
->members
.list
[--n
]->user
, channel
, false, 1);
561 /* delete all channel bans */
562 for (n
=channel
->banlist
.used
; n
>0; )
563 free(channel
->banlist
.list
[--n
]);
564 channel
->banlist
.used
= 0;
566 /* delete all channel exempts */
567 for (n
=channel
->exemptlist
.used
; n
>0; )
568 free(channel
->exemptlist
.list
[--n
]);
569 channel
->exemptlist
.used
= 0;
571 for (n
=0; n
<dcf_used
; n
++)
572 dcf_list
[n
](channel
);
574 modeList_clean(&channel
->members
);
575 banList_clean(&channel
->banlist
);
576 exemptList_clean(&channel
->exemptlist
);
581 AddChannelUser(struct userNode
*user
, struct chanNode
* channel
)
583 struct modeNode
*mNode
;
586 mNode
= GetUserMode(channel
, user
);
590 mNode
= malloc(sizeof(*mNode
));
592 /* set up modeNode */
593 mNode
->channel
= channel
;
597 mNode
->idle_since
= now
;
599 /* Add modeNode to channel and to user.
600 * We have to do this before calling join funcs in case the
601 * modeNode is manipulated (e.g. chanserv ops the user).
603 modeList_append(&channel
->members
, mNode
);
604 modeList_append(&user
->channels
, mNode
);
606 if (channel
->members
.used
== 1
607 && !(channel
->modes
& MODE_REGISTERED
)
608 && !(channel
->modes
& MODE_APASS
))
609 mNode
->modes
|= MODE_CHANOP
;
611 for (n
=0; n
<jf_used
; n
++) {
612 /* Callbacks return true if they kick or kill the user,
613 * and we can continue without removing mNode. */
614 if (jf_list
[n
](mNode
))
619 irc_join(user
, channel
);
624 static part_func_t
*pf_list
;
625 static unsigned int pf_size
= 0, pf_used
= 0;
628 reg_part_func(part_func_t handler
)
630 if (pf_used
== pf_size
) {
633 pf_list
= realloc(pf_list
, pf_size
*sizeof(part_func_t
));
636 pf_list
= malloc(pf_size
*sizeof(part_func_t
));
639 pf_list
[pf_used
++] = handler
;
643 unreg_part_func(part_func_t handler
)
646 for (i
=0; i
<pf_used
; i
++)
647 if (pf_list
[i
] == handler
)
651 memmove(pf_list
+i
, pf_list
+i
+1, (pf_used
-i
-1)*sizeof(pf_list
[0]));
656 LockChannel(struct chanNode
* channel
)
662 UnlockChannel(struct chanNode
*channel
)
664 assert(channel
->locks
> 0);
665 if (!--channel
->locks
&& !channel
->members
.used
)
670 DelChannelUser(struct userNode
* user
, struct chanNode
* channel
, const char *reason
, int deleting
)
672 struct modeNode
* mNode
;
676 irc_part(user
, channel
, reason
);
678 mNode
= GetUserMode(channel
, user
);
680 /* Sometimes we get a PART when the user has been KICKed.
681 * In this case, we get no usermode, and should not try to free it.
686 /* remove modeNode from channel and user */
687 modeList_remove(&channel
->members
, mNode
);
688 modeList_remove(&user
->channels
, mNode
);
691 for (n
=0; n
<pf_used
; n
++)
692 pf_list
[n
](mNode
, reason
);
697 /* A single check for APASS only should be enough here */
698 if (!deleting
&& !channel
->members
.used
&& !channel
->locks
699 && !(channel
->modes
& MODE_REGISTERED
) && !(channel
->modes
& MODE_APASS
))
703 static kick_func_t
*kf_list
;
704 static unsigned int kf_size
= 0, kf_used
= 0;
707 KickChannelUser(struct userNode
* target
, struct chanNode
* channel
, struct userNode
*kicker
, const char *why
)
711 if (!target
|| !channel
|| IsService(target
) || !GetUserMode(channel
, target
))
714 /* This may break things, but lets see.. -Rubin */
715 for (n
=0; n
<kf_used
; n
++)
716 kf_list
[n
](kicker
, target
, channel
);
718 /* don't remove them from the channel, since the server will send a PART */
719 irc_kick(kicker
, target
, channel
, why
);
723 /* NULL reason because we don't want a PART message to be
724 sent by DelChannelUser. */
725 DelChannelUser(target
, channel
, NULL
, 0);
730 reg_kick_func(kick_func_t handler
)
732 if (kf_used
== kf_size
) {
735 kf_list
= realloc(kf_list
, kf_size
*sizeof(kick_func_t
));
738 kf_list
= malloc(kf_size
*sizeof(kick_func_t
));
741 kf_list
[kf_used
++] = handler
;
745 ChannelUserKicked(struct userNode
* kicker
, struct userNode
* victim
, struct chanNode
* channel
)
750 if (!victim
|| !channel
|| !GetUserMode(channel
, victim
))
753 /* Update the kicker's idle time (kicker may be null if it was a server) */
754 if (kicker
&& (mn
= GetUserMode(channel
, kicker
)))
755 mn
->idle_since
= now
;
757 for (n
=0; n
<kf_used
; n
++)
758 kf_list
[n
](kicker
, victim
, channel
);
760 DelChannelUser(victim
, channel
, 0, 0);
763 irc_part(victim
, channel
, NULL
);
766 int ChannelBanExists(struct chanNode
*channel
, const char *ban
)
770 for (n
= 0; n
< channel
->banlist
.used
; n
++)
771 if (match_ircglobs(channel
->banlist
.list
[n
]->ban
, ban
))
776 int ChannelExemptExists(struct chanNode
*channel
, const char *exempt
)
780 for (n
= 0; n
< channel
->exemptlist
.used
; n
++)
781 if (match_ircglobs(channel
->exemptlist
.list
[n
]->exempt
, exempt
))
786 static topic_func_t
*tf_list
;
787 static unsigned int tf_size
= 0, tf_used
= 0;
790 reg_topic_func(topic_func_t handler
)
792 if (tf_used
== tf_size
) {
795 tf_list
= realloc(tf_list
, tf_size
*sizeof(topic_func_t
));
798 tf_list
= malloc(tf_size
*sizeof(topic_func_t
));
801 tf_list
[tf_used
++] = handler
;
805 SetChannelTopic(struct chanNode
*channel
, struct userNode
*service
, struct userNode
*user
, const char *topic
, int announce
)
809 char old_topic
[TOPICLEN
+1];
811 safestrncpy(old_topic
, channel
->topic
, sizeof(old_topic
));
812 safestrncpy(channel
->topic
, topic
, sizeof(channel
->topic
));
813 channel
->topic_time
= now
;
816 safestrncpy(channel
->topic_nick
, user
->nick
, sizeof(channel
->topic_nick
));
818 /* Update the setter's idle time */
819 if ((mn
= GetUserMode(channel
, user
)))
820 mn
->idle_since
= now
;
824 /* We don't really care if a local user messes with the topic,
825 * so don't call the tf_list functions. */
826 irc_topic(service
, user
, channel
, topic
);
828 for (n
=0; n
<tf_used
; n
++)
829 if (tf_list
[n
](user
, channel
, old_topic
))
835 GetChannel(const char *name
)
837 return dict_find(channels
, name
, NULL
);
841 GetUserMode(struct chanNode
*channel
, struct userNode
*user
)
844 struct modeNode
*mn
= NULL
;
847 verify(channel
->members
.list
);
849 verify(user
->channels
.list
);
850 if (channel
->members
.used
< user
->channels
.used
) {
851 for (n
=0; n
<channel
->members
.used
; n
++) {
852 verify(channel
->members
.list
[n
]);
853 if (user
== channel
->members
.list
[n
]->user
) {
854 mn
= channel
->members
.list
[n
];
859 for (n
=0; n
<user
->channels
.used
; n
++) {
860 verify(user
->channels
.list
[n
]);
861 if (channel
== user
->channels
.list
[n
]->channel
) {
862 mn
= user
->channels
.list
[n
];
870 struct userNode
*IsInChannel(struct chanNode
*channel
, struct userNode
*user
)
875 verify(channel
->members
.list
);
877 verify(user
->channels
.list
);
878 if (channel
->members
.used
< user
->channels
.used
) {
879 for (n
=0; n
<channel
->members
.used
; n
++) {
880 verify(channel
->members
.list
[n
]);
881 if (user
== channel
->members
.list
[n
]->user
) {
886 for (n
=0; n
<user
->channels
.used
; n
++) {
887 verify(user
->channels
.list
[n
]);
888 if (channel
== user
->channels
.list
[n
]->channel
) {
896 DEFINE_LIST(userList
, struct userNode
*)
897 DEFINE_LIST(modeList
, struct modeNode
*)
898 DEFINE_LIST(banList
, struct banNode
*)
899 DEFINE_LIST(exemptList
, struct exemptNode
*)
900 DEFINE_LIST(channelList
, struct chanNode
*)
901 DEFINE_LIST(serverList
, struct server
*)
906 dict_iterator_t it
, next
;
908 DelServer(self
, 0, NULL
);
909 for (it
= dict_first(channels
); it
; it
= next
) {
910 next
= iter_next(it
);
911 DelChannel(iter_data(it
));
913 dict_delete(channels
);
914 dict_delete(clients
);
915 dict_delete(servers
);
916 userList_clean(&curr_opers
);