buf.h 1.8 KB
Newer Older
D
Daniel Veillard 已提交
1
/*
D
Daniel P. Berrange 已提交
2
 * buf.h: buffers for libvirt
D
Daniel Veillard 已提交
3
 *
E
Eric Blake 已提交
4
 * Copyright (C) 2005-2008, 2011 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

E
Eric Blake 已提交
16 17
# include <stdarg.h>

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

26 27
# ifndef __VIR_BUFFER_C__
#  define VIR_BUFFER_INITIALIZER { 0, 0, 0, NULL }
28 29 30

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

D
Daniel P. Berrange 已提交
39
char *virBufferContentAndReset(const virBufferPtr buf);
40
void virBufferFreeAndReset(const virBufferPtr buf);
D
Daniel P. Berrange 已提交
41
int virBufferError(const virBufferPtr buf);
42
unsigned int virBufferUse(const virBufferPtr buf);
D
Daniel P. Berrange 已提交
43 44
void virBufferAdd(const virBufferPtr buf, const char *str, int len);
void virBufferAddChar(const virBufferPtr buf, char c);
45
void virBufferAsprintf(const virBufferPtr buf, const char *format, ...)
46
  ATTRIBUTE_FMT_PRINTF(2, 3);
E
Eric Blake 已提交
47 48
void virBufferVasprintf(const virBufferPtr buf, const char *format, va_list ap)
  ATTRIBUTE_FMT_PRINTF(2, 0);
49 50
void virBufferStrcat(const virBufferPtr buf, ...)
  ATTRIBUTE_SENTINEL;
51
void virBufferEscapeString(const virBufferPtr buf, const char *format, const char *str);
52
void virBufferEscapeSexpr(const virBufferPtr buf, const char *format, const char *str);
S
Sage Weil 已提交
53
void virBufferEscape(const virBufferPtr buf, const char *toescape, const char *format, const char *str);
54
void virBufferURIEncodeString (const virBufferPtr buf, const char *str);
D
Daniel Veillard 已提交
55

56
# define virBufferAddLit(buf_, literal_string_) \
D
Daniel P. Berrange 已提交
57
  virBufferAdd (buf_, "" literal_string_ "", sizeof literal_string_ - 1)
58

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