Exemplo n.º 1
0
int main(int argc, char *argv[])
{
	struct t_dfa *pd = make_dfa();
	struct t_dfa d = *pd;

	add_state_d(pd, 5);
	add_charset_d(pd, "01");
	add_move_d(pd, 0, '0', 1);
	add_move_d(pd, 1, '1', 2);
	add_move_d(pd, 2, '0', 2);
	add_move_d(pd, 2, '1', 3);
	add_move_d(pd, 3, '0', 4);
	add_move_d(pd, 3, '1', 2);
	add_move_d(pd, 4, '0', 2);
	add_move_d(pd, 4, '1', 2);

	int fcnt = 1;
	int fset[] = {4};
	add_finalset_d(pd, fset, fcnt);

	char str[1000];
	while (scanf("%s", str) != EOF && strcmp(str, "end") != 0) {
		if (check_d(pd, str)) {
			printf("%s. test true!\n", str);
		} else {
			printf("%s. test false!\n", str);
		}
	}

	free(pd);

	return 0;
}
Exemplo n.º 2
0
void execution(int argc,char* argv[])
{

	int in=0 ,io=0 ,copy_flag=0 , flag_fname=0;
		char f[6];			
	in_len=argc;
	flag_h=0;
	flag_d=0;	
	d_value=0;
	flag_f=0;
	
	for(in=0; in< in_len ;in++)
	{
			strcpy(input_arra[in],argv[in]);
	}
	//	printf("val of srgasdc is %d \n",in_len);
	flag_f=check_f(in_len);
	flag_h=check_h(in_len);
	flag_d=check_d(in_len);
//	printf("h is %d\n",flag_h);		
	if(flag_h == 1)
	{
		printf("help karo\n");
		return ;
	}			
	if(in_len < 2)
	{
		printf("\n usage ./a.out inputfile<test.cap>\n");
			return ;
	}
	if(flag_d == 0)
	{
		
		strcpy(inputfile,argv[in_len-1]);
		
	}
	else
	{

		d_value=atoi(argv[in_len-1]);
		//printf("d_value is %d \n\n",d_value);
		strcpy(inputfile,argv[in_len-3]);
	}

	//check filename exists or not	
	//printf("filename is %s",inputfile);
	 flag_fname=check_filename();	
	if(flag_fname == 1 )
	{
		printf("\n input file name is wrong\n");
		return;

	}
	for(in=0;in<30;in++)
		strcpy(runtimecmd[in]," ");
	cmd_flag=0;
	int len=0;
	//printf("number is %d \n\n",in_len);
	if(flag_d==1)
		len=in_len-3;
	else
		len=in_len-1;
	if(flag_f != 0)
	{
			
		cmd_flag=1;		
	//	printf("cmd is jgjnade %d us %d jhkj \n",flag_f,in_len);	
		io=0;
		for(in=flag_f;in<len;in++)
		{
			//printf("insied	");
			strcpy(runtimecmd[io],input_arra[in]);
				io++;		
						
		}		
		
	//	for(in=0;in<in_len;in++)	
	//		printf("runtime is  %s  ",runtimecmd[in]);
	}//	printf("\n");
	int ret, check_ret=0;
	check_ret=get_data();
	//return 1;
	if(check_ret==1)
		return;
	int checkt =-1, checkf=0;
	int checkfst=0;	
	
	//number of words in input
	int inputsize=in_len;

	strcpy(user_input,input_arra[1]);
	printdata();
	while(1)
	{
		//printf("inside while");
		checkt=-1;
		checkf=0;
		

		//checkf=check_f(inputsize);		

		if(checkfst==1)
		{
			strcpy(user_input,"");
			//checkfst=1;	


			printf(" \n enter the new commnad  \n ");
			//scanf(" %s ",input_value);
			int j=0,m=0;
			for(m=0;m<100;m++)
			{		
  				for(j=0;j<100;j++)
    					input_arra[m][j]='\0';
			}			
 			char c; 
       			for (m=0;m<100;)
            		{     
                 		for(j=0;j<100;j++)
                    		{	
                            		scanf("%c",&c);
                             		if(c==' ') 
					{
						 m++; break;
					}
                             		if(c=='\n') 
						break;
                             		input_arra[m][j]=c; 
                     		}
         			 
                		 if(c=='\n')break;
              

           		}	
			inputsize=m;
			//for( j=0;j<=m;j++)			
			  //    printf("in put is %s \n",input_arra[j]); 
                        strcpy(user_input,input_arra[0]);
		}
		checkt=check_t(inputsize);
		if(!strcmp(user_input,"exit"))
			break;			
		
		else if(!strcmp(user_input,"help"))
		{

			printf("\n am in help \n");

		}			
		else if(checkt !=-1 && checkfst == 1)
		{

	//		printf("t is present at pos %ddsf and in put size is %d \n",checkt , inputsize);			
			testcase(checkt,inputsize);
			
				
		}
		else
		{
			if(checkfst==1)
			{			
			printf("wrong command entered \n");
			}

		}
		checkfst=1;	
		


	}
	




}
Exemplo n.º 3
0
void testcase(int index , int size)
{
	//printf("inside testcase");	
	int checkip=0 , checkdel =0 ,checkd ;
	strcpy(testname,input_arra[index]);
	checkip=check_ip(size);
	checkd=check_d(size);
	checkdel=check_delta(size);
	if(checkdel != -1)
	{
		//strcpy(ip," ");
		delta=0;		
		delta=atof(input_arra[checkdel]);
		//printf("delta is %f  \n",delta);	
	}
	else
	{
		delta=0.10;
		//printf("delta is %f we\n",delta);	
	}	
	if(checkd != -1)
	{
		//strcpy(ip," ");
		d_value=0;		
		d_value=atof(input_arra[checkd]);
		//printf("delta is %f  \n",delta);	
	}
	else
	{
		d_value=2;
		//printf("delta is %f we\n",delta);	
	}	

	if(checkip != 0)
	{
				
		strcpy(ip," ");
		strcpy(ip,input_arra[checkip]);
	}
	//printf("testcase name %s is  checking on ip = %s and ",testname, ip);	
	int checks=-1;
	checks=check_s(index,size);	
	if(checks != -1)
	{
		teststream=atoi(input_arra[checks]);
		//printf("stream number is %d  \n",teststream);	
		checks=teststream;	
		if(checks>node_count)
		{
			printf(" \t stream number entered is out of range ! \n ");
			return;
		}
	}
	
	if( !strcmp(testname,"FR") || !strcmp(testname,"fr"))	
	{
		
		 tc_fr(checks , checkip );

	}
	else if( !strcmp(testname,"RT") || !strcmp(testname,"rt"))
	{
			
				 tc_rt(checks , checkip);
	}
	else
	{

		printf("wrong test case name \n");
	}		

}