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

📄 option.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	item = panel_create_item(panel_handle, PANEL_TOGGLE,		PANEL_CHOICE_STRINGS,	choice->label, 0,		PANEL_TOGGLE_VALUE,	0, value,        	PANEL_ITEM_X,           ATTR_COL(col),        	PANEL_ITEM_Y,           ATTR_ROW(row),		0);	break;      case TEXT_ITEM:	item = panel_create_item(panel_handle,	PANEL_TEXT,		PANEL_LABEL_STRING,     choice->label,		PANEL_VALUE,  		choice->choice[value],		PANEL_ITEM_X,		ATTR_COL(col),		PANEL_ITEM_Y,		ATTR_ROW(row),		0);	break;      default:	return((Panel_item)0);    }    return(item);  }}/****************************************************************************** * option_item2(), supports 2 column format in the option window in TTY mode. * * NOTE: extra arg column_num;  0 for first column and 1 for second column    * ******************************************************************************/static	Panel_item	option_item2(panel_handle, choice, value, col, row, column_num, row_num)Panel	panel_handle;struct	option_choice	*choice;int	value;				/* index to choice->choice */int	col;int	row;int     column_num;int	row_num;{  Panel_item	item;  char	buf[82];  if (tty_mode)  {    if (value >= choice->num) value = 0;    (void)sprintf(buf, "[%c]%s%c", choice->com-0x20, choice->label,		choice->type==TOGGLE_ITEM?':':' ');    (void)mvwaddstr(tty_option, row_num+TTY_ROW_OFFSET, (column_num?45:8), buf);    wclrtoeol(tty_option);    (void)sprintf(buf, "%s", choice->choice[value]);    (void)mvwaddstr(tty_option, row_num+TTY_ROW_OFFSET, (column_num?66:28), buf);    wclrtoeol(tty_option);    return((Panel_item)0);  }  else  {	return(option_item(panel_handle, choice, value, col, row));  }}intinit_processors_choice(panel_handle, test_id)Panel panel_handle;int test_id;{    int i, num;     unsigned int b;     char processor_name[30], processor_enable[30], processor_disable[30];    for (i = 0, b = 1, num = 0; num < number_processors; b <<= 1, i++)	if (processors_mask & b)	{	    mp4_processors_choice[i].num = 2;            bzero(processor_name, 30);            sprintf(processor_name, "Processor %d", i);	    mp4_processors_choice[i].label = (char *)malloc(sizeof(processor_name));	    strcpy(mp4_processors_choice[i].label, processor_name);	    mp4_processors_choice[i].type = CYCLE_ITEM;	    mp4_processors_choice[i].com = i + 'a';            bzero(processor_enable, 30);            sprintf(processor_enable, "enable");	    mp4_processors_choice[i].choice[0] = (char *)malloc(sizeof(processor_enable));	    strcpy(mp4_processors_choice[i].choice[0], processor_enable);            bzero(processor_disable, 30);            sprintf(processor_disable, "disable");	    mp4_processors_choice[i].choice[1] = (char *)malloc(sizeof(processor_disable));	    strcpy(mp4_processors_choice[i].choice[1], processor_disable);	    mp4_processors_choice[i].choice[2] = NULL;	    mp4_processors_choice[i].choice[3] = NULL;            processor_item[i] =                         option_item(panel_handle, &mp4_processors_choice[i],                        ((int)tests[test_id]->data&(0x10 << i)) >> (4+i), 4, 2+num);	    num++;	}    return(num);} /****************************************************************************** * Initialize the items in the option popup, depends on which test it is.     * * Input: test_id, internal test number.				      * * Output: the popup panel's handle.					      * ******************************************************************************/Panel	init_opt_panel(test_id)int		test_id;{  int	done_row=0, add_row;  int	unit, i;  float amt;  Panel	panel_handle;  char	tmp[62];			/* buffer for messages on popup's */  char	tmp1[62];			/* buffer for messages on popup's */  char	*tapename;  struct option_choice	*tmp_choice;  char  *tmpname="/tmp/sundiag.XXXXXX";  char  enet_buffer[120];               /* buffer for ENET calls */  char  hostname[40];                   /* buffer stores hostname */  char  domainname[40];                 /* buffer stores domainname */  int   ypup;                           /* if yp running, & tmp pointer */  static  long  hostid;                 /* to store hex value for ENET info */  FILE  *enet_fp;                       /* points to tmpname */  struct hostent *hp;                   /* host entry info for ENET info */  if (!tty_mode)    panel_handle = window_create(option_frame, PANEL, 0); /* create the panel */  switch (tests[test_id]->id)		/* depend on which test it is */  {    case PMEM:	panel_label("Physical Memory");	panel_printf(panel_handle, "Configurations:", 1, 0);	(void)sprintf(tmp, "Amount: %d MB",		tests[test_id]->conf->uval.meminfo.amt);	panel_printf(panel_handle, tmp, 4, 1);	panel_printf(panel_handle, "Sub-tests:  None", 1, 3);	panel_printf(panel_handle, "Options:    None", 1, 5);	done_row = 6;	break;    case VMEM:	panel_label("Virtual Memory");	panel_printf(panel_handle, "Configurations:", 1, 0);	(void)sprintf(tmp, "Amount: %d MB",		tests[test_id]->conf->uval.meminfo.amt);	panel_printf(panel_handle, tmp, 4, 1);	panel_printf(panel_handle, "Sub-tests:  None", 1, 3);	panel_printf(panel_handle, "Options:", 1, 5);	item1 = option_item(panel_handle, &wait_choice,				(int)tests[test_id]->data, 4, 6);	(void)sprintf(tmp1, "%d", (int)tests[test_id]->special);	reserve_choice.choice[0] = tmp1;	item2 = option_item(panel_handle, &reserve_choice, 0, 4, 7);	if (!tty_mode)	  (void)panel_set(item2, 		PANEL_VALUE_DISPLAY_LENGTH,	6,		PANEL_VALUE_STORED_LENGTH,	6,		0);	done_row = 8;	break;    case AUDIO:        if (tests[option_id]->conf->uval.devinfo.status == 0) {        panel_label(tests[test_id]->label);        panel_printf(panel_handle, "Configurations: None", 1, 0);        panel_printf(panel_handle, "Options:", 1, 1);        item1 = option_item(panel_handle, &audio_choice,                                (int)tests[test_id]->data&1, -1, 2);        (void)sprintf(tmp1, "%d", (int)tests[test_id]->special);        loud_choice.choice[0] = tmp1;        item2 = option_item(panel_handle, &loud_choice, 0, -1, 3);        if (!tty_mode)        {          (void)panel_set(item2,                PANEL_VALUE_DISPLAY_LENGTH,     3,                PANEL_VALUE_STORED_LENGTH,      3,                0);        }        done_row = 4;        }        else {        panel_label(tests[test_id]->label);        panel_printf(panel_handle, "Configurations: None", 1, 0);        panel_printf(panel_handle, "Options:", 1, 1);         item6 = option_item(panel_handle, &audbri_audio_choice,                                ((int)tests[test_id]->data & 0x40) >> 6, 4, 7);        item5 = option_item(panel_handle, &audbri_controls_choice,                                ((int)tests[test_id]->data & 0x20) >> 5, 4, 6);        item4 = option_item(panel_handle, &audbri_crystal_choice,                                ((int)tests[test_id]->data & 0x10) >> 4, 4, 5);        item3 = option_item(panel_handle, &audbri_loop_calib_choice,                                ((int)tests[test_id]->data & 0x8) >> 3, 4, 4);        item2 = option_item(panel_handle, &audbri_loop_choice,                                ((int)tests[test_id]->data & 0x4) >> 2, 4, 3);        item1 = option_item(panel_handle, &audbri_loop_type_choice,                                (int)tests[test_id]->data & 0x1 , 4, 2);                 audbri_ref_file_choice.choice[0] =(char *)tests[test_id]->special;        item7 = option_item(panel_handle, &audbri_ref_file_choice, 0, 4, 8);        if (!tty_mode) {          (void)panel_set(item7,                PANEL_VALUE_DISPLAY_LENGTH,     25,                PANEL_VALUE_STORED_LENGTH,      200,                0);        }        done_row = 9;        }        break;     case CPU_SP:	panel_label("On-Board TTY Ports");	panel_printf(panel_handle, "Configurations:", 1, 0);	panel_printf(panel_handle, "Ports: ttya & ttyb", 4, 1);	panel_printf(panel_handle, "Sub-tests:  None", 1, 3);	panel_printf(panel_handle, "Options:", 1, 5);	item1 = option_item(panel_handle, &cpusp_choice,				(int)tests[test_id]->data, 4, 6);	done_row = 7;	break;    case CPU_SP1:	panel_label("On-Board TTY Ports");	panel_printf(panel_handle, "Configurations:", 1, 0);	panel_printf(panel_handle, "Ports: ttyc & ttyd", 4, 1);	panel_printf(panel_handle, "Sub-tests:  None", 1, 3);	panel_printf(panel_handle, "Options:", 1, 5);	item1 = option_item(panel_handle, &cpusp1_choice,				(int)tests[test_id]->data, 4, 6);	done_row = 7;	break;    case ENET0:    case ENET1:    case ENET2:    case OMNI_NET:    case FDDI:    case TRNET:	(void)sprintf(tmp, "%s #%d Information", tests[test_id]->label, 			tests[test_id]->unit);	panel_label(tmp);	panel_printf(panel_handle, "Configurations:", 1, 0);        mktemp(tmpname);        (void)sprintf(enet_buffer,"/usr/ucb/netstat -i | /bin/grep '^%s' | \            /bin/awk '{ print $4 }' > %s ", tests[test_id]->devname, tmpname);        system(enet_buffer);        enet_buffer[0]= '\0';        if (( enet_fp = fopen(tmpname, "r")) == NULL) {                (void)sprintf(tmp1,"fopen error for %s\n", tmpname);		logmsg(tmp1, 1, FAILED_NET_INFO);        }         fgets(enet_buffer, 40, enet_fp);        fclose(enet_fp);        if (enet_buffer[0] != '\0') {                for (i=0; i < 40 && enet_buffer[i] != '\n'; ++i);                enet_buffer[i]='\0';        }         (void)sprintf(tmp,"Host Name:   %s", enet_buffer);        panel_printf(panel_handle, tmp, 8, 1);         hostid = gethostid();        (void)sprintf(tmp,"Host ID:   %x", hostid);        panel_printf(panel_handle, tmp, 10, 2);         if ((hp = gethostbyname(enet_buffer)) == NULL) {		(void)sprintf(tmp1, "can't get host entry");		logmsg(tmp1, 1, FAILED_NET_INFO);        	(void)sprintf(tmp1,"Host Address:  No Host Entry");        	panel_printf(panel_handle, tmp1, 5, 3);        } else {        	(void)sprintf(tmp,"Host Address:   %d.%d.%d.%d  ",        	hp->h_addr[0] & 0xff, hp->h_addr[1] & 0xff, 		hp->h_addr[2] & 0xff, hp->h_addr[3] & 0xff);        	panel_printf(panel_handle, tmp, 5, 3);	}         if ((ypup = getdomainname(domainname, 40)) == -1) {                (void)sprintf(tmp1, "Can't get domain entry YP not running");		logmsg(tmp1, 1, FAILED_NET_INFO);                (void)sprintf(tmp1, "Domain Name:   N/A - YP not running");                panel_printf(panel_handle, tmp1, 6, 4);        } else {                (void)sprintf(tmp,"Domain Name:   %s", domainname);                panel_printf(panel_handle, tmp, 6, 4);        }	panel_printf(panel_handle, "Sub-tests:  None", 1, 6);	panel_printf(panel_handle, "Options:", 1, 8);	item1 = option_item(panel_handle, &spray_choice,			(int)tests[test_id]->data & 0x01, 4, 9);	(void)sprintf(tmp1, "%d", (int)tests[test_id]->special);	delay_choice.choice[0] = tmp1;	item2 = option_item(panel_handle, &delay_choice,			0, 4, 10);	item3 = option_item(panel_handle, &driver_choice,			((int)tests[test_id]->data & 0x02) >> 1, 4, 11);        enet_buffer[0]= '\0';        (void)sprintf(enet_buffer, "/bin/rm -rf %s", tmpname);        system(enet_buffer);        enet_buffer[0]= '\0';        done_row = 12;	if (!tty_mode)	{	  (void)panel_set(item2, 		PANEL_VALUE_DISPLAY_LENGTH,	4,		PANEL_VALUE_STORED_LENGTH,	4,		0);	}        break;    case CDROM:	(void)sprintf(tmp,"%s%d",tests[test_id]->label, tests[test_id]->unit);	panel_label(tmp);	panel_printf(panel_handle, "Configurations:", 1, 0);	(void)sprintf(tmp, "Capacity: %d MB",		tests[test_id]->conf->uval.diskinfo.amt);	panel_printf(panel_handle, tmp, 4, 1);	unit = tests[test_id]->conf->uval.diskinfo.ctlr_type;	(void)sprintf(tmp, "Controller: %s",		disk_ctlr[unit>=NDISKCTLR?0:unit]);	panel_printf(panel_handle, tmp, 4, 2);	(void)sprintf(tmp, "Host Adaptor: %s%d",		tests[test_id]->conf->uval.diskinfo.ctlr,		tests[test_id]->conf->uval.diskinfo.ctlr_num);	panel_printf(panel_handle, tmp, 4, 3);	panel_printf(panel_handle, "Sub-tests:  None", 1, 4);	panel_printf(panel_handle, "Options:", 1, 5);	item1 = option_item(panel_handle, &cdtype_choice,				(int)tests[test_id]->data & 7, 4, 6);	item2 = option_item(panel_handle, &datatest1_choice,				((int)tests[test_id]->data & 8) >> 3, 4, 7);	item6 = option_item(panel_handle, &datatest2_choice,				((int)tests[test_id]->data & 0x40) >> 6, 4, 8);	(void)sprintf(tmp1, "%d", (int)tests[test_id]->data >> 8);	datatrack_choice.choice[0] = tmp1;	item7 = option_item(panel_handle, &datatrack_choice, 0, 4, 9);	item5 = option_item(panel_handle, &readmode_choice,				((int)tests[test_id]->data & 0x20) >> 5, 4, 10);	item3 = option_item(panel_handle, &audiotest_choice,				((int)tests[test_id]->data & 0x10) >> 4, 4, 11);	(void)sprintf(tmp1, "%d", (int)tests[test_id]->special);	volume_choice.choice[0] = tmp1;	item4 = option_item(panel_handle, &volume_choice, 0, 4, 12);	if (!tty_mode)	{	  (void)panel_set(item4, 		PANEL_VALUE_DISPLAY_LENGTH,	3,		PANEL_VALUE_STORED_LENGTH,	3,		0);	  (void)panel_set(item7, 		PANEL_VALUE_DISPLAY_LENGTH,	3,		PANEL_VALUE_STORED_LENGTH,	3,		0);	}	done_row = 13;	break;    case SCSIDISK1:    case XYDISK1:    case XDDISK1:    case IPIDISK1:    case IDDISK1:    case SFDISK1:    case OBFDISK1:	if (tests[test_id]->id != IDDISK1)	  (void)sprintf(tmp,"%s%d",tests[test_id]->label, tests[test_id]->unit);	else          (void)sprintf(tmp,"%s%03x",			tests[test_id]->label, tests[test_id]->unit);	panel_label(tmp);	panel_printf(panel_handle, "Configurations:", 1, 0);	amt = tests[test_id]->conf->uval.diskinfo.amt;	(void)sprintf(tmp, "Capacity: %.1f MB", amt/1000);	panel_printf(panel_handle, tmp, 4, 1);	unit = tests[test_id]->conf->uval.diskinfo.ctlr_type;	(void)sprintf(tmp, "Controller: %s",		disk_ctlr[unit>=NDISKCTLR?0:unit]);	panel_printf(panel_handle, tmp, 4, 2);	if (tests[test_id]->conf->uval.diskinfo.ctlr_num != -1)	  (void)sprintf(tmp, "Host Adaptor: %s%d",		tests[test_id]->conf->uval.diskinfo.ctlr,		tests[test_id]->conf->uval.diskinfo.ctlr_num);	else	  (void)sprintf(tmp, "Host Adaptor: %s",		tests[test_id]->conf->uval.diskinfo.ctlr);	panel_printf(panel_handle, tmp, 4, 3);	panel_printf(panel_handle, "Sub-tests:", 1, 5);	item1 = option_item(panel_handle, &raw_choice,				tests[test_id]->enable, 4, 6);	item2 = option_item(panel_handle, &fs_choice,				tests[test_id+1]->enable, 4, 7);	panel_printf(panel_handle, "Options:", 1, 9

⌨️ 快捷键说明

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