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
27 /* XXX XDR code should be in its own mini-library.
28 * OR we should export a way to serialize function calls.
32 static void main_loop (void);
37 main (int argc, char *argv[])
39 /* Command line XXX */
43 fprintf (stderr, "could not allocate wrappi handle\n");
64 struct wrap_int_message_header hdr;
65 struct wrap_int_message_error err;
69 /* Receive the request header. */
70 xdrstdio_create (&xdr, stdin, XDR_DECODE);
71 memset (&hdr, 0, sizeof hdr);
72 if (!wrap_int_xdr_message_header (&xdr, &hdr)) {
73 fprintf (stderr, "error receiving request header\n");
77 if (hdr.magic != WRAP_INT_PROTO_MAGIC) {
78 fprintf (stderr, "error in request: unexpected magic (%x)\n",
82 if (hdr.protocol != WRAP_INT_PROTOCOL) {
83 fprintf (stderr, "error in request: unexpected protocol number (%d)\n",
87 if (hdr.type != WRAP_INT_PROTO_TYPE_REQUEST) {
88 fprintf (stderr, "error in request: unexpected type (%d)\n",
93 /* Convert the proc name to the internal entry point. */
94 /* XXX We're going to use gperf here, as we do in libguestfs. */
95 for (i = 0; i < wrap_int_nr_procs; ++i) {
96 if (STREQ (wrap_int_proc_table[i].name, hdr.proc))
99 fprintf (stderr, "unknown proc name in request: %s\n", hdr.proc);
103 xdrp_args = wrap_int_proc_table[i].xdr_args;
105 xdrp_ret = wrap_int_proc_table[i].xdr_ret;
108 /* Receive the arguments. */