From 2fb83cc8ed4c5879d1b29a56e993e749df439a78 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 7 Aug 2011 21:04:00 +0100 Subject: [PATCH] fish: Declare run_* functions in a generated header file. Calls to these functions are generated, so there is no need to declare the functions by hand. Cherry picked from commit 3064277680ad11f887691646d0fa17bb35f38c19 and backported to stable-1.10 branch. --- .gitignore | 1 + fish/fish.h | 38 ++------------------------------------ generator/generator_fish.ml | 20 +++++++++++++++++++- generator/generator_main.ml | 3 ++- 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 95159ad..9cafbc7 100644 --- a/.gitignore +++ b/.gitignore @@ -78,6 +78,7 @@ fish/cmds.c fish/cmds_gperf.c fish/cmds_gperf.gperf fish/completion.c +fish/fish-cmds.h fish/guestfish fish/guestfish.1 fish/guestfish-actions.pod diff --git a/fish/fish.h b/fish/fish.h index a885b89..dec1c81 100644 --- a/fish/fish.h +++ b/fish/fish.h @@ -21,6 +21,8 @@ #include +#include "fish-cmds.h" + #ifdef HAVE_GETTEXT #include "gettext.h" #define _(str) dgettext(PACKAGE, (str)) @@ -92,40 +94,13 @@ extern int complete_dest_paths; extern char *complete_dest_paths_generator (const char *text, int state); /* in alloc.c */ -extern int run_alloc (const char *cmd, size_t argc, char *argv[]); -extern int run_sparse (const char *cmd, size_t argc, char *argv[]); extern int alloc_disk (const char *filename, const char *size, int add, int sparse); extern int parse_size (const char *str, off_t *size_rtn); -/* in copy.c */ -extern int run_copy_in (const char *cmd, size_t argc, char *argv[]); -extern int run_copy_out (const char *cmd, size_t argc, char *argv[]); - -/* in echo.c */ -extern int run_echo (const char *cmd, size_t argc, char *argv[]); - -/* in edit.c */ -extern int run_edit (const char *cmd, size_t argc, char *argv[]); - /* in help.c */ extern void display_help (void); -/* in hexedit.c */ -extern int run_hexedit (const char *cmd, size_t argc, char *argv[]); - -/* in lcd.c */ -extern int run_lcd (const char *cmd, size_t argc, char *argv[]); - -/* in glob.c */ -extern int run_glob (const char *cmd, size_t argc, char *argv[]); - -/* in man.c */ -extern int run_man (const char *cmd, size_t argc, char *argv[]); - -/* in more.c */ -extern int run_more (const char *cmd, size_t argc, char *argv[]); - /* in prep.c */ struct prep_data { const struct prep *prep; @@ -153,15 +128,6 @@ extern void rc_listen (void) __attribute__((noreturn)); extern int rc_remote (int pid, const char *cmd, size_t argc, char *argv[], int exit_on_error); -/* in reopen.c */ -extern int run_reopen (const char *cmd, size_t argc, char *argv[]); - -/* in supported.c */ -extern int run_supported (const char *cmd, size_t argc, char *argv[]); - -/* in time.c */ -extern int run_time (const char *cmd, size_t argc, char *argv[]); - /* in tilde.c */ extern char *try_tilde_expansion (char *path); diff --git a/generator/generator_fish.ml b/generator/generator_fish.ml index 532639d..ef5ea5f 100644 --- a/generator/generator_fish.ml +++ b/generator/generator_fish.ml @@ -53,11 +53,13 @@ let generate_fish_cmds () = 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"; @@ -616,6 +618,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; diff --git a/generator/generator_main.ml b/generator/generator_main.ml index f3d3340..f6e99a5 100644 --- a/generator/generator_main.ml +++ b/generator/generator_main.ml @@ -1,5 +1,5 @@ (* libguestfs - * Copyright (C) 2009-2010 Red Hat Inc. + * Copyright (C) 2009-2011 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -98,6 +98,7 @@ Run it from the top source directory using the command output_to "fish/cmds_gperf.gperf" generate_fish_cmds_gperf; output_to "fish/cmds.c" generate_fish_cmds; output_to "fish/completion.c" generate_fish_completion; + output_to "fish/fish-cmds.h" generate_fish_cmds_h; output_to "fish/guestfish-commands.pod" generate_fish_commands_pod; output_to "fish/guestfish-actions.pod" generate_fish_actions_pod; output_to "fish/prepopts.c" generate_fish_prep_options_c; -- 1.8.3.1