⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m_mode.c

📁 Unreal irc 服务器源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	/* Should stop null modes */	if (*(modebuf + 1) == '\0')		return;	if (IsPerson(sptr) && samode && MyClient(sptr))	{		sendto_serv_butone_token(NULL, me.name, MSG_GLOBOPS,		    TOK_GLOBOPS, ":%s used SAMODE %s (%s%s%s)", sptr->name,		    chptr->chname, modebuf, *parabuf ? " " : "", parabuf);		sendto_failops_whoare_opers		    ("from %s: %s used SAMODE %s (%s%s%s)", me.name, sptr->name,		    chptr->chname, modebuf, *parabuf ? " " : "", parabuf);		sptr = &me;		sendts = 0;	}		sendto_channel_butserv(chptr, sptr, ":%s MODE %s %s %s",	    sptr->name, chptr->chname, modebuf, parabuf);	if (IsServer(sptr) && sendts != -1)		sendto_serv_butone_token(cptr, sptr->name, MSG_MODE, TOK_MODE,		    "%s %s%s %s %lu", chptr->chname, isbounce ? "&" : "",		    modebuf, parabuf, sendts);	else if (samode && IsMe(sptr)) /* SAMODE is a special case: always send a TS of 0 (omitting TS==desynch) */		sendto_serv_butone_token(cptr, sptr->name, MSG_MODE, TOK_MODE,		    "%s %s %s 0", chptr->chname, modebuf, parabuf);	else		sendto_serv_butone_token(cptr, sptr->name, MSG_MODE, TOK_MODE,		    "%s %s%s %s", chptr->chname, isbounce ? "&" : "",		    modebuf, parabuf);	/* tell them it's not a timestamp, in case the last param	   ** is a number. */	if (MyConnect(sptr))		RunHook7(HOOKTYPE_LOCAL_CHANMODE, cptr, sptr, chptr, modebuf, parabuf, sendts, samode);	else		RunHook7(HOOKTYPE_REMOTE_CHANMODE, cptr, sptr, chptr, modebuf, parabuf, sendts, samode);}/* make_mode_str -- written by binary *	Reconstructs the mode string, to make it look clean.  mode_buf will *  contain the +x-y stuff, and the parabuf will contain the parameters. *  If bounce is set to 1, it will make the string it needs for a bounce. */#ifdef EXTCMODEvoid make_mode_str(aChannel *chptr, long oldm, Cmode_t oldem, long oldl, int pcount, 	char pvar[MAXMODEPARAMS][MODEBUFLEN + 3], char *mode_buf, char *para_buf, char bounce)#elsevoid make_mode_str(aChannel *chptr, long oldm, long oldl, int pcount, 	char pvar[MAXMODEPARAMS][MODEBUFLEN + 3], char *mode_buf, char *para_buf, char bounce)#endif{	char tmpbuf[MODEBUFLEN+3], *tmpstr;	aCtab *tab = &cFlagTab[0];	char *x = mode_buf;	int  what, cnt, z;#ifdef EXTCMODE	int i;#endif	char *m;	what = 0;	*tmpbuf = '\0';	*mode_buf = '\0';	*para_buf = '\0';	what = 0;	/* + param-less modes */	tab = &cFlagTab[0];	while (tab->mode != 0x0)	{		if (chptr->mode.mode & tab->mode)		{			if (!(oldm & tab->mode))			{				if (what != MODE_ADD)				{					*x++ = bounce ? '-' : '+';					what = MODE_ADD;				}				*x++ = tab->flag;			}		}		tab++;	}#ifdef EXTCMODE	/* + paramless extmodes... */	for (i=0; i <= Channelmode_highest; i++)	{		if (!Channelmode_Table[i].flag || Channelmode_Table[i].paracount)			continue;		/* have it now and didn't have it before? */		if ((chptr->mode.extmode & Channelmode_Table[i].mode) &&		    !(oldem & Channelmode_Table[i].mode))		{			if (what != MODE_ADD)			{				*x++ = bounce ? '-' : '+';				what = MODE_ADD;			}			*x++ = Channelmode_Table[i].flag;		}	}#endif	*x = '\0';	/* - param-less modes */	tab = &cFlagTab[0];	while (tab->mode != 0x0)	{		if (!(chptr->mode.mode & tab->mode))		{			if (oldm & tab->mode)			{				if (what != MODE_DEL)				{					*x++ = bounce ? '+' : '-';					what = MODE_DEL;				}				*x++ = tab->flag;			}		}		tab++;	}#ifdef EXTCMODE	/* - extmodes (both "param modes" and paramless don't have	 * any params when unsetting...	 */	for (i=0; i <= Channelmode_highest; i++)	{		if (!Channelmode_Table[i].flag /* || Channelmode_Table[i].paracount */)			continue;		/* don't have it now and did have it before */		if (!(chptr->mode.extmode & Channelmode_Table[i].mode) &&		    (oldem & Channelmode_Table[i].mode))		{			if (what != MODE_DEL)			{				*x++ = bounce ? '+' : '-';				what = MODE_DEL;			}			*x++ = Channelmode_Table[i].flag;		}	}#endif	*x = '\0';	/* user limit */	if (chptr->mode.limit != oldl)	{		if ((!bounce && chptr->mode.limit == 0) ||		    (bounce && chptr->mode.limit != 0))		{			if (what != MODE_DEL)			{				*x++ = '-';				what = MODE_DEL;			}			if (bounce)				chptr->mode.limit = 0;	/* set it back */			*x++ = 'l';		}		else		{			if (what != MODE_ADD)			{				*x++ = '+';				what = MODE_ADD;			}			*x++ = 'l';			if (bounce)				chptr->mode.limit = oldl;	/* set it back */			ircsprintf(para_buf, "%s%d ", para_buf, chptr->mode.limit);		}	}	/* reconstruct bkov chain */	for (cnt = 0; cnt < pcount; cnt++)	{		if ((*(pvar[cnt]) == '+') && what != MODE_ADD)		{			*x++ = bounce ? '-' : '+';			what = MODE_ADD;		}		if ((*(pvar[cnt]) == '-') && what != MODE_DEL)		{			*x++ = bounce ? '+' : '-';			what = MODE_DEL;		}		*x++ = *(pvar[cnt] + 1);		tmpstr = &pvar[cnt][2];		z = (MODEBUFLEN * MAXMODEPARAMS);		m = para_buf;		while ((*m)) { m++; }		while ((*tmpstr) && ((m-para_buf) < z))		{			*m = *tmpstr; 			m++;			tmpstr++;		}		*m++ = ' ';		*m = '\0';	}	if (bounce)	{		chptr->mode.mode = oldm;#ifdef EXTCMODE		chptr->mode.extmode = oldem;#endif	}	z = strlen(para_buf);	if (para_buf[z - 1] == ' ')		para_buf[z - 1] = '\0';	*x = '\0';	if (*mode_buf == '\0')	{		*mode_buf = '+';		mode_buf++;		*mode_buf = '\0';		/* Don't send empty lines. */	}	return;}/* do_mode_char *  processes one mode character *  returns 1 if it ate up a param, otherwise 0 *	written by binary *  modified for Unreal by stskeeps.. */#define REQUIRE_PARAMETER() { if (!param || *pcount >= MAXMODEPARAMS) { retval = 0; break; } retval = 1; }#ifdef PREFIX_AQ#define is_xchanop(x) ((x & (CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER)))#else#define is_xchanop(x) ((x & CHFL_CHANOP))#endifint  do_mode_char(aChannel *chptr, long modetype, char modechar, char *param, 	u_int what, aClient *cptr,	 u_int *pcount, char pvar[MAXMODEPARAMS][MODEBUFLEN + 3], char bounce, long my_access){	aCtab *tab = &cFlagTab[0];	int  retval = 0;	Member *member = NULL;	Membership *membership = NULL;	aClient *who;	unsigned int tmp = 0;	char tmpbuf[512], *tmpstr;	char tc = ' ';		/* */	int  chasing, x;	int xxi, xyi, xzi, hascolon;	char *xp;	int  notsecure;	chasing = 0;	if ((my_access & CHFL_HALFOP) && !is_xchanop(my_access) && !IsULine(cptr)	    && !op_can_override(cptr) && !samode_in_progress)	{		if (MyClient(cptr) && (modetype == MODE_HALFOP) && (what == MODE_DEL) &&		    param && (find_client(param, NULL) == cptr))		{			/* halfop -h'ing him/herself */			/* ALLOW */		} else		{			/* Ugly halfop hack --sts 			   - this allows halfops to do +b +e +v and so on */			/* (Syzop/20040413: Allow remote halfop modes */			if ((Halfop_mode(modetype) == FALSE) && MyClient(cptr))			{				int eaten = 0;				while (tab->mode != 0x0)				{					if (tab->mode == modetype)					{						sendto_one(cptr,						    err_str(ERR_NOTFORHALFOPS), me.name,						    cptr->name, tab->flag);						eaten = tab->parameters;						break;					}					tab++;				}				return eaten;			}		} /* not -h self */	}	switch (modetype)	{	  case MODE_AUDITORIUM:		  if (IsULine(cptr) || IsServer(cptr) || samode_in_progress)			  goto auditorium_ok;		  if (MyClient(cptr) && !is_chanowner(cptr, chptr) && !op_can_override(cptr))		  {			sendto_one(cptr, err_str(ERR_CHANOWNPRIVNEEDED), me.name, cptr->name,				   chptr->chname);			break;		  }		auditorium_ok:		  goto setthephuckingmode;	  case MODE_OPERONLY:		  if (MyClient(cptr) && !IsAnOper(cptr))		  {			sendto_one(cptr, err_str(ERR_NOPRIVILEGES), me.name, cptr->name);			break;		  }		  goto setthephuckingmode;	  case MODE_ADMONLY:		  if (!IsSkoAdmin(cptr) && !IsServer(cptr)		      && !IsULine(cptr))		  {			sendto_one(cptr, err_str(ERR_NOPRIVILEGES), me.name, cptr->name);			break;		  }		  goto setthephuckingmode;	  case MODE_RGSTR:		  if (!IsServer(cptr) && !IsULine(cptr))		  {			sendto_one(cptr, err_str(ERR_ONLYSERVERSCANCHANGE), me.name, cptr->name,				   chptr->chname);			break;		  }		  goto setthephuckingmode;	  case MODE_SECRET:	  case MODE_PRIVATE:	  case MODE_MODERATED:	  case MODE_TOPICLIMIT:	  case MODE_NOPRIVMSGS:	  case MODE_RGSTRONLY:	  case MODE_MODREG:	  case MODE_NOCOLOR:	  case MODE_NOKICKS:	  case MODE_STRIP:	  	goto setthephuckingmode;	  case MODE_INVITEONLY:		if (what == MODE_DEL && modetype == MODE_INVITEONLY && (chptr->mode.mode & MODE_NOKNOCK))			chptr->mode.mode &= ~MODE_NOKNOCK;		goto setthephuckingmode;	  case MODE_NOKNOCK:		if (what == MODE_ADD && modetype == MODE_NOKNOCK && !(chptr->mode.mode & MODE_INVITEONLY))		{			sendto_one(cptr, err_str(ERR_CANNOTCHANGECHANMODE), 				me.name, cptr->name, 'K', "+i must be set");			break;		}		goto setthephuckingmode;	  case MODE_ONLYSECURE:	  	notsecure = 0;	  	if (what == MODE_ADD && modetype == MODE_ONLYSECURE && !(IsServer(cptr) || IsULine(cptr)))		{		  for (member = chptr->members; member; member = member->next)		  {		    if (!IsSecureConnect(member->cptr) && !IsULine(member->cptr))		    {			sendto_one(cptr, err_str(ERR_CANNOTCHANGECHANMODE), 				   me.name, cptr->name, 'z', 				   "all members must be connected via SSL");			notsecure = 1;			break;		    }		  }		  member = NULL;		  /* first break nailed the for loop, this one nails switch() */		  if (notsecure == 1) break;		}		goto setthephuckingmode;	  case MODE_NOCTCP:	  case MODE_NONICKCHANGE:	  case MODE_NOINVITE:		setthephuckingmode:		  retval = 0;		  if (what == MODE_ADD) {			  /* +sp bugfix.. (by JK/Luke)*/		 	 if (modetype == MODE_SECRET			      && (chptr->mode.mode & MODE_PRIVATE))				  chptr->mode.mode &= ~MODE_PRIVATE;			  if (modetype == MODE_PRIVATE			      && (chptr->mode.mode & MODE_SECRET))				  chptr->mode.mode &= ~MODE_SECRET;			  if (modetype == MODE_NOCOLOR			      && (chptr->mode.mode & MODE_STRIP))				  chptr->mode.mode &= ~MODE_STRIP;			  if (modetype == MODE_STRIP			      && (chptr->mode.mode & MODE_NOCOLOR))				  chptr->mode.mode &= ~MODE_NOCOLOR;			  chptr->mode.mode |= modetype;		  }		  else		  {			  chptr->mode.mode &= ~modetype;#ifdef NEWCHFLOODPROT			  /* reset joinflood on -i, reset msgflood on -m, etc.. */			  if (chptr->mode.floodprot)			  {				switch(modetype)				{				case MODE_NOCTCP:					chptr->mode.floodprot->c[FLD_CTCP] = 0;					chanfloodtimer_del(chptr, 'C', MODE_NOCTCP);					break;				case MODE_NONICKCHANGE:					chptr->mode.floodprot->c[FLD_NICK] = 0;					chanfloodtimer_del(chptr, 'N', MODE_NONICKCHANGE);					break;				case MODE_MODERATED:					chptr->mode.floodprot->c[FLD_MSG] = 0;					chptr->mode.floodprot->c[FLD_CTCP] = 0;					chanfloodtimer_del(chptr, 'm', MODE_MODERATED);					break;				case MODE_NOKNOCK:					chptr->mode.floodprot->c[FLD_KNOCK] = 0;					chanfloodtimer_del(chptr, 'K', MODE_NOKNOCK);					break;				case MODE_INVITEONLY:					chptr->mode.floodprot->c[FLD_JOIN] = 0;					chanfloodtimer_del(chptr, 'i', MODE_INVITEONLY);					break;				case MODE_MODREG:					chptr->mode.floodprot->c[FLD_MSG] = 0;					chptr->mode.floodprot->c[FLD_CTCP] = 0;					chanfloodtimer_del(chptr, 'M', MODE_MODREG);					break;				case MODE_RGSTRONLY:					chptr->mode.floodprot->c[FLD_JOIN] = 0;					chanfloodtimer_del(chptr, 'R', MODE_RGSTRONLY);					break;				default:					break;				}			  }#endif		  }		  break;/* do pro-opping here (popping) */	  case MODE_CHANOWNER:		  REQUIRE_PARAMETER()		  if (!IsULine(cptr) && !IsServer(cptr) && !is_chanowner(cptr, chptr) && !samode_in_progress)		  {		  	  if (MyClient(cptr) && !op_can_override(cptr))		  	  {		  	  	sendto_one(cptr, err_str(ERR_CHANOWNPRIVNEEDED), me.name, cptr->name, chptr->chname);		  	  	break;		  	  }			  if (IsOper(cptr))			  {				if (!is_halfop(cptr, chptr)) /* htrig will take care of halfop override notices */				   opermode = 1;			  }		  }	  case MODE_CHANPROT:		  REQUIRE_PARAMETER()		  /* not uline, not server, not chanowner, not an samode, not -a'ing yourself... */		  if (!IsULine(cptr) && !IsServer(cptr) && !is_chanowner(cptr, chptr) && !samode_in_progress &&		      !(param && (what == MODE_DEL) && (find_client(param, NULL) == cptr)))		  {		  	  if (MyClient(cptr) && !op_can_override(cptr))		  	  {		  	  	sendto_one(cptr, err_str(ERR_CHANOWNPRIVNEEDED), me.name, cptr->name, chptr->chname);		  	  	break;		  	  }			  if (IsOper(cptr))			  {				if (!is_halfop(cptr, chptr)) /* htrig will take care of halfop override notices */				   opermode = 1;			  }		  }		 	  case MODE_HALFOP:	  case MODE_CHANOP:	  case MODE_VOICE:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -