[srvx-commits] CVS: services/src chanserv.c,1.380,1.381
Brought to you by:
entrope
From: Entrope <en...@us...> - 2003-09-26 15:13:54
|
Update of /cvsroot/srvx/services/src In directory sc8-pr-cvs1:/tmp/cvs-serv32572/src Modified Files: chanserv.c Log Message: formatting changes to make profiling more accurate get rid of constant "arg" variable in cmd_note Index: chanserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/chanserv.c,v retrieving revision 1.380 retrieving revision 1.381 diff -C2 -r1.380 -r1.381 *** chanserv.c 9 Sep 2003 16:40:28 -0000 1.380 --- chanserv.c 26 Sep 2003 15:13:47 -0000 1.381 *************** *** 594,598 **** struct userData *uData, **head; ! if(!channel || !handle) return NULL; if(override && HANDLE_FLAGGED(handle, HELPING) --- 594,599 ---- struct userData *uData, **head; ! if(!channel || !handle) ! return NULL; if(override && HANDLE_FLAGGED(handle, HELPING) *************** *** 616,622 **** uData->next = helperList; if(helperList) - { helperList->prev = uData; - } helperList = uData; } --- 617,621 ---- *************** *** 627,633 **** { for(uData = channel->users; uData; uData = uData->next) ! { ! if((uData->handle == handle) && (allow_suspended || !IsUserSuspended(uData))) break; ! } head = &(channel->users); --- 626,631 ---- { for(uData = channel->users; uData; uData = uData->next) ! if((uData->handle == handle) && (allow_suspended || !IsUserSuspended(uData))) ! break; head = &(channel->users); *************** *** 637,642 **** { /* Shuffle the user to the head of whatever list he was in. */ ! if(uData->next) uData->next->prev = uData->prev; ! if(uData->prev) uData->prev->next = uData->next; uData->prev = NULL; --- 635,642 ---- { /* Shuffle the user to the head of whatever list he was in. */ ! if(uData->next) ! uData->next->prev = uData->prev; ! if(uData->prev) ! uData->prev->next = uData->next; uData->prev = NULL; *************** *** 644,650 **** if(*head) - { (**head).prev = uData; - } *head = uData; } --- 644,648 ---- *************** *** 684,688 **** struct userData *uData; ! if(!channel->channel_info || IsSuspended(channel->channel_info)) return; uData = GetTrueChannelAccess(channel->channel_info, handle); --- 682,687 ---- struct userData *uData; ! if(!channel->channel_info || IsSuspended(channel->channel_info)) ! return; uData = GetTrueChannelAccess(channel->channel_info, handle); *************** *** 713,720 **** /* Bail early if channel is inactive or doesn't restrict CTCPs, or sender is a service */ ! if(!channel->channel_info || IsSuspended(channel->channel_info)) return; ! if(channel->channel_info->options[optCTCPUsers] == 'a') return; ! if(IsService(user)) return; ! if(!ircncasecmp(text, "ACTION ", 7)) return; /* Figure out the minimum level needed to CTCP the channel */ switch(channel->channel_info->options[optCTCPUsers]) { --- 712,721 ---- /* Bail early if channel is inactive or doesn't restrict CTCPs, or sender is a service */ ! if(!channel->channel_info ! || IsSuspended(channel->channel_info) ! || (channel->channel_info->options[optCTCPUsers] == 'a') ! || IsService(user) ! || !ircncasecmp(text, "ACTION ", 7)) ! return; /* Figure out the minimum level needed to CTCP the channel */ switch(channel->channel_info->options[optCTCPUsers]) { *************** *** 728,732 **** /* Exit if they're allowed to CTCP the channel. */ uData = GetChannelUser(channel->channel_info, user->handle_info); ! if(uData && (uData->access >= minlvl)) return; /* We need to enforce against them; do so. */ eflags = 0; --- 729,734 ---- /* Exit if they're allowed to CTCP the channel. */ uData = GetChannelUser(channel->channel_info, user->handle_info); ! if(uData && (uData->access >= minlvl)) ! return; /* We need to enforce against them; do so. */ eflags = 0; *************** *** 734,738 **** argv[1] = user->nick; argc = 2; ! if(GetUserMode(channel, user)) eflags |= ACTION_KICK; switch(channel->channel_info->options[optCTCPReaction]) { default: case 'k': /* just do the kick */ break; --- 736,741 ---- argv[1] = user->nick; argc = 2; ! if(GetUserMode(channel, user)) ! eflags |= ACTION_KICK; switch(channel->channel_info->options[optCTCPReaction]) { default: case 'k': /* just do the kick */ break; *************** *** 768,774 **** struct note_type *ntype = data; ! if(--ntype->refs > 0) { return; - } free(ntype); } --- 771,776 ---- struct note_type *ntype = data; ! if(--ntype->refs > 0) return; free(ntype); } *************** *** 778,784 **** { struct chanData *cData; ! for (cData = channelList; cData; cData = cData->next) { dict_remove(cData->notes, ntype->name); - } } --- 780,785 ---- { struct chanData *cData; ! for (cData = channelList; cData; cData = cData->next) dict_remove(cData->notes, ntype->name); } *************** *** 792,798 **** for (cData = channelList; cData; cData = cData->next) { note = dict_find(cData->notes, ntype->name, NULL); ! if (!note) { continue; - } if (strlen(note->note) > ntype->max_length) { dict_remove2(cData->notes, ntype->name, 1); --- 793,798 ---- for (cData = channelList; cData; cData = cData->next) { note = dict_find(cData->notes, ntype->name, NULL); ! if (!note) continue; if (strlen(note->note) > ntype->max_length) { dict_remove2(cData->notes, ntype->name, 1); *************** *** 1317,1321 **** struct banData *bd; ! if(!mask) return NULL; bd = malloc(sizeof(struct banData)); --- 1317,1322 ---- struct banData *bd; ! if(!mask) ! return NULL; bd = malloc(sizeof(struct banData)); *************** *** 1327,1331 **** safestrncpy(bd->mask, mask, sizeof(bd->mask)); ! if(owner) safestrncpy(bd->owner, owner, sizeof(bd->owner)); bd->reason = reason ? strdup(reason) : NULL; --- 1328,1333 ---- safestrncpy(bd->mask, mask, sizeof(bd->mask)); ! if(owner) ! safestrncpy(bd->owner, owner, sizeof(bd->owner)); bd->reason = reason ? strdup(reason) : NULL; *************** *** 1516,1528 **** /* See if the channel can be expired. */ ! if((now - channel->visited) <= chanserv_conf.channel_expire_delay) continue; ! if(IsProtected(channel)) continue; /* Make sure there are no high-ranking users still in the channel. */ for(user=channel->users; user; user=user->next) ! { ! if(user->present && (user->access >= ulMaster)) break; ! } ! if(user) continue; /* Unregister the channel */ --- 1518,1531 ---- /* See if the channel can be expired. */ ! if(((now - channel->visited) <= chanserv_conf.channel_expire_delay) ! || IsProtected(channel)) ! continue; /* Make sure there are no high-ranking users still in the channel. */ for(user=channel->users; user; user=user->next) ! if(user->present && (user->access >= ulMaster)) ! break; ! if(user) ! continue; /* Unregister the channel */ *************** *** 1576,1584 **** { case 'l': ! if(cs_victim->access > cs_aggressor->access) return 1; break; case 'a': case 'e': ! if(cs_victim->access >= cs_aggressor->access) return 1; break; } --- 1579,1589 ---- { case 'l': ! if(cs_victim->access > cs_aggressor->access) ! return 1; break; case 'a': case 'e': ! if(cs_victim->access >= cs_aggressor->access) ! return 1; break; } *************** *** 1593,1598 **** if((cs_victim = GetChannelUser(channel->channel_info, victim->handle_info)) ! && (cs_victim->access >= ulOp)) return 1; ! if(!check_user_level(user, channel, channel->channel_info->options[optStrictOp], 1, 0)) { chanserv_notice(user, CSMSG_OPBY_LOCKED); --- 1598,1603 ---- if((cs_victim = GetChannelUser(channel->channel_info, victim->handle_info)) ! && (cs_victim->access >= ulOp) ! && !check_user_level(user, channel, channel->channel_info->options[optStrictOp], 1, 0)) { chanserv_notice(user, CSMSG_OPBY_LOCKED); *************** *** 1608,1612 **** struct userData *uData; ! if(!check_user_level(user, channel, channel->channel_info->options[optAutoOp], 0, 0)) return 0; uData = GetChannelAccess(channel->channel_info, user->handle_info); /* uData may be NULL if optAutoOp is "all" */ --- 1613,1618 ---- struct userData *uData; ! if(!check_user_level(user, channel, channel->channel_info->options[optAutoOp], 0, 0)) ! return 0; uData = GetChannelAccess(channel->channel_info, user->handle_info); /* uData may be NULL if optAutoOp is "all" */ *************** *** 1664,1675 **** if(handle) { ! if((dnr = dict_find(handle_dnrs, handle->handle, NULL))) return dnr; } if(chan_name) { ! if((dnr = dict_find(plain_dnrs, chan_name, NULL))) return dnr; for(it = dict_first(mask_dnrs); it; it = iter_next(it)) { ! if(match_ircglob(chan_name, iter_key(it))) return iter_data(it); } } --- 1670,1684 ---- if(handle) { ! if((dnr = dict_find(handle_dnrs, handle->handle, NULL))) ! return dnr; } if(chan_name) { ! if((dnr = dict_find(plain_dnrs, chan_name, NULL))) ! return dnr; for(it = dict_first(mask_dnrs); it; it = iter_next(it)) { ! if(match_ircglob(chan_name, iter_key(it))) ! return iter_data(it); } } *************** *** 1800,1804 **** for(owned=0, cList=hi->channels; cList; cList=cList->u_next) { ! if(cList->access == ulOwner) owned++; } return owned; --- 1809,1814 ---- for(owned=0, cList=hi->channels; cList; cList=cList->u_next) { ! if(cList->access == ulOwner) ! owned++; } return owned; *************** *** 2674,2678 **** } ! if(!strcmp(argv[1], "bans")) { cmd_trim_bans(user, channel, duration); --- 2684,2688 ---- } ! if(!irccasecmp(argv[1], "bans")) { cmd_trim_bans(user, channel, duration); *************** *** 2680,2684 **** } ! if(!strcmp(argv[1], "users")) { cmd_trim_users(user, channel, ulNone, duration); --- 2690,2694 ---- } ! if(!irccasecmp(argv[1], "users")) { cmd_trim_users(user, channel, ulNone, duration); *************** *** 4518,4523 **** { case NOTE_SET_CHANNEL_ACCESS: ! if(!user->handle_info) return 0; ! if(!(uData = GetChannelUser(channel->channel_info, user->handle_info))) return 0; return uData->access >= ntype->set_access.min_ulevel; case NOTE_SET_CHANNEL_SETTER: --- 4528,4535 ---- { case NOTE_SET_CHANNEL_ACCESS: ! if(!user->handle_info) ! return 0; ! if(!(uData = GetChannelUser(channel->channel_info, user->handle_info))) ! return 0; return uData->access >= ntype->set_access.min_ulevel; case NOTE_SET_CHANNEL_SETTER: *************** *** 4532,4536 **** struct note *note; struct note_type *ntype; - unsigned int arg = 1; cData = channel->channel_info; --- 4544,4547 ---- *************** *** 4542,4546 **** /* If no arguments, show all visible notes for the channel. */ ! if(argc <= arg) { dict_iterator_t it; --- 4553,4557 ---- /* If no arguments, show all visible notes for the channel. */ ! if(argc < 2) { dict_iterator_t it; *************** *** 4550,4569 **** { note = iter_data(it); ! if(!note_type_visible_to_user(cData, note->type, user)) continue; ! if(!count++) chanserv_notice(user, CSMSG_NOTELIST_HEADER, channel->name); chanserv_notice(user, CSMSG_NOTE_FORMAT, iter_key(it), note->setter, note->note); } ! if(count) chanserv_notice(user, CSMSG_NOTELIST_END, channel->name); ! else chanserv_notice(user, CSMSG_NOTELIST_EMPTY, channel->name); } /* If one argument, show the named note. */ ! else if(argc == arg+1) { ! if((note = dict_find(cData->notes, argv[arg], NULL)) && note_type_visible_to_user(cData, note->type, user)) { chanserv_notice(user, CSMSG_NOTE_FORMAT, note->type->name, note->setter, note->note); } ! else if((ntype = dict_find(note_types, argv[arg], NULL)) && note_type_visible_to_user(NULL, ntype, user)) { --- 4561,4584 ---- { note = iter_data(it); ! if(!note_type_visible_to_user(cData, note->type, user)) ! continue; ! if(!count++) ! chanserv_notice(user, CSMSG_NOTELIST_HEADER, channel->name); chanserv_notice(user, CSMSG_NOTE_FORMAT, iter_key(it), note->setter, note->note); } ! if(count) ! chanserv_notice(user, CSMSG_NOTELIST_END, channel->name); ! else ! chanserv_notice(user, CSMSG_NOTELIST_EMPTY, channel->name); } /* If one argument, show the named note. */ ! else if(argc == 2) { ! if((note = dict_find(cData->notes, argv[1], NULL)) && note_type_visible_to_user(cData, note->type, user)) { chanserv_notice(user, CSMSG_NOTE_FORMAT, note->type->name, note->setter, note->note); } ! else if((ntype = dict_find(note_types, argv[1], NULL)) && note_type_visible_to_user(NULL, ntype, user)) { *************** *** 4573,4577 **** else { ! chanserv_notice(user, CSMSG_BAD_NOTE_TYPE, argv[arg]); return 0; } --- 4588,4592 ---- else { ! chanserv_notice(user, CSMSG_BAD_NOTE_TYPE, argv[1]); return 0; } *************** *** 4581,4593 **** { char *note_text; ! ntype = dict_find(note_types, argv[arg], NULL); if(!ntype) { ! chanserv_notice(user, CSMSG_BAD_NOTE_TYPE, argv[arg]); return 0; } else if(note_type_settable_by_user(channel, ntype, user)) { ! note_text = unsplit_string(argv+arg+1, argc-arg-1, NULL); chanserv_add_channel_note(cData, ntype, user->handle_info->handle, note_text); chanserv_notice(user, CSMSG_NOTE_SET, ntype->name, channel->name); --- 4596,4608 ---- { char *note_text; ! ntype = dict_find(note_types, argv[1], NULL); if(!ntype) { ! chanserv_notice(user, CSMSG_BAD_NOTE_TYPE, argv[1]); return 0; } else if(note_type_settable_by_user(channel, ntype, user)) { ! note_text = unsplit_string(argv+2, argc-2, NULL); chanserv_add_channel_note(cData, ntype, user->handle_info->handle, note_text); chanserv_notice(user, CSMSG_NOTE_SET, ntype->name, channel->name); |