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
24 #include <sys/types.h>
33 struct wrap_h *w = calloc (1, sizeof *w);
37 w->serial = random ();
43 wrap_close (wrap_h *w)
46 waitpid (w->pid, NULL, 0);
59 set_error_buf (struct wrap_internal_h *w,
60 char *buf, int errnum, const char *func)
66 /* 'func' is always statically allocated, since it comes from
67 * C99 __func__, so this is safe.
69 if (STRPREFIX (func, "impl_"))
71 else if (STRPREFIX (func, "wrap_"))
75 /* XXX This will be conditional on the user setting an error handler. */
76 fprintf (stderr, "wrappi: %s: %s\n", func, buf);
80 wrap_int_set_error (struct wrap_internal_h *w,
89 err = vasprintf (&msg, fs, args);
94 set_error_buf (w, msg, 0, func);
98 wrap_int_set_error_errno (struct wrap_internal_h *w,
108 err = vasprintf (&msg, fs, args);
113 set_error_buf (w, msg, errnum, func);