예제 #1
0
void lp_parse_push_uint32(lp_parse_env* lp_p, llp_uint32 data)
{
	byte temp = 0;
	temp = (byte)(data & 0x000000FF);
	lp_list_add(&lp_p->parse_out, &temp);

	temp = (byte)( (data&(0x0000FF00))>>8 );
	lp_list_add(&lp_p->parse_out, &temp);

	temp = (byte)( (data&(0x00FF0000))>>16 );
	lp_list_add(&lp_p->parse_out, &temp);

	temp = (byte)( (data&(0xFF000000))>>24 );
	lp_list_add(&lp_p->parse_out, &temp);
}
예제 #2
0
struct lp_list *
marshal_g4_idx(struct idx *idx, int n, struct idx *idxen, struct track *track) {
  int i, j;
  struct lp_list *l = lp_new_list();

  l->linelen = 1;

  for(i = 0; i < n; i++) {
    struct idx *ii = &idx[i];
    struct lp_list *lent = lp_new_list();
    struct lp_value *vlent = lp_new_listv(lent);

    // this breaks if an index has a mixture of track and index
    // children
    if(idx[i].ents[0].childtype == TRACK) {
      lent->linelen = 11;
    }
    else {
      lent->linelen = 10;
    }

    for(j = 0; j < ii->ents_len; j++) {
      marshal_g4_idx_ent(&ii->ents[j],  idxen, track, lent);
    }

    lp_list_add(l, vlent);
  }


  return l;
}
예제 #3
0
int lp_parse_push(lp_parse_env* lp_p, void* data, unsigned int len)
{
	unsigned int i=0;
	check_null(data, LP_FAIL);
	
	for(i=0; i<len; i++)
		lp_list_add(&lp_p->parse_out, ((byte*)data)+i);
	return LP_TRUE;
}
예제 #4
0
파일: util.c 프로젝트: Vivien-Michel/PFSsim
struct lp_list *
lp_new_intlist(int *intarr, int len)
{
  int i;
  struct lp_list *l = lp_new_list();

  for(i = 0; i < len; i++) {
    lp_list_add(l, lp_new_intv(intarr[i]));
  }
  return l;
}
예제 #5
0
struct lp_list *
marshal_g4_tp(struct track *t, int len) {
  struct lp_list *l = lp_new_list();
  int i;

  l->linelen = 3;

  for(i = 0; i < len; i++) {
    struct lp_value *v;

    v = lp_new_intv(t[i].low);
    lp_list_add(l, v);
    v = lp_new_intv(t[i].high);
    lp_list_add(l, v);
    v = lp_new_intv(t[i].spt);
    lp_list_add(l, v);
  }


  return l;
}
예제 #6
0
struct lp_list *
marshal_g4_slip(struct slip *slips, int n) {
  struct lp_list *l = lp_new_list();
  int i = 0;

  l->linelen = 2;

  if(slips[0].off == 0 && slips[0].count == 0) {
    i = 1;
  }

  for( ; i < n; i++) {
    struct lp_value *v;
    v = lp_new_intv(slips[i].off);
    lp_list_add(l,v);
    v = lp_new_intv(slips[i].count - slips[i-1].count);
    lp_list_add(l,v);
  }

  return l;
}
예제 #7
0
struct lp_list *
marshal_g4_remaps(struct remap *remaps, int n) {
  struct lp_list *l = lp_new_list();
  int i;

  l->linelen = 6;

  for(i = 0; i < n; i++) {
    struct lp_value *v;
    struct remap *ri = &remaps[i];

    v = lp_new_intv(ri->off);
    lp_list_add(l,v);
    v = lp_new_intv(ri->count);
    lp_list_add(l,v);
    v = lp_new_intv(ri->dest.cyl);
    lp_list_add(l,v);
    v = lp_new_intv(ri->dest.head);
    lp_list_add(l,v);
    v = lp_new_intv(ri->dest.sector);
    lp_list_add(l,v);
    v = lp_new_intv(ri->spt);
    lp_list_add(l,v);
  }


  return l;
}
예제 #8
0
static int lp_parse_closure(lp_parse_env* lp_p, lp_list* lp_out, llp_uint32* out_count, lp_table* ide_table, char* at_mes)
{
	byte tag = 0;
	byte lt;
	lp_token* temp = NULL;
	lp_token* ide = NULL;
	int fmes = fmes_internal;
	check_null(lp_p, LP_FAIL);
	check_null(lp_out, LP_FAIL);
	check_null(at_mes, LP_FAIL);
	check_null(ide_table, LP_FAIL);
	check_null(out_count, LP_FAIL);

	lp_watch(lp_p, t_lb);
	
	temp = lp_at_token(lp_p);
	if(temp == NULL)
		lp_watch(lp_p, t_rb);
	
	for( ;(temp=lp_at_token(lp_p))!=NULL; )
	{
		switch(temp->type)
		{
		case t_Kinteger:
		case t_Kreal:
		case t_kstring:
		case t_Kbytes:
		case t_ide:
			{
				lp_token* tt = NULL;
				if(temp->type != t_ide)
				{
					lt = tt2lt(temp->type);
					lp_watch(lp_p, temp->type);
				}
				else
				{
					lt = LLPT_MESSAGE;
					lp_string_clear(&lp_p->mes_name);
					check_fail(lp_parse_defM(lp_p, at_mes, &lp_p->mes_name, &fmes), LP_FAIL);
				}
				tt= lp_at_token(lp_p);
				if(tt == NULL)
					lp_watch(lp_p, t_rb);
				if(tt->type == t_ll)			// if is arraylist []
				{	
					lp_watch(lp_p, t_ll);
					lp_watch(lp_p, t_rl);
					tag = lp_tag(lt, e_rep);
					lp_get_token(lp_p, t_ide, ide);
					lp_watch(lp_p, t_end);
				}
				else if(tt->type == t_ide)
				{
					ide = tt;
					tag = lp_tag(lt, e_req);
					lp_watch(lp_p, t_ide);
					lp_watch(lp_p, t_end);		// ;
				}
				else
				{
					print("parse[error line: %d]not find ide!\n", tt->line);
					return LP_FAIL;
				}

				{
					char a=0;
					size_t i=0;
					int ret = 0;
					if( (ret=lp_table_add(ide_table, (char*)ide->name.str.list_p, fmes_internal))==LP_EXIST)
					{
						print("parse[error line: %d] the ide \"%s\" is redef!\n", lp_p->line, (char*)ide->name.str.list_p);
						return LP_FAIL;
					}
					else if(ret == LP_FAIL)
					{
						print("Serious error[line: %d]: add ide is error! \n", lp_p->line);
						return LP_FAIL;
					}
					
					lp_list_add(lp_out, &tag);			// push tag
					if(temp->type==t_ide)				// push message type name
					{
						union {
							int v;
							byte ei;
						}v;
						v.v = fmes;
						lp_list_add(lp_out, &(v.ei));
						for(i=0; i<lp_p->mes_name.str.list_len; i++)
							lp_list_add(lp_out, lp_p->mes_name.str.list_p+i);
						lp_list_add(lp_out, (byte*)(&a));
					}
					for(i=0; i<ide->name.str.list_len; i++)	// push  ide name
						lp_list_add(lp_out, ide->name.str.list_p+i);
					lp_list_add(lp_out, (byte*)&a);
					(*out_count)++;
				}
			}
			break;
		case t_Kmessage:
			check_fail(lp_parse_message(lp_p, at_mes), LP_FAIL);
			break;
		case t_rb:
			lp_watch(lp_p, t_rb);
// 			if(back_out_lens >= lp_out->list_len)
// 			{
// 				print("parse[error line: %d] at message \"%s\" is empty body!\n", lp_p->line, at_mes);
// 				return LP_FAIL;
// 			}
			goto CLO_END;
		default:
			print("parse[error line: %d] at {} not allow!\n", temp->line);
			return LP_FAIL;
		}
	}
	
	print("parse[error line: %d] you are lose \"}\"!\n", lp_p->line);
	return LP_FAIL;
CLO_END:
	return LP_TRUE;
}
예제 #9
0
struct lp_list *
marshal_g4_idx_ent(struct idx_ent *e, 
		   struct idx *idx, 
		   struct track *track,
		   struct lp_list *l) 
{
  int i;
  struct lp_value *v;
  char *ctstr; // child type
  int coffset; // offset of child in its array

  printf("%s() lbn %d alen %f off %f\n", __func__, e->lbn,
	 dm_angle_itod(e->alen), dm_angle_itod(e->off));

  v = lp_new_intv(e->lbn);
  lp_list_add(l, v);
  v = lp_new_intv(e->cyl);
  lp_list_add(l, v);
  v = lp_new_doublev(dm_angle_itod(e->off));
  lp_list_add(l, v);

  v = lp_new_intv(e->len);
  lp_list_add(l, v);
  v = lp_new_intv(e->cyllen);
  lp_list_add(l, v);
  v = lp_new_doublev(dm_angle_itod(e->alen));
  lp_list_add(l, v);

  v = lp_new_intv(e->runlen);
  lp_list_add(l, v);
  v = lp_new_intv(e->cylrunlen);
  lp_list_add(l, v);

  switch(e->childtype) {
  case IDX:
    ctstr = "IDX";
    coffset = aoffset(idx, e->child.i, sizeof(*e->child.i));
    break;
  case TRACK:
    ctstr = "TRACK";
    coffset = aoffset(track, e->child.t, sizeof(*e->child.t));
    break;
  default: ddbg_assert(0); break;
  }

  v = lp_new_stringv(ctstr);
  lp_list_add(l, v);

  v = lp_new_intv(coffset);
  lp_list_add(l, v);

  if(e->childtype == TRACK) {
    v = lp_new_intv(e->head);
    lp_list_add(l, v);
  }

  return l;
}