[Libguestfs] [PATCH] Add command trace functionality

Jim Meyering jim at meyering.net
Fri Sep 11 09:53:24 UTC 2009


Richard W.M. Jones wrote:
> Here's an updated patch incorporating Jim's and Matt's changes.

Looks good.  Thanks.

...
> +    pr "    printf (\"%%s\", \"%s\");\n" shortname;
> +    List.iter (
> +      function
> +      | String n			(* strings *)
> +      | Device n
> +      | Pathname n
> +      | Dev_or_Path n
> +      | FileIn n
> +      | FileOut n ->
> +	  (* guestfish doesn't support string escaping, so neither do we *)
> +	  pr "    printf (\" \\\"%%s\\\"\", %s);\n" n
> +      | OptString n ->			(* string option *)
> +	  pr "    if (%s) printf (\" \\\"%%s\\\"\", %s);\n" n n;
> +	  pr "    else printf (\" null\");\n"
> +      | StringList n
> +      | DeviceList n ->			(* string list *)
> +	  pr "    putchar ('\"');\n";
> +	  pr "    for (i = 0; %s[i]; ++i) {\n" n;
> +	  pr "      if (i > 0) putchar (' ');\n";
> +	  pr "      fputs (%s[i], stdout);\n" n;
> +	  pr "    }\n";
> +	  pr "    putchar ('\"');\n";
> +      | Bool n ->			(* boolean *)
> +	  pr "    fputs (%s ? \" true\" : \" false\", stdout);\n" n
> +      | Int n ->			(* int *)
> +	  pr "    printf (\" %%d\", %s);\n" n
> +    ) (snd style);
> +    pr "    printf (\"\\n\");\n";

Doesn't really matter, but here's one more:

       pr "    putchar ('\\n');\n";

> +    pr "  }\n";
> +    pr "\n";
> +  in




More information about the Libguestfs mailing list