コード例 #1
0
ファイル: clock.c プロジェクト: Cloudxtreme/epic5
static void	reset_metric_clock (void)
{
static	long	last_milliday;
	double	metric_time;
	long	current_milliday;

	get_metric_time(&metric_time);
	current_milliday = (long)metric_time;

	snprintf(current_clock, sizeof current_clock, 
			"%ld", (long)metric_time);

	if (current_milliday != last_milliday)
	{
		int	old_server = from_server;
		int	idle_milliday;

		idle_milliday = (int)(timeval_to_metric(&idle_time).mt_mdays);
		from_server = primary_server;
		do_hook(TIMER_LIST, "%03ld", current_milliday);
		do_hook(IDLE_LIST, "%ld", 
			(long)(idle_milliday - current_milliday));
		from_server = old_server;
		last_milliday = current_milliday;
	}
}
コード例 #2
0
ファイル: funny.c プロジェクト: BitchX/BitchX1.1
void funny_mode(char *from, char **ArgList)
{
	char	*mode, *channel;
	ChannelList *chan = NULL;
		
	if (!ArgList[0]) return;

	channel = ArgList[0];
	mode = ArgList[1];
	PasteArgs(ArgList, 1);

	if((channel && in_join_list(channel, from_server)) || get_chan_from_join_list(from_server))
	{
		if (!channel)
			channel = get_chan_from_join_list(from_server);
		update_channel_mode(from, channel, from_server, mode, chan);
		update_all_status(current_window, NULL, 0);
		got_info(channel, from_server, GOTMODE);
	}
	else
	{
		if (channel)
		{
			set_display_target(channel, LOG_CRAP);
			if (do_hook(current_numeric, "%s %s %s", from, channel, mode))
				put_it("%s", convert_output_format(fget_string_var(FORMAT_MODE_CHANNEL_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, *FromUserHost ? FromUserHost:"ÿ", channel, mode));
			reset_display_target();
		}
		else
		{
			if (do_hook(current_numeric, "%s %s", from, mode))
				put_it("%s", convert_output_format(fget_string_var(FORMAT_MODE_CHANNEL_FSET), "%s %s %s %s", update_clock(GET_TIME), from, *FromUserHost ? FromUserHost:"ÿ", mode));
		}
	}
}
コード例 #3
0
ファイル: hash.c プロジェクト: BitchX/BitchX-SVN
int show_wholeft_hashtable(WhowasWrapList *cptr, time_t ltime, int *total, int *hook, char *list)
{
        int count, count2;
        WhowasList *ptr;

        for (count = 0; count < WHOWASLIST_HASHSIZE; count++) 
        {
		
		if (cptr->NickListTable[count].links == 0)
			continue;
                for (ptr = (WhowasList *) cptr->NickListTable[count].list, count2 = 1; ptr; count2++, ptr = ptr->next) 
		{
			if (ptr->server1/* && ptr->server2*/)
			{
				if (!(*total)++ && (*hook = do_hook(WHOLEFT_HEADER_LIST, "%s %s %s %s %s %s", "Nick", "Host", "Channel", "Time", "Server", "Server")))
					put_it("%s", convert_output_format(fget_string_var(FORMAT_WHOLEFT_HEADER_FSET), NULL));
				if (do_hook(WHOLEFT_LIST, "%s %s %s %ld %s %s", ptr->nicklist->nick, ptr->nicklist->host, ptr->channel, ltime-ptr->time, ptr->server1?ptr->server1:"Unknown", ptr->server2?ptr->server2:"Unknown"))
					put_it("%s", convert_output_format(fget_string_var(FORMAT_WHOLEFT_USER_FSET), "%s %s %s %l %s", ptr->nicklist->nick, ptr->nicklist->host, ptr->channel, (long)ltime-ptr->time, ptr->server1?ptr->server1:empty_string));
			}
		}
        }
	if (*total)
		do_hook(WHOLEFT_FOOTER_LIST, "%s", "End of WhoLeft");
	return *hook;
}
コード例 #4
0
ファイル: chelp.c プロジェクト: nikolatesla/BitchXMPP
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;
}
コード例 #5
0
ファイル: main.c プロジェクト: jnbek/TekNap
/* update_clock: figUres out the current time and returns it in a nice format */
char	*update_clock(int flag)
{
	static	int		min = -1,
				hour = -1;
	static	time_t		last_minute = -1;
	time_t			idlet;
	static struct tm	time_val;
		time_t		hideous;
		int		new_minute = 0;
		int		new_hour = 0;

	hideous = now;

#if !defined(NO_CHEATING)
	if (hideous / 60 > last_minute)
	{
		last_minute = hideous / 60;
		time_val = *localtime(&hideous);
	}
#else
	time_val = *localtime(&hideous);
#endif


	if (flag == RESET_TIME || time_val.tm_min != min || time_val.tm_hour != hour)
	{
		if (time_format)	/* XXXX Bogus XXXX */
			strftime(time_str, 60, time_format, &time_val);
		else if (get_int_var(CLOCK_24HOUR_VAR))
			strftime(time_str, 60, strftime_24hour, &time_val);
		else
			strftime(time_str, 60, strftime_12hour, &time_val);

		lower(time_str);
		if ((time_val.tm_min != min) || (time_val.tm_hour != hour))
		{
			if (time_val.tm_hour != hour)
				new_hour = 1;
			new_minute = 1;
			hour = time_val.tm_hour;
			min = time_val.tm_min;
			do_hook(TIMER_LIST, "%02d:%02d", hour, min);
			if (min == 0 || new_hour)
				do_hook(TIMER_HOUR_LIST, "%02d:%02d", hour, min);
			idlet = (hideous - idle_time) / 60L;
			do_hook(IDLE_LIST, "%lu", (unsigned long)idlet);
		}
		if (!((hideous - start_time) % 20))
			check_serverlag(-1);
		if (flag != RESET_TIME || new_minute)
			return time_str;
		else
			return NULL;
	}
	if (flag == GET_TIME)
		return time_str;
	else
		return NULL;
}
コード例 #6
0
ファイル: notice.c プロジェクト: BitchX/BitchX1.1
static	void parse_server_notice(char *from, char *line)
{
	int	flag = 0;
	int	up_status = 0;
const	char	*f;	
				
	f = from;
	if (!f || !*f)
		if (!(f = get_server_itsname(from_server)))
			f = get_server_name(from_server);
			
	if (*line != '*'  && *line != '#' && strncmp(line, "MOTD ", 4))
		flag = 1;
	else
		flag = 0;

	if (do_hook(SERVER_NOTICE_LIST, flag?"%s *** %s":"%s %s", f, line))
	{
#ifdef WANT_OPERVIEW
		if (handle_oper_vision(f, line, &up_status))
			reset_display_target();
		else 
#endif
		if (strstr(line, "***"))
		{
			set_display_target(NULL, LOG_SNOTE);
#ifdef WANT_OPERVIEW
			if (get_int_var(OV_VAR) && !(get_server_ircop_flags(from_server) & SERVER_CRAP))
				goto done1;
#endif
			if (do_hook(SERVER_NOTICE_LIST, flag ? "%s *** %s" : "%s %s", f, line))
			{
				char *for_;
				for_ = next_arg(line,&line);
				serversay(1, from_server, "%s", 
				convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FSET), "%s %s %s", update_clock(GET_TIME), 
				f, stripansicodes(line)));
				add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, line);
			}
		}
		else
		{
			set_display_target(NULL, LOG_SNOTE);
#ifdef WANT_OPERVIEW
			if (get_int_var(OV_VAR) && !(get_server_ircop_flags(from_server) & SERVER_CRAP))
				goto done1;
#endif
			if (do_hook(SERVER_NOTICE_LIST, flag ? "%s *** %s" : "%s %s", f, line))
				serversay(1, from_server, "%s", 
				convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FSET), "%s %s %s", update_clock(GET_TIME), 
				f, stripansicodes(line)));
			add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, line);
		}
	}
	if (up_status)
		update_all_status(current_window, NULL, 0);
done1:
	reset_display_target();
}
コード例 #7
0
ファイル: ctcp.c プロジェクト: srfrog/epic5
/*
 * This is no longer directly sends information to its target.
 * As part of a larger attempt to consolidate all data transmission
 * into send_text, this function was modified so as to use send_text().
 * This function can send both direct CTCP requests, as well as the
 * appropriate CTCP replies.  By its use of send_text(), it can send
 * CTCPs to DCC CHAT and irc nickname peers, and handles encryption
 * transparantly.  This greatly reduces the logic, complexity, and
 * possibility for error in this function.
 */
void	send_ctcp (int type, const char *to, int datatag, const char *format, ...)
{
	char 	putbuf [BIG_BUFFER_SIZE + 1],
		*putbuf2;
	int	len;
	int	l;
	const char *pb;
	char	*extra = NULL;

	/* Make sure that the final \001 doesnt get truncated */
	if ((len = IRCD_BUFFER_SIZE - (12 + strlen(to))) <= 0)
		return;				/* Whatever. */
	putbuf2 = alloca(len);

	l = message_from(to, LEVEL_CTCP);
	if (format)
	{
		va_list args;
		va_start(args, format);
		vsnprintf(putbuf, BIG_BUFFER_SIZE, format, args);
		va_end(args);

		pb = outbound_recode(to, from_server, putbuf, &extra);

		do_hook(SEND_CTCP_LIST, "%s %s %s %s", 
				ctcp_type[type], to, 
				ctcp_cmd[datatag].name, pb);
		snprintf(putbuf2, len, "%c%s %s%c", 
				CTCP_DELIM_CHAR, 
				ctcp_cmd[datatag].name, pb, 
				CTCP_DELIM_CHAR);

		new_free(&extra);
	}
	else
	{
		do_hook(SEND_CTCP_LIST, "%s %s %s", 
				ctcp_type[type], to, 
				ctcp_cmd[datatag].name);
		snprintf(putbuf2, len, "%c%s%c", 
				CTCP_DELIM_CHAR, 
				ctcp_cmd[datatag].name, 
				CTCP_DELIM_CHAR);
	}

	/* XXX - Ugh.  What a hack. */
	putbuf2[len - 2] = CTCP_DELIM_CHAR;
	putbuf2[len - 1] = 0;

	send_text(from_server, to, putbuf2, ctcp_type[type], 0, 1);
	pop_message_from(l);
}
コード例 #8
0
ファイル: audio.c プロジェクト: BitchX/BitchX-SVN
void report_header_error(int err)
{
char *s = NULL;
	switch (err) {
		case GETHDR_ERR: 
			s = "error reading mpeg bitstream. exiting.";
			break;
		case GETHDR_NS : 
			s = "this is a file in MPEG 2.5 format, which is not defined" \
			    "by ISO/MPEG. It is \"a special Fraunhofer format\"." \
			    "amp does not support this format. sorry.";
			break;
		case GETHDR_FL1: 
			s = "ISO/MPEG layer 1 is not supported by amp (yet).";
			break;
		case GETHDR_FF : 
			s = "free format bitstreams are not supported. sorry.";
			break;	
		case GETHDR_SYN: 
			s = "oops, we're out of sync.";
			break;
		case GETHDR_EOF: 
		default: 		; /* some stupid compilers need the semicolon */
	}	
	if (s)
		do_hook(MODULE_LIST, "AMP ERROR blip %s", s);
}
コード例 #9
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
static void p_part(char *from, char **ArgList)
{
    char *channel;

    if (!from || !*from)
	return;
    channel = ArgList[0];

    PasteArgs(ArgList, 1);
    message_from(channel, LOG_CRAP);
    in_on_who = 1;

    if ((check_ignore(from, FromUserHost, channel, IGNORE_PARTS | IGNORE_CRAP, NULL) != IGNORED) &&
	do_hook(LEAVE_LIST, "%s %s %s %s", from, channel, FromUserHost, ArgList[1] ? ArgList[1] : empty_str))
	put_it("%s",
	       convert_output_format(get_format(FORMAT_LEAVE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost,
				     channel, ArgList[1] ? ArgList[1] : empty_str));
    if (!my_stricmp(from, get_server_nickname(from_server))) {
	remove_channel(channel, from_server);
	remove_from_mode_list(channel, from_server);
	remove_from_join_list(channel, from_server);
	set_input_prompt(curr_scr_win, get_string_var(INPUT_PROMPT_VAR), 0);
    } else {
	remove_from_channel(channel, from, from_server, 0, NULL);
    }
    update_all_status(curr_scr_win, NULL, 0);
    update_input(UPDATE_ALL);
    message_from(NULL, LOG_CRAP);
    in_on_who = 0;
}
コード例 #10
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
/* in response to a TOPIC message from the server */
static void p_topic(char *from, char **ArgList)
{
    struct channel *tmp;

    if (!ArgList[1]) {
	fake();
	return;
    }
    tmp = lookup_channel(ArgList[0], from_server, CHAN_NOUNLINK);
    malloc_strcpy(&tmp->topic, ArgList[1]);
    if (check_ignore(from, FromUserHost, tmp->channel, IGNORE_TOPICS | IGNORE_CRAP, NULL) != IGNORED) {
	message_from(ArgList[0], LOG_CRAP);
	if (do_hook(TOPIC_LIST, "%s %s %s", from, ArgList[0], ArgList[1])) {
	    if (ArgList[1] && *ArgList[1]) {
		if (get_format(FORMAT_TOPIC_CHANGE_HEADER_FSET))
		    put_it("%s",
			   convert_output_format(get_format(FORMAT_TOPIC_CHANGE_HEADER_FSET), "%s %s %s %s", update_clock(GET_TIME),
						 from, ArgList[0], ArgList[1]));
		put_it("%s",
		       convert_output_format(get_format(FORMAT_TOPIC_CHANGE_FSET), "%s %s %s %s", update_clock(GET_TIME), from,
					     ArgList[0], ArgList[1]));
	    } else
		put_it("%s",
		       convert_output_format(get_format(FORMAT_TOPIC_UNSET_FSET), "%s %s %s", update_clock(GET_TIME), from,
					     ArgList[0]));
	}

	message_from(NULL, LOG_CRAP);
    }
    update_all_status(curr_scr_win, NULL, 0);
}
コード例 #11
0
ファイル: debug.c プロジェクト: BitchX/BitchX1.1
void	debugyell(const char *format, ...)
{
const char *save_from;
unsigned long save_level;
unsigned long old_alias_debug = alias_debug;
	alias_debug = 0;
	save_display_target(&save_from, &save_level);
	set_display_target(NULL, LOG_DEBUG);
	if (format)
	{
		char debugbuf[BIG_BUFFER_SIZE+1];
		va_list args;
		va_start (args, format);
		*debugbuf = 0;
		vsnprintf(debugbuf, BIG_BUFFER_SIZE, format, args);
		va_end(args);
		in_debug_yell = 1;
		if (*debugbuf && do_hook(DEBUG_LIST, "%s", debugbuf))
			put_echo(debugbuf);
		in_debug_yell = 0;
	}
	alias_debug = old_alias_debug;
	reset_display_target();
	restore_display_target(save_from, save_level);
}
コード例 #12
0
ファイル: help.c プロジェクト: carriercomm/epic5-1
static	void	help_put_it	(const char *topic, const char *format, ...)
{
    char putbuf[BIG_BUFFER_SIZE * 3 + 1];

    if (format)
    {
        va_list args;
        va_start (args, format);
        vsnprintf(putbuf, BIG_BUFFER_SIZE * 3, format, args);
        va_end(args);

        if (do_hook(HELP_LIST, "%s %s", topic, putbuf))
        {
            Window *old_to_window = to_window;

            /*
             * 'to_window' is of higher priority than who_level
             * so we don't have to mangle who_level to send the
             * output to the help window.
             */
            if (help_window)
                to_window = help_window;
            else
                to_window = current_window;
            add_to_screen(putbuf);
            to_window = old_to_window;
        }
    }
}
コード例 #13
0
LRESULT CALLBACK
hook_proc(int nCode, WPARAM wParam, LPARAM lParam) {
	char hook_type[64];
	pthread_t ga_server_thread;

	if(module_checked || app_hooked)
		return CallNextHookEx(gHook, nCode, wParam, lParam);

	if(hook_app() < 0)
		return CallNextHookEx(gHook, nCode, wParam, lParam);
	
	// identified the executable: initialize once

	if(do_hook(hook_type, sizeof(hook_type)) < 0) {
		ga_error("hook_proc: hook failed.\n");
		return CallNextHookEx(gHook, nCode, wParam, lParam);
	}
	
	// SDL: override controller
	if(strcasecmp(hook_type, "sdl") == 0) {
		sdl12_mapinit();
		ctrl_server_setreplay(sdl_hook_replay_callback);
		no_default_controller = 1;
		ga_error("hook_proc: sdl - use native replayer.\n");
	}
	// start hook server
	if(pthread_create(&ga_server_thread, NULL, ga_server, NULL) != 0) {
		ga_error("cannot create GA server thread\n");
		return CallNextHookEx(gHook, nCode, wParam, lParam);
	}
	pthread_detach(ga_server_thread);
	
	return CallNextHookEx(gHook, nCode, wParam, lParam);
}
コード例 #14
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);
        }
コード例 #15
0
ファイル: mail.c プロジェクト: carriercomm/epic4
static void	update_mail_level2_mbox (void)
{
	Stat	stat_buf;
	int	status;
	int	count;

	status = poll_mbox_status(&stat_buf);

	/* There is no mail */
	if (status == 0)
	{
		mail_last_count = 0;
		if (mail_last_count_str)
			new_free(&mail_last_count_str);
	}

	/* If our count is invalid or there is new mail, recount mail */
	else if (mail_last_count == -1 || status == 2)
	{
	    /* So go ahead and recount the mails in mbox */
	    count = mbox_count();

	    if (count == 0)
		new_free(&mail_last_count_str);
	    else
	    {
		malloc_sprintf(&mail_last_count_str, "%d", count);

		/* 
		 * If there is new mail, or if we're switching to 
		 * /set mail 2, tell the user how many emails there are.
		 */
		if (count > mail_last_count)
		{
		    /* This is to avoid $0 in /on mail being wrong. */
		    if (mail_last_count < 0)
			mail_last_count = 0;

		    if (!mail_latch)
		    {
			mail_latch++;
			if (do_hook(MAIL_LIST, "%d %d", 
					count - mail_last_count, count))
			{
			    int lastlog_level = 
					set_lastlog_msg_level(LOG_CRAP);
			    say("You have new email.");
			    set_lastlog_msg_level(lastlog_level);
			}
			mail_latch--;
		    }
		}

		mbox_last_changed = stat_buf.st_ctime;
	        mbox_last_size = stat_buf.st_size;
		mail_last_count = count;
	    }
	}
}
コード例 #16
0
ファイル: funny.c プロジェクト: BitchX/BitchX1.1
void funny_print_widelist(void)
{
	int	i;
	char	buffer1[BIG_BUFFER_SIZE];
	char	buffer2[BIG_BUFFER_SIZE];
	char	*ptr;

	if (!wide_list)
		return;

	if (funny_flags & FUNNY_NAME)
		qsort((void *) wide_list, wl_elements, sizeof(WideList *),
		(int (*) (const void *, const void *)) funny_widelist_names);
	else if (funny_flags & FUNNY_USERS)
		qsort((void *) wide_list, wl_elements, sizeof(WideList *),
		(int (*) (const void *, const void *)) funny_widelist_users);

	set_display_target(NULL, LOG_CRAP);
	*buffer1 = '\0';
	for (i = 1; i < wl_elements; i++)
	{
		sprintf(buffer2, "%s(%d) ", wide_list[i]->channel,
				wide_list[i]->users);
		ptr = strchr(buffer1, '\0');
		if (strlen(buffer1) + strlen(buffer2) > current_term->TI_cols - 5)
		{
			if (do_hook(WIDELIST_LIST, "%s", buffer1))
				put_it("%s", convert_output_format(fget_string_var(FORMAT_WIDELIST_FSET), "%s %s", update_clock(GET_TIME), buffer1));
			*buffer1 = 0;
			strcat(buffer1, buffer2);
		}
		else
			strcpy(ptr, buffer2);
	}
	if (*buffer1 && do_hook(WIDELIST_LIST, "%s", buffer1))
		put_it("%s", convert_output_format(fget_string_var(FORMAT_WIDELIST_FSET), "%s %s", update_clock(GET_TIME), buffer1));

	reset_display_target();
	for (i = 0; i < wl_elements; i++)
	{
		new_free(&wide_list[i]->channel);
		new_free((char **)&wide_list[i]);
	}
	new_free((char **)&wide_list);
	wl_elements = wl_size = 0;
}
コード例 #17
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
static void p_silence(char *from, char **ArgList)
{
    char *target = ArgList[0];
    char *mag = target++;

    if (do_hook(SILENCE_LIST, "%c %s", *mag, target))
	put_it("%s", convert_output_format(get_format(FORMAT_SILENCE_FSET), "%s %c %s", update_clock(GET_TIME), *mag, target));
}
コード例 #18
0
ファイル: main.c プロジェクト: jnbek/TekNap
/* nap_exit: cleans up and leaves */
void nap_exit (int really_quit, char *reason, char *format, ...)
{
	if (dead == 1) {
		kill_all_threads();
		exit(1);
	}
	else if (dead == 2) {
		kill_all_threads();
		_exit(1);
	}
	else if (dead == 3) {
		kill_all_threads();
		kill(getpid(), SIGKILL);
	}
	dead++;

	set_lastlog_size(NULL, NULL, 0);
	set_history_size(NULL, NULL, 0);

	if (really_quit)
	{
		kill_all_threads();
		say("Signon time  :    %s", my_ctime(start_time));
		say("Signoff time :    %s", my_ctime(now));
		say("Total uptime :    %s", convert_time(now - start_time));
	}
	do_hook(EXIT_LIST, "%s", reason ? reason : empty_string);
	if (reason)
		say("%s", reason);

	close_all_servers();
	close_all_sockets();
	if (term_initialized)
	{
		cursor_to_input();
		term_cr();
		term_clear_to_eol();
		term_reset();
	}

	remove_bindings();
	clear_variables();
	delete_all_windows();
	destroy_call_stack();		
	write_unfinished_list();
	
	debug_cleanup();
	fprintf(stdout, "\r");
	fflush(stdout);
	if (really_quit)
		exit(0);

	kill_all_threads();
	my_signal(SIGABRT, SIG_DFL, 0);
	kill(getpid(), SIGABRT);
	kill(getpid(), SIGQUIT);
	exit(1);
}
コード例 #19
0
ファイル: audio.c プロジェクト: BitchX/BitchX-SVN
static void print_id3_tag(FILE *fp, char *buf)
{
	struct id3tag {
		char tag[3];
		char title[30];
		char artist[30];
		char album[30];
		char year[4];
		char comment[30];
		unsigned char genre;
	};
	struct idxtag {
		char tag[3];
		char title[90];
		char artist[50];
		char album[50];
		char comment[50];
	};
	struct id3tag *tag = (struct id3tag *) buf;
	struct idxtag *xtag = (struct idxtag *) buf;
	char title[121]="\0";
	char artist[81]="\0";
	char album[81]="\0";
	char year[5]="\0";
	char comment[81]="\0";

	strncpy(title,tag->title,30);
	strncpy(artist,tag->artist,30);
	strncpy(album,tag->album,30);
	strncpy(year,tag->year,4);
	strncpy(comment,tag->comment,30);
	strunpad(title);
	strunpad(artist);
	strunpad(album);
	strunpad(comment);
	
	if ((fseek(fp, 384, SEEK_END) != -1) && (fread(buf, 256, 1, fp) == 1))
	{
		if (!strncmp(buf, "TXG", 3))
		{
			strncat(title, xtag->title, 90);
			strncat(artist, xtag->artist, 50);
			strncat(album, xtag->album, 50);
			strncat(comment, xtag->comment, 50);
			strunpad(title);
			strunpad(artist);
			strunpad(album);
			strunpad(comment);
		}
	}
	if (!do_hook(MODULE_LIST, "AMP ID3 \"%s\" \"%s\" \"%s\" %s %d %s", title, artist, album, year, tag->genre, comment))
	{
		bitchsay("Title  : %.120s  Artist: %s",title, artist);
		bitchsay("Album  : %.80s  Year: %4s, Genre: %d",album, year, (int)tag->genre);
		bitchsay("Comment: %.80s",comment);
	}
}
コード例 #20
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
static void p_odd(char *from, char *comm, char **ArgList)
{
    PasteArgs(ArgList, 0);
    if (do_hook(ODD_SERVER_STUFF_LIST, "%s %s %s", from ? from : "*", comm, ArgList[0])) {
	if (from)
	    say("Odd server stuff: \"%s %s\" (%s)", comm, ArgList[0], from);
	else
	    say("Odd server stuff: \"%s %s\"", comm, ArgList[0]);
    }
}
コード例 #21
0
ファイル: ctcp.c プロジェクト: carriercomm/epic4
/*
 * This is no longer directly sends information to its target.
 * As part of a larger attempt to consolidate all data transmission
 * into send_text, this function was modified so as to use send_text().
 * This function can send both direct CTCP requests, as well as the
 * appropriate CTCP replies.  By its use of send_text(), it can send
 * CTCPs to DCC CHAT and irc nickname peers, and handles encryption
 * transparantly.  This greatly reduces the logic, complexity, and
 * possibility for error in this function.
 */
void	send_ctcp (int type, const char *to, int datatag, const char *format, ...)
{
	char 	putbuf [BIG_BUFFER_SIZE + 1],
		*putbuf2;
	int	len;

	/* Make sure that the final \001 doesnt get truncated */
	if ((len = IRCD_BUFFER_SIZE - (12 + strlen(to))) <= 0)
		return;				/* Whatever. */
	putbuf2 = alloca(len);

	if (format)
	{
		va_list args;
		va_start(args, format);
		vsnprintf(putbuf, BIG_BUFFER_SIZE, format, args);
		va_end(args);

		do_hook(SEND_CTCP_LIST, "%s %s %s %s", 
				ctcp_type[type], to, 
				ctcp_cmd[datatag].name, putbuf);
		snprintf(putbuf2, len, "%c%s %s%c", 
				CTCP_DELIM_CHAR, 
				ctcp_cmd[datatag].name, putbuf, 
				CTCP_DELIM_CHAR);
	}
	else
	{
		do_hook(SEND_CTCP_LIST, "%s %s %s", 
				ctcp_type[type], to, 
				ctcp_cmd[datatag].name);
		snprintf(putbuf2, len, "%c%s%c", 
				CTCP_DELIM_CHAR, 
				ctcp_cmd[datatag].name, 
				CTCP_DELIM_CHAR);
	}

	/* XXX - Ugh.  What a hack. */
	putbuf2[len - 2] = CTCP_DELIM_CHAR;
	putbuf2[len - 1] = 0;

	send_text(to, putbuf2, ctcp_type[type], 0);
}
コード例 #22
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
static void p_quit(char *from, char **ArgList)
{
    int one_prints = 0;
    char *chan = NULL;
    char *Reason;
    int netsplit = 0;
    int ignore;

    PasteArgs(ArgList, 0);
    if (ArgList[0]) {
	Reason = ArgList[0];
	netsplit = check_split(from, Reason, chan);
    } else
	Reason = "?";

    ignore = check_ignore(from, FromUserHost, NULL, (netsplit ? IGNORE_SPLITS : IGNORE_QUITS) | IGNORE_ALL, NULL);
    for (chan = walk_channels(from, 1, from_server); chan; chan = walk_channels(from, 0, -1)) {
	if (ignore != IGNORED) {
	    message_from(chan, LOG_CRAP);
	    if (do_hook(CHANNEL_SIGNOFF_LIST, "%s %s %s", chan, from, Reason))
		one_prints = 1;
	    message_from(NULL, LOG_CURRENT);
	}
    }
    if (one_prints) {
	chan = what_channel(from, from_server);

	ignore = check_ignore(from, FromUserHost, chan, (netsplit ? IGNORE_SPLITS : IGNORE_QUITS) | IGNORE_ALL, NULL);

	message_from(chan, LOG_CRAP);
	if ((ignore != IGNORED) && do_hook(SIGNOFF_LIST, "%s %s", from, Reason) && !netsplit)
	    put_it("%s",
		   convert_output_format(get_format(FORMAT_CHANNEL_SIGNOFF_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from,
					 FromUserHost, chan, Reason));
	message_from(NULL, LOG_CURRENT);
    }
    if (!netsplit)
	check_orig_nick(from);
    notify_mark(from, NULL, NULL, 0);
    remove_from_channel(NULL, from, from_server, netsplit, Reason);
    message_from(NULL, LOG_CRAP);
    update_all_status(curr_scr_win, NULL, 0);
}
コード例 #23
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;
	}
}
コード例 #24
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
static void p_nick(char *from, char **ArgList)
{
    int one_prints = 0, ign = 0, its_me = 0;
    struct channel *chan;
    char *line;

    line = ArgList[0];
    if (!my_stricmp(from, get_server_nickname(from_server))) {
	accept_server_nickname(from_server, line);
	its_me = 1;
	user_changing_nickname = 0;
    }
    ign = check_ignore(from, FromUserHost, NULL, IGNORE_NICKS | IGNORE_CRAP, NULL);
    for (chan = server_list[from_server].chan_list; chan; chan = chan->next) {
	message_from(chan->channel, LOG_CRAP);
	if (ign != IGNORED && do_hook(CHANNEL_NICK_LIST, "%s %s %s", chan->channel, from, line))
	    one_prints = 1;
    }
    if (one_prints) {
	if (its_me) {
	    message_from(NULL, LOG_CRAP);
	} else
	    message_from(what_channel(from, from_server), LOG_CRAP);
	if (ign != IGNORED && do_hook(NICKNAME_LIST, "%s %s", from, line))
	    put_it("%s",
		   convert_output_format(get_format
					 (its_me ? FORMAT_NICKNAME_USER_FSET : im_on_channel(what_channel(from, from_server)) ?
					  FORMAT_NICKNAME_FSET : FORMAT_NICKNAME_OTHER_FSET), "%s %s %s %s", update_clock(GET_TIME),
					 from, "-", line));
    }
    rename_nick(from, line, from_server);
    if (!its_me) {
	char *user, *host;

	user = m_strdup(FromUserHost);
	host = strchr(user, '@');
	*host++ = '\0';

	notify_mark(from, user, host, 0);
	notify_mark(line, user, host, 1);
	new_free(&user);
    }
}
コード例 #25
0
ファイル: chelp.c プロジェクト: dmashal/bitchx-ancient
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);
}
コード例 #26
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;
	}
}
コード例 #27
0
ファイル: mail.c プロジェクト: carriercomm/epic4
static void	update_mail_level1_maildir (void)
{
	int	status;
	Stat	stat_buf;

	status = poll_maildir_status(&stat_buf);

	/* There is no mail */
	if (status == 0)
	{
		if (mail_last_count_str)
			new_free(&mail_last_count_str);
	}
	/* Mailbox changed. */
	else if (status == 2)
	{
		int	count_new = maildir_count();

		/* There is no mail */
		if (count_new == 0)
		{
			if (mail_last_count_str)
				new_free(&mail_last_count_str);
		}

		/* Maildir changed. */
		if (count_new > mail_last_count)
		{
			/* Tell the user that they have new mail. */
			if (!mail_latch)
			{
				mail_latch++;
				if (do_hook(MAIL_LIST, "You have new email"))
				{
					int lastlog_level = 
						set_lastlog_msg_level(LOG_CRAP);
					say("You have new email.");
					set_lastlog_msg_level(lastlog_level);
				}
				mail_latch--;
			}

			malloc_strcpy(&mail_last_count_str, empty_string);
		}

		/* 
		 * Mark the last time we checked mail, and revoke the
		 * "count", so it must be regened by /set mail 2.
		 */
		maildir_last_changed = stat_buf.st_ctime;
		mail_last_count = count_new;
	}
}
コード例 #28
0
ファイル: output.c プロジェクト: Cloudxtreme/epic5
void	yell (const char *format, ...)
{
	if (format)
	{
		va_list args;
		va_start (args, format);
		vsnprintf(putbuf, sizeof putbuf, format, args);
		va_end(args);
		if (do_hook(YELL_LIST, "%s", putbuf))
			put_echo(putbuf);
	}
}
コード例 #29
0
ファイル: notice.c プロジェクト: BitchX/BitchX1.1
void got_initial_version_28 (char **ArgList)
{
	char *server, *sversion, *user_modes, *channel_modes;

	server = ArgList[0];
	sversion = ArgList[1];
	user_modes = ArgList[2];
	channel_modes = ArgList[3];
		
	if (sversion)
	{
		if (!strncmp(sversion, "2.8", 3))
		{
			if (strstr(sversion, "mu") || strstr(sversion, "me"))
				set_server_version(from_server, Server_u2_8);
			else if (strstr(sversion, "hybrid-6"))
				set_server_version(from_server, Server2_8hybrid6);
			else if (strstr(sversion, "hybrid"))
				set_server_version(from_server, Server2_8hybrid);
			else if (strstr(sversion, "comstud"))
				set_server_version(from_server, Server2_8comstud);
			else if (strstr(channel_modes, "che"))
				set_server_version(from_server, Server2_8ts4); 
			else
				set_server_version(from_server, Server2_8);
		}
		else if (!strncmp(sversion, "2.9", 3))
		        set_server_version(from_server, Server2_9);
		else if (!strncmp(sversion, "2.10", 4))
	        	set_server_version(from_server, Server2_10);
		else if (!strncmp(sversion, "u2.9", 4))
			set_server_version(from_server, Server_u2_9);
		else if (!strncmp(sversion, "u2.10", 4))
			set_server_version(from_server, Server_u2_10);
		else if (!strncmp(sversion, "u3.0", 4))
			set_server_version(from_server, Server_u3_0);
		else
			set_server_version(from_server, Server2_8);
	} else
		set_server_version(from_server, Server2_8);

	set_server_version_string(from_server, sversion ? sversion : "2.8");
	set_server_itsname(from_server, server);
	reconnect_all_channels(from_server);

	reset_display_target();
	reinstate_user_modes();
	if (use_nat_address == 1)
		userhostbase(get_server_nickname(from_server), get_nat_address, 1, "%s", get_server_nickname(from_server));
	update_all_status(current_window, NULL, 0);
	do_hook(CONNECT_LIST, "%s %d %s", get_server_name(from_server), get_server_port(from_server), get_server_itsname(from_server));
}
コード例 #30
0
ファイル: output.c プロジェクト: BitchX/BitchX1.2
/*
 * Error is exactly like yell, except that if the error occured while
 * you were loading a script, it tells you where it happened.
 */
void 	error (const char *format, ...)
{
	dump_load_stack(0);
	if (format)
	{
		va_list args;
		va_start (args, format);
		vsnprintf(putbuf, LARGE_BIG_BUFFER_SIZE, format, args);
		va_end(args);
		do_hook(YELL_LIST, "%s", putbuf);
		put_echo(putbuf);
	}
}