Enscript Output

extractedLnx/linux-2.5.9/drivers/s390/misc/chandev.c_chandev_setup.c

static int chandev_setup(int in_read_conf,char *instr,char *errstr,int lineno)
{
	chandev_strval   val=isnull;
	chandev_str_enum stridx;
	long             endlong;
	chandev_type     chan_type;
	char             *str,*currstr,*interpretstr=NULL;
	int              cnt,strcnt;
	int              retval=0;
#define CHANDEV_MAX_EXTRA_INTS 12
	chandev_int ints[CHANDEV_MAX_EXTRA_INTS+1];
	currstr=alloca(strlen(instr)+1);
	strcpy(currstr,instr);
	strcnt=chandev_pack_args(currstr);
	for(cnt=1;cnt<=strcnt;cnt++)
	{
		interpretstr=currstr;
		memset(ints,0,sizeof(ints));
		for(stridx=first_stridx;stridx<last_stridx;stridx++)
		{
			str=currstr;
			if((val=chandev_strcmp(argstrs[stridx],&str,&endlong)))
				break;
		}
		currstr=str;
		if(val)
		{
			val=(((chandev_strval)stridx)*stridx_mult)+(val&~isstr);
			switch(val)
			{
			case (add_parms_stridx*stridx_mult)|iscomma:
				currstr=chandev_get_options(currstr,4,ints);
				if(*currstr&&ints[0]>=1)
				{
					if(ints[0]==1)
					{
						ints[2]=0;
						ints[3]=0xffff;
					}
					else if(ints[0]==2)
						ints[3]=ints[2];
					chandev_add_parms(ints[1],ints[2],ints[3],currstr);
					goto NextOption;
				}
				else
					goto BadArgs;
				break;
			case (claw_stridx*stridx_mult)|isnum|iscomma:
			case (claw_stridx*stridx_mult)|iscomma:
				currstr=chandev_get_options(str,6,ints);
				break;
			default:
				if(val&iscomma)
					currstr=chandev_get_options(str,CHANDEV_MAX_EXTRA_INTS,ints);
				break;
			}
			switch(val)
			{
			case noauto_stridx*stridx_mult:
			case (noauto_stridx*stridx_mult)|iscomma:
				switch(ints[0])
				{
				case 0: 
					chandev_free_all_list((list **)&chandev_noauto_head);
					chandev_add_noauto(0,0xffff);
					break;
				case 1:
					ints[2]=ints[1];
				case 2:
					chandev_add_noauto(ints[1],ints[2]);
					break;
				default:
					goto BadArgs;
				}
				break;
			case (auto_msck_stridx*stridx_mult)|iscomma:
				switch(ints[0])
				{
				case 1:
					chandev_free_all_list((list **)&chandev_msck_range_head);
					chandev_add_msck_range(0,0xffff,ints[1]);
					break;
				case 2:
					chandev_add_msck_range(ints[1],ints[1],ints[2]);
					break;
				case 3:
					chandev_add_msck_range(ints[1],ints[2],ints[3]);
					break;
				default:
					goto BadArgs;
					
				}
			case del_auto_msck_stridx*stridx_mult:
			case (del_auto_msck_stridx*stridx_mult)|iscomma:
				switch(ints[0])
				{
				case 0:
					chandev_free_all_list((list **)&chandev_msck_range_head);
					break;
				case 1:
					chandev_del_msck(ints[1]);
				default:
					goto BadArgs;
				}
			case del_noauto_stridx*stridx_mult:
				chandev_free_all_list((list **)&chandev_noauto_head);
				break;
			case (del_noauto_stridx*stridx_mult)|iscomma:
				if(ints[0]==1)
					chandev_del_noauto(ints[1]);
				else
					goto BadArgs;
				break;
			case (qeth_stridx*stridx_mult)|isnum|iscomma:
				if(ints[0]<3||ints[0]>7)
					goto BadArgs;
				chandev_add_force(chandev_type_qeth,endlong,ints[1],ints[2],
						  ints[3],ints[4],ints[5],ints[6],ints[7],
						  NULL,NULL,NULL);
				break;
			case (ctc_stridx*stridx_mult)|isnum|iscomma:
			case (escon_stridx*stridx_mult)|isnum|iscomma:
			case (lcs_stridx*stridx_mult)|isnum|iscomma:
			case (osad_stridx*stridx_mult)|isnum|iscomma:
			case (ctc_stridx*stridx_mult)|iscomma:
			case (escon_stridx*stridx_mult)|iscomma:
			case (lcs_stridx*stridx_mult)|iscomma:
			case (osad_stridx*stridx_mult)|iscomma:
				switch(val&~(isnum|iscomma))
				{
				case (ctc_stridx*stridx_mult):
					chan_type=chandev_type_ctc;
					break;
				case (escon_stridx*stridx_mult):
					chan_type=chandev_type_escon;
					break;
				case (lcs_stridx*stridx_mult):
					chan_type=chandev_type_lcs;
					break;
				case (osad_stridx*stridx_mult):
					chan_type=chandev_type_osad;
					break;
				case (qeth_stridx*stridx_mult):
					chan_type=chandev_type_qeth;
					break;
				default:
					goto BadArgs;
				}
				if((val&isnum)==0)
					endlong=-2;
				if(ints[0]<2||ints[0]>6)
					goto BadArgs;
				chandev_add_force(chan_type,endlong,ints[1],ints[2],
						  0,ints[3],ints[4],ints[5],ints[6],
						  NULL,NULL,NULL);
				break;
			case (claw_stridx*stridx_mult)|isnum|iscomma:
			case (claw_stridx*stridx_mult)|iscomma:
				if(ints[0]>=2&&ints[0]<=5)
				{
					char    *host_name,*adapter_name,*api_type;
					char    *clawstr=alloca(strlen(currstr)+1);
					
					strcpy(clawstr,currstr);
					if(!(chandev_get_string(&clawstr,&host_name)==2&&
					     chandev_get_string(&clawstr,&adapter_name)==2&&
					     chandev_get_string(&clawstr,&api_type)==1&&
					     chandev_add_force(chandev_type_claw,
							       endlong,ints[1],ints[2],0,
							       ints[3],0,ints[4],ints[5],
							       host_name,adapter_name,api_type)==0))
						goto BadArgs;
						
				}
				else
					goto BadArgs;
				break;
			case (del_parms_stridx*stridx_mult):
				ints[1]=-1;
			case (del_parms_stridx*stridx_mult)|iscomma:
				if(ints[0]==0)
					ints[1]=-1;
				if(ints[0]<=1)
					ints[2]=FALSE;
				if(ints[0]<=2)
					ints[3]=-1;
				if(ints[0]>3)
					goto BadArgs;
				chandev_remove_parms(ints[1],ints[2],ints[3]);
				break;
			case (del_force_stridx*stridx_mult)|iscomma:
				if(ints[0]!=1)
					goto BadArgs;
				chandev_del_force(ints[1]);
				break;
			case (del_force_stridx*stridx_mult):
				chandev_del_force(-1);
				break;
#if LINUX_VERSION_CODE>=KERNEL_VERSION(2,3,0)
			case (use_devno_names_stridx*stridx_mult):
				chandev_use_devno_names=TRUE;
				break;
			case (dont_use_devno_names_stridx*stridx_mult):
				chandev_use_devno_names=FALSE;
				break;
#endif
			case (cautious_auto_detect_stridx*stridx_mult):
				chandev_cautious_auto_detect=TRUE;
				break;
			case (non_cautious_auto_detect_stridx*stridx_mult):
				chandev_cautious_auto_detect=FALSE;
				break;
			case (add_model_stridx*stridx_mult)|iscomma:
				if(ints[0]<3)
					goto BadArgs;
				if(ints[0]==3)
					ints[4]=-1;
				if(ints[0]<=4)
					ints[5]=-1;
				if(ints[0]<=5)
					ints[6]=-1;
				if(ints[0]<=6)
					ints[7]=default_msck_bits;
				if(ints[0]<=7)
					ints[8]=FALSE;
				if(ints[0]<=8)
					ints[9]=FALSE;
				ints[0]=7;
				chandev_add_model(ints[1],ints[2],ints[3],
						  ints[4],ints[5],ints[6],ints[7],ints[8],ints[9]);
				break;
			case (del_model_stridx*stridx_mult)|iscomma:
				if(ints[0]<2||ints[0]>4)
					goto BadArgs;
				if(ints[0]<3)
					ints[3]=-2;
				if(ints[0]<4)
					ints[4]=-2;
				ints[0]=4;
				chandev_del_model(ints[1],ints[2],ints[3],ints[4]);
				break;
			case del_all_models_stridx*stridx_mult:
				chandev_remove_all_models();
				break;
			case reset_conf_stridx*stridx_mult:
				chandev_reset();
				chandev_init_default_models();
				break;
			case reset_conf_clean_stridx*stridx_mult:
				chandev_reset();
				break;
			case shutdown_stridx*stridx_mult:
				chandev_shutdown_all();
				break;
			case (shutdown_stridx*stridx_mult)|iscomma:
				switch(ints[0])
				{
				case 0:
					if(strlen(str))
						chandev_shutdown_by_name(str);
					else
						goto BadArgs;
					break;
				case 1:
					chandev_shutdown_by_devno(ints[1]);
					break;
				default:
					goto BadArgs;
				}
				break;
			case reprobe_stridx*stridx_mult:
				chandev_probe();
				break;
			case unregister_probe_stridx*stridx_mult:
				chandev_free_all_list((list **)&chandev_probelist_head);
				break;
			case (unregister_probe_stridx*stridx_mult)|iscomma:
				if(ints[0]!=1)
					goto BadArgs;
				chandev_unregister_probe((chandev_probefunc)ints[1]);
				break;
			case (unregister_probe_by_chan_type_stridx*stridx_mult)|iscomma:
				if(ints[0]!=1)
					goto BadArgs;
				chandev_unregister_probe_by_chan_type((chandev_type)ints[1]);
				break;
			case read_conf_stridx*stridx_mult:
				if(in_read_conf)
				{
					printk("attempt to recursively call read_conf\n");
					goto BadArgs;
				}
				chandev_read_conf();
				break;
			case dont_read_conf_stridx*stridx_mult:
				atomic_set(&chandev_conf_read,TRUE);
				break;
			case (persist_stridx*stridx_mult)|iscomma:
				if(ints[0]==1)
					chandev_persistent=ints[1];
				else
					goto BadArgs;
				break;
			default:
				goto BadArgs;
			}
		}
		else
			goto BadArgs;
	NextOption:
		if(cnt<strcnt)
		{
			/* eat up stuff till next string */
			while(*(currstr++));
		}
	}
	retval=1;
 BadArgs:
	if(!retval)
	{
		printk("chandev_setup %s %s",(val==0 ? "unknown verb":"bad argument"),instr);
		if(errstr)
		{
			printk("%s %d interpreted as %s",errstr,lineno,interpretstr);
			if(strcnt>1)
			{
				if(cnt==strcnt)
					printk(" after the last semicolon\n");
				else
					printk(" before semicolon no %d",cnt);
			}
		}
		printk(".\n Type man chandev for more info.\n\n");
	}
	return(retval);
}

Generated by GNU enscript 1.6.4.