Clean and tiddy-up files.
[tomato.git] / release / src / router / udpxy / prbuf.h
blob74bc6d64715920701494fb76c664ca37657792b3
1 /* @(#) interface to memory-buffer printf API
3 * Copyright 2008-2011 Pavel V. Cherenkov (pcherenkov@gmail.com)
5 * This file is part of udpxy.
7 * udpxy is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * udpxy is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with udpxy. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef PRBUF_H_12272007bsl_
22 #define PRBUF_H_12272007bsl_
24 typedef struct printbuf* prbuf_t;
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
31 /* create/open print buffer
33 * @param pb - address of the new print buffer
34 * @param buf - (pre-allocated) memory buffer
35 * to associate new printbuffer with
36 * @param n - size (in bytes) of the memory buffer
38 * @return 0 if success: contents of pb are updated with
39 * the address on new printbuffer; -1 otherwise
41 int prbuf_open( prbuf_t* pb, void* buf, size_t n );
44 /* close print buffer
46 * @param pb - print buffer to close
48 * @return 0 if success, -1 otherwise
50 int prbuf_close( prbuf_t pb );
53 /* write a formatted string into the print buffer,
54 * beginning at the current position (each write
55 * advances the position appropriately)
57 * @param - destination print buffer
58 * @param - printf-style format string
60 * @return 0 if end of buffer has been reached,
61 * -1 in case of error,
62 * n > 0, where n is the number of characters written
63 * into the buffer (not including trailing zero character)
65 int prbuf_printf( prbuf_t pb, const char* format, ... );
68 /* @ return length of the text inside the buffer
69 * NOT including the termination zero character
72 size_t prbuf_len( prbuf_t pb );
75 /* set current position to the beginning of the print buffer
77 * @param pb - destination print buffer
79 void prbuf_rewind( prbuf_t pb );
81 #ifdef __cplusplus
83 #endif
85 #endif /* PRBUF_H_12272007bsl_ */
87 /* __EOF__ */