buf.h 1.4 KB
Newer Older
D
Daniel Veillard 已提交
1
/*
D
Daniel P. Berrange 已提交
2
 * buf.h: buffers for libvirt
D
Daniel Veillard 已提交
3
 *
4
 * Copyright (C) 2005-2008 Red Hat, Inc.
D
Daniel Veillard 已提交
5 6 7 8 9 10
 *
 * See COPYING.LIB for the License of this software
 *
 * Daniel Veillard <veillard@redhat.com>
 */

D
Daniel P. Berrange 已提交
11
#ifndef __VIR_BUFFER_H__
12
# define __VIR_BUFFER_H__
D
Daniel Veillard 已提交
13

14
# include "internal.h"
D
Daniel Veillard 已提交
15 16

/**
D
Daniel P. Berrange 已提交
17
 * virBuffer:
D
Daniel Veillard 已提交
18 19 20
 *
 * A buffer structure.
 */
D
Daniel P. Berrange 已提交
21 22
typedef struct _virBuffer virBuffer;
typedef virBuffer *virBufferPtr;
23

24 25
# ifndef __VIR_BUFFER_C__
#  define VIR_BUFFER_INITIALIZER { 0, 0, 0, NULL }
26 27 28

/* This struct must be kept in syn with the real struct
   in the buf.c impl file */
D
Daniel P. Berrange 已提交
29
struct _virBuffer {
30 31 32 33
    unsigned int a;
    unsigned int b;
    unsigned int c;
    char *d;
D
Daniel Veillard 已提交
34
};
35
# endif
D
Daniel Veillard 已提交
36

D
Daniel P. Berrange 已提交
37
char *virBufferContentAndReset(const virBufferPtr buf);
38
void virBufferFreeAndReset(const virBufferPtr buf);
D
Daniel P. Berrange 已提交
39
int virBufferError(const virBufferPtr buf);
40
unsigned int virBufferUse(const virBufferPtr buf);
D
Daniel P. Berrange 已提交
41 42 43
void virBufferAdd(const virBufferPtr buf, const char *str, int len);
void virBufferAddChar(const virBufferPtr buf, char c);
void virBufferVSprintf(const virBufferPtr buf, const char *format, ...)
44
  ATTRIBUTE_FMT_PRINTF(2, 3);
45 46
void virBufferStrcat(const virBufferPtr buf, ...)
  ATTRIBUTE_SENTINEL;
47 48
void virBufferEscapeString(const virBufferPtr buf, const char *format, const char *str);
void virBufferURIEncodeString (const virBufferPtr buf, const char *str);
D
Daniel Veillard 已提交
49

50
# define virBufferAddLit(buf_, literal_string_) \
D
Daniel P. Berrange 已提交
51
  virBufferAdd (buf_, "" literal_string_ "", sizeof literal_string_ - 1)
52

D
Daniel P. Berrange 已提交
53
#endif /* __VIR_BUFFER_H__ */