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

📄 panelprocs.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
	    FRAME_SHOW_LABEL,	TRUE,	    FRAME_LABEL,	"Option File Menu",	    WIN_X,	(int)((STATUS_WIDTH+PERFMON_WIDTH)*frame_width)+15,	    WIN_Y,	20,            FRAME_DONE_PROC, frame_destroy_proc,	    0);	of_panel = window_create(of_frame, PANEL,	    0);	of_fname_item = panel_create_item(of_panel, PANEL_TEXT,	    PANEL_LABEL_STRING,		"Option File Name: ",	    PANEL_VALUE,		option_fname,	    PANEL_VALUE_DISPLAY_LENGTH,	22,	    PANEL_ITEM_X,               ATTR_COL(0),            PANEL_ITEM_Y,               ATTR_ROW(1),	    PANEL_NOTIFY_PROC,		fname_proc,            0);	(void)panel_create_item(of_panel, PANEL_BUTTON,	    PANEL_LABEL_IMAGE,  panel_button_image(of_panel,					"Load", 8, (Pixfont *)NULL),	    PANEL_ITEM_X,		ATTR_COL(0),	    PANEL_ITEM_Y,		ATTR_ROW(3),	    PANEL_NOTIFY_PROC,		load_option_files,	    0);	(void)panel_create_item(of_panel, PANEL_BUTTON,	    PANEL_LABEL_IMAGE,  panel_button_image(of_panel,					"Store", 8, (Pixfont *)NULL),	    PANEL_ITEM_X,		ATTR_COL(12),	    PANEL_ITEM_Y,		ATTR_ROW(3),	    PANEL_NOTIFY_PROC,		store_option_files,	    0);	(void)panel_create_item(of_panel, PANEL_BUTTON,	    PANEL_LABEL_IMAGE,  panel_button_image(of_panel,					"Done", 8, (Pixfont *)NULL),	    PANEL_ITEM_X,		ATTR_COL(24),	    PANEL_ITEM_Y,		ATTR_ROW(3),	    PANEL_NOTIFY_PROC,		done_option_files,	    0);	(void)panel_create_item(of_panel, PANEL_BUTTON,	    PANEL_LABEL_IMAGE,  panel_button_image(of_panel,					"List", 8, (Pixfont *)NULL),	    PANEL_ITEM_X,		ATTR_COL(0),	    PANEL_ITEM_Y,		ATTR_ROW(4),	    PANEL_EVENT_PROC,		list_option_files,	    0);	(void)panel_create_item(of_panel, PANEL_BUTTON,	    PANEL_LABEL_IMAGE,  panel_button_image(of_panel,					"Remove", 8, (Pixfont *)NULL),	    PANEL_ITEM_X,		ATTR_COL(12),	    PANEL_ITEM_Y,		ATTR_ROW(4),	    PANEL_NOTIFY_PROC,		remove_option_files,	    0);	window_fit(of_panel);        window_fit(of_frame);        (void)window_set(of_frame, WIN_SHOW, TRUE, 0);}/****************************************************************************** * Gets names of all files in the specified directory.			      * * Input: directory, the name of the directory to be searched.		      * * Output: pointer to the array of file names.				      * ******************************************************************************/char **get_file_names(directory)char *directory;{  static char *list[BUFSIZ+1];  DIR *dirp;  struct direct *dp;  int i = 0;           dirp = opendir(directory);  if (dirp != NULL)  {        while (dp = readdir(dirp))	{            if ((strcmp(dp->d_name, ".") != 0) &&            	(strcmp(dp->d_name, "..") != 0))	    {                list[i] = malloc((unsigned)strlen(dp->d_name)+4);		(void)strcpy(list[i++], dp->d_name);	    }        }    (void)closedir(dirp);  }  list[i] = NULL;  return(list);}/****************************************************************************** * Panel notify procedure for the "file name:" text item in "Option Files"    * * popup window.						              * ******************************************************************************/static Panel_setting fname_proc(item, event)Panel_item	item;Event		*event;{  if (event_id(event) == '\r')		/* the Return key was hit */    (void)strcpy(option_fname, (char *)panel_get_value(item));  return(panel_text_notify(item, event));}/****************************************************************************** * Panel notify procedure for the "Load" button item in "Option Files"	      * * popup window.						              * ******************************************************************************/load_option_files(){  char	*tmp;  if (!tty_mode)  {    tmp = (char *)panel_get_value(of_fname_item);    if (*tmp == '\0') return;	/* no file specified */    (void)strcpy(option_fname, tmp);  }  (void)load_option(option_fname, 1);}/****************************************************************************** * Panel notify procedure for the "Store" button item in "Option Files"	      * * popup window.						              * ******************************************************************************/store_option_files(){  char	temp[82], *tmp;  if (!tty_mode)  {    tmp = (char *)panel_get_value(of_fname_item);    while (*tmp == ' ') ++tmp;	/* skip leading spaces */    if (*tmp == '\0') return;	/* no file specified */    (void)strcpy(option_fname, tmp);      (void)sprintf(temp, "%s/%s", OPTION_DIR, option_fname);    if (access(temp, F_OK) == 0)	/* the option file already exists */      if (!confirm_yes("OK to reuse existing option file?")) return;  }  (void)store_option(option_fname);}/****************************************************************************** * Panel notify procedure for the "List" button item in "Option Files"	      * * popup window.						              * ******************************************************************************/list_option_files(item, event)Panel_item	item;Event		*event;{  int	name_index;  int	i=1;  char	**namelist, **keeplist;  Menu	of_menu;  if (event_id(event) == MS_RIGHT && event_is_down(event))  {    of_menu = menu_create(MENU_NCOLS, 3, 0);    namelist = get_file_names(OPTION_DIR);    keeplist = namelist;	/* keep the head pointer */    if (*namelist == NULL)    {	(void)menu_set(of_menu, MENU_NCOLS, 1, 0);	(void)menu_set(of_menu, MENU_STRING_ITEM, "??? no option files", 1, 0);    }    else      while (*namelist)        (void)menu_set(of_menu, MENU_STRING_ITEM, *namelist++, i++, 0);    name_index = (int)menu_show(of_menu, sundiag_control, event, 0);    if (name_index != 0 && *keeplist != NULL)	/* one file name was selected */    {	(void)strcpy(option_fname, *(keeplist+name_index-1));/* keep the name */	(void)panel_set(of_fname_item, PANEL_VALUE, option_fname, 0);					/* display it too */    }    menu_destroy(of_menu);    namelist = keeplist;    while (*namelist)      free(*namelist++);  }  else	(void)panel_default_handle_event(item, event);}/****************************************************************************** * Panel notify procedure for the "Remove" button item in "Option Files"      * * popup window.						              * ******************************************************************************/remove_option_files(){  char	temp[82], *tmp;  if (!tty_mode)  {    tmp = (char *)panel_get_value(of_fname_item);    if (*tmp == '\0') return;	    /* no file specified */    (void)sprintf(temp, "%s/%s", OPTION_DIR, tmp);    if (access(temp, F_OK) == 0)    /* the specified option file does exist */      if (confirm_yes("OK to remove sundiag option file?"))        if (!unlink(temp))	    /* successful */	  (void)panel_set(of_fname_item, PANEL_VALUE, "", 0);  }  else  {    (void)sprintf(temp, "%s/%s", OPTION_DIR, option_fname);    if (unlink(temp))      (void)confirm("The specified option file was not removed!", TRUE);  }}/****************************************************************************** * Panel notify procedure for the "Done" button item in "Option Files"	      * * popup window.						              * ******************************************************************************/static done_option_files(){  (void)strcpy(option_fname, (char *)panel_get_value(of_fname_item));  (void)window_set(of_frame, FRAME_NO_CONFIRM, TRUE, 0);  (void)window_destroy(of_frame);  of_frame = NULL;}/****************************************************************************** * Notify procedure for the "Options" button.				      * ******************************************************************************//***** global flag(switch) variables. *****/int	core_file=0;	/* generate core files? */int	single_pass=0;	/* single pass for all enabled tests? */int	quick_test=0;	/* run tests with "q(uick)" option? */int	verbose=0;	/* run tests in verbose mode? */int	trace=0;	/* run tests in trace mode? */int	auto_start=0;	/* automatically start testing when booted? */int	run_error=0;	/* enable run_on_error mode? */int	max_errors=1;	/* max. # of errors allowed if run_on_error enabled */int	max_tests=2;	/* max. # of tests in a group */int	log_period=0;	/* period(in minutes) to log the staus, or send email */int	send_email=0;	/* automatically send mail on conditions */int	max_sys_pass=0;	/* to keep maximum system pass count */char	eaddress[52]="root";	/* to contain the email address *//***** forward references *****/static option_done_proc();static option_default_proc();/*ARGSUSED*/options_proc(){  char  tmp1[12];  char	tmp2[12];  char	tmp3[12];  int	which_row=0;	if (running == GO) return;	/* repaint the system option popup */	if (o_frame != NULL)	  frame_destroy_proc(o_frame);	/* o_frame & of_frame can't be up at the same time */	if (of_frame != NULL)	  frame_destroy_proc(of_frame);	o_frame = window_create(sundiag_frame, FRAME,	    FRAME_SHOW_LABEL,	TRUE,	    FRAME_LABEL,	"System Option Menu",	    WIN_X,	(int)((STATUS_WIDTH+PERFMON_WIDTH)*frame_width)+15,	    WIN_Y,	20,            FRAME_DONE_PROC, frame_destroy_proc, 0);	o_panel = window_create(o_frame, PANEL, 0);	core_item = panel_create_item(o_panel, PANEL_CYCLE,            PANEL_LABEL_STRING,         "Core Files:   ",	    PANEL_CHOICE_STRINGS,	"Disable ", "Enable", 0,	    PANEL_VALUE,		core_file,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	single_item = panel_create_item(o_panel, PANEL_CYCLE,            PANEL_LABEL_STRING,         "Single Pass:  ",	    PANEL_CHOICE_STRINGS,	"Disable ", "Enable", 0,	    PANEL_VALUE,		single_pass,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	quick_item = panel_create_item(o_panel, PANEL_CYCLE,            PANEL_LABEL_STRING,         "Quick Test:   ",	    PANEL_CHOICE_STRINGS,	"Disable ", "Enable", 0,	    PANEL_VALUE,		quick_test,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	verbose_item = panel_create_item(o_panel, PANEL_CYCLE,            PANEL_LABEL_STRING,         "Verbose:      ",	    PANEL_CHOICE_STRINGS,	"Disable ", "Enable", 0,	    PANEL_VALUE,		verbose,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	trace_item = panel_create_item(o_panel, PANEL_CYCLE,            PANEL_LABEL_STRING,         "trace:        ",	    PANEL_CHOICE_STRINGS,	"Disable ", "Enable", 0,	    PANEL_VALUE,		trace,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	auto_item = panel_create_item(o_panel, PANEL_CYCLE,            PANEL_LABEL_STRING,         "Auto Start:   ",	    PANEL_CHOICE_STRINGS,	"Disable ", "Enable", 0,	    PANEL_VALUE,		auto_start,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	run_error_item = panel_create_item(o_panel, PANEL_CYCLE,            PANEL_LABEL_STRING,         "Run On Error: ",	    PANEL_CHOICE_STRINGS,	"Disable ", "Enable", 0,	    PANEL_VALUE,		run_error,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	email_item = panel_create_item(o_panel, PANEL_CYCLE,            PANEL_LABEL_STRING,         "Send Email:   ",	    PANEL_CHOICE_STRINGS,		"Disable", "On_Error", "Periodically", "Both", 0,	    PANEL_VALUE,		send_email,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	(void)sprintf(tmp1, "%u", max_sys_pass);	max_passes_item = panel_create_item(o_panel, PANEL_TEXT,            PANEL_LABEL_STRING,         "Max. # of Passes:  ",	    PANEL_VALUE,		tmp1,	    PANEL_VALUE_DISPLAY_LENGTH,	5,	    PANEL_VALUE_STORED_LENGTH,	5,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	(void)sprintf(tmp1, "%u", max_errors);	max_errors_item = panel_create_item(o_panel, PANEL_TEXT,            PANEL_LABEL_STRING,         "Max. # of Errors:  ",	    PANEL_VALUE,		tmp1,	    PANEL_VALUE_DISPLAY_LENGTH,	5,	    PANEL_VALUE_STORED_LENGTH,	5,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	(void)sprintf(tmp2, "%u", max_tests);	max_tests_item = panel_create_item(o_panel, PANEL_TEXT,            PANEL_LABEL_STRING,         "Concurrent Tests #:",	    PANEL_VALUE,		tmp2,	    PANEL_VALUE_DISPLAY_LENGTH,	5,	    PANEL_VALUE_STORED_LENGTH,	5,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	(void)sprintf(tmp3, "%u", log_period);	log_period_item = panel_create_item(o_panel, PANEL_TEXT,            PANEL_LABEL_STRING,         "Log/Email Period:  ",	    PANEL_VALUE,		tmp3,	    PANEL_VALUE_DISPLAY_LENGTH,	8,	    PANEL_VALUE_STORED_LENGTH,	10,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	address_item = panel_create_item(o_panel, PANEL_TEXT,            PANEL_LABEL_STRING,         "Email Address:",	    PANEL_VALUE,		eaddress,	    PANEL_VALUE_DISPLAY_LENGTH,	12,	    PANEL_VALUE_STORED_LENGTH,	20,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	printer_name_item = panel_create_item(o_panel, PANEL_TEXT,            PANEL_LABEL_STRING,         "Printer Name: ",	    PANEL_VALUE,		printer_name,	    PANEL_VALUE_DISPLAY_LENGTH,	12,	    PANEL_VALUE_STORED_LENGTH,	20,            PANEL_ITEM_X,               ATTR_COL(1),            PANEL_ITEM_Y,               ATTR_ROW(which_row++),            0);	(void)panel_create_item(o_panel, PANEL_BUTTON,	    PANEL_LABEL_IMAGE,		panel_button_image(o_panel,					"Default", 7, (Pixfont *)NULL),	    PANEL_ITEM_X,		ATTR_COL(1),	    PANEL_ITEM_Y,		ATTR_ROW(which_row),	    PANEL_NOTIFY_PROC,		option_default_proc,	    0);	(void)panel_create_item(o_panel, PANEL_BUTTON,	    PANEL_LABEL_IMAGE,		panel_button_image(o_panel,					"Done", 7, (Pixfont *)NULL),	    PANEL_NOTIFY_PROC,		option_done_proc,	    0);	window_fit(o_panel);        window_fit(o_frame);        (void)window_set(o_frame, WIN_SHOW, TRUE, 0);}/****************************************************************************** * Panel notify procedure for the "defualt" button item in "System Options"   * * popup subwindow.							      * ******************************************************************************/static option_default_proc(){  char	*tmp, *getenv();  (void)panel_set(core_item, PANEL_VALUE, 0, 0);  (void)panel_set(single_item, PANEL_VALUE, 0, 0);  (void)panel_set(quick_item, PANEL_VALUE, 0, 0);  (void)panel_set(verbose_item, PANEL_VALUE, 0, 0);  (void)panel_set(trace_item, PANEL_VALUE, 0, 0);  (void)panel_set(auto_item, PANEL_VALUE, 0, 0);  (void)panel_set(run_error_item, PANEL_VALUE, 0, 0);  (void)panel_set(max_passes_item, PANEL_VALUE, "0", 0);  (void)panel_set(max_errors_item, PANEL_VALUE, "1", 0);  (void)panel_set(max_tests_item, PANEL_VALUE, "2", 0);  (void)panel_set(email_item, PANEL_VALUE, 0, 0);  (void)panel_set(log_period_item, PANEL_VALUE, "0", 0);  (void)panel_set(address_item, PANEL_VALUE, "root", 0);

⌨️ 快捷键说明

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