2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _ASR_BUF_H
2N/A#define _ASR_BUF_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C"
2N/A{
2N/A#endif
2N/A
2N/A#include <stdio.h>
2N/A#include <sys/types.h>
2N/A#include <sys/nvpair.h>
2N/A#include <sys/varargs.h>
2N/A
2N/A#define ASRB_GROW_LEN 32
2N/A
2N/Atypedef struct asr_buf {
2N/A char *asrb_data;
2N/A size_t asrb_length;
2N/A size_t asrb_allocated;
2N/A int asrb_error;
2N/A} asr_buf_t;
2N/A
2N/Aextern asr_buf_t *asr_buf_alloc(size_t size);
2N/Aextern void asr_buf_free(asr_buf_t *abp);
2N/Aextern char *asr_buf_free_struct(asr_buf_t *abp);
2N/Aextern void asr_buf_reset(asr_buf_t *abp);
2N/A
2N/Aextern char *asr_buf_data(asr_buf_t *abp);
2N/Aextern size_t asr_buf_size(asr_buf_t *abp);
2N/A
2N/A/*
2N/A * Text formatting functions
2N/A */
2N/Aextern int asr_buf_append(asr_buf_t *abp, const char *format, ...);
2N/Aextern int asr_buf_vappend(asr_buf_t *abp, const char *format, va_list va);
2N/Aextern int asr_buf_append_buf(asr_buf_t *abp, const asr_buf_t *buf);
2N/Aextern int asr_buf_append_str(asr_buf_t *abp, const char *value);
2N/Aextern int asr_buf_append_raw(asr_buf_t *abp, const void *data, size_t size);
2N/Aextern int asr_buf_append_char(asr_buf_t *abp, const char value);
2N/Aextern void asr_buf_trim(asr_buf_t *abp);
2N/Aextern int asr_buf_terminate(asr_buf_t *abp);
2N/A
2N/A/*
2N/A * XML formating functions
2N/A */
2N/Aextern int asr_buf_append_xml_elem(
2N/A asr_buf_t *abp, unsigned int pad, const char *name);
2N/Aextern int asr_buf_append_xml_end(
2N/A asr_buf_t *abp, unsigned int pad, const char *name);
2N/Aextern int asr_buf_append_xml_val(asr_buf_t *abp, const char *value);
2N/Aextern int asr_buf_append_xml_token(asr_buf_t *abp, const char *token);
2N/Aextern int asr_buf_append_xml_nv(asr_buf_t *abp, unsigned int pad,
2N/A const char *name, const char *value);
2N/Aextern int asr_buf_append_xml_nnv(asr_buf_t *abp, unsigned int pad,
2N/A const char *name, const char *value, int n);
2N/Aextern int asr_buf_append_xml_nb(asr_buf_t *abp, unsigned int pad,
2N/A const char *name, const boolean_t value);
2N/Aextern int asr_buf_append_xml_nvtoken(asr_buf_t *abp, unsigned int pad,
2N/A const char *name, const char *value);
2N/Aextern int asr_buf_append_xml_anv(
2N/A asr_buf_t *abp, unsigned int pad, const char *aname, const char *avalue,
2N/A const char *name, const char *value);
2N/Aextern int asr_buf_append_xml_ai(
2N/A asr_buf_t *bp, int pad, const char *name, const char *value);
2N/Aextern int asr_buf_append_xml_ainvl(asr_buf_t *bp, int pad, nvlist_t *nvl);
2N/Aextern int asr_buf_append_pad(asr_buf_t *abp, unsigned int pad);
2N/A
2N/Aextern int asr_buf_readln(asr_buf_t *abp, FILE *file);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _ASR_BUF_H */