]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/atf/atf-c/detail/dynstr.h
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / contrib / atf / atf-c / detail / dynstr.h
1 /*
2  * Automated Testing Framework (atf)
3  *
4  * Copyright (c) 2008 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17  * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #if !defined(ATF_C_DYNSTR_H)
31 #define ATF_C_DYNSTR_H
32
33 #include <stdarg.h>
34 #include <stdbool.h>
35 #include <stddef.h>
36
37 #include <atf-c/error_fwd.h>
38
39 /* ---------------------------------------------------------------------
40  * The "atf_dynstr" type.
41  * --------------------------------------------------------------------- */
42
43 struct atf_dynstr {
44     char *m_data;
45     size_t m_datasize;
46     size_t m_length;
47 };
48 typedef struct atf_dynstr atf_dynstr_t;
49
50 /* Constants */
51 extern const size_t atf_dynstr_npos;
52
53 /* Constructors and destructors */
54 atf_error_t atf_dynstr_init(atf_dynstr_t *);
55 atf_error_t atf_dynstr_init_ap(atf_dynstr_t *, const char *, va_list);
56 atf_error_t atf_dynstr_init_fmt(atf_dynstr_t *, const char *, ...);
57 atf_error_t atf_dynstr_init_raw(atf_dynstr_t *, const void *, size_t);
58 atf_error_t atf_dynstr_init_rep(atf_dynstr_t *, size_t, char);
59 atf_error_t atf_dynstr_init_substr(atf_dynstr_t *, const atf_dynstr_t *,
60                                    size_t, size_t);
61 atf_error_t atf_dynstr_copy(atf_dynstr_t *, const atf_dynstr_t *);
62 void atf_dynstr_fini(atf_dynstr_t *);
63 char *atf_dynstr_fini_disown(atf_dynstr_t *);
64
65 /* Getters */
66 const char *atf_dynstr_cstring(const atf_dynstr_t *);
67 size_t atf_dynstr_length(const atf_dynstr_t *);
68 size_t atf_dynstr_rfind_ch(const atf_dynstr_t *, char);
69
70 /* Modifiers */
71 atf_error_t atf_dynstr_append_ap(atf_dynstr_t *, const char *, va_list);
72 atf_error_t atf_dynstr_append_fmt(atf_dynstr_t *, const char *, ...);
73 void atf_dynstr_clear(atf_dynstr_t *);
74 atf_error_t atf_dynstr_prepend_ap(atf_dynstr_t *, const char *, va_list);
75 atf_error_t atf_dynstr_prepend_fmt(atf_dynstr_t *, const char *, ...);
76
77 /* Operators */
78 bool atf_equal_dynstr_cstring(const atf_dynstr_t *, const char *);
79 bool atf_equal_dynstr_dynstr(const atf_dynstr_t *, const atf_dynstr_t *);
80
81 #endif /* ATF_C_DYNSTR_H */