Add Sys::Guestfs::Lib - useful functions for using libguestfs from Perl.
[libguestfs.git] / src / generator.ml
index e97472d..d94ec14 100755 (executable)
@@ -3722,10 +3722,10 @@ check_state (guestfs_h *g, const char *caller)
        | RBool _ | RString _ | RStringList _
        | RStruct _ | RStructList _
        | RHashtable _ ->
        | RBool _ | RString _ | RStringList _
        | RStruct _ | RStructList _
        | RHashtable _ ->
-           pr "  if (!xdr_%s_ret (xdr, &ctx->ret)) {\n" name;
-           pr "    error (g, \"%%s: failed to parse reply\", \"%s\");\n" name;
-           pr "    return;\n";
-           pr "  }\n";
+          pr "  if (!xdr_%s_ret (xdr, &ctx->ret)) {\n" name;
+          pr "    error (g, \"%%s: failed to parse reply\", \"%s\");\n" name;
+          pr "    return;\n";
+          pr "  }\n";
       );
 
       pr " done:\n";
       );
 
       pr " done:\n";
@@ -3922,9 +3922,9 @@ and generate_daemon_actions_h () =
 
   List.iter (
     fun (name, style, _, _, _, _, _) ->
 
   List.iter (
     fun (name, style, _, _, _, _, _) ->
-       generate_prototype
-         ~single_line:true ~newline:true ~in_daemon:true ~prefix:"do_"
-         name style;
+      generate_prototype
+       ~single_line:true ~newline:true ~in_daemon:true ~prefix:"do_"
+       name style;
   ) daemon_functions
 
 (* Generate the server-side stubs. *)
   ) daemon_functions
 
 (* Generate the server-side stubs. *)
@@ -4093,9 +4093,9 @@ and generate_daemon_actions () =
 
   List.iter (
     fun (name, style, _, _, _, _, _) ->
 
   List.iter (
     fun (name, style, _, _, _, _, _) ->
-       pr "    case GUESTFS_PROC_%s:\n" (String.uppercase name);
-       pr "      %s_stub (xdr_in);\n" name;
-       pr "      break;\n"
+      pr "    case GUESTFS_PROC_%s:\n" (String.uppercase name);
+      pr "      %s_stub (xdr_in);\n" name;
+      pr "      break;\n"
   ) daemon_functions;
 
   pr "    default:\n";
   ) daemon_functions;
 
   pr "    default:\n";
@@ -4121,8 +4121,8 @@ and generate_daemon_actions () =
        pr "  int i, j;\n";
        pr "\n";
        (*
        pr "  int i, j;\n";
        pr "\n";
        (*
-       pr "  fprintf (stderr, \"%%s: <<%%s>>\\n\", __func__, str);\n";
-       pr "\n";
+         pr "  fprintf (stderr, \"%%s: <<%%s>>\\n\", __func__, str);\n";
+         pr "\n";
        *)
        pr "  if (!str) {\n";
        pr "    fprintf (stderr, \"%%s: failed: passed a NULL string\\n\", __func__);\n";
        *)
        pr "  if (!str) {\n";
        pr "    fprintf (stderr, \"%%s: failed: passed a NULL string\\n\", __func__);\n";
@@ -5009,15 +5009,22 @@ and generate_fish_cmds () =
   (* print_* functions *)
   List.iter (
     fun (typ, cols) ->
   (* print_* functions *)
   List.iter (
     fun (typ, cols) ->
+      let needs_i =
+        List.exists (function (_, FUUID) -> true | _ -> false) cols in
+
       pr "static void print_%s (struct guestfs_%s *%s)\n" typ typ typ;
       pr "{\n";
       pr "static void print_%s (struct guestfs_%s *%s)\n" typ typ typ;
       pr "{\n";
+      if needs_i then (
+        pr "  int i;\n";
+        pr "\n"
+      );
       List.iter (
        function
        | name, FString ->
            pr "  printf (\"%s: %%s\\n\", %s->%s);\n" name typ name
        | name, FUUID ->
            pr "  printf (\"%s: \");\n" name;
       List.iter (
        function
        | name, FString ->
            pr "  printf (\"%s: %%s\\n\", %s->%s);\n" name typ name
        | name, FUUID ->
            pr "  printf (\"%s: \");\n" name;
-           pr "  for (int i = 0; i < 32; ++i)\n";
+           pr "  for (i = 0; i < 32; ++i)\n";
            pr "    printf (\"%%c\", %s->%s[i]);\n" typ name;
            pr "  printf (\"\\n\");\n"
        | name, (FUInt64|FBytes) ->
            pr "    printf (\"%%c\", %s->%s[i]);\n" typ name;
            pr "  printf (\"\\n\");\n"
        | name, (FUInt64|FBytes) ->
@@ -6113,6 +6120,10 @@ Libguestfs provides ways to enumerate guest storage (eg. partitions,
 LVs, what filesystem is in each LV, etc.).  It can also run commands
 in the context of the guest.  Also you can access filesystems over FTP.
 
 LVs, what filesystem is in each LV, etc.).  It can also run commands
 in the context of the guest.  Also you can access filesystems over FTP.
 
+See also L<Sys::Guestfs::Lib(3)> for a set of useful library
+functions for using libguestfs from Perl, including integration
+with libvirt.
+
 =head1 ERRORS
 
 All errors turn into calls to C<croak> (see L<Carp(3)>).
 =head1 ERRORS
 
 All errors turn into calls to C<croak> (see L<Carp(3)>).
@@ -6184,7 +6195,10 @@ Please see the file COPYING.LIB for the full license.
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
-L<guestfs(3)>, L<guestfish(1)>.
+L<guestfs(3)>,
+L<guestfish(1)>,
+L<http://libguestfs.org>,
+L<Sys::Guestfs::Lib(3)>.
 
 =cut
 "
 
 =cut
 "
@@ -7297,7 +7311,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
         | RStringList _ | RStructList _ -> true
         | RErr | RBool _ | RInt _ | RInt64 _ | RConstString _
         | RString _ | RStruct _ | RHashtable _ -> false) ||
         | RStringList _ | RStructList _ -> true
         | RErr | RBool _ | RInt _ | RInt64 _ | RConstString _
         | RString _ | RStruct _ | RHashtable _ -> false) ||
-       List.exists (function StringList _ -> true | _ -> false) (snd style) in
+         List.exists (function StringList _ -> true | _ -> false) (snd style) in
       if needs_i then
        pr "  int i;\n";
 
       if needs_i then
        pr "  int i;\n";
 
@@ -8050,7 +8064,7 @@ and generate_lang_bindtests call =
                CallStringList ["1"]; CallBool false;
                CallInt 0; CallString ""; CallString ""]
 
                CallStringList ["1"]; CallBool false;
                CallInt 0; CallString ""; CallString ""]
 
-  (* XXX Add here tests of the return and error functions. *)
+(* XXX Add here tests of the return and error functions. *)
 
 (* This is used to generate the src/MAX_PROC_NR file which
  * contains the maximum procedure number, a surrogate for the
 
 (* This is used to generate the src/MAX_PROC_NR file which
  * contains the maximum procedure number, a surrogate for the
@@ -8089,7 +8103,7 @@ let output_to filename =
 let () =
   check_functions ();
 
 let () =
   check_functions ();
 
-  if not (Sys.file_exists "config.status") then (
+  if not (Sys.file_exists "HACKING") then (
     eprintf "\
 You are probably running this from the wrong directory.
 Run it from the top source directory using the command
     eprintf "\
 You are probably running this from the wrong directory.
 Run it from the top source directory using the command