File: ibuf_peek.c

package info (click to toggle)
bglibs 2.04%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,468 kB
  • sloc: ansic: 15,821; perl: 674; sh: 63; makefile: 29
file content (13 lines) | stat: -rw-r--r-- 345 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "ibuf.h"

/** Retrieve the next character in the \c ibuf without advancing the
    current read position. */
int ibuf_peek(ibuf* in, char* ch)
{
  iobuf* io;
  io = &(in->io);
  if (ibuf_eof(in) || ibuf_error(in)) return 0;
  if (io->bufstart >= io->buflen && !ibuf_refill(in)) return 0;
  *ch = io->buffer[io->bufstart];
  return 1;
}