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)
52 waitpid (w->pid, NULL, 0);
55 free (w->wrappid_path);
60 set_error_buf (struct wrap_internal_h *w,
61 char *buf, int errnum, const char *func)
67 /* 'func' is always statically allocated, since it comes from
68 * C99 __func__, so this is safe.
70 if (STRPREFIX (func, "impl_"))
72 else if (STRPREFIX (func, "wrap_"))
76 /* XXX This will be conditional on the user setting an error handler. */
77 fprintf (stderr, "wrappi: %s: %s\n", func, buf);
81 wrap_int_set_error (struct wrap_internal_h *w,
90 err = vasprintf (&msg, fs, args);
95 set_error_buf (w, msg, 0, func);
99 wrap_int_set_error_errno (struct wrap_internal_h *w,
109 err = vasprintf (&msg, fs, args);
114 set_error_buf (w, msg, errnum, func);
117 /* Note the gperf perfect hash in lib/internal-procs-lookup.gperf */
119 wrap_int_lookup_proc_entry (const char *name)
121 const struct proc_entry *v =
122 wrap_int_gperf_lookup_proc_entry (name, strlen (name));