X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator%2Fgenerator_fish.ml;h=4111be560dbde3adafeb921f4ed02714468fe091;hb=c4bd6bba8d88ecf1ebf4a9c2c80a407d9971aaf7;hp=516c5b197121efbee6f84a20c88124a0908a6d58;hpb=272b754093ef824486993540a893d39be8e7e9f0;p=libguestfs.git diff --git a/generator/generator_fish.ml b/generator/generator_fish.ml index 516c5b1..4111be5 100644 --- a/generator/generator_fish.ml +++ b/generator/generator_fish.ml @@ -30,6 +30,13 @@ open Generator_structs open Generator_prepopts open Generator_c +let doc_opttype_of = function + | Bool n -> "true|false" + | Int n + | Int64 n -> "N" + | String n -> ".." + | _ -> assert false + (* Generate a lot of different functions for guestfish. *) let generate_fish_cmds () = generate_header CStyle GPLv2plus; @@ -48,16 +55,21 @@ let generate_fish_cmds () = pr "#include \n"; pr "\n"; + pr "/* It is safe to call deprecated functions from this file. */\n"; + pr "#undef GUESTFS_WARN_DEPRECATED\n"; + pr "\n"; pr "#include \n"; pr "#include \n"; pr "#include \n"; pr "#include \n"; pr "\n"; - pr "#include \n"; pr "#include \"c-ctype.h\"\n"; pr "#include \"full-write.h\"\n"; pr "#include \"xstrtol.h\"\n"; + pr "\n"; + pr "#include \n"; pr "#include \"fish.h\"\n"; + pr "#include \"fish-cmds.h\"\n"; pr "#include \"options.h\"\n"; pr "#include \"cmds_gperf.h\"\n"; pr "\n"; @@ -117,7 +129,9 @@ let generate_fish_cmds () = (String.concat "" (List.map (fun arg -> " " ^ name_of_argt arg) args)) (String.concat "" - (List.map (fun arg -> sprintf " [%s:..]" (name_of_argt arg)) optargs)) in + (List.map (fun arg -> + sprintf " [%s:%s]" (name_of_argt arg) (doc_opttype_of arg) + ) optargs)) in let warnings = if List.exists (function Key _ -> true | _ -> false) args then @@ -131,16 +145,6 @@ Guestfish will prompt for these separately." ("\n\n" ^ protocol_limit_warning) else "" in - (* For DangerWillRobinson commands, we should probably have - * guestfish prompt before allowing you to use them (especially - * in interactive mode). XXX - *) - let warnings = - warnings ^ - if List.mem DangerWillRobinson flags then - ("\n\n" ^ danger_will_robinson) - else "" in - let warnings = warnings ^ match deprecation_notice flags with @@ -393,7 +397,7 @@ Guestfish will prompt for these separately." pr " %s = argv[i++];\n" name | Pathname name | Dev_or_Path name -> - pr " %s = resolve_win_path (argv[i++]);\n" name; + pr " %s = win_prefix (argv[i++]); /* process \"win:\" prefix */\n" name; pr " if (%s == NULL) return -1;\n" name | OptString name -> pr " %s = STRNEQ (argv[i], \"\") ? argv[i] : NULL;\n" name; @@ -413,6 +417,8 @@ Guestfish will prompt for these separately." pr " if (%s == NULL) return -1;\n" name | Key name -> pr " %s = read_key (\"%s\");\n" name name; + pr " if (keys_from_stdin)\n"; + pr " input_lineno++;\n"; pr " if (%s == NULL) return -1;\n" name | Bool name -> pr " %s = is_true (argv[i++]) ? 1 : 0;\n" name @@ -459,10 +465,12 @@ Guestfish will prompt for these separately." "The Int type in the generator is a signed 31 bit int." in Some (min, max, comment) in let expr = sprintf "&argv[i][%d]" (len+1) in - parse_integer expr "xstrtoll" "long long" "int" range name + parse_integer expr "xstrtoll" "long long" "int" range + (sprintf "optargs_s.%s" n) | Int64 n -> let expr = sprintf "&argv[i][%d]" (len+1) in - parse_integer expr "xstrtoll" "long long" "int64_t" None name + parse_integer expr "xstrtoll" "long long" "int64_t" None + (sprintf "optargs_s.%s" n) | String n -> pr " optargs_s.%s = &argv[i][%d];\n" n (len+1); | _ -> assert false @@ -614,6 +622,22 @@ Guestfish will prompt for these separately." pr " }\n"; pr "}\n" +and generate_fish_cmds_h () = + generate_header CStyle GPLv2plus; + + pr "#ifndef FISH_CMDS_H\n"; + pr "#define FISH_CMDS_H\n"; + pr "\n"; + + List.iter ( + fun (shortname, _, _, _, _, _, _) -> + pr "extern int run_%s (const char *cmd, size_t argc, char *argv[]);\n" + shortname + ) fish_commands; + + pr "\n"; + pr "#endif /* FISH_CMDS_H */\n" + (* gperf code to do fast lookups of commands. *) and generate_fish_cmds_gperf () = generate_header CStyle GPLv2plus; @@ -819,7 +843,8 @@ and generate_fish_actions_pod () = ) args; List.iter ( function - | Bool n | Int n | Int64 n | String n -> pr " [%s:..]" n + | (Bool n | Int n | Int64 n | String n) as arg -> + pr " [%s:%s]" n (doc_opttype_of arg) | _ -> assert false ) optargs; pr "\n"; @@ -840,9 +865,6 @@ Guestfish will prompt for these separately.\n\n"; if List.mem ProtocolLimitWarning flags then pr "%s\n\n" protocol_limit_warning; - if List.mem DangerWillRobinson flags then - pr "%s\n\n" danger_will_robinson; - match deprecation_notice flags with | None -> () | Some txt -> pr "%s\n\n" txt