 /* File alstoi2r_prot.c */

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

  void alignment_s_to_ir_prot(ALIGNMENT_INT_PROT *pia1, ALIGNMENT_CHR_PROT *psa1,
     pcodeset *pcode1,TTP_PCDRLS_PARAMETERS *ttp_pcdrls_parms, int *perr)
 /**********************************************************************/
 /*                                                                    */
 /*    Converts the protected character string alignment *psa1 into an */
 /* integer alignment *psa1, using pcode *pcode1 and sypplying the     */
 /* encoding function with TTP parameters *ttp_pcdrls_parms in case    */
 /* it has to make up some new word pronunciations.                    */
 /*                                                                    */
 /*   *perr = 0 means a.o.k.                                           */
 /*           1 means encoding error                                   */
 /*           2 means pia1->aligned == T, but na != nb                 */
 /*                                                                    */
 /**********************************************************************/

{
/* local data: */
  char *proc = " alignment_s_to_ir_prot";
/* code: */
 db_enter_msg(proc,0); /* debug only */
/* initialize */
  *perr=0;
/* go */
  pia1->aligned = psa1->aligned;
if (db_level > 2) printf("%s encoding psa1->sa->str\n",pdb);
  encode3r(psa1->sa->str,pcode1,ttp_pcdrls_parms,pia1->nsa,perr);
  if (*perr > 0)
    {fprintf(stderr,"*ERR:%s: encode3r returns *perr=%d\n",proc,*perr);
     fprintf(stderr," trying to encode '%s'\n",psa1->sa->str);
     fprintf(stderr," using pcode '%s'\n",pcode1->name);
     *perr = 1;
     goto RETURN;}
  encode3r(psa1->sb->str,pcode1,ttp_pcdrls_parms,pia1->nsb,perr);
  if (*perr > 0)
    {fprintf(stderr,"*ERR:%s: encode3r returns *perr=%d\n",proc,*perr);
     fprintf(stderr," trying to encode '%s'\n",psa1->sb->str);
     fprintf(stderr," using pcode '%s'\n",pcode1->name);
     *perr = 1;
     goto RETURN;}
  if ((pia1->aligned) && (pia1->nsa->str[0] != pia1->nsb->str[0]))
    {fprintf(stderr,"*ERR:%s: psa1 is supposed to be aligned, but\n",proc);
     fprintf(stderr," length(nsa->str) NOT = length(nsb->str).\n");
     *perr = 11;
     goto RETURN;
    } /* "if (pia1->aligned ... " */
 RETURN:
 db_leave_msg(proc,0); /* debug only */
  } /* end of function "alignment_s_to_ir_prot" */
 /* end file alstoi2r_prot.c */
