/* file lc_istr_prot.c */

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


int *lc_istr_prot(PROTECTED_INT_STR *sx, int ichr, pcodeset *pcode, ALIGNMENT_INT_PROT *pal)
/************************************************************/
/* Puts the lower code integer string for code <ichr> of    */
/* pcodeset *pcode into sx, returning sx->str.  If ichr is  */
/* outside the bounds of *pcode, looks in pal->auxtab.      */
/* NOTE: returns sx->str, not *sx.                          */
/************************************************************/
{char *proc = "lc_istr_prot";
  int iaux,j,kx;
  PROTECTED_INT_STR *px;
/* code */
  /*  alloc_prot_int_str_guts(sx,26);*/
  if (ichr < 0) fatal_error(proc,"invalid pcode value",ichr);
  else
    {if (ichr <= pcode->pctab_length)
       sx = nstrcpy_prot_s(sx,pcode->pc[ichr].lc_int);
     else
       {iaux = ichr - pcode->pctab_length;
        if (iaux > pal->naux)
          {fprintf(stderr,"*ERR:%s: iaux=%d,naux=%d\n",
             proc,iaux,pal->naux); 
           goto RETURN;
          }
        sx->str[0] = 0;
        px = pal->auxtab[iaux];
        for (j=1; j <= px->str[0]; j++) 
          {kx = px->str[j];
           sx = nstrcat_prot_s(sx,pcode->pc[kx].lc_int);
    }  }  }
RETURN:
  return sx->str;
 }
/* end function lc_istr_prot() */
