- pr " if (!xdr_guestfs_message_header (xdr, &state->hdr)) {\n";
- pr " error (g, \"%s: failed to parse reply header\");\n" name;
+ pr " guestfs__switch_to_receiving (g);\n";
+ pr " ctx->cb_sequence = 1;\n";
+ pr " ml->main_loop_quit (ml, g);\n";
+ pr "}\n";
+ pr "\n";
+
+ (* Generate the reply callback function. *)
+ pr "static void %s_reply_cb (guestfs_h *g, void *data, XDR *xdr)\n" shortname;
+ pr "{\n";
+ pr " guestfs_main_loop *ml = guestfs_get_main_loop (g);\n";
+ pr " struct %s_ctx *ctx = (struct %s_ctx *) data;\n" shortname shortname;
+ pr "\n";
+ pr " if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {\n";
+ pr " error (g, \"%%s: failed to parse reply header\", \"%s\");\n" name;