2 * Copyright (C) 2011-2012 Red Hat Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 struct wrap_h *w = calloc (1, sizeof *w);
39 wrap_close (wrap_h *w)
45 set_error_buf (struct wrap_internal_h *w,
46 char *buf, int errnum, const char *func)
52 /* 'func' is always statically allocated, since it comes from
53 * C99 __func__, so this is safe.
55 if (STRPREFIX (func, "impl_"))
57 else if (STRPREFIX (func, "wrap_"))
61 /* XXX This will be conditional on the user setting an error handler. */
62 fprintf (stderr, "wrappi: %s: %s\n", func, buf);
66 wrap_int_set_error (struct wrap_internal_h *w,
75 err = vasprintf (&msg, fs, args);
80 set_error_buf (w, msg, 0, func);
84 wrap_int_set_error_errno (struct wrap_internal_h *w,
94 err = vasprintf (&msg, fs, args);
99 set_error_buf (w, msg, errnum, func);