obuf.h
00001
#ifndef IO_BUF__OBUF__H__
00002
#define IO_BUF__OBUF__H__
00003
00004
#include <iobuf/common.h>
00005
00010
typedef int (*obuf_fn)(
int,
const void*,
unsigned long);
00011
00013 struct obuf
00014 {
00016 iobuf io;
00018 unsigned bufpos;
00020 unsigned count;
00022 obuf_fn
writefn;
00023 };
00024
typedef struct obuf obuf;
00025
00026
extern obuf outbuf;
00027
extern obuf errbuf;
00028
00029
extern const char obuf_dec_digits[10];
00030
extern const char obuf_hex_lcase_digits[16];
00031
extern const char obuf_hex_ucase_digits[16];
00032
00034
#define OBUF_CREATE O_CREAT
00035
00036
#define OBUF_EXCLUSIVE O_EXCL
00037
00038
#define OBUF_TRUNCATE O_TRUNC
00039
00040
#define OBUF_APPEND O_APPEND
00041
00042
int obuf_init(obuf* out,
int fd, obuf_fn fn,
unsigned flags,
unsigned bufsize);
00043
int obuf_open(obuf* out,
const char* filename,
int oflags,
int mode,
unsigned bufsize);
00044
int obuf_close(obuf* out);
00046
#define obuf_error(out) iobuf_error(&(out)->io)
00047
00048
#define obuf_closed(out) iobuf_closed(&(out)->io)
00049
00050
#define obuf_timedout(out) iobuf_timedout(&((out)->io))
00051
int obuf_flush(obuf* out);
00052
int obuf_sync(obuf* out);
00053
int obuf_write_large(obuf* out,
const char* data,
unsigned datalen);
00054
int obuf_write(obuf* out,
const char* data,
unsigned datalen);
00055
int obuf_seek(obuf* out,
unsigned offset);
00057
#define obuf_rewind(out) obuf_seek(out,0)
00058
00059
#define obuf_tell(out) ((out)->io.offset+(out)->bufpos)
00060
00061
int obuf_pad(obuf* out,
unsigned width,
char ch);
00062
int obuf_endl(obuf* out);
00063
int obuf_putc(obuf* out,
char ch);
00065
#define obuf_puts(out,str) obuf_write(out,str,strlen(str))
00066
int obuf_put2s(obuf* out,
const char* s1,
const char* s2);
00067
int obuf_put3s(obuf* out,
const char* s1,
const char* s2,
const char* s3);
00068
int obuf_put4s(obuf* out,
const char* s1,
const char* s2,
const char* s3,
00069
const char* s4);
00070
int obuf_put5s(obuf* out,
const char* s1,
const char* s2,
const char* s3,
00071
const char* s4,
const char* s5);
00072
int obuf_put6s(obuf* out,
const char* s1,
const char* s2,
const char* s3,
00073
const char* s4,
const char* s5,
const char* s6);
00074
int obuf_put7s(obuf* out,
const char* s1,
const char* s2,
const char* s3,
00075
const char* s4,
const char* s5,
const char* s6,
const char* s7);
00076
int obuf_putns(obuf* out,
unsigned int count, ...);
00078
#define obuf_putstr(out,str) obuf_write(out,(str)->s,(str)->len)
00079
int obuf_putsflush(obuf* out,
const char* s);
00080
int obuf_puti(obuf* out,
long data);
00081
int obuf_putiw(obuf* out,
long data,
unsigned width,
char pad);
00082
int obuf_putu(obuf* out,
unsigned long data);
00083
int obuf_putuw(obuf* out,
unsigned long data,
unsigned width,
char pad);
00084
int obuf_putill(obuf* out,
long long data);
00085
int obuf_putiwll(obuf* out,
long long data,
unsigned width,
char pad);
00086
int obuf_putull(obuf* out,
unsigned long long data);
00087
int obuf_putuwll(obuf* out,
unsigned long long data,
unsigned width,
char pad);
00088
int obuf_putx(obuf* out,
unsigned long data);
00089
int obuf_putxw(obuf* out,
unsigned long data,
unsigned width,
char pad);
00090
int obuf_putX(obuf* out,
unsigned long data);
00091
int obuf_putXw(obuf* out,
unsigned long data,
unsigned width,
char pad);
00092
int obuf_putxll(obuf* out,
unsigned long long data);
00093
int obuf_putxwll(obuf* out,
unsigned long long data,
unsigned width,
char pad);
00094
int obuf_putXll(obuf* out,
unsigned long long data);
00095
int obuf_putXwll(obuf* out,
unsigned long long data,
unsigned width,
char pad);
00096
int obuf_putsnumw(obuf* out,
long num,
unsigned width,
char pad,
00097
unsigned base,
const char* digits);
00098
int obuf_putunumw(obuf* out,
unsigned long num,
unsigned width,
char pad,
00099
unsigned base,
const char* digits);
00100
int obuf_putsllnumw(obuf* out,
long long num,
unsigned width,
char pad,
00101
unsigned base,
const char* digits);
00102
int obuf_putullnumw(obuf* out,
unsigned long long num,
unsigned width,
char pad,
00103
unsigned base,
const char* digits);
00104
int obuf_putnetstring(obuf* out,
const char* data,
unsigned datalen);
00105
int obuf_sign_pad(obuf* out,
int sign,
unsigned width,
char pad);
00106
00107
00108
#endif
Generated on Mon Nov 15 14:50:26 2004 for bglibs by
1.3.8