/* file fcndcls.h              */
/* local function declarations */
/* export version - stripped of all functions not relevant to aldistsm_prot() */

#ifndef FCNDCLS_HEADER
#define FCNDCLS_HEADER

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 char          *adjust_type_case(char *s, pcodeset *pcode);
extern int            aldist_static_prot(ALIGNMENT_INT_PROT *pal, int *perr);
extern int            aldist2_prot(ALIGNMENT_INT_PROT *pt1, int (*w) (int,int,pcodeset*,int*), int return_alignment, ALIG\
NMENT_INT_PROT *pt2, 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 void           alignment_s_to_ir_prot(ALIGNMENT_INT_PROT *pia1, ALIGNMENT_CHR_PROT *psa1, pcodeset *pcode1,TTP_PCD\
RLS_PARAMETERS *ttp_pcdrls_parms, int *perr);
extern void           alignment_i_to_s_prot(ALIGNMENT_INT_PROT *pia1, ALIGNMENT_CHR_PROT *psa1, int *perr);
extern void           aln_i_to_s_prot5(ALIGNMENT_INT_PROT *pia1, ALIGNMENT_CHR_PROT *psa1, char *delimiter, int *perr);
extern PROTECTED_CHR_STR *apply_rules2_prot(PROTECTED_CHR_STR *pb, char *sa, RULESET2 *rset, int *perr);
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 char          *bool_print(boolean x);
boolean               bound(char c);
extern boolean        boundary_mark(int i, pcodeset *pcdp);
extern char          *build_key3(char *key, char *le, char *tg, char *re, char tgbound);
extern void          *calloc_safe(size_t nobj, size_t size, char *calling_proc);
extern PROTECTED_CHR_STR *char_name_prot(PROTECTED_CHR_STR *psx, char character);
extern ALIGNMENT_INT_PROT *copy_int_al_prot(ALIGNMENT_INT_PROT *p2, ALIGNMENT_INT_PROT *p1);
extern boolean        consonantal(int i, pcodeset *pcdp);
extern boolean        coronal(char c);
extern void           db_enter_msg(char *proc, int level);
extern void           db_leave_msg(char *proc, int level);
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 char          *del_eol(char *ps);
extern void           dump_auxtab_prot(ALIGNMENT_INT_PROT *pal);
extern void           dump_bpaths(struct BPATH *bpath);
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_prot(ALIGNMENT_INT_PROT *p1);
extern void           dump_int_alignment4_prot(ALIGNMENT_INT_PROT *paln);
extern void           dump_pcode2(pcodeset *p1);
extern void           dump_pcode3(pcodeset *p1);
extern void           dump_ppf2(pcodeset *pcode);
extern void           dump_pron2(struct PRON2 *pron);
extern void           dump_syl_parms(struct SYL_PARMS *syl_parms);
extern void           dump_words(struct WORD1 *word, int nwords);
extern void           dump_sylbs(struct SYLB1 *sylb, int nsylbs);
extern void           encode_lcsr(pcodeset *p1, TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms, 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 char          *expenv(char *s, int slength);
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           find_next_token2(SUBSTRING *x, SUBSTRING *y);
extern void           fold_tiers2(WCHAR_T *sint, struct PRON2 *pron, int *lmark, int *rmark, int *wbound);
extern void           free_al_chr_prot(ALIGNMENT_CHR_PROT *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_pcode(pcodeset *p);
extern void           free_rules2(RULESET2 *rset);
extern void           free_str(char *s);
extern void           free_syl_parms2(struct SYL_PARMS *syl_parms);
boolean               fric1(char *p);
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_comment_flag(char *s, char *comment_flag);
extern void           get_next_alignment_chr_prot(FILE *cfp, ALIGNMENT_CHR_PROT *palc1, boolean *p_at_end);
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_pcode_element(char *pline, int compositional, 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 void           init_al_chr_prot(ALIGNMENT_CHR_PROT *palc1);
extern void           init_al_int_prot(ALIGNMENT_INT_PROT *paln1, pcodeset *pcode1);
extern void           init_pc_table(pcodeset *p1);
extern void           init_pcdrls(pcodeset *pcdrls, int max_ncodes, boolean hashed);
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 int           *lc_istr_prot(PROTECTED_INT_STR *sx, int ichr, pcodeset *pcode, ALIGNMENT_INT_PROT *pal);
extern ALIGNMENT_CHR_PROT *make_al_chr_prot2(char *ident);
extern ALIGNMENT_INT_PROT *make_al_int_prot2(char *ident, pcodeset *pcode1);
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_elementr(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 char          *make_lower(char *s);
extern void           make_pcd_from_rls_file(pcodeset *pcdrls,char *fname_pcdrls,char *path, char tgbound, int *perr);
extern char          *make_upper(char *s);
extern void           make_pc_table(pcodeset *p1);
extern void          *malloc_safe(size_t size, char *calling_proc);
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 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            ntokens(char *s);
extern boolean        ok_final_cluster2(WCHAR_T *aint, struct INTERVAL1 cluster, struct SYL_PARMS *syl_parms);
extern boolean        ok_init_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_rule_key(SUBSTRING *ss_le, SUBSTRING *ss_tg, SUBSTRING *ss_re,char *rkey, char tgbound);
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 int            pcodeset_misorders(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        pcindex5r(char *symbol, pcodeset *pc1, int add_to_core, int add_to_file, TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms);
extern void           pcsort1(pcodeset *p1);
extern enum edits1    pick_min1du(unsigned short int dx[]);
extern char          *pltrim(char *s);
extern char          *pltrimf(char *s);
extern char          *prtrim(char *s);
extern char          *prtrim2(char *s);
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);
 
/* 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           put_sm_into_aln_prot(ALIGNMENT_INT_PROT *pal, SM_TAB_STR2 *smtab, int *perr);
extern void           read_syl_parms(struct SYL_PARMS *syl_parms, int *perr);
extern char          *remove_comments(char *s, char *comment_flag);
extern char          *remove_diacritics(char *out, char *in);
extern void           remove_zeros(WCHAR_T *s);
extern void           report_lex_add2(int i, pcodeset *pc1, int *perr);
extern char          *safe_print(char *s);
boolean               short_env(char *p);
extern char          *simplify_null_reps(char *s);
extern int            sm_correction2_prot(ALIGNMENT_INT_PROT *pt1, double fom_threshold, SM_TAB_STR2 *smtab, int *perr);
extern void           sort_pcodeset_a(pcodeset *p1);
extern void           sort_sm_by_iloc(SM_TAB_STR2 *smtab);
extern PROTECTED_CHR_STR  *spell_mode_prot(PROTECTED_CHR_STR *sph, SUBSTRING *ss_token);
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      sstok(SUBSTRING *ssx, char *delimiters);
extern SUBSTRING      sstok2(char *sx, char *delimiters);
extern SUBSTRING      sstok4(char *x);
extern SUBSTRING      sstok_lr_s(char *sx, char lbound, char rbound,boolean include_bounds);
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 char          *strmap1(char *s, char *x, char *y);
extern int            substr_length(SUBSTRING *substr);
extern char          *substr_to_str(SUBSTRING *substr, char *str, int lmax);
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 boolean        suprasegmental(int i, pcodeset *pcdp);
extern char          *switch_case(char *sx);
extern boolean        syllabic(int i, pcodeset *pcdp);
extern int            textlen(char *s);
extern PROTECTED_CHR_STR *ttp_prep1_prot(PROTECTED_CHR_STR *ps_out, char *s_in);
extern PROTECTED_CHR_STR *ttp3s_prot(PROTECTED_CHR_STR *sp, char *st, TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms, int *perr);
extern PROTECTED_CHR_STR *ttp_pcdrls2ss_prot(PROTECTED_CHR_STR *sp, SUBSTRING *sst_in, pcodeset *pcdrls, struct BPATH *bpath,int *perr);
extern boolean        unstressed(struct SYLB1 *sylb, pcodeset *pcdp);
extern boolean        valid_data_line(char *s, char *comment_flag);
boolean               velar(char c);
boolean               voiced(char *p);
extern void           warn_if_add_file(char *fname, char *time);
extern int            wod2_prot(int i, int j, pcodeset *pcij, int *perr);
extern char          *wbtrim(char *s);
extern void           zapchar(char *text, char zapped);

#endif
/* end file fcndcls.h        */
