/* file parse_rkey.c */

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

void parse_rule_key(SUBSTRING *ss_le, SUBSTRING *ss_tg, SUBSTRING *ss_re,
  char *rkey, char tgbound)
 
  /*****************************************************/
  /*  Parses rule key *rkey into left environment,     */
  /*  target, and right envrionment, returned in       */
  /*  ss_le, ss_tg, and ss_re, respectively, assuming  */
  /*  tgbound delimits the target part of the rules.   */
  /*****************************************************/
 {char *proc = "parse_rule_key";
  int tg_size;
  boolean include_bounds;
/* code */
db_enter_msg(proc,1); /* debug only */
if (db_level > 2) printf("%s on entrance, rkey=[%s]\n",pdb,rkey);

  *ss_tg = sstok_lr_s(rkey,tgbound,tgbound,include_bounds=F);
  tg_size = substr_length(ss_tg);
  if (tg_size < 1) fatal_error(proc,"no target in rule key",-1);
  ss_le->start = rkey;
  ss_le->end   = ss_tg->start - 2;
  ss_re->start = ss_tg->end + 2;
  ss_re->end   = rkey + strlen(rkey) - 1;
db_leave_msg(proc,1); /* debug only */
  return;
 }
