2 libcore: library for basic data structures and algorithms.
3 Copyright (C) 2005 IPD Goos, Universit"at Karlsruhe, Germany
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 * Something to which can be appended.
24 * @author Sebastian Hack
28 #ifndef _LIBCORE_APPENDABLE_H
29 #define _LIBCORE_APPENDABLE_H
33 struct _lc_appendable_funcs_t;
35 typedef struct _lc_appendable_t {
39 const struct _lc_appendable_funcs_t *app;
42 typedef struct _lc_appendable_funcs_t {
43 void (*init)(lc_appendable_t *obj);
44 void (*finish)(lc_appendable_t *obj);
45 int (*snadd)(lc_appendable_t *obj, const char *str, size_t len);
46 int (*chadd)(lc_appendable_t *obj, int ch);
47 } lc_appendable_funcs_t;
49 #define lc_appendable_snadd(obj,str,len) ((obj)->app->snadd(obj, str, len))
50 #define lc_appendable_chadd(obj,ch) ((obj)->app->chadd(obj, ch))
51 #define lc_appendable_finish(obj) ((obj)->app->finish(obj))
53 extern void lc_appendable_init(lc_appendable_t *app, const lc_appendable_funcs_t *funcs,
54 void *obj, size_t limit);
56 extern int lc_appendable_snwadd(lc_appendable_t *app, const char *str,
57 size_t len, unsigned int width, int left_just, char pad);
59 extern const lc_appendable_funcs_t *lc_appendable_file;
60 extern const lc_appendable_funcs_t *lc_appendable_string;
61 extern const lc_appendable_funcs_t *lc_appendable_obstack;