Exemple #1
0
void add_mode(ChannelList *chan, char *mode, int plus, char *nick, char *reason, int max_modes)
{
	char buffer[BIG_BUFFER_SIZE+1];
	
	if (mode_len >= (IRCD_BUFFER_SIZE-100))
	{
		flush_mode(chan);
		push_len = 0;
	}

	if (reason)
	{
		sprintf(buffer, "KICK %s %s :%s\r\n", chan->channel, nick, reason);
		push_len = strlen(buffer);
		add_mode_buffer(buffer, push_len);
	}
	else
	{
		mode_str_len++;
		strcat(plus_mode, plus ? "+" : "-");
		malloc_strcat(&mode_str, mode);
		m_s3cat(&user, space, nick);
		if (mode_str_len >= max_modes)
		{
			sprintf(buffer, "MODE %s %s%s %s\r\n", chan->channel, plus_mode, mode_str, user);
			push_len = strlen(buffer);
			add_mode_buffer(buffer, push_len);
			new_free(&mode_str);
			new_free(&user);
			memset(plus_mode, 0, sizeof(plus_mode));
			mode_str_len = push_len = 0;
		}
	}
}
Exemple #2
0
char *get_help_topic(char *args, int helpfunc)
{
char *new_comm = NULL;
int found = 0, i;
char *others = NULL;

	new_comm = LOCAL_COPY(args);

	for (i = 0; helpfunc ? script_help[i] : help_index[i]; i++)
	{
		if (!my_strnicmp(helpfunc?script_help[i]->title:help_index[i]->title, new_comm, strlen(new_comm)))
		{
			int j;
			char *text = NULL;
			if (found++)
			{
				m_s3cat(&others, " , ", helpfunc?script_help[i]->title:help_index[i]->title);
				continue;
			}
			if (args && *args && do_hook(HELPTOPIC_LIST, "%s", args))
				put_it("%s",convert_output_format("$G \002$0\002: Help on Topic: \002$1\002", version, args));
			for (j = 0; ; j++)
			{
				if (helpfunc && (script_help[i] && script_help[i]->contents[j]))
					text = script_help[i]->contents[j];
				else if (!helpfunc && (help_index[i] && help_index[i]->contents[j]))
					text = help_index[i]->contents[j];
				else 
					break;

				if (text && do_hook(HELPSUBJECT_LIST, "%s %s", new_comm, text))
				{
					in_chelp++;
					put_it("%s", convert_output_format(text, NULL));
					in_chelp--;
				}
			}		
			text = helpfunc ?script_help[i]->relates:help_index[i]->relates;
			if (text && do_hook(HELPTOPIC_LIST, "%s", text))
				put_it("%s", convert_output_format(text, NULL));
		}
		else if (found)
			break;
	}
	if (!found)
	{
		if (do_hook(HELPTOPIC_LIST, "%s", args))
			bitchsay("No help on %s", args);
	}

	if (others && found)
	{
		if (do_hook(HELPTOPIC_LIST, "%d %s", found, others))
			put_it("Other %d subjects: %s", found - 1, others);
	}
	new_free(&others);
	if (helpfunc)
		return m_strdup(empty_string);
	return NULL;
}
Exemple #3
0
char *get_all_fset(void)
{
	int i;
	char *ret = NULL;
	IrcVariable *ptr;
	FsetNumber *tmp = numeric_fset;
	for (i = 0; i < NUMBER_OF_FSET; i++)
		m_s3cat(&ret, space, fset_array[i].name);
	for (i = 0; i < ext_fset_list.max; i++)
	{
		ptr = ext_fset_list.list[i];
		m_s3cat(&ret, space, ptr->name);
	}
	for (tmp = numeric_fset; tmp; tmp = tmp->next)
		m_s3cat(&ret, space, ltoa(tmp->numeric));
	return ret;
}
Exemple #4
0
char *get_fset(char *str)
{
	int i;
	char *ret = NULL;
	IrcVariable *ptr;
	FsetNumber *tmp;
	if (!str || !*str)
		return get_all_fset();
	for (i = 0; i < NUMBER_OF_FSET; i++)
		if (wild_match(str, fset_array[i].name))
			m_s3cat(&ret, space, fset_array[i].name);
	for (i = 0; i < ext_fset_list.max; i++)
	{
		ptr = ext_fset_list.list[i];
		if (wild_match(str, ptr->name))
			m_s3cat(&ret, space, ptr->name);
	}
	for (tmp = numeric_fset; tmp; tmp = tmp->next)
		if (wild_match(str, ltoa(tmp->numeric)))
			m_s3cat(&ret, space, ltoa(tmp->numeric));
	return ret ? ret : m_strdup(empty_string);
}
Exemple #5
0
void	rebuild_notify_ison (int server)
{
	char *stuff;
	int i;
	if (from_server == -1)
		return;
	stuff = NOTIFY_LIST(from_server)->ison;

	if (NOTIFY_LIST(from_server)->ison)
		NOTIFY_LIST(from_server)->ison[0] = 0;

	for (i = 0; i < NOTIFY_MAX(from_server); i++)
	{
		m_s3cat(&(NOTIFY_LIST(from_server)->ison),
			space, NOTIFY_ITEM(from_server, i)->nick);
	}
}
Exemple #6
0
void get_help_topic(const char *args, int helpfunc)
{
	int found = 0, i;
	char *others = NULL;
	struct chelp_index *index = helpfunc ? &script_help : &bitchx_help;
	size_t arglen = strlen(args);

	for (i = 0; i < index->size; i++) {
		if (!my_strnicmp(index->entries[i].title, args, arglen)) {
			int j;
			char *text = NULL;

			if (found++) {
				m_s3cat(&others, " , ", index->entries[i].title);
				continue;
			}
			if (do_hook(HELPTOPIC_LIST, "%s", index->entries[i].title))
				put_it("%s", convert_output_format("$G \002$0\002: Help on Topic: \002$1-\002",
				                                   "%s %s", version, index->entries[i].title));
			for (j = 0; (text = index->entries[i].contents[j]) != NULL; j++) {
				if (do_hook(HELPSUBJECT_LIST, "%s , %s", index->entries[i].title, text)) {
					in_chelp++;
					put_it("%s", convert_output_format(text, NULL));
					in_chelp--;
				}
			}
			text = index->entries[i].relates;
			if (text && do_hook(HELPTOPIC_LIST, "%s", text))
				put_it("%s", convert_output_format(text, NULL));
		} else if (found)
			break;
	}
	if (!found) {
		if (do_hook(HELPTOPIC_LIST, "%s", args))
			bitchsay("No help on %s", args);
	}
	if (others && found) {
		if (do_hook(HELPTOPIC_LIST, "%d %s", found, others))
			put_it("Other %d subjects: %s", found - 1, others);
	}
	new_free(&others);
}
Exemple #7
0
void batch_notify_userhost (char *nick)
{
	m_s3cat(&batched_notify_userhosts, space, nick);
	batched_notifies++;
}
Exemple #8
0
int	parse_mangle (char *value, int nvalue, char **rv)
{
	char	*str1, *str2;
	char	*copy;
	char	*nv = NULL;

	if (rv)
		*rv = NULL;

	if (!value)
		return 0;

	copy = LOCAL_COPY(value);

	while ((str1 = new_next_arg(copy, &copy)))
	{
		while (*str1 && (str2 = next_in_comma_list(str1, &str1)))
		{
			     if (!my_strnicmp(str2, "ALL_OFF", 4))
				nvalue |= STRIP_ALL_OFF;
			else if (!my_strnicmp(str2, "-ALL_OFF", 5))
				nvalue &= ~(STRIP_ALL_OFF);
			else if (!my_strnicmp(str2, "ALL", 3))
				nvalue = (0x7FFFFFFF - (MANGLE_ESCAPES));
			else if (!my_strnicmp(str2, "-ALL", 4))
				nvalue = 0;
			else if (!my_strnicmp(str2, "ANSI", 2))
				nvalue |= MANGLE_ANSI_CODES;
			else if (!my_strnicmp(str2, "-ANSI", 3))
				nvalue &= ~(MANGLE_ANSI_CODES);
			else if (!my_strnicmp(str2, "BLINK", 2))
				nvalue |= STRIP_BLINK;
			else if (!my_strnicmp(str2, "-BLINK", 3))
				nvalue &= ~(STRIP_BLINK);
			else if (!my_strnicmp(str2, "BOLD", 2))
				nvalue |= STRIP_BOLD;
			else if (!my_strnicmp(str2, "-BOLD", 3))
				nvalue &= ~(STRIP_BOLD);
			else if (!my_strnicmp(str2, "COLOR", 1))
				nvalue |= STRIP_COLOR;
			else if (!my_strnicmp(str2, "-COLOR", 2))
				nvalue &= ~(STRIP_COLOR);
			else if (!my_strnicmp(str2, "ESCAPE", 1))
				nvalue |= MANGLE_ESCAPES;
			else if (!my_strnicmp(str2, "-ESCAPE", 2))
				nvalue &= ~(MANGLE_ESCAPES);
			else if (!my_strnicmp(str2, "ND_SPACE", 2))
				nvalue |= STRIP_ND_SPACE;
			else if (!my_strnicmp(str2, "-ND_SPACE", 3))
				nvalue &= ~(STRIP_ND_SPACE);
			else if (!my_strnicmp(str2, "NONE", 2))
				nvalue = 0;
			else if (!my_strnicmp(str2, "REVERSE", 2))
				nvalue |= STRIP_REVERSE;
			else if (!my_strnicmp(str2, "-REVERSE", 3))
				nvalue &= ~(STRIP_REVERSE);
			else if (!my_strnicmp(str2, "ROM_CHAR", 2))
				nvalue |= STRIP_ROM_CHAR;
			else if (!my_strnicmp(str2, "-ROM_CHAR", 3))
				nvalue &= ~(STRIP_ROM_CHAR);
			else if (!my_strnicmp(str2, "UNDERLINE", 1))
				nvalue |= STRIP_UNDERLINE;
			else if (!my_strnicmp(str2, "-UNDERLINE", 2))
				nvalue &= ~(STRIP_UNDERLINE);
		}
	}

	if (rv)
	{
		if (nvalue & MANGLE_ESCAPES)
			m_s3cat(&nv, comma, "ESCAPE");
		if (nvalue & MANGLE_ANSI_CODES)
			m_s3cat(&nv, comma, "ANSI");
		if (nvalue & STRIP_COLOR)
			m_s3cat(&nv, comma, "COLOR");
		if (nvalue & STRIP_REVERSE)
			m_s3cat(&nv, comma, "REVERSE");
		if (nvalue & STRIP_UNDERLINE)
			m_s3cat(&nv, comma, "UNDERLINE");
		if (nvalue & STRIP_BOLD)
			m_s3cat(&nv, comma, "BOLD");
		if (nvalue & STRIP_BLINK)
			m_s3cat(&nv, comma, "BLINK");
		if (nvalue & STRIP_ROM_CHAR)
			m_s3cat(&nv, comma, "ROM_CHAR");
		if (nvalue & STRIP_ND_SPACE)
			m_s3cat(&nv, comma, "ND_SPACE");
		if (nvalue & STRIP_ALL_OFF)
			m_s3cat(&nv, comma, "ALL_OFF");

		*rv = nv;
	}

	return nvalue;
}
Exemple #9
0
int parse_debug(char *value, int nvalue, char **rv)
{
	char	*str1, *str2;
	char	 *copy;
	char	*nv = NULL;

	if (rv)
		*rv = NULL;

	if  (!value)
		return 0;

	copy = alloca(strlen(value) + 1);
	strcpy(copy, value);
	
	while ((str1 = new_next_arg(copy, &copy)))
	{
		while (*str1 && (str2 = next_in_comma_list(str1, &str1)))
		{
			if (!my_strnicmp(str2, "ALL", 3))
				nvalue = (0x7F - (DEBUG_TCL));
			else if (!my_strnicmp(str2, "-ALL", 4))
				nvalue = 0;
			else if (!my_strnicmp(str2, "COMMANDS", 4))
				nvalue |= DEBUG_COMMANDS;
			else if (!my_strnicmp(str2, "-COMMANDS", 4))
				nvalue &= ~(DEBUG_COMMANDS);
			else if (!my_strnicmp(str2, "EXPANSIONS", 4))
				nvalue |= DEBUG_EXPANSIONS;
			else if (!my_strnicmp(str2, "-EXPANSIONS", 4))
				nvalue &= ~(DEBUG_EXPANSIONS);
			else if (!my_strnicmp(str2, "TCL", 3))
				nvalue |= DEBUG_TCL;
			else if (!my_strnicmp(str2, "-TCL", 3))
				nvalue &= ~(DEBUG_TCL);
			else if (!my_strnicmp(str2, "ALIAS", 3))
				nvalue |= DEBUG_CMDALIAS;
			else if (!my_strnicmp(str2, "-ALIAS", 3))
				nvalue &= ~(DEBUG_CMDALIAS);
			else if (!my_strnicmp(str2, "HOOK", 3))
				nvalue |= DEBUG_HOOK;
			else if (!my_strnicmp(str2, "-HOOK", 3))
				nvalue &= ~(DEBUG_HOOK);
			else if (!my_strnicmp(str2, "VARIABLES", 3))
				nvalue |= DEBUG_VARIABLE;
			else if (!my_strnicmp(str2, "-VARIABLES", 3))
				nvalue &= ~(DEBUG_VARIABLE);
			else if (!my_strnicmp(str2, "FUNCTIONS", 3))
				nvalue |= DEBUG_FUNC;
			else if (!my_strnicmp(str2, "-FUNCTIONS", 3))
				nvalue &= ~(DEBUG_FUNC);
			else if (!my_strnicmp(str2, "STRUCTURES", 3))
				nvalue |= DEBUG_STRUCTURES;
			else if (!my_strnicmp(str2, "-STRUCTURES", 3))
				nvalue &= ~(DEBUG_STRUCTURES);
		}
	}
	if (rv)
	{
		if (nvalue & DEBUG_COMMANDS)
			m_s3cat(&nv, comma, "COMMANDS");
		if (nvalue & DEBUG_EXPANSIONS)
			m_s3cat(&nv, comma, "EXPANSIONS");
		if (nvalue & DEBUG_TCL)
			m_s3cat(&nv, comma, "TCL");
		if (nvalue & DEBUG_CMDALIAS)
			m_s3cat(&nv, comma, "ALIAS");
		if (nvalue & DEBUG_HOOK)
			m_s3cat(&nv, comma, "HOOK");
		if (nvalue & DEBUG_VARIABLE)
			m_s3cat(&nv, comma, "VARIABLES");
		if (nvalue & DEBUG_FUNC)
			m_s3cat(&nv, comma, "FUNCTIONS");
		if (nvalue & DEBUG_STRUCTURES)
			m_s3cat(&nv, comma, "STRUCTURES");
		*rv = nv;
	}
	return nvalue;
}