2 * Copyright 2007 Red Hat Inc., Durham, North Carolina.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * John Dennis <jdennis@redhat.com>
23 #ifndef DATA_BUF_HEADER
24 #define DATA_BUF_HEADER
26 /*****************************************************************************/
27 /******************************* Include Files *******************************/
28 /*****************************************************************************/
32 /*****************************************************************************/
33 /*********************************** Defines *********************************/
34 /*****************************************************************************/
36 #define DATABUF_FLAG_PRESERVE_HEAD (1 << 0)
37 #define DATABUF_FLAG_STRING (2 << 0)
40 /*****************************************************************************/
41 /******************************* Type Definitions ****************************/
42 /*****************************************************************************/
44 typedef struct Databuf {
53 /*****************************************************************************/
54 /************************* External Global Variables ***********************/
55 /*****************************************************************************/
57 /*****************************************************************************/
58 /***************************** Inline Functions ****************************/
59 /*****************************************************************************/
61 static inline char *databuf_beg(DataBuf *db)
62 {return (db->alloc_ptr == NULL) ? NULL : db->alloc_ptr+db->offset;}
64 /*****************************************************************************/
65 /**************************** Exported Functions ***************************/
66 /*****************************************************************************/
68 void databuf_print(DataBuf *db, int print_data, char *fmt, ...) hidden
70 __attribute__ ((format (printf, 3, 4)));
74 int databuf_init(DataBuf *db, size_t size, unsigned flags) hidden;
75 void databuf_free(DataBuf *db) hidden;
76 int databuf_append(DataBuf *db, const char *src, size_t src_size) hidden;
77 int databuf_advance(DataBuf *db, size_t advance) hidden;
78 int databuf_reset(DataBuf *db) hidden;