File: obuf_putc.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 (17 lines) | stat: -rw-r--r-- 375 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "obuf.h"

/** Write a single character to the \c obuf */
int obuf_putc(obuf* out, char ch)
{
  iobuf* io;
  
  io = &out->io;
  if (iobuf_bad(io)) return 0;
  
  out->count = 0;
  io->buffer[out->bufpos++] = ch;
  if (out->bufpos >= io->buflen) io->buflen = out->bufpos;
  if (io->buflen >= io->bufsize && !obuf_flush(out)) return 0;
  out->count = 1;
  return 1;
}