|
1 /* |
|
2 Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved. |
|
3 This program is free software; you can redistribute it and/or modify it |
|
4 under the terms of version 2 of the GNU General Public License as |
|
5 published by the Free Software Foundation. |
|
6 |
|
7 This program is distributed in the hope that it would be useful, but |
|
8 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10 |
|
11 Further, this software is distributed without any warranty that it is |
|
12 free of the rightful claim of any third person regarding infringement |
|
13 or the like. Any license provided herein, whether implied or |
|
14 otherwise, applies only to this software file. Patent licenses, if |
|
15 any, provided herein do not apply to combinations of this program with |
|
16 other software, or any other product whatsoever. |
|
17 |
|
18 You should have received a copy of the GNU General Public License along |
|
19 with this program; if not, write the Free Software Foundation, Inc., 51 |
|
20 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. |
|
21 |
|
22 Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, |
|
23 Mountain View, CA 94043, or: |
|
24 |
|
25 http://www.sgi.com |
|
26 |
|
27 For further information regarding this notice, see: |
|
28 |
|
29 http://oss.sgi.com/projects/GenInfo/NoticeExplan |
|
30 |
|
31 |
|
32 $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/esb.h,v 1.1 2005/08/04 05:09:37 davea Exp $ */ |
|
33 |
|
34 |
|
35 /* esb.h |
|
36 Extensible string buffer. |
|
37 A simple vaguely object oriented extensible string buffer. |
|
38 |
|
39 The struct could be opaque here, but it seems ok to expose |
|
40 the contents: simplifies debugging. |
|
41 */ |
|
42 |
|
43 |
|
44 struct esb_s { |
|
45 string esb_string; /* pointer to the data itself, or NULL. */ |
|
46 size_t esb_allocated_size; /* Size of allocated data or 0 */ |
|
47 size_t esb_used_bytes; /* Amount of space used or 0 */ |
|
48 }; |
|
49 |
|
50 /* string length taken from string itself. */ |
|
51 void esb_append(struct esb_s *data, string in_string); |
|
52 |
|
53 /* The 'len' is believed. Do not pass in strings < len bytes long. */ |
|
54 void esb_appendn(struct esb_s *data, string in_string, size_t len); |
|
55 |
|
56 /* Always returns an empty string or a non-empty string. Never 0. */ |
|
57 string esb_get_string(struct esb_s *data); |
|
58 |
|
59 |
|
60 /* Sets esb_used_bytes to zero. The string is not freed and |
|
61 esb_allocated_size is unchanged. */ |
|
62 void esb_empty_string(struct esb_s *data); |
|
63 |
|
64 |
|
65 /* Return esb_used_bytes. */ |
|
66 size_t esb_string_len(struct esb_s *data); |
|
67 |
|
68 /* The following are for testing esb, not use by dwarfdump. */ |
|
69 |
|
70 /* *data is presumed to contain garbage, not values, and |
|
71 is properly initialized. */ |
|
72 void esb_constructor(struct esb_s *data); |
|
73 |
|
74 /* The string is freed, contents of *data set to zeroes. */ |
|
75 void esb_destructor(struct esb_s *data); |
|
76 |
|
77 |
|
78 /* To get all paths in the code tested, this sets the |
|
79 allocation/reallocation to the given value, which can be quite small |
|
80 but must not be zero. */ |
|
81 void esb_alloc_size(size_t size); |
|
82 size_t esb_get_allocated_size(struct esb_s *data); |
|
83 |