/* file acstri_prot.c */

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


char *ascii_stri_prot(PROTECTED_CHR_STR  *sx,
 PCIND_T ichr, pcodeset *pcode, ALIGNMENT_INT_PROT *pal)
/**********************************************************/
/* Puts the ASCII string for code <ichr> of pcodeset      */
/* *pcode into *sx->str, returning *sx->str.  If ichr is  */
/* too big to be an ordinary pcode, looks in pal->auxtab. */
/*  If ichr is < 0, puts in "*INVALID*".                  */
/**********************************************************/
 {char *proc = "ascii_stri_prot";
  int iaux,j,kx;
  PROTECTED_INT_STR *px;
/* code */  
 db_enter_msg(proc,3); /* debug only */
  if (ichr < 0) sx = strcpy_prot_s(sx,"*INVALID*");
  else
    {if (ichr <= pcode->pctab_length) sx = strcpy_prot_s(sx,pcode->pc[ichr].ac);
     else
       {iaux = ichr - pcode->pctab_length;
        sx = strcpy_prot_s(sx,"");
        if (iaux > pal->naux) fatal_error(proc,"iaux > naux",iaux);
        px = pal->auxtab[iaux];
        for (j=1; j <= px->str[0]; j++) 
          {kx = px->str[j];
           if (j > 1) sx = strcat_prot_s(sx," ");
           sx = strcat_prot_s(sx,pcode->pc[kx].ac);
    }  }  }
 db_leave_msg(proc,3); /* debug only */
  return sx->str;
 }
/* end function ascii_stri_prot() */
