obuf.h

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

Generated on Thu Feb 19 11:11:50 2009 for bglibs by  doxygen 1.5.4