/* file pcindex_char_looup.c */

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


int pcindex_char_lookup(char *symb, pcodeset *pc1, boolean *found)
 
     /********************************************************/
     /* Returns index of *symb in pc1->pc[*] table, assuming */
     /* that *symb is a 2-byte integer character (Mandarin). */
     /* Returns indication of success by setting *found.     */
     /********************************************************/
 {char *proc = "pcindex_char_lookup";
  int i;
  union
    {char byte[2];
     short unsigned int usint;
    } char_2byte;
  /* code */
  db_enter_msg(proc,3); /* debug only */
  *found = F;
  i = -1;
  switch(strlen(symb))
    {case 1:
       if (streq(symb,"*")) {i = 0; *found = T;}
       break;
     case 2:
       if ( (possible_mandarin_byte(symb+0))
         && (possible_mandarin_byte(symb+1)) )
         {char_2byte.byte[0] = *(symb+0);
          char_2byte.byte[1] = *(symb+1);
          i = char_2byte.usint; 
          if (strlen(pc1->pc[i].ac) < 1) *found = F;
          else                           *found = T;
         }
       break;
    }
if (db_level > 3) printf("%s Mandarin, i=%d, found=%s\n",pdb,i,bool_print(*found));
 db_leave_msg(proc,3); /* debug only */
  return i;
}
