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

📄 xpromptpar.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * This material contains unpublished, proprietary software of  * Entropic Research Laboratory, Inc. Any reproduction, distribution,  * or publication of this work must be authorized in writing by Entropic  * Research Laboratory, Inc., and must bear the notice:  * *    "Copyright (c) 1989-1990  Entropic Speech, Inc.  *    "Copyright (c) 1990-1991  Entropic Research Laboratory, Inc.  *                   All rights reserved" * * The copyright notice above does not evidence any actual or intended  * publication of this source code.      * * Written by:  John Shore * Checked by: * Revised by:  Alan Parker * * Brief description: utility functions for parameter prompting * */static char *sccs_id = "@(#)xpromptpar.c	1.25	2/21/96	ESI/ERL";/* * system include files */#include <stdio.h>#include <xview/xview.h>#include <xview/frame.h>#include <xview/panel.h>#include <xview/svrimage.h>#include <xview/tty.h>#include <xview/text.h>#include <xview/cms.h>#include <xview/notice.h>#include <xview/scrollbar.h>/* * esps include files */#include <esps/esps.h>#ifndef DS3100#include <esps/unix.h>#endif#include <esps/exview.h> #ifndef NULL#define NULL 0#endif/* * defines */#define Fprintf (void)fprintf#define Fflush (void)fflush#define DEBUG(n) if (debug_level >= n) Fprintf#define PARAM_OK      0#define PARAM_MAX     1		/* parameter was greater than maximum */#define PARAM_MIN     2		/* parameter was less than minimum */#define PARAM_CHOICE  3		/* illegal discrete choice */#define PARAM_FORMAT  4		/* parameter string value has bad format */#define PARAM_NO_WRITE 5        /* couldn't write parameter */#define DONE_OK  0#define BAD_PARAMS 1#define DONE_NOT_OK  2#define EXIT_NOT_DONE  3/* * global variable declarations */static int frame_exit_status; /* for exit status of main frame */extern int debug_level;extern int do_color; #if !defined(hpux) && !defined(DEC_ALPHA)char *calloc();#endifchar *savestring();char **symlist();char **symchoices();char *get_helpfile();char *symprompt();char getsymdef_c();double getsymdef_d();char* getsymdef_s();long strtol();double strtod();static int	sh_fill_param_file();static void	copysym();       char	*getsymdef_string();static int	param_checkwrite();static int	x_fill_param_file();       Frame	create_param_frame();static Panel	create_param_panels();static void	set_defaults();static void	set_default_item();static int	write_param();static void	raise_param_notice();static void	done();       void	get_nrows_ncols();/*   This routine (exv_prompt_params) right now is the only visible one from this   module; it fills in a parameter file via window or shell prompts based on    input parameter file; definite parameters are copied from input    to output file; prompts are used for the indefinite parameters    before putting them in output file*/intexv_prompt_params(param_file, flag, check_file, outfile, program, x_pos, y_pos)char *param_file;		/* input parameter file */int flag;			/* flag for Common processing */char *check_file;		/* check file for Common processing */char *outfile;			/* output parameter file */char *program;			/* intended program for param file*/int x_pos, y_pos;		/* if non-zero, locates (possible) X window */{  char *funcname = "exv_prompt_params";  char **allparams = NULL;	/* list of parameters */  char **indef_params = NULL;	/* list of indefinite parameters */  char *param = NULL;		/* specific parameter */  int nparam = 0;		/* total number of parameters */  int i, j;			/* loop indices */  int ret;			/* a return code variable */  int rp_ret;			/* for read_params return */  int xwin;			/* flag for X Windows */  spsassert(outfile != NULL, "exv_prompt_params() called with null outfile");  DEBUG(2) (stderr, "Entered promp_params\n");  if (debug_level > 1) {    Fprintf(stderr, "%s: read_params called with:\n", funcname);    Fprintf(stderr, "\t\tparam_file = %s\n", param_file);    Fprintf(stderr, "\t\tflag = %s\n", 	    (flag == SC_NOCOMMON ? "SC_NOCOMMON" : "SC_CHECK_FILE"));    Fprintf(stderr, "\t\tcheck_file = %s\n", 	    (check_file == NULL ? "NULL" : check_file));  }	    rp_ret = read_params(param_file, flag, check_file);  symerr_exit();  if ((rp_ret == -1) || (rp_ret == -3)) {    Fprintf(stderr, 	  "%s: read_params couldn't read parameter file\n", 	    funcname, param_file);    return(1);  }  if (debug_level && (rp_ret == -2))    Fprintf(stderr, "%s: read_params couldn't read Common\n", funcname);   /*get list of parameters*/  if ((allparams = symlist(&nparam)) == NULL) {    Fprintf(stderr, "%s: no parameters in symbol table\n", funcname);    return(BAD_PARAMS);  }  if (debug_level > 1)     Fprintf(stderr, "%s: %d parameters reported by symlist()\n",	    funcname, nparam);  /*allocate (excess) memory to duplicate the param list*/    indef_params = (char **) calloc((unsigned) (nparam + 1), sizeof(char *));  if(indef_params == NULL) {    fprintf(stderr, 	    "%s:couldn't allocate memory for indefinite parameter list\n",	    funcname);    return(BAD_PARAMS);    }  /* copy all parameters and get list of indefinite parameters*/  /* note: we copy them all, since defaults may be taken without change*/  if (debug_level > 1)     Fprintf(stderr, "%s: copying parameters to file %s\n",	    funcname,  outfile);  j = 0;  for (i = 0; i < nparam; i++) {    param = allparams[i];    copysym(param, outfile);    if (!symdefinite(param)) {      indef_params[j] = savestring(param); /*create new one for safety*/      j++;    }  }  indef_params[j] = NULL;  if (debug_level > 1)     Fprintf(stderr, "%s: found %d indefinite parameters\n", funcname, j);  if (j == 0) {    if (debug_level)       Fprintf(stderr, "%s: no indefinite parameters in parameter file %s\n",	      funcname, param_file);    return(BAD_PARAMS);  }  /* prompt for the indefinite parameters and fill in the rest of the file*/  /* right now wire for X; later go with detection or environment variable*/  xwin = 1;  if (!xwin)     ret = sh_fill_param_file(indef_params, outfile);  else    ret = x_fill_param_file(indef_params, outfile, program, x_pos, y_pos);  return(ret);}staticintsh_fill_param_file(params, outfile)char ** params;			/* list of indefinite parameters */char *outfile;			/* output parameter file *//* use shell prompts to fill out the indefinite parameters   from a parameter file; we assume that read_params has already been    called, and that the output param file already has the definite    parameters*/{  spsassert(outfile != NULL, "sh_fill_param_file: null outfile");  spsassert(outfile != NULL, "sh_fill_param_file: no params (null)");  DEBUG(2) (stderr, "Entered sh_fill_param_file\n");  /*use common routines with x_fill_param:    read default numeric val and return as string    convert string to numberic value and putsym    check limits on numeric items    */  /* also need routine to check string choice item (use linsearch)*/  Fprintf(stderr, "sh_fill_param_file: function not implemented yet\n");   return(0);}staticvoidcopysym(param, file)char *param;			/* name of parameter */char *file;			/* output parameter file */{  /*reads default value from parameter file and copies to named file*/  int ptype;			/* data type of parameter */  ptype = symtype(param);  switch (ptype) {  case ST_INT:    fputsym_i(param, getsymdef_i(param), file);    break;  case ST_CHAR:    Fprintf(stderr, "copysym: can't putsym for CHAR type yet\n");/*    fputsym_c(param, getsymdef_c(param), file);*/    break;  case ST_STRING:    fputsym_s(param, getsymdef_s(param), file);    break;  case ST_FLOAT:    fputsym_f(param, getsymdef_d(param), file);    break;  case ST_IARRAY:   case ST_FARRAY:     Fprintf(stderr, "copysym: parameter type not supported yet\n");    break;  case ST_UNDEF:    Fprintf(stderr, "copysym: undefined parameter %s\n", param);    break;  }  return;}char *getsymdef_string(param)char *param;{  /* return default value as a string */  int ptype;			/* data type of parameter */  char *retstr;			/* actual return string */  char strval[100];		/* space to construct return value */  ptype = symtype(param);  switch (ptype) {  case ST_INT:    sprintf(strval, "%d", getsymdef_i(param));    retstr = savestring(strval);     break;  case ST_CHAR:    sprintf(strval, "%c", getsymdef_c(param));    retstr = savestring(strval);     break;  case ST_STRING:    retstr = savestring(getsymdef_s(param));    break;  case ST_FLOAT:    sprintf(strval, "%g", getsymdef_d(param));    retstr = savestring(strval);     break;  case ST_IARRAY:     Fprintf(stderr, "getsymdef_string: ST_IARRAY not supported yet\n");    retstr = NULL;/*    size = symsize(param);        TRYALLOC(int, size, iarray, "iarray");    lim = getsymdef_ia(param, iarray, size);    for (i = 0; i < lim; i++)	Fprintf(stdout,"%d ", iarray[i]);    Fprintf(stdout, "\n");    if ((lim != size) && !zflag) {	Fprintf(stderr, 		"%s: WARNING - inconsistent size of int array\n", ProgName);	return(2);      }    else       return(0);    }*/    break;  case ST_FARRAY:         Fprintf(stderr, "getsymdef_string: ST_FARRAY not supported yet\n");    retstr = NULL;/*    size = symsize("param");        TRYALLOC(float, size, farray, "farray");    lim = getsymdef_ia(param, iarray, size);    for (i = 0; i < lim; i++)      for (i = 0; i < size; i++)      Fprintf(stdout,"%g ", farray[i]);    Fprintf(stdout, "\n");    if ((lim != size) && !zflag) {      Fprintf(stderr, 	      "%s: WARNING - inconsistent size of float array\n", ProgName);      return(2);    }    else       return(0);      }*/    break;  case ST_UNDEF:    Fprintf(stderr, "getsymdef_string: undefined parameter %s\n", param);    retstr = NULL;    break;      }  if (retstr == NULL)     Fprintf(stderr, 	  "getsymdef_string: bad parameter, bad type, or couldn't allocate memory for string\n");  return(retstr); }static intparam_checkwrite(param, strval, newval, parfile) char *param;			/* parameter name */char *strval;			/* string value of parameter */char **newval;			/* pointer to new value when limit error */char *parfile;			/* parameter file name */

⌨️ 快捷键说明

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