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

📄 m_message.c

📁 Unreal irc 服务器源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
			sendnotice(from, "User %s is currently not accepting DCC SENDs with such a filename/filetype from you. "				"Your file %s was not sent.", to->name, displayfile);			sendnotice(to, "%s (%s@%s) tried to DCC SEND you a file named '%s', the request has been blocked.",				from->name, from->user->username, GetHost(from), displayfile);			if (!IsDCCNotice(to))			{				SetDCCNotice(to);				sendnotice(to, "Files like these might contain malicious content (viruses, trojans). "					"Therefore, you must explicitly allow anyone that tries to send you such files.");				sendnotice(to, "If you trust %s, and want him/her to send you this file, you may obtain "					"more information on using the dccallow system by typing '/DCCALLOW HELP'", from->name);			}				/* if (SHOW_ALLDENIEDDCCS) */			if (0)			{				sendto_umode(UMODE_VICTIM,					"[DCCALLOW] %s tried to send forbidden file %s (%s) to %s",					from->name, displayfile, fl->reason, to->name);			}			return 0;		}	}	return 1; /* allowed */}/* This was modified a bit in order to use newconf. The loading functions * have been trashed and integrated into the config parser. The striping * function now only uses REPLACEWORD if no word is specifically defined * for the word found. Also the freeing function has been ditched. -- codemastr */#ifdef FAST_BADWORD_REPLACE/* * our own strcasestr implementation because strcasestr is often not * available or is not working correctly (??). */char *our_strcasestr(char *haystack, char *needle) {int i;int nlength = strlen (needle);int hlength = strlen (haystack);	if (nlength > hlength) return NULL;	if (hlength <= 0) return NULL;	if (nlength <= 0) return haystack;	for (i = 0; i <= (hlength - nlength); i++) {		if (strncasecmp (haystack + i, needle, nlength) == 0)			return haystack + i;	}  return NULL; /* not found */}inline int fast_badword_match(ConfigItem_badword *badword, char *line){ 	char *p;	int bwlen = strlen(badword->word);	if ((badword->type & BADW_TYPE_FAST_L) && (badword->type & BADW_TYPE_FAST_R))		return (our_strcasestr(line, badword->word) ? 1 : 0);	p = line;	while((p = our_strcasestr(p, badword->word)))	{		if (!(badword->type & BADW_TYPE_FAST_L))		{			if ((p != line) && !iswseperator(*(p - 1))) /* aaBLA but no *BLA */				goto next;		}		if (!(badword->type & BADW_TYPE_FAST_R))		{			if (!iswseperator(*(p + bwlen)))  /* BLAaa but no BLA* */				goto next;		}		/* Looks like it matched */		return 1;next:		p += bwlen;	}	return 0;}/* fast_badword_replace: * a fast replace routine written by Syzop used for replacing badwords. * searches in line for huntw and replaces it with replacew, * buf is used for the result and max is sizeof(buf). * (Internal assumptions: max > 0 AND max > strlen(line)+1) */inline int fast_badword_replace(ConfigItem_badword *badword, char *line, char *buf, int max){/* Some aliases ;P */char *replacew = badword->replace ? badword->replace : REPLACEWORD;char *pold = line, *pnew = buf; /* Pointers to old string and new string */char *poldx = line;int replacen = -1; /* Only calculated if needed. w00t! saves us a few nanosecs? lol */int searchn = -1;char *startw, *endw;char *c_eol = buf + max - 1; /* Cached end of (new) line */int run = 1;int cleaned = 0;	Debug((DEBUG_NOTICE, "replacing %s -> %s in '%s'", badword->word, replacew, line));	while(run) {		pold = our_strcasestr(pold, badword->word);		if (!pold)			break;		if (replacen == -1)			replacen = strlen(replacew);		if (searchn == -1)			searchn = strlen(badword->word);		/* Hunt for start of word */ 		if (pold > line) {			for (startw = pold; (!iswseperator(*startw) && (startw != line)); startw--);			if (iswseperator(*startw))				startw++; /* Don't point at the space/seperator but at the word! */		} else {			startw = pold;		}		if (!(badword->type & BADW_TYPE_FAST_L) && (pold != startw)) {			/* not matched */			pold++;			continue;		}		/* Hunt for end of word */		for (endw = pold; ((*endw != '\0') && (!iswseperator(*endw))); endw++);		if (!(badword->type & BADW_TYPE_FAST_R) && (pold+searchn != endw)) {			/* not matched */			pold++;			continue;		}		cleaned = 1; /* still too soon? Syzop/20050227 */		/* Do we have any not-copied-yet data? */		if (poldx != startw) {			int tmp_n = startw - poldx;			if (pnew + tmp_n >= c_eol) {				/* Partial copy and return... */				memcpy(pnew, poldx, c_eol - pnew);				*c_eol = '\0';				return 1;			}			memcpy(pnew, poldx, tmp_n);			pnew += tmp_n;		}		/* Now update the word in buf (pnew is now something like startw-in-new-buffer */		if (replacen) {			if ((pnew + replacen) >= c_eol) {				/* Partial copy and return... */				memcpy(pnew, replacew, c_eol - pnew);				*c_eol = '\0';				return 1;			}			memcpy(pnew, replacew, replacen);			pnew += replacen;		}		poldx = pold = endw;	}	/* Copy the last part */	if (*poldx) {		strncpy(pnew, poldx, c_eol - pnew);		*(c_eol) = '\0';	} else {		*pnew = '\0';	}	return cleaned;}#endif/* * Returns a string, which has been filtered by the words loaded via * the loadbadwords() function.  It's primary use is to filter swearing * in both private and public messages */char *stripbadwords(char *str, ConfigItem_badword *start_bw, int *blocked){	regmatch_t pmatch[MAX_MATCH];	static char cleanstr[4096];	char buf[4096];	char *ptr;	int  matchlen, m, stringlen, cleaned;	ConfigItem_badword *this_word;		*blocked = 0;	if (!start_bw)		return str;	/*	 * work on a copy	 */	stringlen = strlcpy(cleanstr, StripControlCodes(str), sizeof cleanstr);	memset(&pmatch, 0, sizeof pmatch);	matchlen = 0;	buf[0] = '\0';	cleaned = 0;	for (this_word = start_bw; this_word; this_word = (ConfigItem_badword *)this_word->next)	{#ifdef FAST_BADWORD_REPLACE		if (this_word->type & BADW_TYPE_FAST)		{			if (this_word->action == BADWORD_BLOCK)			{				if (fast_badword_match(this_word, cleanstr))				{					*blocked = 1;					return NULL;				}			}			else			{				int n;				/* fast_badword_replace() does size checking so we can use 512 here instead of 4096 */				n = fast_badword_replace(this_word, cleanstr, buf, 512);				if (!cleaned && n)					cleaned = n;				strcpy(cleanstr, buf);				memset(buf, 0, sizeof(buf)); /* regexp likes this somehow */			}		} else		if (this_word->type & BADW_TYPE_REGEX)		{#endif			if (this_word->action == BADWORD_BLOCK)			{				if (!regexec(&this_word->expr, cleanstr, 0, NULL, 0))				{					*blocked = 1;					return NULL;				}			}			else			{				ptr = cleanstr; /* set pointer to start of string */				while (regexec(&this_word->expr, ptr, MAX_MATCH, pmatch,0) != REG_NOMATCH)				{					if (pmatch[0].rm_so == -1)						break;					m = pmatch[0].rm_eo - pmatch[0].rm_so;					if (m == 0)						break; /* anti-loop */					cleaned = 1;					matchlen += m;					strlncat(buf, ptr, sizeof buf, pmatch[0].rm_so);					if (this_word->replace)						strlcat(buf, this_word->replace, sizeof buf); 					else						strlcat(buf, REPLACEWORD, sizeof buf);					ptr += pmatch[0].rm_eo;	/* Set pointer after the match pos */					memset(&pmatch, 0, sizeof(pmatch));				}				/* All the better to eat you with! */				strlcat(buf, ptr, sizeof buf);					memcpy(cleanstr, buf, sizeof cleanstr);				memset(buf, 0, sizeof(buf));				if (matchlen == stringlen)					break;			}#ifdef FAST_BADWORD_REPLACE		}#endif	}	cleanstr[511] = '\0'; /* cutoff, just to be sure */	return (cleaned) ? cleanstr : str;}#ifdef STRIPBADWORDSchar *_stripbadwords_channel(char *str, int *blocked){	return stripbadwords(str, conf_badword_channel, blocked);}char *_stripbadwords_message(char *str, int *blocked){	return stripbadwords(str, conf_badword_message, blocked);}char *_stripbadwords_quit(char *str, int *blocked){	return stripbadwords(str, conf_badword_quit, blocked);}#elsechar *_stripbadwords_channel(char *str, int *blocked){	return NULL;}char *_stripbadwords_message(char *str, int *blocked){	return NULL;}char *_stripbadwords_quit(char *str, int *blocked){	return NULL;}#endif/* Taken from xchat by Peter Zelezny * changed very slightly by codemastr * RGB color stripping support added -- codemastr */char *_StripColors(unsigned char *text) {	int i = 0, len = strlen(text), save_len=0;	char nc = 0, col = 0, rgb = 0, *save_text=NULL;	static unsigned char new_str[4096];	while (len > 0) 	{		if ((col && isdigit(*text) && nc < 2) || (col && *text == ',' && nc < 3)) 		{			nc++;			if (*text == ',')				nc = 0;		}		/* Syntax for RGB is ^DHHHHHH where H is a hex digit.		 * If < 6 hex digits are specified, the code is displayed		 * as text		 */		else if ((rgb && isxdigit(*text) && nc < 6) || (rgb && *text == ',' && nc < 7))		{			nc++;			if (*text == ',')				nc = 0;		}		else 		{			if (col)				col = 0;			if (rgb)			{				if (nc != 6)				{					text = save_text+1;					len = save_len-1;					rgb = 0;					continue;				}				rgb = 0;			}			if (*text == '\003') 			{				col = 1;				nc = 0;			}			else if (*text == '\004')			{				save_text = text;				save_len = len;				rgb = 1;				nc = 0;			}			else 			{				new_str[i] = *text;				i++;			}		}		text++;		len--;	}	new_str[i] = 0;	return new_str;}/* strip color, bold, underline, and reverse codes from a string */char *_StripControlCodes(unsigned char *text) {	int i = 0, len = strlen(text), save_len=0;	char nc = 0, col = 0, rgb = 0, *save_text=NULL;	static unsigned char new_str[4096];	while (len > 0) 	{		if ( col && ((isdigit(*text) && nc < 2) || (*text == ',' && nc < 3)))		{			nc++;			if (*text == ',')				nc = 0;		}		/* Syntax for RGB is ^DHHHHHH where H is a hex digit.		 * If < 6 hex digits are specified, the code is displayed		 * as text		 */		else if ((rgb && isxdigit(*text) && nc < 6) || (rgb && *text == ',' && nc < 7))		{			nc++;			if (*text == ',')				nc = 0;		}		else 		{			if (col)				col = 0;			if (rgb)			{				if (nc != 6)				{					text = save_text+1;					len = save_len-1;					rgb = 0;					continue;				}				rgb = 0;			}			switch (*text)			{			case 3:				/* color */				col = 1;				nc = 0;				break;			case 4:				/* RGB */				save_text = text;				save_len = len;				rgb = 1;				nc = 0;				break;			case 2:				/* bold */				break;			case 31:				/* underline */				break;			case 22:				/* reverse */				break;			case 15:				/* plain */				break;			default:				new_str[i] = *text;				i++;				break;			}		}		text++;		len--;	}	new_str[i] = 0;	return new_str;}

⌨️ 快捷键说明

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