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

📄 tool.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		mt_load_messages = mt_At_Startup;	else if (strcmp(mt_value("loadmessages"), "Asked") == 0)		mt_load_messages = mt_When_Asked;	else 		(void)fprintf(stderr, "unrecognized default setting: %s\n",			mt_value("loadmessages"));***/	mt_memory_maximum = TEXTSW_INFINITY;	/*	 * Get the sizes of the various subwindows.	 */	mt_headerlines = 10;	mt_maillines = 30;	mt_popuplines = 30;	if ((p = mt_value("headerlines")) && (i = atoi(p)) > 0)		mt_headerlines = i;	if ((p = mt_value("maillines")) && (i = atoi(p)) > 0)		mt_maillines = i;	if ((p = mt_value("popuplines")) && (i = atoi(p)) > 0)		mt_popuplines = i;	mt_bells = 0;	mt_flashes = 0;	if (p = mt_value("bell")) {		mt_bells = atoi(p);		if (mt_bells <= 0)			mt_bells = 0;	}	if (p = mt_value("flash")) {		mt_flashes = atoi(p);		if (mt_flashes <= 0)			mt_flashes = 0;	}	/*	 * If "autoprint" is set, turn it off.  We do it ourselves.	 */	if (mt_value("autoprint"))		mt_set_var("autoprint", (char *)NULL);}/* ARGSUSED */static Notify_valuemt_frame_event_proc(client, event, arg, when)	Notify_client   client;	Event          *event;	Notify_arg      arg;	Notify_event_type when;{	Notify_value    rc;	int             closed_initial, closed_current;	closed_initial = (int)window_get(client, FRAME_CLOSED);	rc = notify_next_event_func(client, event, arg, NOTIFY_SAFE);	if (event_action(event) == WIN_RESIZE) {		mt_namestripe_width = (int)window_get(mt_frame, WIN_COLUMNS);		mt_set_namestripe_both();		return (rc);	}	closed_current = (int)window_get(client, FRAME_CLOSED);	if (closed_current || closed_initial) {		if (mt_cd_frame) {			int	displayed;			displayed = (int)window_get(mt_cd_frame, WIN_SHOW);			if (displayed == closed_current)				window_set(mt_cd_frame,					WIN_SHOW, !displayed,					0);		}	}	if (closed_initial && !closed_current) {		menu_set(mt_open_menu_item, MENU_PULLRIGHT, NULL, 0);		if (mt_idle) {			/*			 * If window was just opened and we are idle			 * then read new mail.			 */			static struct itimerval itv = { {0, 0}, {0, 1} };			/*			 * Set up timer to go off once and immediately.			 * This schedules the mail activity to be done upon			 * opening the tool, to occur after the tool is open			 * completely.			 */			notify_set_itimer_func(&mt_mailclient, mt_itimer_doit,			    ITIMER_VIRTUAL, &itv, 0);		}	}	return (rc);}/* * SIGTERM and SIGXCPU handler. * Save mailbox and exit. *//* ARGSUSED */static Notify_valuemt_signal_func(client, sig)	Notify_client   client;	int             sig;{	if (!mt_idle)		mt_stop_mail(0);	if (sig == SIGXCPU) {		/* for debugging */		(void)sigsetmask(0);		abort();	}	mt_done(sig == SIGTERM ? 0 : 1);}static Notify_valuemt_destroy(client, status)	Notify_client   client;	Destroy_status  status;{	Notify_value	val;	if (status == DESTROY_CHECKING) {		if (mt_aborting) {			if (!mt_confirm(mt_frame, FALSE, FALSE,				"Confirm",				"Cancel",				"Are you sure you want to Quit",				"without committing changes?",				0)) {				notify_veto_destroy(client);				mt_aborting = FALSE;			} else {				mt_prepare_to_die(client);				val = notify_next_destroy_func(client, status);			}		} else {			if (!mt_confirm(mt_frame, FALSE, TRUE,				"Confirm",				"Cancel",				"Are you sure you want to Quit?",				0)) 				notify_veto_destroy(client);			else {	/* entire tool is going away */				mt_save_curmsg();				mt_prepare_to_die(client);				val = notify_next_destroy_func(client, status);			}		}	} else {		val = notify_next_destroy_func(client, status);		notify_remove(&mt_mailclient);	}	return (val);}static voidmt_prepare_to_die(client)	Notify_client   client;{	Frame           frame;	struct reply_panel_data *ptr;	char		dead_letter[256];	mt_destroying = TRUE;	/*	 * tells replysw's that any necessary confirmation has	 * already taken place 	 */	textsw_reset(mt_headersw, 0, 0);	textsw_reset(mt_msgsw, 0, 0);	ptr = (struct reply_panel_data *)panel_get(		mt_cmdpanel, PANEL_CLIENT_DATA);	if (mt_value("save")) {		char	*s;		FILE	*f;		s = mt_value("DEAD");		/* 		 * (Bug# 1014141 fix) added code to recognise		 * "/dev/null" and not to save to it.		 */		if (strcmp(s,"/dev/null") != 0) 		{		  if (s == NULL || *s == '\0')			s = "~/dead.letter";		  mt_full_path_name(s, dead_letter);		  if (f = mt_fopen(dead_letter, "w")) 			/* check to see if can write to this file */			(void) fclose(f);		  else			dead_letter[0] = '\0';		}		else		  dead_letter[0] = '\0';	}	/*	 * find all the popups and kill them. 	 */	while (ptr) {		if (dead_letter[0] != '\0' && ptr->inuse)		/*		 * NEEDS TO BE FIXED TO HANDLE CASE WHERE THERE IS MORE THAN		 * ONE ACTIVE REPLYSW, IE. TO CAT THE FILES TOGETHER INTO		 * DEAD LETTER 		 */			(void) textsw_store_file(ptr->replysw,				dead_letter, 0, 0);		textsw_reset(ptr->replysw, 0, 0);		frame = window_get(			ptr->replysw, WIN_OWNER);		if (frame != mt_frame) {			window_set(frame,			   FRAME_NO_CONFIRM, TRUE, 0);			window_destroy(frame);		}		ptr = ptr->next_ptr;	}	window_set(client, FRAME_NO_CONFIRM, TRUE, 0);}/* timers *//* * Start the timer to look for new mail. */voidmt_start_timer(){	static struct itimerval itv;	char           *p;	int             interval = 0;	if (p = mt_value("interval"))		interval = atoi(p);	if (interval == 0)		interval = 5*60;	/* 5 minutes */	itv.it_interval.tv_sec = interval;	itv.it_value.tv_sec = interval;	(void)notify_set_itimer_func(&mt_mailclient, mt_itimer,		ITIMER_REAL, &itv, 0);	if (mt_load_messages == mt_At_Startup) {		static struct itimerval itv = { {0, 0}, {0, 1} };		/*		 * Set up timer to go off once and immediately.		 */		mt_load_messages = mt_When_Asked;	/* mt_start_timer gets							 * called again later.							 * The mt_At_Startup							 * only affects the							 * first time */		notify_set_itimer_func(&mt_mailclient, mt_itimer_doit,		    ITIMER_VIRTUAL, &itv, 0);	}}/* * Check for new mail when timer expires.  *//* ARGSUSED */static Notify_valuemt_itimer(client, which)	Notify_client   client;	int             which;{/* not used - hala	char           *p, *s; */	mt_check_mail_box();/****	int             interval, commit = FALSE;	p = mt_value("commitfrequency");	if (p != NULL && mt_del_count > atoi(p))		commit = TRUE;	if ((mt_check_mail_box() || commit)	   && mt_system_mail_box	   && (p = mt_value("retrieveinterval"))	   && (interval = atoi(p)) > 0	   ) {		if (mt_current_time() > (interval + last_event_time)) {			static struct itimerval itv;			mt_update_info(commit ?				"About to commit your changes and retrieve your new mail..."				: "About to retrieve your new mail...");			window_bell(mt_cmdpanel);			itv.it_interval.tv_sec = 15;			itv.it_value.tv_sec = 15;			last_event_time = 0;			(void)notify_set_itimer_func(&mt_mailclient, 				mt_itimer1, ITIMER_REAL, &itv, 0);		}	}*****/ 	return (NOTIFY_DONE);}/* called from mt_frame_event_proc, mt_start_timer *//* ARGSUSED */static Notify_valuemt_itimer_doit(client, which)	Notify_client   client;	int             which;{	Event	event;	event_set_shiftmask(&event, 0);	event_time(&event).tv_sec = 0;	/* indicates that this is a					 * "synthetic" event */	mail_load_messages(		(mt_load_from_folder ? mt_folder_item : mt_state_item),		&event, NULL);	return (NOTIFY_DONE);}/* called from mt_frame_event_proc, mt_start_timer *//* ARGSUSED */static voidmail_load_messages(item, event, notify_proc)	Panel_item      item;	Event          *event;	Void_proc       notify_proc;{	mt_idle = FALSE;	mt_call_cmd_proc(item, event, notify_proc);}/* ARGSUSED */static caddr_tmt_just_open_proc(m, mi)	Menu            m;	Menu_item       mi;{	Event		event;	event_set_shiftmask(&event, 0);	event_time(&event).tv_sec = 0;	/* indicates that this is a					 * "synthetic" event */	mt_idle = FALSE;	(void) window_set(mt_frame, FRAME_CLOSED, FALSE, 0);}/* ARGSUSED */static caddr_tmt_open_and_compose_proc(m, mi)	Menu            m;	Menu_item       mi;{	Event		event;	int		always_use_popup = mt_always_use_popup;	event_set_shiftmask(&event, 0);	event_time(&event).tv_sec = 0;	/* indicates that this is a					 * "synthetic" event */	mt_always_use_popup = TRUE;	mt_comp_proc(mt_compose_item, &event);	mt_always_use_popup = always_use_popup;}/* ARGSUSED */static caddr_tmt_open_and_read_proc(m, mi)	Menu            m;	Menu_item       mi;{	mt_idle = TRUE;	(void) window_set(mt_frame, FRAME_CLOSED, FALSE, 0);}/* not used - hala static Menumt_switch_folder_gen_proc(mi, operation)	Menu_item       mi;	Menu_generate   operation;{	Menu            pull_right, parent;	struct Menu_client_data *menu_data;	mt_folder_menu = mt_get_folder_menu(mt_folder_menu, "", "");	return (mt_folder_menu);}*/static voidmt_msgsw_notify_proc(textsw, attributes)	Textsw          textsw;	Attr_avlist     attributes;{	int             pass_on = FALSE;	Attr_avlist     attrs;	for (attrs = attributes; *attrs; attrs = attr_next(attrs)) {		switch ((Textsw_action) (*attrs)) {			case  TEXTSW_ACTION_EDITED_MEMORY:				if (!mt_value("editmessagewindow") &&					!mt_confirm(mt_frame, TRUE, TRUE,						"Confirm",						"Cancel",				"Did you really intend to edit this window?",						0)) {					window_set(textsw,						TEXTSW_RESET_TO_CONTENTS, 0);					return;					}			default:				pass_on = TRUE;				break;		}	}	if (pass_on)		cached_mt_msgsw_notify(textsw, attributes);}/**** * * Used for autoreading. Checks to see if user has performed any activity in * last 15 seconds, thereby vetoing autoread  *static Notify_valuemt_itimer1(client, which)	Notify_client   client;	int             which;{	int             interval;	interval = atoi(mt_value("retrieveinterval"));	if (last_event_time == 0) {		 *		 * user may have performed some activity during 15 second		 * period in order to prevent committing/retrieving new mail 		 *		Event	event;		if (mt_debugging)			printf("retrieving mail");		mt_update_info("");		event_set_shiftmask(&event, 0);		mail_load_messages(mt_state_item, &event,			mt_auto_retrieve_mail_proc);		last_event_time = mt_current_time();	} 	* restore timer *	mt_start_timer();	return (NOTIFY_DONE);}****/

⌨️ 快捷键说明

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