コード例 #1
0
ファイル: clock.c プロジェクト: carriercomm/epic4
void	reset_clock (const void *stuff)
{
	if (x_debug & DEBUG_BROKEN_CLOCK)
		reset_broken_clock();
	else if (get_int_var(METRIC_TIME_VAR))
		reset_metric_clock();
	else
		reset_standard_clock();

	update_all_status();
	cursor_to_input();
}
コード例 #2
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
static void p_kill(char *from, char **ArgList)
{
    char sc[20];
    int port;
    int local = 0;

    port = get_server_port(from_server);
    if (ArgList[1] && strstr(ArgList[1], get_server_name(from_server)))
	if (!strchr(from, '.'))
	    local = 1;
    snprintf(sc, 19, "+%i %d", from_server, port);

    close_server(from_server, empty_str);
    clean_whois_queue();
    window_check_servers();
    set_input_prompt(curr_scr_win, get_string_var(INPUT_PROMPT_VAR), 0);

    if (strchr(from, '.')) {
	say("Server [%s] has rejected you (probably due to a nick collision)", from);
	t_parse_command("SERVER", NULL);
    } else {
	if (local && get_int_var(NEXT_SERVER_ON_LOCAL_KILL_VAR)) {
	    int i = from_server + 1;

	    if (i >= number_of_servers)
		i = 0;
	    snprintf(sc, 19, "+%i", i);
	    from_server = -1;
	}
	if (do_hook(DISCONNECT_LIST, "Killed by %s (%s)", from, ArgList[1] ? ArgList[1] : "(No Reason Given)"))
	    put_it("%s",
		   convert_output_format(get_format(FORMAT_KILL_FSET), "%s %s", update_clock(GET_TIME),
					 ArgList[1] ? ArgList[1] : "You have been Killed"));
	if (get_int_var(AUTO_RECONNECT_VAR))
	    t_parse_command("SERVER", NULL);
    }
    update_all_status(curr_scr_win, NULL, 0);
}
コード例 #3
0
ファイル: numbers.c プロジェクト: NathanHowell/epic
/*
 * banner: This returns in a static string of either "xxx" where
 * xxx is the current numeric, or "***" if SHOW_NUMBERS is OFF 
 */
const char *	banner (void)
{
	static	char	thing[80];
	char *str;

	if (current_numeric > 0 && get_int_var(SHOW_NUMERICS_VAR))
		snprintf(thing, sizeof thing, "%3.3u", current_numeric);
	else if ((str = get_string_var(BANNER_VAR)))
	{
		if (get_int_var(BANNER_EXPAND_VAR))
		{
			char *foo = expand_alias(str, empty_string);
			strlcpy(thing, foo, sizeof thing);
			new_free(&foo);
		}
		else
			strlcpy(thing, str, sizeof thing);
	}
	else
		*thing = 0;

	return (thing);
}
コード例 #4
0
ファイル: userlist.c プロジェクト: nikolatesla/BitchXMPP
void check_hack(char *nick, ChannelList *channel, NickList *ThisNick, char *from)
{
#ifdef WANT_USERLIST
UserList *userptr = NULL;
ShitList *shitptr = NULL;
#endif
WhowasList *check_op = NULL;

int	flag;

	if (from && *from && !strchr(from, '.'))
		return;

	if (!channel || !are_you_opped(channel->channel) || !nick || !ThisNick || wild_match(nick, get_server_nickname(from_server)))
		return;
	if (!(flag = get_cset_int_var(channel->csets, HACKING_CSET)))
		return;
	if ((ThisNick->sent_deop) && (now - ThisNick->sent_deop_time < 10))
		return;

#ifdef WANT_USERLIST
	userptr = ThisNick->userlist;
	shitptr = ThisNick->shitlist;
#endif
	check_op = check_whosplitin_buffer(nick, ThisNick->host, channel->channel, 0);
	if (check_op && check_op->has_ops)
		return;
		
#ifdef WANT_USERLIST
	if ( !userptr || (userptr && !check_channel_match(userptr->channels, channel->channel)) ||
		(shitptr && check_channel_match(shitptr->channels, channel->channel)))
#endif
	{
		switch(flag)
		{
			case 1:
			case 3:
				if (is_chanop(channel->channel, nick))
					add_mode(channel, "o", 0, nick, NULL, get_int_var(NUM_OPMODES_VAR));
				ThisNick->sent_deop++;
				ThisNick->sent_deop_time = now;
			case 2:
				if (flag != 1)
					bitchsay("NetHack detected on %s by %s!%s", channel->channel, nick, ThisNick->host); 
			case 0:
			default:
				break;
		}
	}
}
コード例 #5
0
ファイル: log.c プロジェクト: BitchX/BitchX-SVN
void do_log(int flag, char *logfile, FILE **fp)
{
#ifdef PUBLIC_ACCESS
	bitchsay("This command has been disabled on a public access system");
	return;
#else
	time_t	t = now;

	if (flag)
	{
		if (*fp)
			say("Logging is already on");
		else
		{
			if (!logfile)
				return;
			if (!(logfile = expand_twiddle(logfile)))
			{
				say("SET LOGFILE: No such user");
				return;
			}

			if ((*fp = fopen(logfile, get_int_var(APPEND_LOG_VAR)?"a":"w")) != NULL)
			{
				say("Starting logfile %s", logfile);
				chmod(logfile, S_IREAD | S_IWRITE);
				fprintf(*fp, "IRC log started %.24s\n", ctime(&t));
				fflush(*fp);
			}
			else
			{
				say("Couldn't open logfile %s: %s", logfile, strerror(errno));
				*fp = NULL;
			}
			new_free(&logfile);
		}
	}
	else
	{
		if (*fp)
		{
			fprintf(*fp, "IRC log ended %.24s\n", ctime(&t));
			fflush(*fp);
			fclose(*fp);
			*fp = NULL;
			say("Logfile ended");
		}
	}
#endif
}
コード例 #6
0
ファイル: clock.c プロジェクト: Cloudxtreme/epic5
void	reset_clock (void *stuff)
{
	char *	sclock;

	if (x_debug & DEBUG_BROKEN_CLOCK)
		reset_broken_clock();
	else if (get_int_var(METRIC_TIME_VAR))
		reset_metric_clock();
	else
		reset_standard_clock();

	sclock = get_string_var(STATUS_CLOCK_VAR);
	if (sclock && *sclock)
		update_all_status();
}
コード例 #7
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
static void p_invite(char *from, char **ArgList)
{
    char *high;

    switch (check_ignore(from, FromUserHost, ArgList[1] ? ArgList[1] : NULL, IGNORE_INVITES, NULL)) {
    case IGNORED:
	if (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));
	return;
    case HIGHLIGHTED:
	high = highlight_char;
	break;
    default:
	high = empty_str;
	break;
    }
    if (ArgList[0] && ArgList[1]) {
	struct channel *chan = NULL;
	struct whowas_chan_list *w_chan = NULL;

	message_from(from, LOG_CRAP);
	malloc_strcpy(&invite_channel, ArgList[1]);
	if (check_flooding(from, INVITE_FLOOD, ArgList[1], NULL) && do_hook(INVITE_LIST, "%s %s", from, ArgList[1])) {
	    put_it("%s", convert_output_format(get_format(FORMAT_INVITE_FSET), "%s %s %s", update_clock(GET_TIME), from, ArgList[1]));
	}
	if (!(chan = lookup_channel(invite_channel, from_server, 0)))
	    if ((w_chan = check_whowas_chan_buffer(invite_channel, 0)))
		chan = w_chan->channellist;
	if (chan && get_int_var(AUTO_REJOIN_VAR) && invite_channel) {
	    if (!in_join_list(invite_channel, from_server))
		send_to_server(SERVER(from_server), "JOIN %s %s", invite_channel, ArgList[2] ? ArgList[2] : "");
	}

	malloc_strcpy(&recv_nick, from);
    }
}
コード例 #8
0
ファイル: userlist.c プロジェクト: nikolatesla/BitchXMPP
int delay_opz (void *arg, char *sub)
{
char * args = (char *)arg;
char * from = NULL;
char * host = NULL;
char * channel = NULL;	
char * mode = NULL;
char * serv_num = NULL;
ChannelList *chan = NULL;
int	this_server = from_server;
char *p = (char *) arg; /* original args unmodified  so we can free them */
	

	channel = next_arg(args, &args);
	from = next_arg(args, &args);
	host = next_arg(args, &args);
	mode = next_arg(args, &args);

	if ((serv_num = next_arg(args, &args)))
		this_server = my_atol(serv_num);
	chan = lookup_channel(channel, this_server, 0);
	if (chan && is_on_channel(channel, this_server, from) && chan->chop) 
	{
		NickList *nick;
		for (nick = next_nicklist(chan, NULL); nick; nick = next_nicklist(chan, nick))
		{
			if (!my_stricmp(nick->nick, from))
			{
				if (!my_stricmp(host, nick->host))
					break;
				else
				{
					new_free(&p); new_free(&sub);
					return 0;
				}
			}
		}
		if (nick && ((!nick_isop(nick) && *mode == 'o') || (!nick_isvoice(nick) && *mode == 'v')))
		{
			my_send_to_server(this_server, "MODE %s +%s %s", channel, mode, from); 
			if (get_int_var(SEND_OP_MSG_VAR))
				my_send_to_server(this_server, "NOTICE %s :You have been delay Auto-%s'd", from, *mode == 'o'? "op":"voice");
		}
	}
	new_free(&p); new_free(&sub);
	return 0;
}
コード例 #9
0
ファイル: exec.c プロジェクト: Nicholas-S/xaric
/*
 * delete_process: Removes the process specifed by index from the process
 * list.  The does not kill the process, close the descriptors, or any such
 * thing.  It only deletes it from the list.  If appropriate, this will also
 * shrink the list as needed
 */
static int delete_process(int process)
{
    int flag;

    if (process_list) {
        if (process >= process_list_size)
            return (-1);
        if (process_list[process]) {
            Process *dead;

            dead = process_list[process];
            process_list[process] = NULL;
            if (process == (process_list_size - 1)) {
                int i;

                for (i = process_list_size - 1; process_list_size; process_list_size--, i--) {
                    if (process_list[i])
                        break;
                }

                if (process_list_size)
                    process_list = new_realloc(process_list, Process *, 0, process_list_size);
                else {
                    new_free(&process_list);
                    process_list = NULL;
                }
            }
            if (dead->logical)
                flag = do_hook(EXEC_EXIT_LIST, "%s %d %d", dead->logical, dead->termsig, dead->retcode);
            else
                flag = do_hook(EXEC_EXIT_LIST, "%d %d %d", process, dead->termsig, dead->retcode);
            if (flag) {
                if (get_int_var(NOTIFY_ON_TERMINATION_VAR)) {
                    if (dead->termsig)
                        say("Process %d (%s) terminated with signal %s (%d)", process, dead->name, sys_siglist[dead->termsig],
                            dead->termsig);
                    else
                        say("Process %d (%s) terminated with return code %d", process, dead->name, dead->retcode);
                }
            }
            new_free(&dead->name);
            new_free(&dead->logical);
            new_free(&dead->who);
            new_free(&dead->redirect);
            new_free(&dead);
            return (0);
        }
コード例 #10
0
ファイル: userlist.c プロジェクト: nikolatesla/BitchXMPP
void check_shit(ChannelList *chan)
{
ShitList *Bans;
	if (!chan || !chan->chop || !shitlist_list || chan->server <= -1 || !get_cset_int_var(chan->csets, SHITLIST_CSET))
		return;
	if (!check_channel_match(get_string_var(PROTECT_CHANNELS_VAR), chan->channel))
		return;
	for (Bans = shitlist_list; Bans; Bans = Bans->next)
	{
		/* this is a permanent ban */
		if (!check_channel_match(Bans->channels, chan->channel))
			continue;
		if ((Bans->level == 4) && !ban_is_on_channel(Bans->filter, chan) && !eban_is_on_channel(Bans->filter, chan))
			add_mode(chan, "b", 1, Bans->filter, NULL, get_int_var(NUM_BANMODES_VAR));
	}
	flush_mode_all(chan);
}
コード例 #11
0
ファイル: numbers.c プロジェクト: NathanHowell/epic
/*
 * display_msg: handles the displaying of messages from the variety of
 * possible formats that the irc server spits out.
 *
 * Simplified some time in 1996.
 * -- called by more than one place.
 */
static void 	display_msg (const char *from, const char *comm, const char **ArgList)
{
	char	*ptr = NULL;
	const char	*rest;
	int	drem;

	/* XXX - 
	 * ArgList[0] was passed to who_from() which means we need to 
	 * either reset who_from() with our own copy, or not detokenize
	 * ArgList[0], because this breaks channel targeting!
	 */
	if (!(rest = PasteArgs(ArgList, 0)))
		{ rfc1459_odd(from, comm, ArgList); return; }

	if (from && (my_strnicmp(get_server_itsname(from_server), from,
			strlen(get_server_itsname(from_server))) == 0))
		from = NULL;

	/* This fix by SrfRog, again by |Rain| */
	if (ptr && ptr > rest && ptr[-1] == ' ')	/* per RFC 1459 */
		*ptr++ = 0;
	else
		ptr = NULL;

        drem = (from) && (!get_int_var(SUPPRESS_FROM_REMOTE_SERVER_VAR));

        /*
         * This handles all the different cases of server messages.
         * If you dont believe me, try it out. :P
         *
         * There are 16 distinct possibilities, since there are 4
         * independant variables.  In practice only about 6 to 8 of 
	 * the possibilities are used.
         */
        put_it("%s %s%s%s%s%s%s%s",
                banner(),
                strlen(rest)        ? rest     : empty_string,
                strlen(rest) && ptr ? ":"      : empty_string,
                strlen(rest)        ? space    : empty_string,
                ptr                 ? ptr      : empty_string,
                drem                ? "(from " : empty_string,
                drem                ? from     : empty_string,
                drem                ? ")"      : empty_string
              );
}
コード例 #12
0
ファイル: output.c プロジェクト: Cloudxtreme/epic5
/*
 * syserr is exactly like say, except that if the error occured while
 * you were loading a script, it tells you where it happened.
 */
static void     vsyserr (int server, const char *format, va_list args)
{
	char *  str;
	int     l, old_from_server = from_server;
	int	i_set_from_server = 0;

        if (!window_display || !format)
		return;

	*putbuf = 0;
	if ((str = get_string_var(BANNER_VAR)))
	{
		if (get_int_var(BANNER_EXPAND_VAR))
		{
		    char *foo;

		    foo = expand_alias(str, empty_string);
		    strlcpy(putbuf, foo, sizeof putbuf);
		    new_free(&foo);
		}
		else
		    strlcpy(putbuf, str, sizeof putbuf);

		strlcat(putbuf, " INFO -- ", sizeof putbuf);
	}

	vsnprintf(putbuf + strlen(putbuf),
		sizeof(putbuf) - strlen(putbuf) - 1,
		format, args);

	if (is_server_valid(server))
	{
		old_from_server = from_server;
		from_server = server;
		i_set_from_server = 1;
	}

	l = message_from(NULL, LEVEL_SYSERR);
	if (do_hook(YELL_LIST, "%s", putbuf))
		put_echo(putbuf);
	pop_message_from(l);

	if (i_set_from_server)
		from_server = old_from_server;
}
コード例 #13
0
ファイル: input.c プロジェクト: Nicholas-S/xaric
/*
 * input_add_character: adds the character c to the input buffer, repecting
 * the current overwrite/insert mode status, etc 
 */
void input_add_character(char c, char *unused)
{
    int display_flag = NO_UPDATE;

    cursor_to_input();
    if (THIS_POS < INPUT_BUFFER_SIZE) {
	if (get_int_var(INSERT_MODE_VAR)) {
	    if (THIS_CHAR) {
		char *ptr = NULL;

		ptr = strdup(&(THIS_CHAR));

		THIS_CHAR = c;
		NEXT_CHAR = 0;
		ADD_TO_INPUT(ptr);
		free(ptr);
		if (term_insert(c)) {
		    term_putchar(c);
		    if (NEXT_CHAR)
			display_flag = UPDATE_FROM_CURSOR;
		    else
			display_flag = NO_UPDATE;
		}
	    } else {
		THIS_CHAR = c;
		NEXT_CHAR = 0;
		term_putchar(c);
	    }
	} else {
	    if (THIS_CHAR == 0)
		NEXT_CHAR = 0;
	    THIS_CHAR = c;
	    term_putchar(c);
	}
	THIS_POS++;
	update_input(display_flag);
    }
    if (in_completion == STATE_COMPLETE && c == ' ' && input_lastmsg) {
	new_free(&input_lastmsg);
	*new_nick = 0;
	in_completion = STATE_NORMAL;
    }
}
コード例 #14
0
ファイル: clock.c プロジェクト: Cloudxtreme/epic5
static void	reset_standard_clock (void)
{
static		int	min = -1;
static		int	hour = -1;
		Timeval	tv;
	struct 	tm	time_val;
		time_t	hideous;

	/* 
	 * Every time /set clock_interval goes off this function calls
	 * localtime() to update $Z.  Localtime() is very expensive, so
	 * if you /set clock_interval too low you will use a lot of cpu.
	 */
	get_time(&tv);
	hideous = tv.tv_sec;
	time_val = *localtime(&hideous);

	if (time_format)	/* XXX Bogus XXX */
		strftime(current_clock, sizeof current_clock, 
				time_format, &time_val);
	else if (get_int_var(CLOCK_24HOUR_VAR))
		strftime(current_clock, sizeof current_clock,
				strftime_24hour, &time_val);
	else
		strftime(current_clock, sizeof current_clock,
				strftime_12hour, &time_val);

	/*
	 * Either way we only update /on timer and /on idle every minute.
	 */
	if ((time_val.tm_min != min) || (time_val.tm_hour != hour))
	{
		int	old_server = from_server;

		hour = time_val.tm_hour;
		min = time_val.tm_min;

		from_server = primary_server;
		do_hook(TIMER_LIST, "%02d:%02d", hour, min);
		do_hook(IDLE_LIST, "%ld", (tv.tv_sec - idle_time.tv_sec) / 60);
		from_server = old_server;
	}
}
コード例 #15
0
ファイル: flood.c プロジェクト: BitchX/BitchX1.2
void get_flood_val(ChannelList *chan, int type, int *flood_count, int *flood_rate)
{
	*flood_count = get_int_var(FLOOD_AFTER_VAR);
	*flood_rate = get_int_var(FLOOD_RATE_VAR);
	if (chan)
	{
		switch(type)
		{
			case JOIN_FLOOD:
				*flood_count = get_cset_int_var(chan->csets, KICK_ON_JOINFLOOD_CSET);
				*flood_rate = get_cset_int_var(chan->csets, JOINFLOOD_TIME_CSET);
				break;
			case PUBLIC_FLOOD:
				*flood_count = get_cset_int_var(chan->csets, KICK_ON_PUBFLOOD_CSET);
				*flood_rate = get_cset_int_var(chan->csets, PUBFLOOD_TIME_CSET);
				break;
			case NICK_FLOOD:
				*flood_count = get_cset_int_var(chan->csets, KICK_ON_NICKFLOOD_CSET);
				*flood_rate = get_cset_int_var(chan->csets, NICKFLOOD_TIME_CSET);
				break;
			case KICK_FLOOD:
				*flood_count = get_cset_int_var(chan->csets, KICK_ON_KICKFLOOD_CSET);
				*flood_rate = get_cset_int_var(chan->csets, KICKFLOOD_TIME_CSET);
				break;
			case DEOP_FLOOD:
				*flood_count = get_cset_int_var(chan->csets, KICK_ON_DEOPFLOOD_CSET);
				*flood_rate = get_cset_int_var(chan->csets, DEOPFLOOD_TIME_CSET);
				break;
			default:
			break;
		}
	}
	else
	{
		switch(type)
		{
			case CDCC_FLOOD:
				*flood_count = get_int_var(CDCC_FLOOD_AFTER_VAR);
				*flood_rate = get_int_var(CDCC_FLOOD_RATE_VAR);
				break;
			case CTCP_FLOOD:
				*flood_count = get_int_var(CTCP_FLOOD_AFTER_VAR);
				*flood_rate = get_int_var(CTCP_FLOOD_RATE_VAR);
			case CTCP_ACTION_FLOOD:
			default:
				break;
		}
	}
}
コード例 #16
0
ファイル: exec.c プロジェクト: Nicholas-S/xaric
/*
 * check_process_limits: checks each running process to see if it's reached
 * the user selected maximum number of output lines.  If so, the processes is
 * effectively killed
 */
void check_process_limits(void)
{
    int limit;
    int i;
    Process *proc;

    if ((limit = get_int_var(SHELL_LIMIT_VAR)) && process_list) {
        for (i = 0; i < process_list_size; i++) {
            if ((proc = process_list[i]) != NULL) {
                if (proc->counter >= limit) {
                    proc->p_stdin = exec_close(proc->p_stdin);
                    proc->p_stdout = exec_close(proc->p_stdout);
                    proc->p_stderr = exec_close(proc->p_stderr);
                    if (proc->exited)
                        delete_process(i);
                }
            }
        }
    }
}
コード例 #17
0
ファイル: network.c プロジェクト: BitchX/BitchX1.1
/*
 * try to negotiate a SOCKS4 connection.
 *
 */
int socks4_connect(int s, int portnum, struct sockaddr_in *server)
{
struct _sock_connect {
	char version;
	char type;
	unsigned short port;
	unsigned long address;
	char username[NAME_LEN+1];
} sock4_connect;
char socksreq[10];
char *p;
int red;

	memset(&sock4_connect, 0, sizeof(sock4_connect));
	sock4_connect.version = SOCKS4_VERSION;
	sock4_connect.type = SOCKS_CONNECT;
	sock4_connect.port = server->sin_port;

	strncpy(sock4_connect.username, socks_user? socks_user: getenv("USER") ? getenv("USER") : username, NAME_LEN);
	p = inet_ntoa(server->sin_addr);
	sock4_connect.address = inet_addr(p);
	if ((red = write(s, &sock4_connect, 8 + strlen(sock4_connect.username) + 1)) == -1)
	{
		bitchsay("Cannot write to socks proxy: %s", strerror(errno));
		return 0;
	}
	alarm(get_int_var(CONNECT_TIMEOUT_VAR));
	if ((red = read(s, socksreq, 8)) == -1)
	{
		alarm(0);
		bitchsay("Cannot read from socks proxy: %s", strerror(errno));
		return 0;
	}
	alarm(0);
	if (socksreq[1] != 90)
	{
		bitchsay("Cannot connect to SOCKS4 proxy: %s", socks4_error(socksreq[1]));
		return 0;
	}
	return 1;
}
コード例 #18
0
ファイル: clock.c プロジェクト: carriercomm/epic4
static void	reset_standard_clock (void)
{
static		int	min = -1;
static		int	hour = -1;
		Timeval	tv;
	struct 	tm	time_val;
		time_t	hideous;

	/*
	 * This is cheating because we only call localtime() once per minute.
	 * This implicitly assumes that you only want to get the localtime
	 * info once every minute, which we do.  If you wanted to get it every
	 * second (which we dont), you DONT WANT TO DO THIS!
	 */
	get_time(&tv);
	hideous = tv.tv_sec;
	time_val = *localtime(&hideous);

	if (time_format)	/* XXX Bogus XXX */
		strftime(current_clock, sizeof current_clock, 
				time_format, &time_val);
	else if (get_int_var(CLOCK_24HOUR_VAR))
		strftime(current_clock, sizeof current_clock,
				strftime_24hour, &time_val);
	else
		strftime(current_clock, sizeof current_clock,
				strftime_12hour, &time_val);

	if ((time_val.tm_min != min) || (time_val.tm_hour != hour))
	{
		int	old_server = from_server;

		hour = time_val.tm_hour;
		min = time_val.tm_min;

		from_server = primary_server;
		do_hook(TIMER_LIST, "%02d:%02d", hour, min);
		do_hook(IDLE_LIST, "%ld", (tv.tv_sec - idle_time.tv_sec) / 60);
		from_server = old_server;
	}
}
コード例 #19
0
ファイル: help.c プロジェクト: carriercomm/epic5-1
/*
 * show_help:  show's either a page of text from a help_fp, or the whole
 * thing, depending on the value of HELP_PAGER_VAR.  If it gets to the end,
 * (in either case it will eventally), it closes the file, and returns 0
 * to indicate this.
 *
 * -- This doesn't need to fiddle with 'to_window' -- help_put_it does
 *    all that for us. (hop, 09/23/2003)
 */
static	int	show_help (Window *window, char *name)
{
    int	rows = -1;
    char	line[256];

    if (!help_fp)
        return 0;

    if (get_int_var(HELP_PAGER_VAR))
    {
        if (help_window)
            rows = help_window->display_size;
        else
            rows = current_window->display_size;
    }

    while (rows)
    {
        if (!fgets(line, 255, help_fp))
        {
            fclose(help_fp);
            help_fp = NULL;
            return 0;
        }

        if (*(line + strlen(line) - 1) == '\n')
            *(line + strlen(line) - 1) = (char) 0;

        /*
         * This is for compatability with ircII-4.4
         */
        if (*line == '!' || *line == '#')
            continue;

        help_put_it(name, "%s", line);
        rows--;
    }

    return (1);
}
コード例 #20
0
ファイル: clock.c プロジェクト: carriercomm/epic4
/*
 * This is a watchdog timer that checks to see when we're idle enough to 
 * turn on CPU SAVER mode.  The above timers may honor what we do here but
 * they're not required to.
 */
int	cpu_saver_timer (void *schedule_only)
{
	double	interval;
	double	been_idlin;

	if (cpu_saver)
		return 0;

	get_time(&now);
	been_idlin = time_diff(idle_time, now);
	interval = get_int_var(CPU_SAVER_AFTER_VAR) * 60;

	if (interval < 1)
		return 0;

	if (been_idlin > interval)
		cpu_saver_on(0, NULL);
	else
		add_timer(1, cpu_saver_timeref, interval - been_idlin, 
				1, cpu_saver_timer, NULL, NULL, -1);
	return 0;
}
コード例 #21
0
ファイル: numbers.c プロジェクト: choppsv1/ircii
/*
 * reset_nickname: when the server reports that the selected nickname is not
 * a good one, it gets reset here. 
 */
static	void
reset_nickname(u_char *from)
{
	u_char	server_num[10];
	const	int	from_server = get_from_server();

	if (already_doing_reset_nickname ||
	    is_server_connected(from_server) ||
	    !server_get_attempting_to_connect(from_server))
		return;

	say("You have specified an illegal nickname");
	if (!term_basic() && !get_int_var(NO_ASK_NICKNAME_VAR))
	{
		already_doing_reset_nickname = 1;
		say("Please enter your nickname");
		snprintf(CP(server_num), sizeof server_num, "%d", parsing_server());
		add_wait_prompt(UP("Nickname: "), nickname_sendline, server_num,
			WAIT_PROMPT_LINE);
	}
	update_all_status();
}
コード例 #22
0
ファイル: funny.c プロジェクト: BitchX/BitchX1.1
void print_funny_names(char *line)
{
register char *t;
int count = 0;
char buffer[BIG_BUFFER_SIZE+1];
char special = '\0';
int cols = get_int_var(NAMES_COLUMNS_VAR);
	if (!cols)
		cols = 1;
	if (line && *line)
	{	
		*buffer = 0;
		t = next_arg(line, &line);
		do {
			if (!count && fget_string_var(FORMAT_NAMES_BANNER_FSET))
				strcpy(buffer, convert_output_format(fget_string_var(FORMAT_NAMES_BANNER_FSET), NULL, NULL));
			if (*t == '@' || *t == '+' || *t == '~' || *t == '-')
			{
				special = *t;
				if (special == '+')
					strcat(buffer, convert_output_format(fget_string_var(FORMAT_NAMES_VOICECOLOR_FSET),"%c %s", special, ++t));
				else
					strcat(buffer, convert_output_format(fget_string_var(FORMAT_NAMES_OPCOLOR_FSET),"%c %s", special, ++t));
			}
			else
				strcat(buffer, convert_output_format(fget_string_var(FORMAT_NAMES_NICKCOLOR_FSET), "$ %s", t));
			strcat(buffer, space);
			if (count++ >= (cols - 1))
			{
				put_it("%s", buffer);
				*buffer = 0;
				count = 0;
			}
		} while ((t = next_arg(line, &line)));

		if (buffer)
			put_it("%s", buffer);
	}
}
コード例 #23
0
ファイル: mail.c プロジェクト: carriercomm/epic4
void	mail_systimer (void)
{
	int	x;

	switch ((x = get_int_var(MAIL_VAR)))
	{
		case 1:
			checkmail->level1();
			break;
		case 2:
			checkmail->level2();
			break;
		case 3:
			checkmail->level3();
			break;
		default:
			panic("mail_systimer called with set mail %d", x);
	}

	update_all_status();
	cursor_to_input();
	return;
}
コード例 #24
0
ファイル: exec.c プロジェクト: carriercomm/epic5-1
/*
 * do_processes: This is called from the main io() loop to handle any
 * pending /exec'd events.  All this does is call handle_filedesc() on
 * the two reading descriptors.  If an EOF is asserted on either, then they
 * are closed.  If EOF has been asserted on both, then  we mark the process
 * as being "dumb".  Once it is reaped (exited), it is expunged.
 */
void 		do_processes (fd_set *rd, fd_set *wd)
{
	int	i;
	int	limit;

	if (!process_list)
		return;

	limit = get_int_var(SHELL_LIMIT_VAR);
	for (i = 0; i < process_list_size; i++)
	{
		Process *proc = process_list[i];

		if (!proc)
			continue;

		if (proc->p_stdout != -1 && FD_ISSET(proc->p_stdout, rd))
		{
			FD_CLR(proc->p_stdout, rd);
			handle_filedesc(proc, &proc->p_stdout, 
					EXEC_PROMPT_LIST, EXEC_LIST);
		}

		if (proc->p_stderr != -1 && FD_ISSET(proc->p_stderr, rd))
		{
			FD_CLR(proc->p_stderr, rd);
			handle_filedesc(proc, &proc->p_stderr,
					EXEC_PROMPT_LIST, EXEC_ERRORS_LIST);
		}

		if (limit && proc->counter >= limit)
			ignore_process(proc->index);
	}

	/* Clean up any (now) dead processes */
	cleanup_dead_processes();
}
コード例 #25
0
ファイル: userlist.c プロジェクト: nikolatesla/BitchXMPP
void sync_shitlist(ShitList *added, int type)
{
ChannelList *chan;
NickList *nick;
int i;
char tmp[BIG_BUFFER_SIZE+1];
char *check;
	
	for (i = 0; i < server_list_size(); i ++)
	{
		for (chan = get_server_channels(i); chan; chan = chan->next)
		{
			for (nick = next_nicklist(chan, NULL); nick; nick = next_nicklist(chan, nick))
			{
				check = clear_server_flags(nick->host);
				sprintf(tmp, "%s!%s", nick->nick, check);
				if (wild_match(added->filter, tmp))
				{
					if (type) 
					{
						nick->shitlist = added;
						check_auto(chan->channel, nick, chan);
					}
					else
					{
						BanList *b = NULL;
						nick->shitlist = NULL;
						if ((b = ban_is_on_channel(tmp, chan)) && !eban_is_on_channel(tmp, chan))
							add_mode(chan, "b", 0, b->ban, NULL, get_int_var(NUM_BANMODES_VAR));
					}
				}
			}
			flush_mode_all(chan);
		}
	}
}
コード例 #26
0
ファイル: log.c プロジェクト: Nicholas-S/xaric
void do_log(int flag, char *logfile, FILE ** fp)
{
    time_t t = time(NULL);

    if (flag) {
	if (*fp)
	    say("Logging is already on");
	else {
	    if (!logfile)
		return;
	    if (!(logfile = expand_twiddle(logfile))) {
		say("SET LOGFILE: No such user");
		return;
	    }

	    if ((*fp = fopen(logfile, get_int_var(APPEND_LOG_VAR) ? "a" : "w")) != NULL) {
		say("Starting logfile %s", logfile);
		chmod(logfile, S_IREAD | S_IWRITE);
		fprintf(*fp, "IRC log started %.24s\n", ctime(&t));
		fflush(*fp);
	    } else {
		say("Couldn't open logfile %s: %s", logfile, strerror(errno));
		*fp = NULL;
	    }
	    new_free(&logfile);
	}
    } else {
	if (*fp) {
	    fprintf(*fp, "IRC log ended %.24s\n", ctime(&t));
	    fflush(*fp);
	    fclose(*fp);
	    *fp = NULL;
	    say("Logfile ended");
	}
    }
}
コード例 #27
0
ファイル: main.c プロジェクト: jnbek/TekNap
void io (const char *what)
{
	static	int	first_time = 1;
		long	clock_timeout = 0, 
			timer_timeout = 0,
			real_timeout = 0; 
static	struct	timeval my_now,
			my_timer,
			*time_ptr = &my_timer;

	int		hold_over,
			rc;
	fd_set		rd, 
			wd;

	get_time(&my_now);
	now = my_now.tv_sec;
	
	/* CHECK FOR CPU SAVER MODE */
	if (!cpu_saver && get_int_var(CPU_SAVER_AFTER_VAR))
		if (now - idle_time > get_int_var(CPU_SAVER_AFTER_VAR) * 60)
			cpu_saver_on(0, NULL);

	rd = readables;
	wd = writables;
	FD_ZERO(&wd);
	FD_ZERO(&rd);

	set_screens(&rd, &wd);
	set_server_bits(&rd, &wd);
	set_process_bits(&rd);
	set_socket_read(&rd, &wd);
	icmp_sockets(&rd, &wd);
	
#if defined(WANT_THREAD)
#ifdef WANT_NSLOOKUP
	set_dns_output_fd(&rd);
#endif
#ifdef WANT_PTEST
	set_ptest_output_fd(&rd);
#endif
#ifdef WANT_MP3PLAYER
	set_mp3_output_fd(&rd);
#endif
	
# if defined(GTK)
	if (tgtk_okay())
		tgtk_set_output_fd(&rd);
# endif
#endif
	clock_timeout = (timeout_select - (my_now.tv_sec % timeout_select)) * 1000;
	if (cpu_saver && get_int_var(CPU_SAVER_EVERY_VAR))
		clock_timeout += (get_int_var(CPU_SAVER_EVERY_VAR) - 1) * 60000;

	timer_timeout = TimerTimeout();

	if ((hold_over = unhold_windows()))
		real_timeout = 0;
	else if (timer_timeout <= clock_timeout)
		real_timeout = timer_timeout;
	else
		real_timeout = clock_timeout;

	if (real_timeout == -1)
		time_ptr = NULL;
	else
	{
		time_ptr->tv_sec = real_timeout / 1000;
		time_ptr->tv_usec = ((real_timeout % 1000) * 1000);
	}
	
	/* GO AHEAD AND WAIT FOR SOME DATA TO COME IN */
	switch ((rc = new_select(&rd, &wd, time_ptr)))
	{
		case 0:
			break;
		case -1:
		{
			/* if we just got a sigint */
			first_time = 0;
			if (cntl_c_hit)
				edit_char('\003');
			else if (errno && errno != EINTR)
			{
				int ii = 0;
				fd_set rd1, wd1;
				char ii_buff_r[500];
				char ii_buff_w[500];
				int ii_r[FD_SETSIZE];
				int ii_w[FD_SETSIZE];
				yell("Select failed with [%d:%s]", errno, strerror(errno));
				/* Reseed fd_sets so we can dig further */
				yell("Packing fd_sets... Dump of fd's set in fd_set");
				ii_buff_r[0] = '\0';
				ii_buff_w[0] = '\0';
				for (ii = 0; ii < FD_SETSIZE; ii++) {
					ii_r[ii] = 0;
					ii_w[ii] = 0;
				}
				FD_ZERO(&wd1);
				FD_ZERO(&rd1);
				set_screens(&rd1, &wd1);
				set_server_bits(&rd1, &wd1);
				set_process_bits(&rd1);
				set_socket_read(&rd1, &wd1);
				icmp_sockets(&rd1, &wd1);
#if defined(WANT_THREAD)
#ifdef WANT_NSLOOKUP
				set_dns_output_fd(&rd1);
#endif
#ifdef WANT_PTEST
				set_ptest_output_fd(&rd1);
#endif
#ifdef WANT_MP3PLAYER
				set_mp3_output_fd(&rd1);
#endif
	
# if defined(GTK)
	if (tgtk_okay())
				tgtk_set_output_fd(&rd1);
# endif
#endif
				for (ii = 0; ii <= global_max_fd; ii++) {
					fd_set rblah, wblah;
					memcpy(&rblah, &rd1, sizeof(fd_set));
					FD_SET(ii, &rblah);
					if (memcmp(&rblah, &rd1, sizeof(fd_set)) == 0) {
						char blahblah[20];
						sprintf(blahblah, "%d ", ii);
						strcat(ii_buff_r, blahblah);
						ii_r[ii] = 1;
					}
					memcpy(&wblah, &wd1, sizeof(fd_set));
					FD_SET(ii, &wblah);
					if (memcmp(&wblah, &wd1, sizeof(fd_set)) == 0) {
						char blahblah[20];
						yell("blah");
						sprintf(blahblah, "%d ", ii);
						strcat(ii_buff_w, blahblah);
						ii_w[ii] = 1;
					}
				}
				yell("Read fd's in set: %s", (ii_buff_r[0] == '\0') ? "<NONE>" : ii_buff_r);
				for (ii = 0; ii <= global_max_fd; ii++) {
					if (ii_r[ii] == 1) {
						struct stat st;
						if (fstat(ii, &st) == -1) {
							yell("READ FD %d is causing the select failure!", ii);
						}
						else {
							if (S_ISSOCK(st.st_mode))
								yell("READ FD %d is a socket!", ii);
							else if (S_ISREG(st.st_mode))
								yell("READ FD %d is a regular file!", ii);
							else if (S_ISFIFO(st.st_mode))
								yell("READ FD %d is a FIFO!", ii);
							else ;
						}
					}
				}
				yell("Write fd's in set: %s", (ii_buff_w[0] == '\0') ? "<NONE>" : ii_buff_w);
				for (ii = 0; ii <= global_max_fd; ii++) {
					if (ii_w[ii] == 1) {
						struct stat st;
						if (fstat(ii, &st) == -1) {
							yell("WRITE FD %d is causing the select failure!", ii);
						}
						else {
							if (S_ISSOCK(st.st_mode))
								yell("WRITE FD %d is a socket!", ii);
							else if (S_ISREG(st.st_mode))
								yell("WRITE FD %d is a regular file!", ii);
							else if (S_ISFIFO(st.st_mode))
								yell("WRITE FD %d is a FIFO!", ii);
							else ;
						}
					}
				}
				sleep(10);
			}
			else 
			{
#if 0
				yell("errno 0 rc = -1, maybe it'll go away");
				sleep(10);
#endif
			}
			break;

		}

		/* we got something on one of the descriptors */
		default:
		{
			cntl_c_hit = 0;
			now = time(NULL);
			make_window_current(NULL);
			do_screens(&rd);
			check_icmpresult(&rd, &wd);
#if defined(WANT_THREAD)
#ifdef WANT_NSLOOKUP
			dns_check(&rd);
#endif
#ifdef WANT_PTEST
			ptest_check(&rd);
#endif
#ifdef WANT_MP3PLAYER
			mp3_check(&rd);
#endif
# if defined(GTK)
			if (tgtk_okay())
				tgtk_check(&rd);
# endif
#endif
			do_server(&rd, &wd);
			do_processes(&rd);
			scan_sockets(&rd, &wd);
			clean_sockets();
			break;
		} 
	}

	now = time(NULL);
	ExecuteTimers();

        get_child_exit(-1);
	if (update_refresh)
	{
		update_refresh = 0;
		refresh_screen(0, NULL);
	}
	if (!hold_over)
		cursor_to_input();


	if (update_clock(RESET_TIME))
	{
		if (get_int_var(CLOCK_VAR))
		{
			update_all_status(current_window, NULL, 0);
			cursor_to_input();
		}
		clean_queue(get_int_var(TRANSFER_TIMEOUT_VAR)); /* timeout if send time is greater than 5 minutes */
	}

	/* (set in term.c) -- we should redraw the screen here */
	if (need_redraw)
		refresh_screen(0, NULL);
#ifdef WANT_THREAD
	if (scan_done)
		scan_is_done();	
#endif
	alloca(0);
	return;
}
コード例 #28
0
ファイル: help.c プロジェクト: carriercomm/epic5-1
/*
 * help_me:  The big one.  The help procedure that handles working out
 * what was actually requested, sets up the paused topic list if it is
 * needed, does pretty much all the hard work.
 */
static	void	help_me (char *topics, char *args)
{
    char *	ptr;
    glob_t	g;
    int	entries = 0,
        cnt,
        i,
        cols;
    Stat	stat_buf;
    char	path[BIG_BUFFER_SIZE+1];
    int	help_paused_first_call = 0;
    char *	help_paused_path = (char *) 0;
    char *	help_paused_name = (char *) 0;
    char *	temp;
    char	tmp[BIG_BUFFER_SIZE+1];
    char	buffer[BIG_BUFFER_SIZE+1];
    char *	pattern = NULL;

    strlcpy(help_topic_list, topics, sizeof help_topic_list);
    ptr = get_string_var(HELP_PATH_VAR);

    snprintf(path, sizeof path, "%s/%s", ptr, topics);
    for (ptr = path; (ptr = strchr(ptr, ' '));)
        *ptr = '/';

    /*
     * first we check access to the help dir, whinge if we can't, then
     * work out we need to ask them for more help, else we check the
     * args list, and do the stuff
     */
    if (help_show_directory)
    {
        help_show_paused_topic(paused_topic, empty_string);
        help_show_directory = 0;
    }

    finished_help_paging = 0;
    if (access(path, R_OK|X_OK))
    {
        help_put_it(no_help, "*** Cannot access help directory!");
        set_help_screen((Screen *) 0);
        return;
    }

    this_arg = next_arg(args, &args);
    if (!this_arg && *help_topic_list && get_int_var(HELP_PROMPT_VAR))
    {
        if ((temp = strrchr(help_topic_list, ' ')) != NULL)
            *temp = '\0';
        else
            *help_topic_list = '\0';

        snprintf(tmp, sizeof tmp, "%s%sHelp? ", help_topic_list, *help_topic_list ? " " : empty_string);

        if (!dumb_mode)
            add_wait_prompt(tmp, help_me, help_topic_list, WAIT_PROMPT_LINE, 1);
        return;
    }

    if (!this_arg)
    {
        set_help_screen((Screen *) 0);
        return;
    }

    create_help_window();

    if (!help_window)
        return;

    /*
     * This is just a bogus while loop which is intended to allow
     * the user to do '/help alias expressions' without having to
     * include a slash inbetween the topic and subtopic.
     *
     * If all goes well, we 'break' at the bottom of the loop.
     */
    while (this_arg)
    {
        entries = 0;

        if (!*this_arg)
            help_topic(path, NULL);

        if (strcmp(this_arg, "?") == 0)
        {
            this_arg = empty_string;
            if (!dont_pause_topic)
                dont_pause_topic = 1;
        }

        /*
         * entry_size is set to the width of the longest help topic
         * (adjusted for compression extensions, of course.)
         */
        entry_size = 0;

        /*
         * Gather up the names of the files in the help directory.
         */
        {
            size_t size;
#ifndef HAVE_FCHDIR
            char 	opath[MAXPATHLEN + 1];
            getcwd(opath, MAXPATHLEN);
#else
            int 	cwd = open(".", O_RDONLY);
#endif

            size = strlen(path) + 2 + strlen(this_arg) + 3;

            chdir(path);
            pattern = alloca(size);
            snprintf(pattern, size, "%s*", this_arg);
#ifdef GLOB_INSENSITIVE
            bsd_glob(pattern, GLOB_INSENSITIVE, NULL, &g);
#else
            bsd_glob(pattern, 0, NULL, &g);
#endif

#ifndef HAVE_FCHDIR
            chdir(opath);
#else
            fchdir(cwd);
            close(cwd);
#endif
        }

        for (i = 0; i < g.gl_matchc; i++)
        {
            char	*tmp2 = g.gl_pathv[i];
            int 	len = strlen(tmp2);

            if (!end_strcmp(tmp2, ".gz", 3))
                len -= 3;
            entry_size = (len > entry_size) ? len : entry_size;
        }

        /*
         * Right here we need to check for an 'exact match'.
         * An 'exact match' would be sitting in gl_pathv[0],
         * and it is 'exact' if it is identical to what we are
         * looking for, or if it is the same except that it has
         * a compression extension on it
         */
        if (g.gl_matchc > 1)
        {
            char *str1 = g.gl_pathv[0];
            const char *str2 = this_arg;
            int len1 = strlen(str1);
            int len2 = strlen(str2);


            if (len1 == len2 && !my_stricmp(str1, str2))
                entries = 1;
            else if (len1 - 3 == len2 && !my_strnicmp(str1, str2, len2) && !end_strcmp(str1, ".gz", 3))
                entries = 1;
            else if (len1 - 2 == len2 && !my_strnicmp(str1, str2, len2) && !end_strcmp(str1, ".Z", 2))
                entries = 1;
            else if (len1 - 2 == len2 && !my_strnicmp(str1, str2, len2) && !end_strcmp(str1, ".z", 2))
                entries = 1;
        }

        if (!*help_topic_list)
            dont_pause_topic = 1;

        /* reformatted */
        /*
         * entries: -1 means something really died, 0 means there
         * was no help, 1, means it wasn't a directory, and so to
         * show the help file, and the default means to add the
         * stuff to the paused topic list..
         */
        if (!entries)
            entries = g.gl_matchc;

        switch (entries)
        {
        case -1:
        {
            help_put_it(no_help, "*** Error during help function: %s", strerror(errno));
            set_help_screen(NULL);
            if (help_paused_first_call)
            {
                help_topic(help_paused_path, help_paused_name);
                help_paused_first_call = 0;
                new_free(&help_paused_path);
                new_free(&help_paused_name);
            }
            message_from(NULL, LOG_CRAP);
            return;
        }
        case 0:
        {
            help_put_it(this_arg, "*** No help available on %s: Use ? for list of topics", this_arg);
            if (!get_int_var(HELP_PROMPT_VAR))
            {
                set_help_screen(NULL);
                break;
            }
            snprintf(tmp, sizeof tmp, "%s%sHelp? ", help_topic_list, *help_topic_list ? " " : empty_string);
            if (!dumb_mode)
                add_wait_prompt(tmp, help_me, help_topic_list, WAIT_PROMPT_LINE, 1);

            if (help_paused_first_call)
            {
                help_topic(help_paused_path, help_paused_name);
                help_paused_first_call = 0;
                new_free(&help_paused_path);
                new_free(&help_paused_name);
            }

            break;
        }
        case 1:
        {
            snprintf(tmp, sizeof tmp, "%s/%s", path, g.gl_pathv[0]);
            stat(tmp, &stat_buf);
            if (stat_buf.st_mode & S_IFDIR)
            {
                strlcpy(path, tmp, sizeof path);
                if (*help_topic_list)
                    strlcat(help_topic_list, " ", sizeof help_topic_list);

                strlcat(help_topic_list, g.gl_pathv[0], sizeof help_topic_list);

                if (!(this_arg = next_arg(args, &args)))
                {
                    help_paused_first_call = 1;
                    malloc_strcpy(&help_paused_path, path);
                    malloc_strcpy(&help_paused_name, g.gl_pathv[0]);
                    dont_pause_topic = -1;
                    this_arg = "?";
                }
                bsd_globfree(&g);
                continue;
            }
            else
            {
                help_topic(path, g.gl_pathv[0]);
                finished_help_paging = 0;
                break;
            }
        }
        default:
        {
            help_show_directory = 1;
            strlcpy(paused_topic, help_topic_list, sizeof paused_topic);
            help_pause_add_line("*** %s choices:", help_topic_list);
            entry_size += 2;
            cols = (current_term->TI_cols - 10) / entry_size;

            strlcpy(buffer, empty_string, sizeof(buffer));
            cnt = 0;

            for (i = 0; i < entries; i++)
            {
                if (!end_strcmp(g.gl_pathv[i], ".gz", 3))
                    chop(g.gl_pathv[i], 3);
                strlcat(buffer, g.gl_pathv[i], sizeof buffer);

                /*
                 * Since we already know how many columns each
                 * line will contain, we check to see if we have
                 * accumulated that many entries.  If we have, we
                 * output the line to the screen.
                 */
                if (++cnt == cols)
                {
                    help_pause_add_line("%s", buffer);
                    *buffer = 0;
                    cnt = 0;
                }

                /*
                 * If we have not finished this line, then we have
                 * to pad the name length out to the expected width.
                 * 'entry_size' is the column width.  We also have
                 * do adjust for compression extension.
                 */
                else
                    strextend(buffer, ' ', entry_size - strlen(g.gl_pathv[i]));
            }

            help_pause_add_line("%s", buffer);
            if (help_paused_first_call)
            {
                help_topic(help_paused_path, help_paused_name);
                help_paused_first_call = 0;
                new_free(&help_paused_path);
                new_free(&help_paused_name);
            }
            if (dont_pause_topic == 1)
            {
                help_show_paused_topic(paused_topic, empty_string);
                help_show_directory = 0;
            }
            break;
        }
        }
        /* end of reformatting */


        bsd_globfree(&g);
        break;
    }

    /*
     * This one is for when there was never a topic and the prompt
     * never got a topic..  and help_screen was never reset..
     * phone, jan 1993.
     */
    if (!*help_topic_list && finished_help_paging)
        set_help_screen((Screen *) 0);

    message_from(NULL, LOG_CRAP);
}
コード例 #29
0
ファイル: help.c プロジェクト: carriercomm/epic5-1
/*
 * help_prompt: The main procedure called to display the help file
 * currently being accessed.  Using add_wait_prompt(), it sets it
 * self up to be recalled when the next page is asked for.   If
 * called when we have finished paging the help file, we exit, as
 * there is nothing left to show.  If line is 'q' or 'Q', exit the
 * help pager, clean up, etc..  If all is cool for now, we call
 * show_help, and either if its finished, exit, or prompt for the
 * next page.   From here, if we've finished the help page, and
 * doing help prompts, prompt for the help..
 */
static	void	help_prompt (char *name, char *line)
{
    if (finished_help_paging)
    {
        if (*paused_topic)
            help_show_paused_topic(paused_topic, empty_string);
        return;
    }

    if (line && toupper(*line) == 'Q')
    {
        finished_help_paging = 1;
        fclose(help_fp);
        help_fp = NULL;
    }

    if (show_help(help_window, name))
    {
        if (dumb_mode)
            help_prompt(name, NULL);
        else
            add_wait_prompt("*** Hit any key for more, 'q' to quit ***",
                            help_prompt, name, WAIT_PROMPT_KEY, 1);
    }
    else
    {
        finished_help_paging = 1;
        if (help_fp)
            fclose(help_fp);
        help_fp = NULL;

        if (help_show_directory)
        {
            if (get_int_var(HELP_PAGER_VAR))
            {
                if (dumb_mode)
                    help_show_paused_topic(name, empty_string);
                else
                    add_wait_prompt("*** Hit any key to end ***",
                                    help_show_paused_topic, paused_topic,
                                    WAIT_PROMPT_KEY, 1);
            }
            else
            {
                help_show_paused_topic(paused_topic, empty_string);
                set_help_screen((Screen *) 0);
            }
            help_show_directory = 0;
            return;
        }
    }

    if (finished_help_paging)
    {
        if (get_int_var(HELP_PROMPT_VAR))
        {
            char	tmp[BIG_BUFFER_SIZE + 1];

            snprintf(tmp, sizeof tmp, "%s%sHelp? ", help_topic_list,
                     *help_topic_list ? " " : empty_string);
            if (!dumb_mode)
                add_wait_prompt(tmp, help_me, help_topic_list,
                                WAIT_PROMPT_LINE, 1);
        }
        else
        {
            if (*paused_topic)
                help_show_paused_topic(paused_topic, empty_string);
#if 0
            set_help_screen((Screen *) 0);
#endif
        }
    }
}
コード例 #30
0
ファイル: send.c プロジェクト: jnbek/TekNap
void napfile_read(int snum)
{
GetFile *gf;
int rc;
SocketList *s;
	s = get_socket(snum);
	if (!(gf = (GetFile *)get_socketinfo(snum)))
	{
		unsigned char buff[2*BIG_BUFFER_SIZE+1];
		unsigned char fbuff[2*BIG_BUFFER_SIZE+1];
		char *nick, *filename, *args;
		
		alarm(10);
		if ((rc = read(snum, buff, 2 * BIG_BUFFER_SIZE)) < 0)
		{
			alarm(0);
			nap_finished_file(snum, PREMATURE_FINISH);
			return;
		}
		alarm(0);
		buff[rc] = 0;
		args = &buff[0];
		if (!*args || !strcmp(buff, "FILE NOT FOUND") || 
			!strcmp(buff, "INVALID REQUEST") || 
			!strcmp(buff, "FILE NOT REQUESTED"))
		{
			say("Error in napfile_read(%d/%s) %s", snum, (rc == 0) ? strerror(errno) : "", *args ? args : "unknown read");
			nap_finished_file(snum, PREMATURE_FINISH);
			return;
		}

		nick = next_arg(args, &args);
		if ((filename = new_next_arg(args, &args)) && *filename)
		{
			strcpy(fbuff, filename);
			convertnap_unix(fbuff);
		}
		if (!nick || !filename || !*filename || !args || !*args
			|| !(gf = find_in_getfile(0, nick, NULL, fbuff, 0, NAP_UPLOAD))
			|| (gf->write == -1))
		{
			memset(buff, 0, 80);
			if (!gf)
				sprintf(buff, "INVALID REQUEST");

			else
			{
				sprintf(buff, "FILE NOT FOUND");
				break_from_list((List **)&transfer_struct, (List *)gf);
				gf->socket = snum;
				if (gf->write == -1)
				{
					send_ncommand(CMDS_REMOVEFILE, "%s", fbuff);
					say("Unable to open [%s]", fbuff);
				}
				else
				{
					close(gf->write);
					gf->write = -1;
				}
			}
			write(snum, buff, strlen(buff));
			nap_finished_file(snum, PREMATURE_FINISH);
			return;
		}
		gf->resume = my_atol(next_arg(args, &args));
		if (gf->resume >= gf->filesize)
		{
			break_from_list((List **)&transfer_struct, (List *)gf);
			close(gf->write);
			gf->write = -1;
			nap_finished_file(snum, PREMATURE_FINISH);
			return;
		}
		if (gf->socket != -1)
		{
			put_it("ERROR gf->socket != -1 %d %s %s", snum, nick, filename);
			break_from_list((List **)&transfer_struct, (List *)gf);
			close(gf->write);
			gf->write = -1;
			nap_finished_file(snum, PREMATURE_FINISH);
			return;
		}
		gf->socket = snum;
		lseek(gf->write, SEEK_SET, gf->resume);
		set_socketinfo(snum, gf);
		memset(buff, 0, 80);
		sprintf(buff, "%lu", gf->filesize);
		write(snum, buff, strlen(buff));
		s->func_write = s->func_read;
		s->is_write = s->is_read;
		if (do_hook(NAPSEND_LIST, "%s %s %lu \"%s\"", gf->resume ? "RESUME":"SEND", gf->nick, gf->filesize, gf->filename) && !get_int_var(QUIET_SENDS_VAR))
			put_it("* %sing file to %s [%s] (%s)", gf->resume ? "Resum" : "Send", gf->nick, base_name(gf->filename), longcomma(gf->filesize));
		set_non_blocking(snum);
		build_status(current_window, NULL, 0);
		send_ncommand(CMDS_UPDATE_SEND1, NULL);
		return;
	} else if (!gf->starttime)
		gf->starttime = now;
	s->func_write = s->func_read = napfile_sendfile;
	napfile_sendfile(snum);
}