obuf.h
#ifndef IO_BUF__OBUF__H__
#define IO_BUF__OBUF__H__
#include <stdarg.h>
#include "sysdeps.h"
#include "iobuf_common.h"
typedef int (*obuf_fn)(int, const void*, unsigned long);
struct obuf
{
iobuf io;
unsigned bufpos;
unsigned count;
obuf_fn writefn;
};
typedef struct obuf obuf;
extern obuf outbuf;
extern obuf errbuf;
extern const char obuf_dec_digits[10] __DEPRECATED__;
extern const char obuf_hex_lcase_digits[16] __DEPRECATED__;
extern const char obuf_hex_ucase_digits[16] __DEPRECATED__;
#define OBUF_CREATE O_CREAT
#define OBUF_EXCLUSIVE O_EXCL
#define OBUF_TRUNCATE O_TRUNC
#define OBUF_APPEND O_APPEND
int obuf_init(obuf* out, int fd, obuf_fn fn, unsigned flags, unsigned bufsize);
int obuf_open(obuf* out, const char* filename, int oflags, int mode, unsigned bufsize);
int obuf_close(obuf* out);
#define obuf_error(out) iobuf_error(&(out)->io)
#define obuf_closed(out) iobuf_closed(&(out)->io)
#define obuf_timedout(out) iobuf_timedout(&((out)->io))
int obuf_flush(obuf* out);
int obuf_sync(obuf* out);
int obuf_write_large(obuf* out, const char* data, unsigned datalen);
int obuf_write(obuf* out, const char* data, unsigned datalen);
int obuf_seek(obuf* out, unsigned offset);
#define obuf_rewind(out) obuf_seek(out,0)
#define obuf_tell(out) ((out)->io.offset+(out)->bufpos)
int obuf_pad(obuf* out, unsigned width, char ch);
int obuf_endl(obuf* out);
int obuf_putc(obuf* out, char ch);
#define obuf_puts(out,str) obuf_write(out,str,strlen(str))
int obuf_put2s(obuf* out, const char* s1, const char* s2);
int obuf_put3s(obuf* out, const char* s1, const char* s2, const char* s3);
int obuf_put4s(obuf* out, const char* s1, const char* s2, const char* s3,
const char* s4);
int obuf_put5s(obuf* out, const char* s1, const char* s2, const char* s3,
const char* s4, const char* s5);
int obuf_put6s(obuf* out, const char* s1, const char* s2, const char* s3,
const char* s4, const char* s5, const char* s6);
int obuf_put7s(obuf* out, const char* s1, const char* s2, const char* s3,
const char* s4, const char* s5, const char* s6, const char* s7);
int obuf_putns(obuf* out, unsigned int count, ...);
int obuf_putf(obuf* out, const char* format, ...);
int obuf_putfv(obuf* out, const char* format, va_list ap);
#define obuf_putstr(out,str) obuf_write(out,(str)->s,(str)->len)
int obuf_putsflush(obuf* out, const char* s);
int obuf_puti(obuf* out, long data);
int obuf_putiw(obuf* out, long data, unsigned width, char pad);
int obuf_putu(obuf* out, unsigned long data);
int obuf_putuw(obuf* out, unsigned long data, unsigned width, char pad);
int obuf_putill(obuf* out, long long data);
int obuf_putiwll(obuf* out, long long data, unsigned width, char pad);
int obuf_putull(obuf* out, unsigned long long data);
int obuf_putuwll(obuf* out, unsigned long long data, unsigned width, char pad);
int obuf_putx(obuf* out, unsigned long data);
int obuf_putxw(obuf* out, unsigned long data, unsigned width, char pad);
int obuf_putX(obuf* out, unsigned long data);
int obuf_putXw(obuf* out, unsigned long data, unsigned width, char pad);
int obuf_putxll(obuf* out, unsigned long long data);
int obuf_putxwll(obuf* out, unsigned long long data, unsigned width, char pad);
int obuf_putXll(obuf* out, unsigned long long data);
int obuf_putXwll(obuf* out, unsigned long long data, unsigned width, char pad);
int obuf_putsnumw(obuf* out, long num, unsigned width, char pad,
unsigned base, const char* digits);
int obuf_putunumw(obuf* out, unsigned long num, unsigned width, char pad,
unsigned base, const char* digits);
int obuf_putsllnumw(obuf* out, long long num, unsigned width, char pad,
unsigned base, const char* digits);
int obuf_putullnumw(obuf* out, unsigned long long num, unsigned width, char pad,
unsigned base, const char* digits);
int obuf_putnetstring(obuf* out, const char* data, unsigned datalen);
int obuf_sign_pad(obuf* out, int sign, unsigned width, char pad);
#endif
obuf_write_large
int obuf_write_large(obuf *out, const char *data, unsigned datalen)
Definition: obuf_write.c:7
obuf_pad
int obuf_pad(obuf *out, unsigned width, char ch)
Definition: obuf_pad.c:4
obuf_putXll
int obuf_putXll(obuf *out, unsigned long long data)
Definition: obuf_putullnumw.c:52
obuf_put5s
int obuf_put5s(obuf *out, const char *s1, const char *s2, const char *s3, const char *s4, const char *s5)
Definition: obuf_put5s.c:5
obuf_put7s
int obuf_put7s(obuf *out, const char *s1, const char *s2, const char *s3, const char *s4, const char *s5, const char *s6, const char *s7)
Definition: obuf_put7s.c:5
obuf_put6s
int obuf_put6s(obuf *out, const char *s1, const char *s2, const char *s3, const char *s4, const char *s5, const char *s6)
Definition: obuf_put6s.c:5
obuf_seek
int obuf_seek(obuf *out, unsigned offset)
Definition: obuf_seek.c:7
obuf_sign_pad
int obuf_sign_pad(obuf *out, int sign, unsigned width, char pad)
Definition: obuf_sign_pad.c:10
obuf_putill
int obuf_putill(obuf *out, long long data)
Definition: obuf_putsllnumw.c:21
obuf_putullnumw
int obuf_putullnumw(obuf *out, unsigned long long num, unsigned width, char pad, unsigned base, const char *digits)
Definition: obuf_putullnumw.c:6
obuf_putu
int obuf_putu(obuf *out, unsigned long data)
Definition: obuf_putunumw.c:21
obuf_putull
int obuf_putull(obuf *out, unsigned long long data)
Definition: obuf_putullnumw.c:24
obuf_open
int obuf_open(obuf *out, const char *filename, int oflags, int mode, unsigned bufsize)
Definition: obuf_open.c:4
obuf::count
unsigned count
Definition: obuf.h:28
obuf_init
int obuf_init(obuf *out, int fd, obuf_fn fn, unsigned flags, unsigned bufsize)
Definition: obuf_init.c:5
obuf_putxwll
int obuf_putxwll(obuf *out, unsigned long long data, unsigned width, char pad)
Definition: obuf_putullnumw.c:31
obuf_putf
int obuf_putf(obuf *out, const char *format,...)
Definition: obuf_putf.c:26
obuf_putsnumw
int obuf_putsnumw(obuf *out, long num, unsigned width, char pad, unsigned base, const char *digits)
Definition: obuf_putsnumw.c:5
obuf_putsflush
int obuf_putsflush(obuf *out, const char *s)
Definition: obuf_putsflush.c:5
obuf_fn
int(* obuf_fn)(int, const void *, unsigned long)
Definition: obuf.h:18
obuf_putiwll
int obuf_putiwll(obuf *out, long long data, unsigned width, char pad)
Definition: obuf_putsllnumw.c:15
obuf_putsllnumw
int obuf_putsllnumw(obuf *out, long long num, unsigned width, char pad, unsigned base, const char *digits)
Definition: obuf_putsllnumw.c:5
obuf::writefn
obuf_fn writefn
Definition: obuf.h:30
obuf_put2s
int obuf_put2s(obuf *out, const char *s1, const char *s2)
Definition: obuf_put2s.c:5
obuf_putX
int obuf_putX(obuf *out, unsigned long data)
Definition: obuf_putunumw.c:47
obuf_putuw
int obuf_putuw(obuf *out, unsigned long data, unsigned width, char pad)
Definition: obuf_putunumw.c:15
obuf::bufpos
unsigned bufpos
Definition: obuf.h:26
obuf::io
iobuf io
Definition: obuf.h:24
obuf_putfv
int obuf_putfv(obuf *out, const char *format, va_list ap)
Definition: obuf_putf.c:6
obuf_putuwll
int obuf_putuwll(obuf *out, unsigned long long data, unsigned width, char pad)
Definition: obuf_putullnumw.c:18
obuf_putc
int obuf_putc(obuf *out, char ch)
Definition: obuf_putc.c:4
obuf_putXwll
int obuf_putXwll(obuf *out, unsigned long long data, unsigned width, char pad)
Definition: obuf_putullnumw.c:45
obuf_putXw
int obuf_putXw(obuf *out, unsigned long data, unsigned width, char pad)
Definition: obuf_putunumw.c:41
obuf_putxw
int obuf_putxw(obuf *out, unsigned long data, unsigned width, char pad)
Definition: obuf_putunumw.c:28
obuf_puti
int obuf_puti(obuf *out, long data)
Definition: obuf_putsnumw.c:21
obuf_putiw
int obuf_putiw(obuf *out, long data, unsigned width, char pad)
Definition: obuf_putsnumw.c:15
obuf
Definition: obuf.h:21
errbuf
obuf errbuf
Definition: obuf_stderr.c:7
obuf_endl
int obuf_endl(obuf *out)
Definition: obuf_endl.c:4
iobuf
Definition: iobuf_common.h:48
obuf_close
int obuf_close(obuf *out)
Definition: obuf_close.c:4
obuf_flush
int obuf_flush(obuf *out)
Definition: obuf_flush.c:6
obuf_putxll
int obuf_putxll(obuf *out, unsigned long long data)
Definition: obuf_putullnumw.c:38
obuf_sync
int obuf_sync(obuf *out)
Definition: obuf_sync.c:6
obuf_write
int obuf_write(obuf *out, const char *data, unsigned datalen)
Definition: obuf_write.c:30
obuf_put3s
int obuf_put3s(obuf *out, const char *s1, const char *s2, const char *s3)
Definition: obuf_put3s.c:5
outbuf
obuf outbuf
Definition: obuf_stdout.c:7
obuf_putns
int obuf_putns(obuf *out, unsigned int count,...)
Definition: obuf_putns.c:6
obuf_putunumw
int obuf_putunumw(obuf *out, unsigned long num, unsigned width, char pad, unsigned base, const char *digits)
Definition: obuf_putunumw.c:5
obuf_putx
int obuf_putx(obuf *out, unsigned long data)
Definition: obuf_putunumw.c:34
obuf_putnetstring
int obuf_putnetstring(obuf *out, const char *data, unsigned datalen)
Definition: obuf_putnetstring.c:4
obuf_put4s
int obuf_put4s(obuf *out, const char *s1, const char *s2, const char *s3, const char *s4)
Definition: obuf_put4s.c:5