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

📄 cli.c

📁 4.8k/s速率FS1016标准语音压缩源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		printf("**** -b option requires specified bit errors file ****\n");		ShortUsage(argv[0], TRUE);	      }	      else	{	        UserParams->bit_error = &argv[i][j];	      }	      break;/*---------------------------------------------------------------------*/	    case 'c':	/* Channel file name *//*  Find next legal character */	      j++;	      if(argv[i][j] == '\0')	{	        i++; 		j=0;	      }	      if(i >= argc)	{/*  If no more arguments, declare it invalid */		status = INVALID;		printf("**** -c option requires specified channel file ****\n");		ShortUsage(argv[0], TRUE);	      }	      else	{	        UserParams->chan_file = &argv[i][j];	      }	      break;/*---------------------------------------------------------------------*/	    case 'd':	/* EDAC *//*  Find next legal character */	      j++;	      if(argv[i][j] == '\0')	{	        i++; 		j=0;	      }	      if(i >= argc)	{/*  If no more arguments, declare it invalid */		status = INVALID;		printf("**** -d option requires specified EDAC file ****\n");		ShortUsage(argv[0], TRUE);	      }	      else	{	        UserParams->error_parms = &argv[i][j];	        UserParams->edac = TRUE;	      }	      break;/*---------------------------------------------------------------------*/	    case 'e':	/* error rate *//*  Find next legal character */	      j++;	      if(argv[i][j] == '\0')	{	        i++; 		j=0;	      }	      if(i >= argc)	{/*  If no more arguments, declare it invalid */		status = INVALID;		printf("**** -e option requires specified error rate ****\n");		ShortUsage(argv[0], TRUE);	      }	      else	{/*  Read new error rate */	      	UserParams->error_rate = (float)(atof(&argv[i][j]));	      }	      break;/*---------------------------------------------------------------------*/	    case 'h':	/*  Help */	      Usage(argv[0]);	      status = HELP;	      break;/*---------------------------------------------------------------------*/	    case 'm':	/* smoothing *//*  Find next legal character */	      j++;	      if(argv[i][j] == '\0')	{	        i++; 		j=0;	      }/*  Assign value if next argument is valid, else consider it TRUE (default) */	      if(i<argc)	{	        if(argv[i][j] == 't' || argv[i][j] == 'T' || argv[i][j] == 'f' || argv[i][j] == 'F')	          UserParams->smoothing = (argv[i][j] == 'F' || argv[i][j] == 'f')?FALSE:TRUE;	        else	          i--;	      }	      break;/*---------------------------------------------------------------------*/	    case 'n':	/* code_param *//*  Find next legal character */	      j++;	      if(argv[i][j] == '\0')	{	        i++; 		j=0;	      }/*  Assign value if next argument is valid, else consider it TRUE (default) */	      if(i<argc)	{	        if(argv[i][j] == 't' || argv[i][j] == 'T' || argv[i][j] == 'f' || argv[i][j] == 'F')	          UserParams->code_param = (argv[i][j] == 'F' || argv[i][j] == 'f')?FALSE:TRUE;	        else	          i--;	      }	      break;/*---------------------------------------------------------------------*/	    case 'r':	/* Read channel (-r) *//*  Find next legal character */	      j++;	      if(argv[i][j] == '\0')	{	        i++; 		j=0;	      }	      switch(argv[i][j])	{		case 'B':		case 'b':		  UserParams->read_chan = BINARY;		  break;		case 'f':		case 'F':		  UserParams->read_chan = FALSE;		  break;		case 'H':		case 'h':		  UserParams->read_chan = HEX;	  	  break;		case 'I':		case 'i':		  UserParams->read_chan = BINARY_INT;	  	  break;		default:		  printf("Incorrect argument to -r %c\n", argv[i][j]);	      }	      break;/*---------------------------------------------------------------------*/	    case 's':	/* synthesis *//*  Find next legal character */	      j++;	      if(argv[i][j] == '\0')	{	        i++; 		j=0;	      }/*  Assign value if next argument is valid, else consider it TRUE (default) */	      if(i<argc)	{	        if(argv[i][j] == 't' || argv[i][j] == 'T' || argv[i][j] == 'f' || argv[i][j] == 'F')	          UserParams->synthesis = (argv[i][j] == 'F' || argv[i][j] == 'f')?FALSE:TRUE;	        else	          i--;	      }	      break;/*---------------------------------------------------------------------*/	    case 't':	/*  Channel Type */	      j++;/*  Find next legal character */	      if(argv[i][j] == '\0')	{	        i++; 	        j=0;	      }	      if(i >= argc)	{/*  If no more arguments, declare it invalid */		status = INVALID;		printf("**** -t option requires specified channel type ****\n");		ShortUsage(argv[0], TRUE);	      }	      else	{/*  Determine what type of channel from next argument */	      	switch(argv[i][j])	{		  case 'c':		    UserParams->channel_type = CLEAR;		    break;		  case 'b':		    UserParams->channel_type = RBER;		    break;		  case 'l':		    UserParams->channel_type = RBLER;		    break;		  case 'o':		    UserParams->channel_type = OTHER;		    break;		  default:		    printf("******* Invalid channel type *******\n");		    status = INVALID;		    break;	        }	      }	      break;/*---------------------------------------------------------------------*/	    case 'w': 	/* write channel (-w) *//*  Find next legal character */	      j++;	      if(argv[i][j] == '\0')	{	        i++; 		j=0;	      }	      switch(argv[i][j])	{		case 'B':		case 'b':		  UserParams->write_chan = BINARY;		  break;		case 'f':		case 'F':		  UserParams->write_chan = FALSE;		  break;		case 'H':		case 'h':		  UserParams->write_chan = HEX;	  	  break;		case 'I':		case 'i':		  UserParams->write_chan = BINARY_INT;	  	  break;		default:		  printf("Incorrect argument to -w %c\n", argv[i][j]);	      }	      break;/*---------------------------------------------------------------------*/	    default:	      printf("Unrecognized option:%s\n", argv[i]);	      ShortUsage(argv[0], TRUE);	      status = INVALID;	      break;	  }	  i++;	}	}/*  Post processing */	if(UserParams->read_chan && infile_open)	{	  *outfile = *infile;	  *infile = "None";	  infile_open = FALSE;	  outfile_open = TRUE;	}	if(status == ALL_VALID)	{	  if(!infile_open || !outfile_open)	{	    if(!infile_open)	      *infile = "None";	    if(!outfile_open)	      *outfile = "None";	  }	}	return(status);}/**************************************************************************** ROUTINE*		GetNewArgs** FUNCTION**		Opens and reads the parameter file and creates a new *		argument array and new number of arguments** SYNOPSIS*		GetNewArgs(i, argv, argc, narg, nargv)**   formal**                       data    I/O*       name            type    type    function*       -------------------------------------------------------------------*	i		int	 i	Placement of argv read in calling *					routine *	argv		char	 i	Command line arguments*	argc		int	 i	Number of arguments in command line*	nargc		int	 o	Number of arguments in new command line*	nargv		char	 o	New command line arguments****************************************************************************/#define LINE_SIZE	180void GetNewArgs(int	i, char	*argv[], int	argc,int	*nargc, char	***nargv){int	j=2;FILE	*fp;char	*Name = "CelpParms.par";int	lc=0, maxlet=0;int	k=0;char 	*status;char 	com_line[LINE_SIZE];char	*temp, **temp2;/*int 	*temp2, *temp3;*/int	arg_found = FALSE;/*  Initialize */	*nargc = 1;/*  Find next legal character */	if(argv[i][j] == '\0')	{	  i++; 	  j=0;	}/*  Assign the parameter file name */	if (i < argc)	  Name = &argv[i][j];/*  Open the paramter file */	if((fp = fopen(Name, "r")) == NULL)	{/*  Inform user if file can't be opened */	  printf("*** %s could not be opened as a parameter file ***\n", Name);	  exit(876);	}	else	{/*  Read file if it can be opened */	  printf("       Options read from: %s\n", Name);/*  Count the number of arguments that will be read *//*  Read lines from the file */	  status = fgets(com_line, LINE_SIZE, fp);	  while(status != NULL)	{	    if((com_line[0] != '#') && (com_line[0] != '\0'))	{/*  Determine the number of arguments on this line *//*  Step past argument	*/	      while((com_line[k] != ' ') && (com_line[k] != '\0') && (com_line[k] != '\n'))	{		        k++; lc++;		arg_found = TRUE;	      }/*  Increment arg counter */	      if(arg_found) {		(*nargc)++;		arg_found = FALSE;	      }/*  Update arg size counter */	      maxlet = (lc > maxlet)?lc:maxlet;/*  Reset char counters */	      lc=0;/*  Decide whether to read another line or not */	      if(com_line[k] == '\n')	{		k=0;	  	status = fgets(com_line, LINE_SIZE, fp);	      }	      else	        k++;	    }	    else	      status = fgets(com_line, LINE_SIZE, fp);	  }/*  Allocate appropriate amount of space for new argv *//*	  maxlet = ((int)(strlen(argv[0])) > maxlet)?strlen(argv[0]):maxlet;	  temp = (char *)calloc(*nargc*(maxlet+1), sizeof(char));		  temp2 = (int *)calloc(*nargc, sizeof(char *));	  temp3 = temp2;	  for(k=0; k<*nargc; k++)	{	    /*temp2[k] = (int)(&temp[k*(maxlet+1)]);*//*	    *temp3 = (int)(&temp[k*(maxlet+1)]);	    temp3++;	  }*/	  maxlet = ((int)(strlen(argv[0])) > maxlet)?strlen(argv[0]):maxlet;	  temp = (char *)calloc(*nargc*(maxlet+1), sizeof(char));		  temp2 = (char **)calloc(*nargc, sizeof(char *));	  for(k=0; k<*nargc; k++)	{	    temp2[k] = (char *)(&temp[k*(maxlet+1)]);	  }/*  Re-initialize */	  rewind(fp);/*  Assign values to new argv */	  AssignVal(fp, *nargc, argv[0], (char **)temp2);	}	/*  Return the allocated space to calling routine */	*nargv = (char **)temp2;}/**************************************************************************** ROUTINE*		AssignVal** FUNCTION**		Reads the opened parameter file and assigns the correct*		values to the new argument array.** SYNOPSIS*		AssignVal(fp, arg_size, filename, new_args)**   formal**                       data    I/O*       name            type    type    function*       -------------------------------------------------------------------*	fp		FILE	 i	File pointer to parameter file*	arg_size	int	 i	Number of arguments in the file*	filename	char	 i	Name of program using this routine*	new_args	char	 o 	Array of new arguments****************************************************************************/void AssignVal(FILE	*fp, int	arg_size,char	filename[],char	*new_args[]){char	*status;char	com_line[LINE_SIZE];int	k, j, lc;int	arg_found=FALSE;/* Assign new arguments to new argv *//*  First assign the program name */	strcpy(new_args[0], filename);	/*  Read a line from the file */	status = fgets(com_line, LINE_SIZE, fp);/*  Initialize counters */	k=0; j=0; lc=1;/*  Begin loop to assign values and read next lines */	while(status != NULL)	{/*  Check for comment line, and don't process if true */	  if((com_line[0] != '#'))	{/*  If not a comment line, step past characters looking for line argument delimiters */	    while(com_line[k] != ' ' && com_line[k] != '\n' && com_line[k] != '\0')	{/*  Increment counters and assign chars when argument is found */	      new_args[lc][j++] = com_line[k++];	      arg_found = TRUE;	    }	    if(arg_found) 	{/*  Assign proper argument delimeter to end of argument 	and continue to next new argument assignment */	      new_args[lc][j] = '\0';	      lc++;	      arg_found = FALSE;	    }/*  Reset pointers depending on current charcter in line */	    j=0;	    if(com_line[k] == '\n')	{/*  If end of line, read new line */	      k=0;	      status = fgets(com_line, LINE_SIZE, fp);	    }	    else if(com_line[k] == ' ' || com_line[k] == '\0')/*  If not end of line, look at next character */	      k++;	    if(lc > arg_size)	      printf("*** Error in nargc calculation ***\n");	  }	  else	    status = fgets(com_line, LINE_SIZE, fp);	    	}}

⌨️ 快捷键说明

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