示例#1
0
文件: vars.c 项目: jnbek/TekNap
static void set_ptest_connect(Window *win, char *unused, int value)
{
	if (value < 1)
		set_int_var(PTEST_CONNECT_TIMEOUT_VAR, 1);
	else if (value > 30)
		set_int_var(PTEST_CONNECT_TIMEOUT_VAR, 30);
}
示例#2
0
文件: vars.c 项目: jnbek/TekNap
void toggle_reverse_status(Window *win, char *unused, int value)
{
	if (!value)
		set_int_var(REVERSE_STATUS_VAR, 1);
	else
		set_int_var(REVERSE_STATUS_VAR, 0);
#ifndef ONLY_STD_CHARS
	set_string_var(SHOW_NUMERICS_STR_VAR, value ? "ùíù" : "-:-");
	set_numeric_string(current_window, value ? "ùíù":"-:-", 0);
#endif
	reinit_status(win, unused, value);
}
示例#3
0
文件: log.c 项目: BitchX/BitchX-SVN
/* logger: if flag is 0, logging is turned off, else it's turned on */
void logger(Window *win, char *unused, int flag)
{
	char	*logfile;
	if ((logfile = get_string_var(LOGFILE_VAR)) == NULL)
	{
		say("You must set the LOGFILE variable first!");
		set_int_var(LOG_VAR, 0);
		return;
	}
	do_log(flag, logfile, &irclog_fp);
	if (!irclog_fp && flag)
		set_int_var(LOG_VAR, 0);
}
示例#4
0
文件: mail.c 项目: carriercomm/epic4
/*
 * init_maildir_checking:  Look for the user's maildir
 *
 * Return value:
 *	1 if a maildir was found.
 *	0 if a maildir was not found.
 */
static int	init_maildir_checking (void)
{
	Filename 	tmp_maildir_path;
	const char *	maildir;
	const char *	envvar;

	envvar = "MAILDIR";
	if (!(maildir = getenv(envvar)))
	{
		envvar = "MAIL";
		if (!(maildir = getenv(envvar)))
		{
			say("Can't find your maildir -- Both your MAILDIR "
				"and MAIL environment variables are unset.");
			set_int_var(MAIL_VAR, 0);
			return 0;
		}
	}

	if (!file_exists(maildir))
	{
		say("The file in your %s environment variable "
			"does not exist.", envvar);
		set_int_var(MAIL_VAR, 0);
		return 0;
	}

	if (!isdir(maildir))
	{
		say("The file in your %s environment variable "
			"is not a directory.", envvar);
		set_int_var(MAIL_VAR, 0);
		return 0;
	}

	strlcpy(tmp_maildir_path, maildir, sizeof(Filename));
	strlcat(tmp_maildir_path, "/new", sizeof(Filename));
	if (!file_exists(tmp_maildir_path) || !isdir(tmp_maildir_path))
	{
		say("The directory in your %s environment variable "
			"does not contain a sub-directory called 'new'", 
				envvar);
		set_int_var(MAIL_VAR, 0);
		return 0;
	}

	maildir_path = malloc_strdup(maildir);
	maildir_last_changed = -1;
	return 1;
}
示例#5
0
文件: log.c 项目: carriercomm/epic5-1
/* logger: if flag is 0, logging is turned off, else it's turned on */
void	logger (const void *stuff)
{
	int	flag = *(const int *)stuff;
	char	*logfile;

	if ((logfile = get_string_var(LOGFILE_VAR)) == (char *) 0)
	{
		say("You must set the LOGFILE variable first!");
		set_int_var(LOG_VAR, 0);
		return;
	}
	do_log(flag, logfile, &irclog_fp);
	if (!irclog_fp && flag)
		set_int_var(LOG_VAR, 0);
}
示例#6
0
文件: input.c 项目: Nicholas-S/xaric
void toggle_insert_mode(char dumb, char *dumber)
{
    int tog = get_int_var(INSERT_MODE_VAR);

    tog ^= 1;
    set_int_var(INSERT_MODE_VAR, tog);
}
示例#7
0
文件: vars.c 项目: jnbek/TekNap
static void set_all_dataport(Window *win, char *unused, int value)
{
int pt = 0;
	make_listen(value, &pt);
	set_int_var(DEFAULT_DATAPORT_VAR, pt);
	send_all_servers(CMDS_CHANGEDATA, "%d", pt);
}
示例#8
0
static int
set_var (const char *var, const char *val, int init)
{
    int     i, n;
    char   *ptr;

    for (i = 0; i < Vars_Size; i++)
    {
	if (!strcmp (Vars[i].name, var))
	{
	    if (!init && (Vars[i].flags & CF_ONCE))
	    {
		log_message ("set_var: %s may not be reset/only set in the config file", Vars[i].name);
		return -1;
	    }
	    if (Vars[i].type == VAR_TYPE_INT)
	    {
		n = strtol (val, &ptr, 10);
		if (*ptr)
		{
		    log_message ("set_var: invalid integer value: %s", val);
		    return -1;
		}
		set_int_var (&Vars[i], n);
	    }
	    else if (Vars[i].type == VAR_TYPE_STR)
		set_str_var (&Vars[i], val);
	    else if (Vars[i].type == VAR_TYPE_BOOL)
	    {
		if (!strcasecmp ("yes", val) || !strcasecmp ("on", val))
		    n = 1;
		else if (!strcasecmp ("no", val) || !strcasecmp ("off", val))
		    n = 0;
		else
		{
		    n = strtol (val, &ptr, 10);
		    if (*ptr)
		    {
			log_message ("set_var: invalid boolean value: %s", val);
			return -1;
		    }
		}
		set_bool_var (&Vars[i], n);
	    }
	    else if (Vars[i].type == VAR_TYPE_LIST)
		set_list_var (&Vars[i], val);
	    else
	    {
		ASSERT (0);
	    }
	    return 0;
	}
    }
    log_message ("set_var: unknown variable %s", var);
    return -1;
}
示例#9
0
文件: clock.c 项目: carriercomm/epic4
void	set_cpu_saver_every (const void *stuff)
{
	int value = *(const int *)stuff;

	if (value < 60)
	{
		say("/SET CPU_SAVER_EVERY must be set to at least 60");
		set_int_var(CPU_SAVER_EVERY_VAR, 60);
	}
}
示例#10
0
文件: mail.c 项目: carriercomm/epic4
/*
 * init_mbox_checking:  Look for the user's mbox
 *
 * Look for an mbox-style mailbox.  If the user sets the MAIL environment
 * variable, we use that.  Otherwise, we look for a file by the user's name
 * in the usual directories (/var/spool/mail, /usr/spool/mail, /var/mail, 
 * and /usr/mail).  If we cannot find an mbox anywhere, we forcibly turn off
 * mail checking.  This will defeat the mail timer and save the user trouble.
 *
 * Return value:
 *	1 if an mbox was found.
 *	0 if an mbox was not found.
 */
static int	init_mbox_checking (void)
{
	const char *mbox_path_list = "/var/spool/mail:/usr/spool/mail:"
					"/var/mail:/usr/mail";
	Filename tmp_mbox_path;

	if (getenv("MAIL") && file_exists(getenv("MAIL")))
		mbox_path = malloc_strdup(getenv("MAIL"));
	else if (!path_search(username, mbox_path_list, tmp_mbox_path))
		mbox_path = malloc_strdup(tmp_mbox_path);
	else
	{
		say("I can't find your mailbox.");
		set_int_var(MAIL_VAR, 0);
		return 0;
	}

	return 1;
}
示例#11
0
文件: vars.c 项目: jnbek/TekNap
static void set_speed(Window *win, char *value, int unused)
{
int def_speed = 0;
	if (value && *value)
	{
		for (def_speed = 0; _n_speed[def_speed]; def_speed++)
		{
			if (!my_strnicmp(value, _n_speed[def_speed], strlen(value)))
				break;
		}
		if (def_speed > MAX_SPEED)
			if (isdigit(*value))
				def_speed = my_atol(value);
		if (def_speed > MAX_SPEED)
			def_speed = 0;
	}
	send_all_servers(CMDS_CHANGESPEED, "%d", def_speed);
	set_int_var(DEFAULT_SPEED_VAR, def_speed);
	set_string_var(DEFAULT_SPEED_VAR, _n_speed[def_speed]);
	return;
}
示例#12
0
文件: mail.c 项目: carriercomm/epic4
void	set_mail (const void *stuff)
{
	int	value = *(const int *)stuff;

	if (value < 0 || value > 3)
	{
		say("/SET MAIL must be 0, 1, 2, or 3");
		set_int_var(MAIL_VAR, 0);
		return;
	}
	else if (value == 0)
		checkmail->deinit();
	else
	{
		if (!checkmail->init())
			return;
	}

	update_system_timer(mail_timeref);
	update_all_status();
	cursor_to_input();
}
示例#13
0
/* load the default settings of the server */
void
config_defaults (void)
{
    int     i;

    for (i = 0; i < Vars_Size; i++)
    {
	if (Vars[i].def)
	{
	    if (Vars[i].type == VAR_TYPE_STR)
		set_str_var (&Vars[i], (char *) Vars[i].def);
	    else if (Vars[i].type == VAR_TYPE_INT)
		set_int_var (&Vars[i], Vars[i].def);
	    else if (Vars[i].type == VAR_TYPE_LIST)
		set_list_var (&Vars[i], (char *) Vars[i].def);
	    else if (Vars[i].type == VAR_TYPE_BOOL)
		set_bool_var (&Vars[i], Vars[i].def);
#if DEBUG
	    else
		ASSERT (0);
#endif
	}
    }
}
示例#14
0
文件: parse.c 项目: Nicholas-S/xaric
static void p_privmsg(char *from, char **Args)
{
    int level, list_type, flood_type, log_type, no_flood = 1, do_beep = 1;

    unsigned char ignore_type;
    char *ptr = NULL, *to;
    char *high;
    struct channel *channel = NULL;
    struct nick_list *tmpnick = NULL;

    if (!from)
	return;
    PasteArgs(Args, 1);
    to = Args[0];
    ptr = Args[1];
    if (!to || !ptr) {
	fake();
	return;
    }
    doing_privmsg = 1;

    if (is_channel(to) && im_on_channel(to)) {
	message_from(to, LOG_MSG);
	malloc_strcpy(&public_nick, from);
	log_type = LOG_PUBLIC;
	ignore_type = IGNORE_PUBLIC;
	flood_type = PUBLIC_FLOOD;

	if (!is_on_channel(to, from_server, from))
	    list_type = PUBLIC_MSG_LIST;
	else {
	    if (is_current_channel(to, from_server, 0))
		list_type = PUBLIC_LIST;
	    else
		list_type = PUBLIC_OTHER_LIST;
	    channel = lookup_channel(to, from_server, CHAN_NOUNLINK);
	    if (channel)
		tmpnick = find_nicklist_in_channellist(from, channel, 0);
	}
    } else {
	message_from(from, LOG_MSG);
	flood_type = MSG_FLOOD;
	if (my_stricmp(to, get_server_nickname(from_server))) {
	    log_type = LOG_WALL;
	    ignore_type = IGNORE_WALLS;
	    list_type = MSG_GROUP_LIST;
	} else {
	    log_type = LOG_MSG;
	    ignore_type = IGNORE_MSGS;
	    list_type = MSG_LIST;
	}
    }
    switch (check_ignore(from, FromUserHost, to, ignore_type, ptr)) {
    case IGNORED:
	if ((list_type == MSG_LIST) && get_int_var(SEND_IGNORE_MSG_VAR))
	    send_to_server(SERVER(from_server), "NOTICE %s :%s is ignoring you", from, get_server_nickname(from_server));
	doing_privmsg = 0;
	return;
    case HIGHLIGHTED:
	high = highlight_char;
	break;
    case CHANNEL_GREP:
	high = highlight_char;
	break;
    default:
	high = empty_str;
	break;
    }

    ptr = do_ctcp(from, to, ptr);
    if (!ptr || !*ptr) {
	doing_privmsg = 0;
	return;
    }

    level = set_lastlog_msg_level(log_type);
    if (flood_type == PUBLIC_FLOOD) {
	int blah = 0;

	if (is_other_flood(channel, tmpnick, PUBLIC_FLOOD, &blah)) {
	    no_flood = 0;
	    flood_prot(tmpnick->nick, FromUserHost, "PUBLIC", flood_type, get_int_var(PUBFLOOD_TIME_VAR), channel->channel);
	}
    } else
	no_flood = check_flooding(from, flood_type, ptr, NULL);

    {
	switch (list_type) {
	case PUBLIC_MSG_LIST:
	    logmsg(LOG_PUBLIC, from, ptr, 0);
	    if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr))
		put_it("%s",
		       convert_output_format(get_format(FORMAT_PUBLIC_MSG_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from,
					     FromUserHost, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr));
	    break;
	case MSG_GROUP_LIST:
	    logmsg(LOG_PUBLIC, from, ptr, 0);
	    if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr))
		put_it("%s",
		       convert_output_format(get_format(FORMAT_MSG_GROUP_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to,
					     get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr));
	    break;
	case MSG_LIST:
	    {
		if (!no_flood)
		    break;
		malloc_strcpy(&recv_nick, from);
		if (away_set) {
		    do_beep = 0;
		    beep_em(get_int_var(BEEP_WHEN_AWAY_VAR));
		    set_int_var(MSGCOUNT_VAR, get_int_var(MSGCOUNT_VAR) + 1);
		}
		logmsg(LOG_MSG, from, ptr, 0);
		addtabkey(from, "msg");

		if (do_hook(list_type, "%s %s", from, ptr))
		    put_it("%s",
			   convert_output_format(get_format(FORMAT_MSG_FSET), "%s %s %s %s", update_clock(GET_TIME), from,
						 FromUserHost, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr));

		if (from_server > -1 && get_server_away(from_server) && get_int_var(SEND_AWAY_MSG_VAR)) {
		    send_to_server(SERVER(from_server), "NOTICE %s :%s", from,
				   stripansicodes(convert_output_format
						  (get_format(FORMAT_SEND_AWAY_FSET), "%l %l %s", time(NULL),
						   server_list[from_server].awaytime, get_int_var(MSGLOG_VAR) ? "On" : "Off")));
		}
		break;
	    }
	case PUBLIC_LIST:{
		logmsg(LOG_PUBLIC, from, ptr, 0);
		if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr))
		    put_it("%s",
			   convert_output_format(get_format(FORMAT_PUBLIC_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to,
						 get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr));
		break;
	    }
	case PUBLIC_OTHER_LIST:{
		logmsg(LOG_PUBLIC, from, ptr, 0);
		if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr))
		    put_it("%s",
			   convert_output_format(get_format(FORMAT_PUBLIC_OTHER_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to,
						 get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr));
		break;
	    }			/* case */
	}			/* switch */
    }
    if (beep_on_level & log_type && do_beep)
	beep_em(1);
    set_lastlog_msg_level(level);
    message_from(NULL, LOG_CRAP);
    doing_privmsg = 0;
}
示例#15
0
文件: keys.c 项目: BitchX/BitchX1.1
/*
 * resize_metamap -- When we need to increase or decrease the number of
 * metamaps that the system is handling, you call this function with the
 * new size, and everything automagically adjusts from there.   This function
 * always succeeds if it returns.  This function is the callback for the
 * /SET META_STATES action.
 */
void	resize_metamap (int new_size)
{
	int	old_size = curr_keys_size;
	int	i, j;

	/*
	 * Sorry, just too much will break if you go lower than 5.
	 */
	if (new_size < 5)
	{
		say("You can't set META_STATES to less than 5.");
		set_int_var(META_STATES_VAR, 5);
	}

	if (old_size == new_size)
		return;		/* What-EVER */

	/*
	 * If we're growing the meta table, resize and copy the data.
	 */
	if (old_size < new_size)
	{
		/*
		 * Realloc and copy if neccesary
		 */
		if (new_size > max_keys_size)
		{
			KeyTable 	new_keys;
			new_keys = new_malloc(sizeof(KeyTable *) * new_size);

			for (i = 0; i < old_size; i++)
				new_keys[i] = keys[i];
			for (i = old_size; i < new_size; i++)
				new_keys[i] = NULL;
			new_free((void **)&keys);
			keys = new_keys;
			max_keys_size = new_size;
		}
		curr_keys_size = new_size;
	}

	/*
	 * If we're shrinking the meta table, just garbage collect all
	 * the old bindings, dont actually bother resizing the table.
	 */
	else
	{
		for (i = new_size; i < old_size; i++)
			delete_metamap(i);
		curr_keys_size = new_size;

		/*
		 * This is a bit tricky -- There might be meta transitions
		 * in other states that point to the now defunct states.
		 * If we leave those bindings around, then they will point
		 * to either meaningless, or bogus data, and either cause
		 * undefined behavior or a total program crash.  So we walk
		 * all of the remaining states and garbage collect any 
		 * meta transisions that are out of bounds.
		 */
		for (i = 0; i < new_size; i++)
		{
		    if (!keys[i])
			continue;
		    for (j = 0; j < 256; j++)
			if (KEY(i, j) && (KEY(i, j)->key_index <= -new_size))
				snew_key(i, j, NULL);
		}
	}

	set_int_var(META_STATES_VAR, curr_keys_size);
}