/* Copyright (c) 2008 The NetBSD Foundation, Inc.1* All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11*12* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND13* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,14* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF15* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16* IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY17* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE19* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS20* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER21* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR22* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN23* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */2425#if !defined(ATF_C_DETAIL_DYNSTR_H)26#define ATF_C_DETAIL_DYNSTR_H2728#include <stdarg.h>29#include <stdbool.h>30#include <stddef.h>3132#include <atf-c/error_fwd.h>3334/* ---------------------------------------------------------------------35* The "atf_dynstr" type.36* --------------------------------------------------------------------- */3738struct atf_dynstr {39char *m_data;40size_t m_datasize;41size_t m_length;42};43typedef struct atf_dynstr atf_dynstr_t;4445/* Constants */46extern const size_t atf_dynstr_npos;4748/* Constructors and destructors */49atf_error_t atf_dynstr_init(atf_dynstr_t *);50atf_error_t atf_dynstr_init_ap(atf_dynstr_t *, const char *, va_list);51atf_error_t atf_dynstr_init_fmt(atf_dynstr_t *, const char *, ...);52atf_error_t atf_dynstr_init_raw(atf_dynstr_t *, const void *, size_t);53atf_error_t atf_dynstr_init_rep(atf_dynstr_t *, size_t, char);54atf_error_t atf_dynstr_init_substr(atf_dynstr_t *, const atf_dynstr_t *,55size_t, size_t);56atf_error_t atf_dynstr_copy(atf_dynstr_t *, const atf_dynstr_t *);57void atf_dynstr_fini(atf_dynstr_t *);58char *atf_dynstr_fini_disown(atf_dynstr_t *);5960/* Getters */61const char *atf_dynstr_cstring(const atf_dynstr_t *);62size_t atf_dynstr_length(const atf_dynstr_t *);63size_t atf_dynstr_rfind_ch(const atf_dynstr_t *, char);6465/* Modifiers */66atf_error_t atf_dynstr_append_ap(atf_dynstr_t *, const char *, va_list);67atf_error_t atf_dynstr_append_fmt(atf_dynstr_t *, const char *, ...);68void atf_dynstr_clear(atf_dynstr_t *);69atf_error_t atf_dynstr_prepend_ap(atf_dynstr_t *, const char *, va_list);70atf_error_t atf_dynstr_prepend_fmt(atf_dynstr_t *, const char *, ...);7172/* Operators */73bool atf_equal_dynstr_cstring(const atf_dynstr_t *, const char *);74bool atf_equal_dynstr_dynstr(const atf_dynstr_t *, const atf_dynstr_t *);7576#endif /* !defined(ATF_C_DETAIL_DYNSTR_H) */777879