Example #1
0
// called from spice_server thread (i.e. red_worker thread)
static int get_command(QXLInstance *qin, struct QXLCommandExt *ext)
{
    if (get_num_commands() == 0) {
        return FALSE;
    }
    *ext = *get_simple_command();
    return TRUE;
}
Example #2
0
command_t get_command(command_stream_t buff)
{
  command_t s;

  while(buff->next_token == NEWLINE_T && (buff = get_token(buff)));

  if(buff->next_token == OPEN_PAREN_T)
  {
    buff->numofopen++;
    s = get_subshell_command(buff);
  }
  else
  {
    s = get_simple_command(buff);
  }

  if(buff->next_token == INPUT_T)
  {
    buff = get_token(buff);
    if(buff->next_token != WORD_T)
      error (1, 0, "Line %d: syntax error: a word followed by <", buff->linenum);

    buff = get_token(buff);

    s->input = checked_malloc(strlen(buff->current_string));
    strcpy(s->input, buff->current_string);

    if(buff->next_token == OUTPUT_T)
    {
      buff = get_token(buff);
      if(buff->next_token != WORD_T)
        error (1, 0, "Line %d: syntax error: a word followed by >", buff->linenum);

      buff = get_token(buff);

      s->output = checked_malloc(strlen(buff->current_string));
      strcpy(s->output, buff->current_string);
    }
  }

  else if(buff->next_token == OUTPUT_T)
  {
    buff = get_token(buff);
    if(buff->next_token != WORD_T)
      error (1, 0, "Line %d: syntax error: a word followed by >", buff->linenum);

    buff = get_token(buff);

    s->output = checked_malloc(strlen(buff->current_string));
    strcpy(s->output, buff->current_string);
    if(buff->next_token == INPUT_T)
      error (1, 0, "Line %d: syntax error: < followed by a word followed by >", buff->linenum);
  }
  if(buff->next_token == CLOSE_PAREN_T)
    buff->numofopen--;

  return s;
}