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

📄 cfg.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 2 页
字号:
                           *(t_arr[ind]) = NULL_CHAR;                       break;                   default:                       fprintf(stderr,"Error: Unknown CONFIG type %d\n",                             cfg->rec_list[i].value_type);                       exit(-1);                       break;	    }        i++;    }}/****************************************************************//*  Return the CFG_C value based on the id string               *//****************************************************************/char * CONFIG_elem_C(cfg,str)CONFIG *cfg;char *str;{    int cfg_ind;    if ((cfg_ind = is_CONFIG_id(cfg,str)) != NOT_CONFIG_ID)        return (cfg->rec_list[cfg_ind].value);    fprintf(stderr,"Error: Unknown Config Paramater Requested %s\n",str);    exit(-1);}/****************************************************************//*  Return the CFG_STR value based on the id string             *//****************************************************************/char * CONFIG_elem_STR(cfg,str)CONFIG *cfg;char *str;{    return(CONFIG_elem_C(cfg,str));}/****************************************************************//*  Return the CFG_TGL value based on the id string             *//****************************************************************/int CONFIG_elem_TGL(cfg,str)CONFIG *cfg;char *str;{    int cfg_ind;    if ((cfg_ind = is_CONFIG_id(cfg,str)) != NOT_CONFIG_ID)        return ((int)cfg->rec_list[cfg_ind].value);    fprintf(stderr,"Error: Unknown Config Paramater Requested %s\n",str);    exit(-1);}/****************************************************************//*  Return the CFG_C2 value based on the id string              *//****************************************************************/char ** CONFIG_elem_C2(cfg,str)CONFIG *cfg;char *str;{    int cfg_ind;    if ((cfg_ind = is_CONFIG_id(cfg,str)) != NOT_CONFIG_ID)        return ((char **)cfg->rec_list[cfg_ind].value);    fprintf(stderr,"Error: Unknown Config Paramater Requested %s\n",str);    exit(-1);}/****************************************************************//*  Set the value for the CFG_TGL value based on the id string  *//****************************************************************/set_CONFIG_elem_TGL(cfg,str,value)CONFIG *cfg;char *str;int value;{    int cfg_ind;    if ((cfg_ind = is_CONFIG_id(cfg,str)) == NOT_CONFIG_ID){        fprintf(stderr,"Error: Unknown Config Paramater Set Requested %s\n",                       str);        exit(-1);    }    cfg->rec_list[cfg_ind].value = (char *)value;}/****************************************************************//*  Set the value for the CFG_C value based on the id string    *//****************************************************************/set_CONFIG_elem_C(cfg,str,value)CONFIG *cfg;char *str;char *value;{    set_CONFIG_elem_STR(cfg,str,value);}/****************************************************************//*  Set the value for the CFG_STR value based on the id string  *//****************************************************************/set_CONFIG_elem_STR(cfg,str,value)CONFIG *cfg;char *str;char *value;{    int cfg_ind;    if ((cfg_ind = is_CONFIG_id(cfg,str)) == NOT_CONFIG_ID){        fprintf(stderr,"Error: Unknown Config Paramater Set Requested %s\n",                       str);        exit(-1);    }    strcpy(cfg->rec_list[cfg_ind].value,value);}/****************************************************************//*  Return the element count for the id string                  *//****************************************************************/CONFIG_elem_count(cfg,str)CONFIG *cfg;char *str;{    int ind;    if ((ind = is_CONFIG_id(cfg,str)) == NOT_CONFIG_ID){        fprintf(stderr,"Error: Invalid id string to find CONFIG ");        fprintf(stderr,"element count\n");        exit(-1);    }    return(cfg->rec_list[ind].num_elem);}/****************************************************************//*  Return the element count for the id string                  *//****************************************************************/CONFIG_elem_present_C2(cfg,str)CONFIG *cfg;char *str;{    int ind, i;    char **t_arr;    if ((ind = is_CONFIG_id(cfg,str)) == NOT_CONFIG_ID){        fprintf(stderr,"Error: Invalid id string to find CONFIG ");        fprintf(stderr,"element present count\n");        exit(-1);    }    t_arr = (char **)cfg->rec_list[ind].value;    for (i=0; i<cfg->rec_list[ind].num_elem; i++)        if (t_arr[i][0] == NULL_CHAR)           return(i);    return(cfg->rec_list[ind].num_elem);}/****************************************************************//*  Return the element index for the id string                  *//****************************************************************/is_CONFIG_id(cfg,id)CONFIG *cfg;char *id;{    int i=0;    while (*(cfg->rec_list[i].intern_id) != NULL_CHAR){        if (strcasecmp(id,cfg->rec_list[i].intern_id) == 0)            return(i);        i++;    }    return(NOT_CONFIG_ID);}/****************************************************************//*  Dump the config structure to stdout                         *//****************************************************************/dump_CONFIG(cfg)CONFIG *cfg;{    int i=0;    printf("Dump of the Configuration arguments and their values\n\n");    printf("      Name       # elem  type    value\n");    while (*(cfg->rec_list[i].intern_id) != NULL_CHAR){       printf(" %15s  %3d    ",cfg->rec_list[i].intern_id,             cfg->rec_list[i].num_elem,             cfg->rec_list[i].value_type);       switch (cfg->rec_list[i].value_type){           case CFG_TGL:              printf("TGL    ");              if ((cfg->rec_list[i].value) == NULL)                  printf(" OFF\n");              else                  printf(" ON\n");              break;           case CFG_STR:              printf("STR    ");              printf(" %s\n",(char *)cfg->rec_list[i].value);              break;           case CFG_C:              printf("FILE   ");              printf(" %s\n",(char *)cfg->rec_list[i].value);              break;           case CFG_C2:{              char **chr;              int ind = 0;              printf("N_STR  ");              chr = (char **)cfg->rec_list[i].value;              if (chr == NULL){                  printf("\n");                  break;	      }              printf(" %s\n",chr[ind]);              for (ind = 1;ind < cfg->rec_list[i].num_elem; ind++)                  if (*(chr[ind]) != NULL_CHAR)                      printf("%30s   %s\n","",chr[ind]);              break;	   }           default:              fprintf(stderr,"Error: Unknown CONFIG type %d\n",                             cfg->rec_list[i].value_type);              exit(-1);              break;       }       i++;    }}/****************************************************************//*  Dump the config structure to stdout (this is as a usage     *//*  statement)                                                  *//****************************************************************/print_usage_CONFIG(cfg,prog_name)CONFIG *cfg;char *prog_name;{    int i=0;    printf("Usage: %s\n",prog_name);    while (*(cfg->rec_list[i].intern_id) != NULL_CHAR){       switch (cfg->rec_list[i].value_type){           case CFG_TGL:              printf("      [ -%s ]\n",cfg->rec_list[i].intern_id);              break;           case CFG_STR:              printf("      [ -%s string ]\n",cfg->rec_list[i].intern_id);              break;           case CFG_C:              printf("      [ -%s file_name ]\n",cfg->rec_list[i].intern_id);              break;           case CFG_C2:{              int ind;              printf("      [ -%s ",cfg->rec_list[i].intern_id);              printf("(MAX %d) file_name ]\n",cfg->rec_list[i].num_elem);              break;	   }           default:               fprintf(stderr,"Error: Unknown CONFIG type %d\n",                              cfg->rec_list[i].value_type);               exit(-1);               break;       }       i++;    }}

⌨️ 快捷键说明

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