Esempio n. 1
0
        void
        dgram::send_dgram(packetbuf_ptr pbuf, id_ptr id, uint8_t type)
        {
                push2queue(id, pbuf, m_id, type);

                request(id);
        }
Esempio n. 2
0
        void
        dgram::send_dgram(const void *msg, int len, id_ptr id,
                          const uint160_t &src)
        {
                if (len < 0)
                        return;
                push2queue(id, msg, len, src);

                request(id);
        }
Esempio n. 3
0
        void
        dgram::push2queue(id_ptr id, const void *msg, int len,
                          const uint160_t &src)
        {
                packetbuf_ptr pbuf = packetbuf::construct();
                void *p;

                p = pbuf->append(len);
                memcpy(p, msg, len);

                push2queue(id, pbuf, src);
        }
Esempio n. 4
0
/*
 *
 *  Process toktab and create output stream.
 *
 */
void s_process()
{
  int icol,icoltt,i,eofldchar=0,eolchar=0;
  int iline,iq,nc;
  int queue_siz;
  struct streams *s, *t;

  s=&instream;
  if (fseek(s->fp,0,SEEK_SET) != 0)
    err_exit(ERR_PRO_SEEK);
  t=create_outstream(&outstream);
  
  /* Check for queue size needed.*/
  for (i=0,queue_siz=0;toktab[i]->valid;i++)
    if (toktab[i]->type == TOKNUM && (toktab[i]->flag == RS2QUE || toktab[i]->flag == RS2QUEOUT)) queue_siz++;
  queue_siz+=1;  /* For col==0; */

  /* Create queue if needed.*/
  if (queue_siz > 1) {
    queue = malloc(queue_siz*sizeof(struct queues *));
    if (queue==NULL) err_exit(ERR_PRO_QUE);
    for (i=0;i<queue_siz;i++) {
      queue[i] = malloc(sizeof(struct queues));
      if (queue[i]==NULL) err_exit(ERR_PRO_QUE);
      queue[i]->col=0;
    }
  }  
  /* Loop over lines in dsv file */
  for (iline=1;;iline++) {

    if (iline == s->nline) {
      if (s->EOLLast != EOF) goto EOFline;
      eolchar = EOF;
    } 
    else
      eolchar = s->EOLc;
    
    icol=1;    
    iq=0;
    
    /* Loop over tokens in toktab */
    for (i=0;toktab[i]->valid;i++) {
      switch (toktab[i]->type) {
      case TOKNUM:
	icoltt = toktab[i]->u.itok;       
	eofldchar = (icoltt == s->ncol) ? eolchar : *(s->delim);

	switch (toktab[i]->flag) {
	case RS2OUT:
	  nc=icoltt-icol;
	  skip_fld(s,nc);icol+=nc;
	  read_fld(s,eofldchar);icol++;          
	  if PUT_DELIM(i) put_delimout(s);
	  break;
	case RS2QUE:
	  nc=icoltt-icol;
	  skip_fld(s,nc);icol+=nc;
	  push2queue(s,queue[iq],eofldchar);
	  queue[iq++]->col=toktab[i]->u.itok;icol++;
	  break;
	case RS2QUEOUT:      
	  nc=icoltt-icol;
	  skip_fld(s,nc);icol+=nc;
	  push2queueout(s,queue[iq],eofldchar);
	  queue[iq++]->col=toktab[i]->u.itok;icol++;
	  if PUT_DELIM(i) put_delimout(s);
	  break;
	case RQUE2OUT:
	  pullfqueue(icoltt,toktab[i]);
	  if PUT_DELIM(i) put_delimout(s);
	  break;
	default:
	  /*  */
	  break;
	}
	break;
      case TOKLIT:
	read_lit(toktab[i]);
	if PUT_DELIM(i) put_delimout(s);
	break;
      case TOKOPE:
	switch (toktab[i]->u.otok) {
	case PLU:  
	  /* Do not insert delim */
	  break;
	default:
	  err_exit(ERR_SWI_LOGIC);
	  break;
	}
	break;
      default:
	err_exit(ERR_SWI_LOGIC);
	break;
      }
    }  
    skip_EOL(s,eolchar);
    
  EOFline:
    put_EOLout(s,t);
    if (!read_EOL(s)) break;

    /* list_queue(); */
  }
  close_stream(s);
  close_stream(t);
}