libvirt/src/util/buf.h

64 lines
1.8 KiB
C
Raw Normal View History

2007-03-15 17:30:04 +00:00
/*
2007-06-26 22:21:22 +00:00
* buf.h: buffers for libvirt
2007-03-15 17:30:04 +00:00
*
* Copyright (C) 2005-2008, 2011 Red Hat, Inc.
2007-03-15 17:30:04 +00:00
*
* See COPYING.LIB for the License of this software
*
* Daniel Veillard <veillard@redhat.com>
*/
2007-06-26 22:21:22 +00:00
#ifndef __VIR_BUFFER_H__
# define __VIR_BUFFER_H__
2007-03-15 17:30:04 +00:00
# include "internal.h"
2007-03-15 17:30:04 +00:00
# include <stdarg.h>
2007-03-15 17:30:04 +00:00
/**
2007-06-26 22:21:22 +00:00
* virBuffer:
2007-03-15 17:30:04 +00:00
*
* A buffer structure.
*/
2007-06-26 22:21:22 +00:00
typedef struct _virBuffer virBuffer;
typedef virBuffer *virBufferPtr;
# ifndef __VIR_BUFFER_C__
# define VIR_BUFFER_INITIALIZER { 0, 0, 0, NULL }
/* This struct must be kept in syn with the real struct
in the buf.c impl file */
2007-06-26 22:21:22 +00:00
struct _virBuffer {
unsigned int a;
unsigned int b;
unsigned int c;
char *d;
2007-03-15 17:30:04 +00:00
};
# endif
2007-03-15 17:30:04 +00:00
char *virBufferContentAndReset(virBufferPtr buf);
void virBufferFreeAndReset(virBufferPtr buf);
2008-11-17 11:03:25 +00:00
int virBufferError(const virBufferPtr buf);
unsigned int virBufferUse(const virBufferPtr buf);
void virBufferAdd(virBufferPtr buf, const char *str, int len);
void virBufferAddChar(virBufferPtr buf, char c);
void virBufferAsprintf(virBufferPtr buf, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3);
void virBufferVasprintf(virBufferPtr buf, const char *format, va_list ap)
ATTRIBUTE_FMT_PRINTF(2, 0);
void virBufferStrcat(virBufferPtr buf, ...)
ATTRIBUTE_SENTINEL;
void virBufferEscape(virBufferPtr buf, const char *toescape,
const char *format, const char *str);
void virBufferEscapeString(virBufferPtr buf, const char *format,
const char *str);
void virBufferEscapeSexpr(virBufferPtr buf, const char *format,
const char *str);
void virBufferEscapeShell(virBufferPtr buf, const char *str);
void virBufferURIEncodeString(virBufferPtr buf, const char *str);
2007-03-15 17:30:04 +00:00
# define virBufferAddLit(buf_, literal_string_) \
virBufferAdd(buf_, "" literal_string_ "", sizeof literal_string_ - 1)
2007-06-26 22:21:22 +00:00
#endif /* __VIR_BUFFER_H__ */