[srvx-commits] CVS: services/src chanserv.c,1.373,1.374 chanserv.h,1.48,1.49 nickserv.c,1.250,1.251
Brought to you by:
entrope
From: Entrope <en...@us...> - 2003-08-05 01:31:19
|
Update of /cvsroot/srvx/services/src In directory sc8-pr-cvs1:/tmp/cvs-serv31018/src Modified Files: chanserv.c chanserv.h nickserv.c nickserv.h Log Message: merge struct chanList into corresponding struct userData get rid of "name" element of struct suspended fix memory leak of failpw_func_list add !deleteme function, and use a new confirmation string based on userData change !unregister confirmation behavior to also use the new hash string Index: chanserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/chanserv.c,v retrieving revision 1.373 retrieving revision 1.374 diff -C2 -r1.373 -r1.374 *** chanserv.c 3 Aug 2003 18:37:52 -0000 1.373 --- chanserv.c 5 Aug 2003 01:31:16 -0000 1.374 *************** *** 142,146 **** #define CSMSG_UNREG_NODELETE "$b%s$b is protected from unregistration." #define CSMSG_CHAN_SUSPENDED "$b$C$b access to $b%s$b has been temporarily suspended (%s)." ! #define CSMSG_CONFIRM_UNREG "To confirm this unregistration, you must append 'CONFIRM' to the end of your command. For example, 'unregister CONFIRM'." /* Channel moving */ --- 142,146 ---- #define CSMSG_UNREG_NODELETE "$b%s$b is protected from unregistration." #define CSMSG_CHAN_SUSPENDED "$b$C$b access to $b%s$b has been temporarily suspended (%s)." ! #define CSMSG_CONFIRM_UNREG "To confirm this unregistration, you must use 'unregister %s'." /* Channel moving */ *************** *** 170,173 **** --- 170,175 ---- #define CSMSG_ALREADY_OPCHANNED "There has been no net.join since the opchan in $b%s$b." #define CSMSG_OPCHAN_DONE "I have (re-)opped myself in $b%s$b." + #define CSMSG_NO_OWNER_DELETEME "You cannot delete your owner access in $b%s$b." + #define CSMSG_CONFIRM_DELETEME "To confirm this user removal, you must use 'deleteme %s'." /* User management */ *************** *** 1249,1253 **** { struct userData *ud; - struct chanList *cl; if(access > USER_LEVEL_HIGHEST || access < USER_LEVEL_LOWEST) --- 1251,1254 ---- *************** *** 1257,1260 **** --- 1258,1262 ---- ud = calloc(1, sizeof(*ud)); + ud->channel = channel; ud->handle = handle; ud->seen = seen; *************** *** 1275,1346 **** userCount[access]++; ! cl = malloc(sizeof(struct chanList)); ! cl->channel = channel; ! cl->user = ud; ! ! cl->prev = NULL; ! cl->next = ud->handle->channels; ! if(cl->next) { ! cl->next->prev = cl; } ! ud->handle->channels = cl; return ud; } ! static struct chanList * ! find_channel_entry(struct chanData *channel, struct userData *user) ! { ! struct chanList *entry = NULL; ! ! for(entry = user->handle->channels; entry; entry = entry->next) ! { ! if(entry->channel == channel) ! { ! return entry; ! } ! } ! ! return NULL; ! } ! ! static void unregister_channel(struct chanData *channel); void ! del_channel_user(struct chanData *channel, struct userData *user, int do_gc) { ! struct chanList *entry = NULL; ! ! if(!channel || !user) return; ! channel->userCount[0]--; ! channel->userCount[user->access]--; userCount[0]--; userCount[user->access]--; - entry = find_channel_entry(channel, user); - if(entry) - { - if(entry->prev) entry->prev->next = entry->next; - else user->handle->channels = entry->next; - - if(entry->next) entry->next->prev = entry->prev; - - free(entry); - } - else - { - log_module(CS_LOG, LOG_ERROR, "Missing access list entry for %s.", user->handle->handle); - } - if(user->prev) user->prev->next = user->next; ! else channel->users = user->next; ! if(user->next) user->next->prev = user->prev; if(user->info) free(user->info); free(user); ! if(do_gc && !channel->users) unregister_channel(channel); } --- 1277,1316 ---- userCount[access]++; ! ud->u_prev = NULL; ! ud->u_next = ud->handle->channels; ! if(ud->u_next) { ! ud->u_next->u_prev = ud; } ! ud->handle->channels = ud; return ud; } ! static void unregister_channel(struct chanData *channel, const char *part_msg); void ! del_channel_user(struct userData *user, int do_gc) { ! struct chanData *channel; ! if(!user) return; ! user->channel->userCount[0]--; ! user->channel->userCount[user->access]--; userCount[0]--; userCount[user->access]--; if(user->prev) user->prev->next = user->next; ! else user->channel->users = user->next; if(user->next) user->next->prev = user->prev; + if(user->u_prev) user->u_prev->u_next = user->u_next; + else user->handle->channels = user->u_next; + if(user->u_next) user->u_next->u_prev = user->u_prev; + if(user->info) free(user->info); + channel = user->channel; free(user); ! if(do_gc && !channel->users) unregister_channel(channel, "Channel lost all users."); } *************** *** 1452,1456 **** static void ! unregister_channel(struct chanData *channel) { /* After channel unregistration, the following must be cleaned --- 1422,1426 ---- static void ! unregister_channel(struct chanData *channel, const char *part_msg) { /* After channel unregistration, the following must be cleaned *************** *** 1472,1476 **** while(channel->users) { ! del_channel_user(channel, channel->users, 0); } --- 1442,1446 ---- while(channel->users) { ! del_channel_user(channel->users, 0); } *************** *** 1492,1496 **** if(channel->suspended) { ! struct chanNode *cNode = dict_find(channels, channel->suspended->name, NULL); struct suspended *suspended, *next_suspended; --- 1462,1466 ---- if(channel->suspended) { ! struct chanNode *cNode = channel->channel; struct suspended *suspended, *next_suspended; *************** *** 1498,1502 **** { next_suspended = suspended->previous; - free(suspended->name); free(suspended->suspender); free(suspended->reason); --- 1468,1471 ---- *************** *** 1515,1519 **** if(channel->notes) dict_delete(channel->notes); ! free(channel); --- 1484,1488 ---- if(channel->notes) dict_delete(channel->notes); ! if(!IsSuspended(channel)) DelChannelUser(chanserv, channel->channel, part_msg, 0); free(channel); *************** *** 1525,1532 **** { struct chanData *channel, *next; - struct chanNode *save; struct userData *user; char delay[INTERVALLEN], reason[INTERVALLEN + 64]; - int suspended; intervalString(delay, chanserv_conf.channel_expire_delay); --- 1494,1499 ---- *************** *** 1549,1557 **** /* Unregister the channel */ ! suspended = IsSuspended(channel); ! log_module(CS_LOG, LOG_INFO, "(%s) Channel registration expired.", (suspended ? channel->suspended->name : channel->channel->name)); ! save = channel->channel; ! unregister_channel(channel); ! if(!suspended) DelChannelUser(chanserv, save, reason, 0); } --- 1516,1521 ---- /* Unregister the channel */ ! log_module(CS_LOG, LOG_INFO, "(%s) Channel registration expired.", channel->channel->name); ! unregister_channel(channel, reason); } *************** *** 1836,1845 **** chanserv_get_owned_count(struct handle_info *hi) { ! struct chanList *cList; unsigned int owned; ! for(owned=0, cList=hi->channels; cList; cList=cList->next) { ! if(cList->user->access == ulOwner) owned++; } return owned; --- 1800,1809 ---- chanserv_get_owned_count(struct handle_info *hi) { ! struct userData *cList; unsigned int owned; ! for(owned=0, cList=hi->channels; cList; cList=cList->u_next) { ! if(cList->access == ulOwner) owned++; } return owned; *************** *** 1968,1971 **** --- 1932,1955 ---- } + static const char * + make_confirmation_string(struct userData *uData) + { + static char strbuf[16]; + char *src; + unsigned int accum; + + accum = 0; + for(src = uData->handle->handle; *src; ) + { + accum = accum * 31 + toupper(*src++); + } + for(src = uData->channel->channel->name; *src; ) + { + accum = accum * 31 + toupper(*src++); + } + sprintf(strbuf, "%08x", accum); + return strbuf; + } + static CHANSERV_FUNC(cmd_unregister) { *************** *** 1974,1985 **** struct chanData *cData; struct userData *uData; - unsigned int suspended, confirm; cData = channel->channel_info; - name = channel->name; - confirm = 1; if(!cData) { ! reply(CSMSG_NOT_REGISTERED, name); return 0; } --- 1958,1966 ---- struct chanData *cData; struct userData *uData; cData = channel->channel_info; if(!cData) { ! reply(CSMSG_NOT_REGISTERED, channel->name); return 0; } *************** *** 1994,1998 **** if(IsProtected(cData)) { ! chanserv_notice(user, CSMSG_UNREG_NODELETE, name); return 0; } --- 1975,1979 ---- if(IsProtected(cData)) { ! chanserv_notice(user, CSMSG_UNREG_NODELETE, channel->name); return 0; } *************** *** 2000,2023 **** if(!IsPrivileged(user)) { if(IsSuspended(cData)) { ! reply(CSMSG_CHAN_SUSPENDED, cData->suspended->name, cData->suspended->reason); return 0; } ! if(argc < confirm + 1 || strcmp(argv[confirm], "CONFIRM")) { ! reply(CSMSG_CONFIRM_UNREG); return 0; } } ! name = strdup(name); ! suspended = IsSuspended(cData); ! unregister_channel(cData); ! if(!suspended) ! { ! sprintf(reason, "Channel unregistered by %s.", user->handle_info->handle); ! DelChannelUser(chanserv, channel, reason, 0); ! } reply(CSMSG_UNREG_SUCCESS, name); sprintf(reason, "%s unregistered by %s.", name, user->handle_info->handle); --- 1981,2001 ---- if(!IsPrivileged(user)) { + const char *confirm_string; if(IsSuspended(cData)) { ! reply(CSMSG_CHAN_SUSPENDED, channel->name, cData->suspended->reason); return 0; } ! confirm_string = make_confirmation_string(uData); ! if((argc < 2) || strcmp(argv[1], confirm_string)) { ! reply(CSMSG_CONFIRM_UNREG, confirm_string); return 0; } } ! name = strdup(channel->name); ! sprintf(reason, "Channel unregistered by %s.", user->handle_info->handle); ! unregister_channel(cData, reason); reply(CSMSG_UNREG_SUCCESS, name); sprintf(reason, "%s unregistered by %s.", name, user->handle_info->handle); *************** *** 2131,2143 **** channel->channel_info = NULL; ! if(IsSuspended(target->channel_info)) ! { ! /* Transfer the suspension information. */ ! struct suspended *suspended = target->channel_info->suspended; ! ! free(suspended->name); ! suspended->name = strdup(target->name); ! } ! else { if(!new_channel) AddChannelUser(chanserv, target); --- 2109,2113 ---- channel->channel_info = NULL; ! if(!IsSuspended(target->channel_info)) { if(!new_channel) AddChannelUser(chanserv, target); *************** *** 2209,2217 **** { dict_remove(merge, suData->handle->handle); ! del_channel_user(source, suData, 0); } else { ! del_channel_user(target, tuData, 0); } } --- 2179,2187 ---- { dict_remove(merge, suData->handle->handle); ! del_channel_user(suData, 0); } else { ! del_channel_user(tuData, 0); } } *************** *** 2220,2225 **** for(it = dict_first(merge); it; it = iter_next(it)) { - struct chanList *entry; - suData = iter_data(it); --- 2190,2193 ---- *************** *** 2227,2230 **** --- 2195,2199 ---- suData->prev = NULL; suData->next = target->users; + suData->channel = target; if(target->users) *************** *** 2238,2252 **** target->userCount[0]++; target->userCount[suData->access]++; - - /* Update the handle-channel link to point to the target. */ - entry = find_channel_entry(source, suData); - if(entry) - { - entry->channel = target; - } - else - { - log_module(CS_LOG, LOG_ERROR, "Missing access list entry for %s.", suData->handle->handle); - } } --- 2207,2210 ---- *************** *** 2418,2423 **** sprintf(reason, "Channel merged into %s by %s.", target->name, user->handle_info->handle); oldname = strdup(channel->name); ! unregister_channel(channel->channel_info); ! DelChannelUser(chanserv, channel, reason, 0); chanserv_notice(user, CSMSG_MERGE_SUCCESS, target->name); --- 2376,2380 ---- sprintf(reason, "Channel merged into %s by %s.", target->name, user->handle_info->handle); oldname = strdup(channel->name); ! unregister_channel(channel->channel_info, reason); chanserv_notice(user, CSMSG_MERGE_SUCCESS, target->name); *************** *** 2607,2611 **** } ! del_channel_user(channel->channel_info, victim, 1); chanserv_notice(user, CSMSG_DELETED_USER, preposition(accessNames[access]), accessNames[access], handle->handle, channel->name); return 1; --- 2564,2568 ---- } ! del_channel_user(victim, 1); chanserv_notice(user, CSMSG_DELETED_USER, preposition(accessNames[access]), accessNames[access], handle->handle, channel->name); return 1; *************** *** 2638,2642 **** if(uData->access == access && match_ircglob(uData->handle->handle, argv[1])) { ! del_channel_user(channel->channel_info, uData, 1); } } --- 2595,2599 ---- if(uData->access == access && match_ircglob(uData->handle->handle, argv[1])) { ! del_channel_user(uData, 1); } } *************** *** 2728,2732 **** if(uData->access == access || (access == ulNone && (uData->access < actor->access))) { ! del_channel_user(channel->channel_info, uData, 1); count++; } --- 2685,2689 ---- if(uData->access == access || (access == ulNone && (uData->access < actor->access))) { ! del_channel_user(uData, 1); count++; } *************** *** 2852,2863 **** static int cmd_all(struct userNode *user, UNUSED_ARG(struct chanNode *channel), UNUSED_ARG(unsigned int argc), UNUSED_ARG(unsigned char *argv[]), struct svccmd *cmd, modcmd_func_t mcmd) { ! struct chanList *cList; ! for(cList = user->handle_info->channels; cList; cList = cList->next) { ! if(!cList->channel->channel ! || IsSuspended(cList->channel) ! || !GetUserMode(cList->channel->channel, user) ! || IsUserSuspended(cList->user)) { continue; --- 2809,2819 ---- static int cmd_all(struct userNode *user, UNUSED_ARG(struct chanNode *channel), UNUSED_ARG(unsigned int argc), UNUSED_ARG(unsigned char *argv[]), struct svccmd *cmd, modcmd_func_t mcmd) { ! struct userData *cList; ! for(cList = user->handle_info->channels; cList; cList = cList->u_next) { ! if(IsSuspended(cList->channel) ! || IsUserSuspended(cList) ! || !GetUserMode(cList->channel->channel, user)) { continue; *************** *** 3473,3477 **** if(!channel) { ! struct chanList *cList; const char *chanName; int hide = 0; --- 3429,3433 ---- if(!channel) { ! struct userData *uData; const char *chanName; int hide = 0; *************** *** 3500,3506 **** } chanserv_notice(user, CSMSG_INFOLINE_LIST, target_handle->handle); ! for (cList = target_handle->channels; cList; cList = cList->next) { ! struct chanData *cData = cList->channel; ! struct userData *uData = cList->user; if(uData->access == ulHelper) continue; --- 3456,3461 ---- } chanserv_notice(user, CSMSG_INFOLINE_LIST, target_handle->handle); ! for (uData = target_handle->channels; uData; uData = uData->u_next) { ! struct chanData *cData = uData->channel; if(uData->access == ulHelper) continue; *************** *** 3509,3513 **** continue; } ! chanName = cData->channel ? cData->channel->name : cData->suspended->name; if(uData->info) { --- 3464,3468 ---- continue; } ! chanName = cData->channel->name; if(uData->info) { *************** *** 4841,4845 **** suspended->revoked = 0; suspended->issued = now; - suspended->name = strdup(channel->name); suspended->suspender = strdup(user->handle_info->handle); suspended->expires = expiry; --- 4796,4799 ---- *************** *** 4866,4872 **** channel->channel_info->flags |= CHANNEL_SUSPENDED; DelChannelUser(chanserv, channel, suspended->reason, 0); ! chanserv_notice(user, CSMSG_SUSPENDED, suspended->name); ! sprintf(reason, "%s suspended by %s.", suspended->name, suspended->suspender); global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, reason); return 1; --- 4820,4826 ---- channel->channel_info->flags |= CHANNEL_SUSPENDED; DelChannelUser(chanserv, channel, suspended->reason, 0); ! chanserv_notice(user, CSMSG_SUSPENDED, channel->name); ! sprintf(reason, "%s suspended by %s.", channel->name, suspended->suspender); global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, reason); return 1; *************** *** 4993,4997 **** chanserv_channel_match(struct chanData *channel, search_t search) { ! const char *name = channel->channel ? channel->channel->name : channel->suspended->name; if((search->name && !match_ircglob(name, search->name)) || (search->registrar && !channel->registrar) || --- 4947,4951 ---- chanserv_channel_match(struct chanData *channel, search_t search) { ! const char *name = channel->channel->name; if((search->name && !match_ircglob(name, search->name)) || (search->registrar && !channel->registrar) || *************** *** 5031,5036 **** search_print(struct chanData *channel, void *data) { ! const char *name = IsSuspended(channel) ? channel->suspended->name : channel->channel->name; ! chanserv_notice(data, CSMSG_SEARCH_DATA, name); } --- 4985,4989 ---- search_print(struct chanData *channel, void *data) { ! chanserv_notice(data, CSMSG_SEARCH_DATA, channel->channel->name); } *************** *** 5879,5882 **** --- 5832,5862 ---- } + static MODCMD_FUNC(cmd_deleteme) + { + struct handle_info *hi; + struct userData *target; + const char *confirm_string; + + hi = user->handle_info; + if(!(target = GetTrueChannelAccess(channel->channel_info, hi))) + { + reply(CSMSG_NO_CHAN_USER, hi->handle, channel->name); + return 0; + } + if(target->access == ulOwner) + { + reply(CSMSG_NO_OWNER_DELETEME, channel->name); + return 0; + } + confirm_string = make_confirmation_string(target); + if((argc < 2) || strcmp(argv[1], confirm_string)) + { + reply(CSMSG_CONFIRM_DELETEME, confirm_string); + return 0; + } + del_channel_user(target, 1); + return 1; + } + static void chanserv_refresh_topics(void *data) *************** *** 6250,6254 **** handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) { ! struct chanList *channel; if(!user->handle_info) --- 6230,6234 ---- handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) { ! struct userData *channel; if(!user->handle_info) *************** *** 6257,6261 **** } ! for(channel = user->handle_info->channels; channel; channel = channel->next) { struct chanNode *cn; --- 6237,6241 ---- } ! for(channel = user->handle_info->channels; channel; channel = channel->u_next) { struct chanNode *cn; *************** *** 6264,6270 **** continue; } ! if(!GetUserMode(cn, user) && !IsUserSuspended(channel->user)) { ! if(IsUserAutoInvite(channel->user) && (cn->modes & (MODE_KEY | MODE_INVITEONLY)) && !self->burst) --- 6244,6250 ---- continue; } ! if(!GetUserMode(cn, user) && !IsUserSuspended(channel)) { ! if(IsUserAutoInvite(channel) && (cn->modes & (MODE_KEY | MODE_INVITEONLY)) && !self->burst) *************** *** 6275,6279 **** } ! if(channel->user->access >= ulMaster) { channel->channel->visited = now; --- 6255,6259 ---- } ! if(channel->access >= ulMaster) { channel->channel->visited = now; *************** *** 6284,6295 **** AddChannelOp(1, &user, cn, chanserv, 1); } ! else if((channel->user->access == ulPeon) ! && IsUserAutoOp(channel->user)) { AddChannelVoice(1, &user, cn, chanserv, 1); } ! channel->user->seen = now; ! channel->user->present = 1; } --- 6264,6275 ---- AddChannelOp(1, &user, cn, chanserv, 1); } ! else if((channel->access == ulPeon) ! && IsUserAutoOp(channel)) { AddChannelVoice(1, &user, cn, chanserv, 1); } ! channel->seen = now; ! channel->present = 1; } *************** *** 6454,6458 **** handle_unreg(UNUSED_ARG(struct userNode *user), struct handle_info *handle) { - struct chanList *channel, *next; struct userNode *h_user; --- 6434,6437 ---- *************** *** 6464,6473 **** } ! for(channel = handle->channels; channel; channel = next) { ! /* del_channel_user() deletes the chanList nodes, so we ! don't worry about them. */ ! next = channel->next; ! del_channel_user(channel->channel, channel->user, 1); } } --- 6443,6449 ---- } ! while(handle->channels) { ! del_channel_user(handle->channels, 1); } } *************** *** 6840,6850 **** return 0; } ! if(num_flags & CHANNEL_SUSPENDED) { ! suspended->name = strdup(key); ! if(suspended->expires > now) ! { ! timeq_add(suspended->expires, chanserv_expire_suspension, suspended); ! } } else --- 6816,6822 ---- return 0; } ! if((num_flags & CHANNEL_SUSPENDED) && (suspended->expires > now)) { ! timeq_add(suspended->expires, chanserv_expire_suspension, suspended); } else *************** *** 6901,6909 **** { log_module(CS_LOG, LOG_ERROR, "Channel %s had no users in database, unregistering it.", key); ! unregister_channel(cData); ! if(cNode) ! { ! DelChannelUser(chanserv, cNode, "Channel has empty user list.", 0); ! } return 0; } --- 6873,6877 ---- { log_module(CS_LOG, LOG_ERROR, "Channel %s had no users in database, unregistering it.", key); ! unregister_channel(cData, "Channel has empty user list."); return 0; } *************** *** 7046,7053 **** chanserv_write_channel(struct saxdb_context *ctx, struct chanData *channel) { ! char buf[MAXLEN], *channame; ! channame = IsSuspended(channel) ? channel->suspended->name : channel->channel->name; ! saxdb_start_record(ctx, channame, 1); saxdb_write_int(ctx, KEY_REGISTERED, channel->registered); --- 7014,7020 ---- chanserv_write_channel(struct saxdb_context *ctx, struct chanData *channel) { ! char buf[MAXLEN]; ! saxdb_start_record(ctx, channel->channel->name, 1); saxdb_write_int(ctx, KEY_REGISTERED, channel->registered); *************** *** 7172,7176 **** chanserv_db_cleanup(void) { unreg_part_func(handle_part); ! while(channelList) unregister_channel(channelList); dict_delete(handle_dnrs); dict_delete(plain_dnrs); --- 7139,7143 ---- chanserv_db_cleanup(void) { unreg_part_func(handle_part); ! while(channelList) unregister_channel(channelList, "Terminating."); dict_delete(handle_dnrs); dict_delete(plain_dnrs); *************** *** 7238,7241 **** --- 7205,7209 ---- DEFINE_COMMAND(suspend, 2, MODCMD_REQUIRE_CHANUSER, "access", "master", NULL); DEFINE_COMMAND(unsuspend, 2, MODCMD_REQUIRE_CHANUSER, "access", "master", NULL); + DEFINE_COMMAND(deleteme, 1, MODCMD_REQUIRE_CHANUSER, NULL); DEFINE_COMMAND(mdelowner, 2, MODCMD_REQUIRE_CHANUSER, "flags", "+helping", NULL); Index: chanserv.h =================================================================== RCS file: /cvsroot/srvx/services/src/chanserv.h,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -r1.48 -r1.49 *** chanserv.h 22 Jul 2003 16:33:44 -0000 1.48 --- chanserv.h 5 Aug 2003 01:31:16 -0000 1.49 *************** *** 131,134 **** --- 131,135 ---- { struct handle_info *handle; + struct chanData *channel; char *info; *************** *** 138,143 **** --- 139,148 ---- enum userLevel access; + /* linked list of userDatas for a chanData */ struct userData *prev; struct userData *next; + /* linked list of userDatas for a handle_info */ + struct userData *u_prev; + struct userData *u_next; }; *************** *** 158,174 **** }; - struct chanList - { - struct chanData *channel; - struct userData *user; - - struct chanList *next; - struct chanList *prev; - }; - struct suspended { struct chanData *cData; - char *name; char *suspender; char *reason; --- 163,169 ---- *************** *** 185,189 **** void init_chanserv(const char *nick); ! void del_channel_user(struct chanData *channel, struct userData *user, int do_gc); struct chanNode *chanserv_support_channel(void); enum userLevel user_level_from_name(const char *name); --- 180,184 ---- void init_chanserv(const char *nick); ! void del_channel_user(struct userData *user, int do_gc); struct chanNode *chanserv_support_channel(void); enum userLevel user_level_from_name(const char *name); Index: nickserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/nickserv.c,v retrieving revision 1.250 retrieving revision 1.251 diff -C2 -r1.250 -r1.251 *** nickserv.c 3 Aug 2003 05:33:13 -0000 1.250 --- nickserv.c 5 Aug 2003 01:31:16 -0000 1.251 *************** *** 1274,1294 **** if (hi->channels) { ! struct chanList *channel, *next; extern char accessChars[]; char *name; for (channel = hi->channels; channel; channel = next) { ! next = channel->next; ! if(IsSuspended(channel->channel)) { ! name = channel->channel->suspended->name; ! } else { ! name = channel->channel->channel->name; ! } herelen = strlen(name); if (pos + herelen + 3 > ArrayLength(buff)) { next = channel; goto print_chans_buff; } ! if (IsUserSuspended(channel->user)) buff[pos++] = '-'; ! buff[pos++] = accessChars[channel->user->access]; memcpy(buff+pos, name, herelen); pos += herelen; buff[pos++] = ' '; --- 1274,1290 ---- if (hi->channels) { ! struct userData *channel, *next; extern char accessChars[]; char *name; for (channel = hi->channels; channel; channel = next) { ! next = channel->u_next; ! name = channel->channel->channel->name; herelen = strlen(name); if (pos + herelen + 3 > ArrayLength(buff)) { next = channel; goto print_chans_buff; } ! if (IsUserSuspended(channel)) buff[pos++] = '-'; ! buff[pos++] = accessChars[channel->access]; memcpy(buff+pos, name, herelen); pos += herelen; buff[pos++] = ' '; *************** *** 2544,2548 **** struct handle_info *hi_from, *hi_to; struct userNode *last_user; ! struct chanList *cList, *cListNext; unsigned int ii, jj, n; char buffer[MAXLEN]; --- 2540,2544 ---- struct handle_info *hi_from, *hi_to; struct userNode *last_user; ! struct userData *cList, *cListNext; unsigned int ii, jj, n; char buffer[MAXLEN]; *************** *** 2597,2626 **** /* Merge channel userlists. */ for (cList=hi_from->channels; cList; cList=cListNext) { ! struct chanList *cList2; ! cListNext = cList->next; for (cList2=hi_to->channels; cList2; cList2=cList2->next) { if (cList->channel == cList2->channel) break; } ! if (cList2 && (cList2->user->access >= cList->user->access)) { /* keep cList2 in hi_to; remove cList from hi_from */ ! del_channel_user(cList->channel, cList->user, 1); } else { if (cList2) { /* hi_from handle has higher access; remove cList2 from hi_to */ ! del_channel_user(cList2->channel, cList2->user, 1); } /* cList needs to be moved from hi_from to hi_to */ ! cList->user->handle = hi_to; /* Remove from linked list for hi_from */ ! if (cList->prev) { ! cList->prev->next = cList->next; ! } else { ! hi_from->channels = cList->next; ! } ! if (cList->next) cList->next->prev = cList->prev; /* Add to linked list for hi_to */ ! cList->prev = NULL; ! if (hi_to->channels) hi_to->channels->prev = cList; ! cList->next = hi_to->channels; hi_to->channels = cList; } --- 2593,2619 ---- /* Merge channel userlists. */ for (cList=hi_from->channels; cList; cList=cListNext) { ! struct userData *cList2; ! cListNext = cList->u_next; for (cList2=hi_to->channels; cList2; cList2=cList2->next) { if (cList->channel == cList2->channel) break; } ! if (cList2 && (cList2->access >= cList->access)) { /* keep cList2 in hi_to; remove cList from hi_from */ ! del_channel_user(cList, 1); } else { if (cList2) { /* hi_from handle has higher access; remove cList2 from hi_to */ ! del_channel_user(cList2, 1); } /* cList needs to be moved from hi_from to hi_to */ ! cList->handle = hi_to; /* Remove from linked list for hi_from */ ! if (cList->u_prev) cList->u_prev->next = cList->u_next; ! else hi_from->channels = cList->u_next; ! if (cList->u_next) cList->u_next->u_prev = cList->u_prev; /* Add to linked list for hi_to */ ! cList->u_prev = NULL; ! if (hi_to->channels) hi_to->channels->u_prev = cList; ! cList->u_next = hi_to->channels; hi_to->channels = cList; } *************** *** 3376,3379 **** --- 3369,3373 ---- if (allowauth_func_list) free(allowauth_func_list); if (handle_merge_func_list) free(handle_merge_func_list); + if (failpw_func_list) free(failpw_func_list); if (nickserv_conf.valid_handle_regex_set) regfree(&nickserv_conf.valid_handle_regex); if (nickserv_conf.valid_nick_regex_set) regfree(&nickserv_conf.valid_nick_regex); Index: nickserv.h =================================================================== RCS file: /cvsroot/srvx/services/src/nickserv.h,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** nickserv.h 3 Aug 2003 03:46:18 -0000 1.44 --- nickserv.h 5 Aug 2003 01:31:16 -0000 1.45 *************** *** 79,83 **** struct string_list *masks; struct userNode *users; ! struct chanList *channels; struct handle_cookie *cookie; char *email_addr; --- 79,83 ---- struct string_list *masks; struct userNode *users; ! struct userData *channels; struct handle_cookie *cookie; char *email_addr; |