+let generate_lib_call_c api =
+ generate_header inputs CStyle LGPLv2plus;
+
+ pr "\
+#include <config.h>
+
+#include <stdio.h>
+
+#include \"wrappi.h\"
+#include \"internal.h\"
+
+void
+wrap_call (wrap_h *w, const char *name, const void *args, void *ret)
+{
+ int proc;
+
+ proc = wrap_int_lookup_proc_entry (name);
+ if (proc == -1) {
+ set_error (\"procedure not found: %%s\", name);
+ return;
+ }
+
+ /* This ends up calling wrap_int_call_<name>. */
+ wrap_int_proc_table[proc].call (w, args, ret);
+}
+
+size_t
+wrap_call_get_args_struct_size (wrap_h *w, const char *name)
+{
+ int proc;
+
+ proc = wrap_int_lookup_proc_entry (name);
+ if (proc == -1) {
+ set_error (\"procedure not found: %%s\", name);
+ return 0;
+ }
+
+ return wrap_int_proc_table[proc].args_struct_size;
+}
+
+size_t
+wrap_call_get_ret_struct_size (wrap_h *w, const char *name)
+{
+ int proc;
+
+ proc = wrap_int_lookup_proc_entry (name);
+ if (proc == -1) {
+ set_error (\"procedure not found: %%s\", name);
+ return 0;
+ }
+
+ return wrap_int_proc_table[proc].ret_struct_size;
+}
+
+/* Really this returns xdrproc_t but we don't want to have to include
+ * XDR headers in the public API.
+ */
+void *
+wrap_call_get_args_xdrproc (wrap_h *w, const char *name)
+{
+ int proc;
+
+ proc = wrap_int_lookup_proc_entry (name);
+ if (proc == -1) {
+ set_error (\"procedure not found: %%s\", name);
+ return 0;
+ }
+
+ return wrap_int_proc_table[proc].args_xdrproc;
+}
+
+/* Really this returns xdrproc_t but we don't want to have to include
+ * XDR headers in the public API.
+ */
+void *
+wrap_call_get_ret_xdrproc (wrap_h *w, const char *name)
+{
+ int proc;
+
+ proc = wrap_int_lookup_proc_entry (name);
+ if (proc == -1) {
+ set_error (\"procedure not found: %%s\", name);
+ return 0;
+ }
+
+ return wrap_int_proc_table[proc].ret_xdrproc;
+}
+";
+
+ iter_entry_points api (
+ fun ep ->
+ pr "\n";
+
+ let name = ep.ep_name in
+ let ret, req, opt = ep.ep_ftype in
+
+ pr "void\n";
+ pr "wrap_int_call_%s (wrap_h *w, const void *argsv, void *retv)\n" name;
+ pr "{\n";
+ if req <> [] || opt <> [] then
+ pr " const struct wrap_%s_args *args = argsv;\n" name;
+ if ret <> RVoid then
+ pr " struct wrap_%s_ret *ret = retv;\n" name;
+ pr "\n";
+
+ pr " ";
+ (match ret with
+ | RVoid -> ()
+ | _ -> pr "ret->r = "
+ );
+
+ pr "wrap_%s (w" name;
+ List.iter (fun (n, _, _) -> pr ", args->%s" n) req;
+
+ if opt <> [] then assert false; (* XXX not implemented *)
+
+ pr ");\n";
+ pr "}\n";
+ )
+