/* file fcndcls.h              */
/* local function declarations */

#ifndef FCNDCLS_HEADER
#define FCNDCLS_HEADER

extern void           add_add_file(pcodeset *p1, char *full_fname, int *perr);
extern void           add_default_stress(int *istr,pcodeset *pcdp,int i_default_stress);
extern void           add_default_stress_prot(PROTECTED_INT_STR *nsx, pcodeset *pcdp,int i_default_stress);
extern int            add_pcode_element(pcodeset *p1, pcode_element *px, int *perr);
extern ARC_LIST_ATOM *add_to_arc_list(ARC_LIST_ATOM *list_atom, ARC *arc, int *perr);
extern struct WPROB_LIST_ATOM *add_to_wprob_list2(struct WPROB_LIST_ATOM *list_atom, struct WPROB *wprobx,pcodeset *pcode1,int *perr);
extern void           adjust_confusion_table(struct WPROB_LIST_ATOM *ct[MAX_WORDS_IN_LEX],double Pcorr,pcodeset *pcode1,int *perr);
extern char          *adjust_type_case(char *s, pcodeset *pcode);
extern int            aldist_static(ALIGNMENT_INT *pal, int *perr);
extern int            aldist_static_prot(ALIGNMENT_INT_PROT *pal, int *perr);
extern int            aldist2(ALIGNMENT_INT *pt1, int (*w) (int, int, pcodeset *, int *), int return_alignment, ALIGNMENT_INT *pt2, int *perr);
extern int            aldist2_prot(ALIGNMENT_INT_PROT *pt1, int (*w) (int,int,pcodeset*,int*), int return_alignment, ALIGNMENT_INT_PROT *pt2, int *perr);
extern int            aldist2c(ALIGNMENT_INT *pt1, int (*w) (int, int, pcodeset *, int *), int return_alignment, int cut_off, ALIGNMENT_INT *pt2, int *perr);
extern int            aldistsm(ALIGNMENT_INT *aln_in, int (*w) (int, int, pcodeset *, int *), int return_alignment, double fom_threshold, ALIGNMENT_INT *aln_out, int *perr);
extern int            aldistsm_prot(ALIGNMENT_INT_PROT *aln_in, int (*w) (int,int,pcodeset*,int*), int return_alignment, double fom_threshold, ALIGNMENT_INT_PROT *aln_out, int *perr);
extern int            aldistn1(NODE *node, ALIGNMENT_INT *aln_base, int (*wod) (int, int, pcodeset *, int *), int return_alignment, ALIGNMENT_INT *aln_best, int *pathn, int *perr);
extern double         aldistt1(ALIGNMENT_INT *pt1, WTOKE_STR1 *ref_segs, WTOKE_STR1 *hyp_segs, int return_alignment, ALIGNMENT_INT *pt2, int *perr);
extern int            aldist2l(char *astr, char *bstr);
extern boolean        aleq1(ALIGNMENT_INT *p1, ALIGNMENT_INT *p2);
extern boolean        aleq1_prot(ALIGNMENT_INT_PROT *p1, ALIGNMENT_INT_PROT *p2);
extern void           alignment_i_to_s(ALIGNMENT_INT *pia1, ALIGNMENT_CHR *psa1, int *perr);
extern void           alignment_s_to_ir(ALIGNMENT_INT *pia1, ALIGNMENT_CHR *psa1, pcodeset *pcode1,TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms, int *perr);
extern void           alignment_s_to_ir_prot(ALIGNMENT_INT_PROT *pia1, ALIGNMENT_CHR_PROT *psa1, pcodeset *pcode1,TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms, int *perr);
extern void           aln_i_to_s_fancy(ALIGNMENT_INT *pia1, ALIGNMENT_CHR *psa1, int *perr);
extern void           aln_i_to_s_fancy2(ALIGNMENT_INT *pia1, ALIGNMENT_CHR *psa1, int *perr);
extern void           aln_i_to_s_prot5(ALIGNMENT_INT_PROT *pia1, ALIGNMENT_CHR_PROT *psa1, char *delimiter, int *perr);
extern void           align_and_tally(ALIGNMENT_INT *pn1, int wb, TALLY_STR *tally_table, int *perr);
extern void           alignment_s_to_i(ALIGNMENT_INT *pia1, ALIGNMENT_CHR *psa1, pcodeset *pcode1, int *perr);
extern void           alignment_i_to_s_prot(ALIGNMENT_INT_PROT *pia1, ALIGNMENT_CHR_PROT *psa1, int *perr);
extern void           alignment_s_to_i3(void (*encode) (char*,pcodeset*,int*,int*,int*),ALIGNMENT_INT *pia1, ALIGNMENT_CHR *psa1, pcodeset *pcode1, int *perr);
extern boolean        all_caps(char *sx);
extern boolean        all_lower(char *sx);
extern char          *apply_rules2(char *pb, char *pa, RULESET2 *rset, int *perr);
extern PROTECTED_CHR_STR *apply_rules2_prot(PROTECTED_CHR_STR *pb, char *sa, RULESET2 *rset, int *perr);
extern void           apply_sylb_rule_IIIp(struct PRON2 *pron, int *hit, struct SYL_PARMS *syl_parms);
extern void           apply_sylb_rule_IVp(struct PRON2 *pron, int *hit, struct SYL_PARMS *syl_parms);
extern void           apply_sylb_rule_Vp(struct PRON2 *pron, int *hit, struct SYL_PARMS *syl_parms);
extern boolean        arcs_equal(ARC *arc1, ARC *arc2);
extern char          *ascii_str(char *sx, PCIND_T ichr, pcodeset *pcode, ALIGNMENT_INT *pal);
extern PROTECTED_CHR_STR *ascii_str_prot(PROTECTED_CHR_STR *sx, PCIND_T ichr, pcodeset *pcode, ALIGNMENT_INT_PROT *pal);
extern char           *ascii_stri_prot(PROTECTED_CHR_STR  *sx, PCIND_T ichr, pcodeset *pcode, ALIGNMENT_INT_PROT *pal);
extern boolean        atobool(char *s);
extern boolean        bad_init_cluster2(WCHAR_T *aint, struct INTERVAL1 cluster,struct SYL_PARMS *syl_parms);
extern char          *bits(long int x, int nbits, char *sx);
extern char          *bool_print(boolean x);
extern boolean        bound(char c);
extern boolean        boundary_mark(int i, pcodeset *pcdp);
extern char          *build_key2(char *key, SUBSTRING *ss_le, SUBSTRING *ss_tg,SUBSTRING *ss_re, char tgbound);
extern char          *build_key3(char *key, char *le, char *tg, char *re, char tgbound);
extern void           calc_aln_errs1(ALIGNMENT_INT *al1, int *sub, int *ins, int *del);
extern void           calc_aln_errs1_prot(ALIGNMENT_INT_PROT *al1, int *sub, int *ins, int *del);
extern void          *calloc_safe(size_t nobj, size_t size, char *calling_proc);
extern char          *char_name(char *sx, char character);
extern PROTECTED_CHR_STR *char_name_prot(PROTECTED_CHR_STR *psx, char character);
extern void           chunk_out(FILE *fp, char *s, int line_width, char continuation_chr);
extern void           chunk_out2(FILE *fp, char *s, int line_width, char *cc1, char continuation_chr);
extern char          *clean_up2(char *w, char *allowed);
extern char          *cocoon(char *sx, char *token);
extern void           compact(ALIGNMENT_INT *pal, int *ndel);
extern DATE_FORMAT1   convert_date1(char *old_date, char *old_format);
extern boolean        consonantal(int i, pcodeset *pcdp);
extern boolean        contains_whitespace(char *token);
extern ALIGNMENT_INT *copy_int_al(ALIGNMENT_INT *p2, ALIGNMENT_INT *p1);
extern ALIGNMENT_INT_PROT *copy_int_al_prot(ALIGNMENT_INT_PROT *p2, ALIGNMENT_INT_PROT *p1);
extern boolean        coronal(char c);
extern NETWORK       *create_parallel_network_from_text(char *name, char *s0, char left_alt_bound, char rght_alt_bound, char alt_symbol, int *perr);
extern NETWORK       *create_series_network_from_text(char *name, char *s0, char left_alt_bound, char rght_alt_bound, char alt_symbol, int *perr);
extern DATE_FORMAT1   datej1(long int jdate);
extern void           db_enter_msg(char *proc, int level);
extern void           db_leave_msg(char *proc, int level);
extern char          *dealt2(char *sy, char *sx, boolean zap_if_null, boolean zap_if_nonlex,boolean dont_pick_null, boolean dont_pick_nonlex,int *perr);
extern void           del_chars(char *sx, char *chars);
extern void           decode2(char *psex, int lpsex, pcodeset *pc1, int *psinin, int *plinin, int *perr);
extern void           decode3_prot(PROTECTED_CHR_STR *sex, pcodeset *pc1, PROTECTED_INT_STR *sin, int *perr);
extern void           deflag1_node_r(NODE *node);
extern void           deflag2_node_r(NODE *node);
extern ARC_LIST_ATOM *del_from_arc_list(ARC_LIST_ATOM **plist, ARC *arc, int *perr);
extern char          *del_eol(char *ps);
extern void           dump_arc(ARC *arc);
extern void           dump_arc_list(ARC_LIST_ATOM *p);
extern void           dump_arc_list2(ARC *arcs[MAX_ARCS], int n_arcs);
extern void           dump_auxtab(ALIGNMENT_INT *pal);
extern void           dump_auxtab_prot(ALIGNMENT_INT_PROT *pal);
extern void           dump_bpaths(struct BPATH *bpath);
extern void           dump_chr_alignment(ALIGNMENT_CHR *p1);
extern void           dump_chr_alignment_prot(ALIGNMENT_CHR_PROT *p1);
extern void           dump_code_table(TABLE_OF_CODESETS *ps1);
extern void           dump_hash_pars(HASH_PARAMETERS *hpars);
extern void           dump_int_alignment(ALIGNMENT_INT *p1);
extern void           dump_int_alignment_prot(ALIGNMENT_INT_PROT *p1);
extern void           dump_int_alignment3(ALIGNMENT_INT *p1, pcodeset *pcode);
extern void           dump_int_alignment4(ALIGNMENT_INT *p1);
extern void           dump_int_alignment4_prot(ALIGNMENT_INT_PROT *paln);
extern void           dump_network(NETWORK *net);
extern void           dump_network_arcs(NETWORK *net);
extern void           dump_node(NODE *node);
extern void           dump_node_r(NODE *node);
extern void           dump_node_arcs_r(NODE *node);
extern void           dump_node_list2(NODE *nodes[MAX_NODES], int n_nodes);
extern void           dump_nstr(int *nstr);
extern void           dump_pcode2(pcodeset *p1);
extern void           dump_pcode3(pcodeset *p1);
extern void           dump_ppf1(pcodeset *pcode);
extern void           dump_ppf2(pcodeset *pcode);
extern void           dump_pron2(struct PRON2 *pron);
extern void           dump_rules2(RULESET2 *rset);
extern void           dump_smtab(SM_TAB_STR2 *smtab);
extern void           dump_sylbs(struct SYLB1 *sylb, int nsylbs);
extern void           dump_syl_parms(struct SYL_PARMS *syl_parms);
extern void           dump_tally1(TALLY_STR *table);
extern void           dump_word_tokens(WTOKE_STR1 *word_tokens, int lim);
extern void           dump_words(struct WORD1 *word, int nwords);
extern void           dump_wprob2(struct WPROB *wprob, pcodeset *pcode1);
extern void           dump_wprob_list2(struct WPROB_LIST_ATOM *list_atom, pcodeset *pcode1);
extern void           dump_confusion_table2(struct WPROB_LIST_ATOM *ct[MAX_WORDS_IN_LEX], pcodeset *pcode1);
extern void           encode_arcs_r(NODE *node, pcodeset *pcode, int *perr);
extern void           encode_lcs(pcodeset *p1, int *perr);
extern void           encode_lcsr(pcodeset *p1, TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms, int *perr);
extern void           encode2(char *psex_in, pcodeset *pcstr, int *psinin, int *plinin, int *perr);
extern void           encode2r(char *sex, pcodeset *pcstr, TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms,int *sinin, int *plinin, int *perr);
extern void           encode3r(char *sex, pcodeset *pc1, TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms, PROTECTED_INT_STR *sin, int *perr);
extern boolean        end_comment(char *sp);
extern boolean        end_crosstalk(char *sp);
extern boolean        end_mispron(char *sp);
extern boolean        end_overlap(char *sp);
extern boolean        end_unsure(char *sp);
extern boolean        eq_ex_rate2(struct PRON2 *pron1, struct PRON2 *pron2);
extern void           expand_sylb3(struct PRON2 pron[MAX_SYLB_PRONS + 1], int i, int *nprons, int rate, struct SYL_PARMS *syl_parms, int *perr);
extern char          *expenv(char *s, int slength);
extern void           expenv_prot(PROTECTED_CHR_STR *s);
extern char          *external_date(char *sx,DATE_FORMAT1 *internal_date,char *ext_format);
extern char          *extract_fname_base(char *fname, char *fname_base);
extern void           extract_evallm_results(double *perp, double *entropy, int *noov, double *percent_oov, char *fname);
extern void           extract_times(double *real_time, double *user_time, double *sys_time,char *fname, int *perr);
extern void           fatal_error(char *reporting_procedure, char *msg, int error_level);
extern PROTECTED_CHR_STR *fgets_prot(PROTECTED_CHR_STR *ps, FILE *stream);
extern int            find_key3(char *pi_tg, int *ib_found, pcodeset *pcdrls, struct BPATH *bpath);
extern void           fill_mark_struct(FILE *fp, WTOKE_STR1 *word_tokens, char *fname, boolean *end_of_file, int *perr);
extern void           find_next_alt_token(SUBSTRING *x, SUBSTRING *y, char left_bound, char rght_bound, char alt_symbol);
extern void           find_next_token(SUBSTRING *x, SUBSTRING *y);
extern void           find_next_token2(SUBSTRING *x, SUBSTRING *y);
extern void           find_next_token3(SUBSTRING *x, SUBSTRING *y);
extern void           find_next_token4(SUBSTRING *x, SUBSTRING *y, char left_bound, char rght_bound, char *special_delimiters);
extern float          float_n_choose_r(int n, int r);
extern void           fold_tiers2(WCHAR_T *sint, struct PRON2 *pron, int *lmark, int *rmark, int *wbound);
extern void           free_al_chr(ALIGNMENT_CHR *p);
extern void           free_al_chr_prot(ALIGNMENT_CHR_PROT *p);
extern void           free_al_int(ALIGNMENT_INT *p);
extern void           free_al_int_prot(ALIGNMENT_INT_PROT *pal);
extern void           free_bpath1(struct BPATH *bpath);
extern void           free_code_table(TABLE_OF_CODESETS *p);
extern void           free_mark_file(WTOKE_STR1 *word_tokens);
extern void           free_network(NETWORK *net);
extern void           free_pcode(pcodeset *p);
extern void           free_pcode_element(pcode_element *px);
extern void           free_rules2(RULESET2 *rset);
extern void           free_str(char *s);
extern void           free_string_array(char *x[], int n1, int n2);
extern void           free_syl_parms(struct SYL_PARMS *syl_parms);
extern void           free_syl_parms2(struct SYL_PARMS *syl_parms);
extern boolean        fric1(char *p);
extern  int           garble3(char *ref, char *hyp, ALIGNMENT_INT *ref_hyp_trans, pcodeset *pcode1,struct WPROB_LIST_ATOM *ct[MAX_WORDS_IN_LEX],int *perr);
extern void           genpaths2(NODE *node, pcodeset *pcode1,void (*pathfcn)(int *istr, pcodeset *pcode1, int *pathn, int *perr),int *pathn, PROTECTED_INT_STR *path, int *perr);
extern void           gct_analyze_line(char *pline, TABLE_OF_CODESETS *ps1, int *perr);
extern void           gct_analyze_line2(char *pline, TABLE_OF_CODESETS *ps1, int use_add_file, int *perr);
extern void           get_bpath_from_pcdrls1(struct BPATH *bpath,pcodeset *pcdrls,char tgbound,int *perr);
extern void           get_code_table(TABLE_OF_CODESETS *ps1, char *fname, int *perr);
extern void           get_code_table2(TABLE_OF_CODESETS *ps1, char *fname, int use_add_file, int *perr);
extern void           get_comment_flag(char *s, char *comment_flag);
extern void           get_confusion_table(struct WPROB_LIST_ATOM *ct[MAX_WORDS_IN_LEX],pcodeset *pcode1,char *fname_ct,int *perr);
extern char          *get_conv_id(char *conv_id,char *mark_file_name);
extern int            getline(char *line, int lmax);
extern void           get_mark_file(char *fname, WTOKE_STR1 *word_tokens, int *perr);
extern void           get_mark_file2(char *fname, WTOKE_STR1 *word_tokens, char *format, int *perr);
extern void           get_next_alignment_chr(FILE *cfp, ALIGNMENT_CHR *palc1, int *p_at_end);
extern void           get_next_alignment_chr_prot(FILE *cfp, ALIGNMENT_CHR_PROT *palc1, boolean *p_at_end);
extern void           get_next_aln_chr2(FILE *fp_ref, FILE *fp_hyp, ALIGNMENT_CHR *palc1, int *p_at_end);
extern void           get_next_mark_utt(FILE *fp, WTOKE_STR1 *word_tokens, char *fname, boolean *end_of_file, int *perr);
extern void           get_next_rec(FILE *fp, char *rec, int rec_length, char *comment_flag);
extern void           get_nstr_table(int **tab, int *n, int nmax, char *fname, pcodeset *pcode, char *comment_flag, int *perr);
extern void           get_pcode3(pcodeset *p1, char *path, char *fname, int *perr);
extern void           get_pcode4(pcodeset *p1, char *path, char *fname, int use_add_file, int *perr);
extern void           get_pcode_element(char *pline, int compositional, pcode_element *px, int *perr);
extern void           get_pcode_element2(char *pline, boolean compositional, char *element_type, pcode_element *px, int *perr);
extern void           get_ppfcn2(ppfcn *ppf, char *fname, pcodeset *pcode, int *perr);
extern void           get_rules2(RULESET2 *rset, char *path, char *fname, int *perr);
extern int            hash(char *key, HASH_PARAMETERS *hpars, int table_length);
extern void           hash_init(HASH_PARAMETERS *hpars);
extern double         hhmmss2secs(SUBSTRING *ss_token);
extern void           init_al_chr(ALIGNMENT_CHR *palc1);
extern void           init_al_chr_prot(ALIGNMENT_CHR_PROT *palc1);
extern void           init_al_int(ALIGNMENT_INT *paln1, pcodeset *pcode1);
extern void           init_al_int_prot(ALIGNMENT_INT_PROT *paln1, pcodeset *pcode1);
extern NETWORK       *init_network2(char *name, char *s0, int *perr);
extern void           init_pc_table(pcodeset *p1);
extern void           init_pcdrls(pcodeset *pcdrls, int max_ncodes, boolean hashed);
extern void           init_syl_parms(struct SYL_PARMS *syl_parms, boolean plus_foreign_loans, int *perr);
extern void           insert_net(NODE *from_node, NODE *to_node, NETWORK *net);
extern void           interchange_tallies(TALLY_STR *table, int i, int j);
extern boolean        isvowel1(char c);
extern boolean        isvowel2(char c);
extern boolean        iscons1(char c);
extern boolean        iscons2(char c);
extern boolean        is_front_vowel(char c);
extern long int       jdate1(DATE_FORMAT1 *date1);
extern void           kill_arc(ARC *arc1);
extern void           kill_node2(NODE *node1);
extern char          *lc_astr(char *sx, int ichr, pcodeset *pcode, ALIGNMENT_INT *pal);
extern int           *lc_istr(int *sx, int ichr, pcodeset *pcode, ALIGNMENT_INT *pal);
extern int           *lc_istr_prot(PROTECTED_INT_STR *sx, int ichr, pcodeset *pcode, ALIGNMENT_INT_PROT *pal);
extern void           literalize_network(NETWORK *net, NODE *node, int *perr);
extern ALIGNMENT_CHR *make_al_chr(void);
extern ALIGNMENT_CHR_PROT *make_al_chr_prot2(char *ident);
extern ALIGNMENT_INT *make_al_int(pcodeset *pcode1);
extern ALIGNMENT_INT_PROT *make_al_int_prot2(char *ident, pcodeset *pcode1);
extern ARC           *make_arc(char *symbol, NODE *from_node, NODE *to_node, int *perr);
extern void           make_basic_int_al(ALIGNMENT_INT *alnx);
extern void           make_basic_int_al_prot(ALIGNMENT_INT_PROT *alnx);
extern void           make_basic_pron4(struct PRON2 *pron, char *sx, struct SYL_PARMS *syl_parms, int *perr);
extern pcode_element *make_element(pcode_element *px, char *symb, pcodeset *pc1);
extern pcode_element *make_elementr(pcode_element *px, char *symb,pcodeset *pc1, TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms);
extern pcode_element *make_elementr_prot(pcode_element *px, char *symb, pcodeset *pc1, TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms);
extern char          *make_full_fname(char *sx, char *path, char *fname);
extern void           make_pcd_from_rls_file(pcodeset *pcdrls,char *fname_pcdrls,char *path, char tgbound, int *perr); 
extern char          *make_lower(char *s);
extern char          *make_upper(char *s);
extern void           make_zap_lists_r(NODE *node1, NODE *nodes[MAX_NODES], int *n_nodes, ARC *arcs[MAX_ARCS], int *n_arcs, int *perr);
extern NODE          *make_node(char *name, ARC *from_arc, ARC *to_arc, int *highest_nnode_name, int *perr);
extern void           make_pc_table(pcodeset *p1);
extern void           make_syllabified_prons(struct PRON2 pron[MAX_SYLB_PRONS + 1], int *nprons, char *ph, struct SYL_PARMS *syl_parms, int *perr);
extern void          *malloc_safe(size_t size, char *calling_proc);
extern boolean        mispron(char *sp);
extern long int       n_choose_r(int n, int r);
extern long int       ndays_in_mo(int imo, int iyr);
extern long int       ndays_in_yr(int iyr);
extern boolean        no_word_boundl(WCHAR_T *bnd_int, struct INTERVAL1 cluster, int iwordbound);
extern boolean        no_word_boundr(WCHAR_T *bnd_int, struct INTERVAL1 cluster, int iwordbound);
extern double         normprob(double z);
extern int            nselected(int *iselect, int *jselect, pcodeset *pcode);
extern int           *nstrcpy(int *pn_to, int *pn_from);
extern int           *nstrcpyn(int *pn_to, int *pn_from, int nmax);
extern int           *nstrcat(int *pn_to, int *pn_from);
extern int           *nstrdup(int *pn);
extern int           *nstrdup_safe(int *pn, char *calling_proc);
extern boolean        nstreq(int *pn1, int *pn2);
extern int            nstrcmp(int *pn1, int *pn2);
extern int           *nstr_rev(int *pn);
extern int            nsylbs1(int iword, pcodeset *pcode_word, int *perr);
extern int            ntokens(char *s);
extern int            number_of_insertions(ALIGNMENT_INT *pn1);
extern int            number_of_deletions(ALIGNMENT_INT *pn1);
extern int            number_of_substitutions(ALIGNMENT_INT *pn1);
extern boolean        ok_init_cluster2(WCHAR_T *aint, struct INTERVAL1 cluster, struct SYL_PARMS *syl_parms);
extern boolean        ok_final_cluster2(WCHAR_T *aint, struct INTERVAL1 cluster, struct SYL_PARMS *syl_parms);
extern int            overlap1(struct INTERVAL1 a, struct INTERVAL1 b);
extern char          *pad_words_with_space(char *out, int out_lim,char *in, int npad);
extern void           parse_alts(SUBSTRING *ss_alts, int *nalts, char *alt[MAX_ALTS]);
extern void           parse_q1_rec(SUBSTRING *ss_head, SUBSTRING *ss_text,SUBSTRING *ss_tail, char *rec);
extern void           parse_rule_key(SUBSTRING *ss_le, SUBSTRING *ss_tg, SUBSTRING *ss_re,char *rkey, char tgbound);
extern void           parse_stm_rec(char *pa,int *nrecs,char *file_id,char *channel,char *speaker_id,double *start_time,double *end_time,char *categories,char *text,int *perr);
extern void           parse_trn2_rec(SUBSTRING *ss_text, SUBSTRING *ss_tail, char *rec);
extern int            pc_htab_store(pcodeset *pc1, pcode_element *element, int *duplicate_key, int *table_full);
extern int            pcindex_htab_lookup(char *symb, pcodeset *pc1, int *found);
extern char          *pcext1(int iphone, pcodeset *pcstr);
extern int            pcodeset_misorders(pcodeset *pc1);
extern PCIND_T        pcindex2(char *phone, pcodeset *pc1);
extern PCIND_T        pcindex2r(char *symbol, pcodeset *pc1,TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms);
extern PCIND_T        pcindex_bsearch(char *astr, pcodeset *pc1);
extern PCIND_T        pcindex_lsearch(char *astr, pcodeset *pc1, boolean *found);
extern PCIND_T        pcindex5(char *symb, pcodeset *pc1, int add_to_core, int add_to_file);
extern PCIND_T        pcindex5r(char *symb, pcodeset *pc1, int add_to_core, int add_to_file,TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms);
extern int            pcindex_char_lookup(char *symb, pcodeset *pc1, boolean *found);
extern void           pcsort1(pcodeset *p1);
extern int            pick_alt(int nalts, char *alt[MAX_ALTS],boolean zap_if_null,boolean zap_if_nonlex,boolean dont_pick_null, boolean dont_pick_nonlex);
extern enum edits1    pick_min1d(short int dx[]);
extern enum edits1    pick_min1du(unsigned short int dx[]);
extern enum edits1    pick_min1f(double dx[]);
extern void           pick_n_new1(int ix[], int nx, int ix_max, boolean picked[],int *perr);
extern void           pick_n_new2(int ix[], int nx, int ix_max, boolean picked[],int *perr);
extern char          *pltrim(char *s);
extern char          *pltrimf(char *s);
extern char          *prtrim(char *s);
extern char          *prtrim2(char *s);
extern boolean        possible_mandarin_byte(char *p);
extern void           print_path2(int *istr, pcodeset *pcode1, int *pathn, int *perr);
extern double         prand1(void);
extern double         prand2(boolean *first_time);
extern void           process_pcode_aux_line(pcodeset *p1, char *pline, int *perr);
extern void           process_pcode_data_line(pcodeset *p1, char *pline, int *perr);
extern boolean        pronounceable_phon(char *ph, struct SYL_PARMS *syl_parms);
extern void           quit2(char *reporting_procedure, int error_level, char *msg, ...);

/* protected character string functions: */
extern PROTECTED_CHR_STR *ss_to_ps(PROTECTED_CHR_STR *ps_to, SUBSTRING *ss_from);
extern PROTECTED_CHR_STR *create_prot_chr_str(int length);
extern void              alloc_prot_chr_str_guts(PROTECTED_CHR_STR *sx, int length);
extern void              destroy_prot_chr_str(PROTECTED_CHR_STR *sx);
extern void              dealloc_prot_chr_str_guts(PROTECTED_CHR_STR *sx);
extern PROTECTED_CHR_STR *strcpy_prot_p(PROTECTED_CHR_STR *ps_to, PROTECTED_CHR_STR *ps_from);
extern PROTECTED_CHR_STR *strcpy_prot_s(PROTECTED_CHR_STR *ps_to, char *s_from);
extern PROTECTED_CHR_STR *strcpy_prot_i(PROTECTED_CHR_STR *ps_to, char c_from);
extern PROTECTED_CHR_STR *strcat_prot_p(PROTECTED_CHR_STR *ps_to, PROTECTED_CHR_STR *ps_from);
extern PROTECTED_CHR_STR *strcat_prot_s(PROTECTED_CHR_STR *ps_to, char *s_from);
extern PROTECTED_CHR_STR *strcat_prot_i(PROTECTED_CHR_STR *ps_to, char c_from);
/* end of protected character string functions */

/* protected integer string functions: */
extern PROTECTED_INT_STR *create_prot_int_str(int length);
extern void              alloc_prot_int_str_guts(PROTECTED_INT_STR *sx, int length);
extern void              destroy_prot_int_str(PROTECTED_INT_STR *sx);
extern void              dealloc_prot_int_str_guts(PROTECTED_INT_STR *sx);
extern PROTECTED_INT_STR *nstrcpy_prot_p(PROTECTED_INT_STR *pn_to, PROTECTED_INT_STR *pn_from);
extern PROTECTED_INT_STR *nstrcpy_prot_s(PROTECTED_INT_STR *pn_to, int *ns_from);
extern PROTECTED_INT_STR *nstrcpy_prot_i(PROTECTED_INT_STR *pn_to, int i);
extern PROTECTED_INT_STR *nstrcat_prot_p(PROTECTED_INT_STR *pn_to, PROTECTED_INT_STR *pn_from);
extern PROTECTED_INT_STR *nstrcat_prot_s(PROTECTED_INT_STR *pn_to, int *ns_from);
extern PROTECTED_INT_STR *nstrcat_prot_i(PROTECTED_INT_STR *pn_to, int i);
/* end of protected integer string functions */

extern void           print_pron3(struct PRON2 *pron, struct SYL_PARMS *syl_parms);
extern void           print_prons3(struct PRON2 *pron, int nprons,struct SYL_PARMS *syl_parms, int no_wbound);
extern void           put_sm_into_aln(ALIGNMENT_INT *pal, SM_TAB_STR2 *smtab, int *perr);
extern void           put_sm_into_aln_prot(ALIGNMENT_INT_PROT *pal, SM_TAB_STR2 *smtab, int *perr);
extern void           read_next_data_line(PROTECTED_CHR_STR *in_line, FILE *fp, char *comment_flag);
extern void           read_syl_parms(struct SYL_PARMS *syl_parms, int *perr);
extern boolean        real_wrd(char *token);
extern char          *regularize_spacing(char *s);
extern char          *remove_comments(char *s, char *comment_flag);
extern char          *remove_diacritics(char *out, char *in);
extern void           remove_symb(int *s, char *symb, pcodeset *pcode);
extern void           remove_zeros(WCHAR_T *s);
extern void           report_lex_add2(int i, pcodeset *pc1, int *perr);
extern double         rnormal(double m, double sd);
extern char          *safe_print(char *s);
extern boolean        same_except_stress(int i, int j, pcodeset *pcode_ph);
extern boolean        short_env(char *p);
extern char          *simplify_null_reps(char *s);
extern void           simplify_prons2(struct PRON2 *pron, int *nprons);
extern int            sm_correction2_prot(ALIGNMENT_INT_PROT *pt1, double fom_threshold, SM_TAB_STR2 *smtab, int *perr);
extern char          *snor1(char *s);
extern void           sort_pcodeset_a(pcodeset *p1);
extern void           sort_sm_by_iloc(SM_TAB_STR2 *smtab);
extern void           sort_tally1(TALLY_STR *table);
extern char          *spell_mode(char *sph, SUBSTRING *ss_token);
extern PROTECTED_CHR_STR  *spell_mode_prot(PROTECTED_CHR_STR *sph, SUBSTRING *ss_token);
extern void           split_tiers2(WCHAR_T *seg_int, WCHAR_T *str_int, WCHAR_T *bnd_int, WCHAR_T *sint, int max_segs, pcodeset *pcdp, int *perr);
extern void           split_tiers2_prot(PROTECTED_INT_STR *seg_int, PROTECTED_INT_STR *str_int, PROTECTED_INT_STR *bnd_int, PROTECTED_INT_STR *sint, pcodeset *pcdp, int *perr);
extern SUBSTRING     *ss_make_lower(SUBSTRING *ssx);
extern SUBSTRING     *ss_make_upper(SUBSTRING *ssx);
extern int            ss_ntokens(SUBSTRING *ssx);
extern SUBSTRING      sstok(SUBSTRING *ssx, char *delimiters);
extern SUBSTRING      sstok2(char *sx, char *delimiters);
extern SUBSTRING      sstok2b(char *sx, char *delimiters);
extern SUBSTRING      sstok2c(char *sx, char *delimiters);
extern SUBSTRING      sstok3(SUBSTRING *ssx, char *delimiters);
extern SUBSTRING      sstok4(char *x);
extern SUBSTRING      *sstok5(SUBSTRING *ssy, char *x);
extern SUBSTRING      sstok_lr_s(char *sx, char lbound, char rbound,boolean include_bounds);
extern char          *sstrchr(SUBSTRING *ssx, char c);
extern SUBSTRING      ssuttid(char *trans);
extern boolean        start_comment(char *sp);
extern boolean        start_crosstalk(char *sp);
extern boolean        start_mispron(char *sp);
extern boolean        start_overlap(char *sp);
extern boolean        start_unsure(char *sp);
extern int            stem_por(char *word);
extern boolean        stranded_segment(struct PRON2 *pron);
extern char          *strdup_safe(char *ps, char *calling_proc);
extern boolean        stress_mark(int i, pcodeset *pcdp);
extern boolean        string_equal(char *cs, char *ct, int ignore_case);
extern int            strcmpi(char *ps1, char *ps2);  /* BCD 4.2; not TURBO C */
extern int            strncmpi(char *ps1, char *ps2, int n);  /* BCD 4.2; not TURBO C */
extern char          *strcutl(char *ps, int n);
extern char          *strcutr(char *ps, int n);
extern char          *strmap1(char *s, char *x, char *y);
extern boolean        substr_eq(SUBSTRING *substr1, SUBSTRING *substr2);
extern int            substr_length(SUBSTRING *substr);
extern char          *substr_to_str(SUBSTRING *substr, char *str, int lmax);
extern boolean        suprasegmental(int i, pcodeset *pcdp);
extern short int      swap_short(short int s);
extern void           swap_int(int a, int b);
extern void           swap_double(double a, double b);
extern char          *switch_case(char *sx);
extern boolean        syllabic(int i, pcodeset *pcdp);
extern void           tally2(int i, int j, TALLY_STR *table);
extern int            textlen(char *s);
extern boolean        token_is_alternation(SUBSTRING *ss_token, char left_alt_bound, char rght_alt_bound, char alt_symbol);
extern char          *trans(char *s2, char *s1, char *outmap, char *inmap);
extern char          *ttp_prep1(char *out, char *in);
extern PROTECTED_CHR_STR *ttp_prep1_prot(PROTECTED_CHR_STR *ps_out, char *s_in);
extern char          *ttp1(char *stx, char *sp, int *perr);
extern char          *ttp1s(char *stx, char *sp, int *perr);
extern char          *ttp1s(char *stx, char *sp, int *perr);
extern char          *ttp2s(char *sp, char *st, pcodeset *pcdrls,struct BPATH *bpath, struct SYL_PARMS *syl_parms,int *perr);
extern char          *ttp3s(char *sp, char *st, TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms, int *perr);
extern PROTECTED_CHR_STR *ttp3s_prot(PROTECTED_CHR_STR *sp, char *st, TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms, int *perr);
extern char          *ttp_pcdrls2ss(char *sp, SUBSTRING *sst_in, pcodeset *pcdrls,struct BPATH *bpath,int *perr);
extern PROTECTED_CHR_STR *ttp_pcdrls2ss_prot(PROTECTED_CHR_STR *sp, SUBSTRING *sst_in, pcodeset *pcdrls, struct BPATH *bpath,int *perr);
extern char          *ttpeng1s(char *stx, char *sp, int *perr);
extern char          *ttpj1(char *stx, char *sp, int *perr);
extern char          *ttpspan2(char *stx, char *sp, char *path, int *perr);
extern boolean        unstressed(struct SYLB1 *sylb, pcodeset *pcdp);
extern boolean        valid_data_line(char *s, char *comment_flag);
extern boolean        valid_date1(DATE_FORMAT1 *date1);
boolean               velar(char c);
boolean               voiced(char *p);
extern void           warn_if_add_file(char *fname, char *time);
extern char          *wbtrim(char *s);
extern int            wod1(int i, int j, pcodeset *pcij);
extern int            wod1f(int i, int j, pcodeset *pcij);
extern int            wod2(int i, int j, pcodeset *pcij, int *perr);
extern int            wod2_prot(int i, int j, pcodeset *pcij, int *perr);
extern int            wod2c(int i, int j, pcodeset *pcij, int cut_off, int *perr);
extern int            wod2t(int i, int j, pcodeset *pcij, TALLY_STR *tally, int *perr);
extern int            wprob_pick(struct WPROB_LIST_ATOM *wprob_list_atom);
extern void           write_phon_ins_del(TALLY_STR *table, pcodeset *pcode);
extern void           write_phon_tally2(TALLY_STR *table, pcodeset *pcode, int *iselect, int *jselect, int ndigits, int style);
extern void           write_phon_tally3(TALLY_STR *table, pcodeset *pcode, int *iselect, int *jselect, int ndigits, int style);
extern void           write_ppf2(TABLE_OF_CODESETS *pctab, int ipc, char *fname, int *perr);
extern void           write_word_tally2(TALLY_STR *table, pcodeset *pcode);
extern char           *zap_non_mandarin(char *s);
extern void           zapchar(char *text, char zapped);

#endif
