Example #1
0
PCFOP * read_instr(struct PCFState * st, const char * line, uint32_t iptr)
{
  char buf[LINE_MAX], *bitr;
  buf[0] = '\0';
  bitr = buf;

  assert(line[0] == '(');
  line++;

  while((line[0] != ' ') && (line[0] != ')'))
    {
      bitr[0] = line[0];
      line++;
      bitr++;
    }
  bitr[0] = '\0';

  if(strcmp(buf, "LABEL") == 0)
    return read_label(line, st, iptr);
  else if(strcmp(buf, "INITBASE") == 0)
    return read_initbase(line);
  else if(strcmp(buf, "CONST") == 0)
    return read_const(line);
  else if(strcmp(buf, "GATE") == 0)
    return read_gate(line);
  else if(strcmp(buf, "BITS") == 0)
    return read_bits(line);
  else if(strcmp(buf, "MKPTR") == 0)
    return read_mkptr(line);
  else if(strcmp(buf, "COPY") == 0)
    return read_copy(line);
  else if(strcmp(buf, "COPY-INDIR") == 0)
    return read_copy_indir(line);
  else if(strcmp(buf, "INDIR-COPY") == 0)
    return read_indir_copy(line);
  else if(strcmp(buf, "CALL") == 0)
    return read_call(line);
  else if(strcmp(buf, "RET") == 0)
    return read_ret(line);
  else if(strcmp(buf, "BRANCH") == 0)
    return read_branch(line);
  else if(strcmp(buf, "CLEAR") == 0)
    return read_clear(line);
  else if(strcmp(buf, "JOIN") == 0)
    return read_join(line);
  else if(strcmp(buf, "ADD") == 0)
    return read_add(line);
  else if(strcmp(buf, "MUL") == 0)
    return read_mul(line);
  assert(0);
}
Example #2
0
File: smag.c Project: 5263/spacenav
int read_smag(struct dev_input *inp)
{
	/*need to return 1 if we fill in inp or 0 if no events */
	struct smag_event *ev;

	input.rbuf_sz = smag_read(dev_fd, input.rbuf, MAXREADSIZE);
	if(input.rbuf_sz > 0) {
		read_copy();
	}
	ev = input.evhead;
	if(ev) {
		input.evhead = input.evhead->next;

		*inp = ev->data;
		free_event(ev);
		return 1;
	}
	return 0;
}