static int token_relation (void)
{
  int token;
  token = 0;
  switch (io_current())
  {
    /* The equal token. */
    case '=':
      io_next();
      token = T_EQUAL;
      break;
    case '<':
      io_next();
      /* The unequal token. */
      if (io_peek() == '>')
      {
        io_next();
        token = T_NOT_EQUAL;
      }
      /* The less-than-or-equal-to token. */
      else if (io_peek() == '=')
      {
        io_next();
        token = T_LT_EQ;
      }
      /* The less-than token. */
      else
      {
        io_next();
        token = T_LT;
      }
      break;
      /* The greater-than token. */
    case '>':
      io_next();
      /* The greater-than-or-equal-to token. */
      if (io_peek() == '=')
      {
        io_next();
        return T_GT_EQ;
      }
      /* The greater-than token. */
      else
      {
        io_next();
        return T_GT;
      }
      break;
  }

  return token;
}
Exemplo n.º 2
0
static int spx_can_decode (struct io_stream *stream)
{
	char buf[36];

	if (io_peek(stream, buf, 36) == 36 && !memcmp(buf, "OggS", 4)
			&& !memcmp(buf + 28, "Speex   ", 8))
		return 1;

	return 0;
}
Exemplo n.º 3
0
bool pipex_readln_nb(pipex_t *pipex, char *string){

    while(!pipex->io->in_eof && !io_line_ready(pipex->io) && io_peek(pipex->io)){
      io_get_update(pipex->io);
  }
  
  if(io_line_ready(pipex->io)){
    return pipex_readln(pipex,string);
  }else if(pipex->io->in_eof){
    string[0]='\0';
    pipex->state|=PIPEX_EOF;
    return FALSE;
  }else {  
    string[0]='\0';
    return FALSE;
  }
}
Exemplo n.º 4
0
/* Return the decoder for this stream. */
struct decoder *get_decoder_by_content (struct io_stream *stream)
{
    char buf[8096];
    ssize_t res;
    int i;
    struct decoder *decoder_by_mime_type;

    assert (stream != NULL);

    /* Peek at the start of the stream to check if sufficient data is
     * available.  If not, there is no sense in trying the decoders as
     * each of them would issue an error.  The data is also needed to
     * get the MIME type. */
    logit ("Testing the stream...");
    res = io_peek (stream, buf, sizeof (buf));
    if (res < 0) {
        error ("Stream error: %s", io_strerror (stream));
        return NULL;
    }

    if (res < 512) {
        logit ("Stream too short");
        return NULL;
    }

    decoder_by_mime_type = get_decoder_by_mime_type (stream);
    if (decoder_by_mime_type)
        return decoder_by_mime_type;

    for (i = 0; i < plugins_num; i++) {
        if (plugins[i].decoder->can_decode
                && plugins[i].decoder->can_decode (stream)) {
            logit ("Found decoder for stream: %s", plugins[i].name);
            return plugins[i].decoder;
        }
    }

    error ("Format not supported");
    return NULL;
}
static int token_eol (int c)
{
  if (c == '\r')
  {
    c = io_peek();
    io_next();
    /* EOL is \r\n. */
    if (c == '\n')
    {
      io_next();
      return T_EOL;
    }
    /* EOL is \r. */
    return T_EOL;
  }
  else if (c == '\n')
  {
    /* EOL is \n. */
    io_next();
    return T_EOL;
  }

  return 0;
}
Exemplo n.º 6
0
BYTE c64io_df00_peek(WORD addr)
{
    DBGRW(("IO: io-df00 p %04x\n", addr));
    return io_peek(&c64io_df00_head, addr);
}
Exemplo n.º 7
0
BYTE vic20io3_peek(WORD addr)
{
    DBGRW(("IO: io3 p %04x\n", addr));
    return io_peek(&vic20io3_head, addr);
}