/* file rsylparms.c */

#if !defined(COMPILE_ENVIRONMENT)
#include <gp/stdcenvf.h> /* std compile environment for functions */
#endif

void read_syl_parms(struct SYL_PARMS *syl_parms, int *perr)
  /**************************************************************/
  /*  Reads in parameter values needed for syllabification,     */
  /*  based on directory, file names, and pointer to a phone    */
  /*  pcodeset that are already in *syl_parms.                  */
  /*  Returns *perr > 0 to indicate error.                      */
  /**************************************************************/
 {char *proc = "read_syl_parms";
  char fnx[LINE_LENGTH], *fname = &fnx[0];
  char *fname_CC_inits     = "CC_inits.txt";
  char *fname_CC_bad_inits = "CC_bad_inits.txt";
  char *fname_CC_final     = "CC_final.txt";
  boolean add_to_core, add_to_file;
 /* code */
db_enter_msg(proc,1); /* debug only */
  *perr = 0;
 /* find left and right syllable boundary marks in int string form */
  syl_parms->lmark[0] = 1;
  syl_parms->lmark[1] = pcindex5r("[",syl_parms->pcdp,add_to_core=F,add_to_file=F,NULL);
  if (syl_parms->lmark[1] < 0)
    {fprintf(stderr,"*ERR:%s: no left syllable boundary ('[') in pcode.\n",proc);
     *perr = 11;
     goto RETURN;
    }
  syl_parms->rmark[0] = 1;
  syl_parms->rmark[1] = pcindex5r("]",syl_parms->pcdp,add_to_core=F,add_to_file=F,NULL);
  if (syl_parms->lmark[1] < 0)
    {fprintf(stderr,"*ERR:%s: no right syllable boundary (']') in pcode.\n",proc);
     *perr = 11;
     goto RETURN;
    }
 /* and word boundary mark */
  syl_parms->wbound[0] = 1;
  syl_parms->wbound[1] = pcindex5r("#",syl_parms->pcdp,add_to_core=F,add_to_file=F,NULL);
  if (syl_parms->lmark[1] < 0)
    {fprintf(stderr,"*ERR:%s: no word boundary ('#') in pcode.\n",proc);
     *perr = 11;
     goto RETURN;
    }
/* get integers representing some particular suprasegmental phones */
  syl_parms->iwordbound = pcindex5r("#",syl_parms->pcdp,add_to_core=F,add_to_file=F,NULL);
  syl_parms->i_default_stress = pcindex5r("'0",syl_parms->pcdp,add_to_core=F,add_to_file=F,NULL);
  if (syl_parms->lmark[1] < 0)
    {fprintf(stderr,"*ERR:%s: no default stress mark ('\'0') in pcode.\n",proc);
     *perr = 11;
     goto RETURN;
    }
/* read in list of allowable initial consonant clusters */
  fname = strcpy(fname,syl_parms->data_dir);
  if (fname[strlen(fname)-1] != '/') fname = strcat(fname,"/");
  fname = strcat(fname,fname_CC_inits);
  get_nstr_table(syl_parms->CC_init,&(syl_parms->n_CC_inits),
    MAX_CC,fname,syl_parms->pcdp,";",perr);
  if (*perr > 0)
    {fprintf(stdout,"*ERR: read of '%s' fails, err=%d\n",fname_CC_inits,*perr);
     goto RETURN;
    }
/* read in list of universally disallowed initial  */
/* consonant clusters, for use in rule IV */
  fname = strcpy(fname,syl_parms->data_dir);
  if (fname[strlen(fname)-1] != '/') fname = strcat(fname,"/");
  fname = strcat(fname,fname_CC_bad_inits);
  get_nstr_table(syl_parms->CC_bad_init,&(syl_parms->n_CC_bad_inits),
    MAX_CC,fname,syl_parms->pcdp,";",perr);
  if (*perr > 0)
    {fprintf(stdout,"*ERR: read of '%s' fails, err=%d\n",fname_CC_bad_inits,*perr);
     goto RETURN;
    }
/* read in list of allowable final consonant clusters */
  fname = strcpy(fname,syl_parms->data_dir);
  if (fname[strlen(fname)-1] != '/') fname = strcat(fname,"/");
  fname = strcat(fname,fname_CC_final);
  get_nstr_table(syl_parms->CC_final,&(syl_parms->n_CC_final),
    MAX_CC,fname,syl_parms->pcdp,";",perr);
  if (*perr > 0)
    {fprintf(stdout,"*ERR: read of '%s' fails, err=%d\n",fname_CC_final,*perr);
     goto RETURN;
    }
 RETURN:
db_leave_msg(proc,1); /* debug only */
  return;
 }
