1 /* libguestfs - guestfish shell
2 * Copyright (C) 2009 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #define _(str) dgettext(PACKAGE, (str))
27 #define N_(str) dgettext(PACKAGE, (str))
35 #define textdomain(Domainname) /* empty */
37 #define bindtextdomain(Domainname, Dirname) /* empty */
40 #define STREQ(a,b) (strcmp((a),(b)) == 0)
41 #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
42 #define STRNEQ(a,b) (strcmp((a),(b)) != 0)
43 #define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0)
44 #define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
45 #define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
46 #define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
47 #define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0)
48 #define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0)
50 #define TMP_TEMPLATE_ON_STACK(var) \
51 const char *ttos_tmpdir = guestfs_tmpdir (); \
52 char var[strlen (ttos_tmpdir) + 32]; \
53 sprintf (var, "%s/guestfishXXXXXX", ttos_tmpdir) \
60 extern int command_num;
62 extern int have_terminfo;
63 extern int progress_bars;
64 extern int remote_control_csh;
65 extern const char *libvirt_uri;
66 extern int issue_command (const char *cmd, char *argv[], const char *pipe, int rc_exit_on_error_flag);
67 extern void list_builtin_commands (void);
68 extern int display_builtin_command (const char *cmd);
69 extern void free_strings (char **argv);
70 extern int count_strings (char *const *argv);
71 extern void print_strings (char *const *argv);
72 extern void print_table (char *const *argv);
73 extern int is_true (const char *str);
74 extern char **parse_string_list (const char *str);
75 extern int xwrite (int fd, const void *buf, size_t len);
76 extern char *win_prefix (const char *path);
77 extern char *file_in (const char *arg);
78 extern void free_file_in (char *s);
79 extern char *file_out (const char *arg);
80 extern void extended_help_message (void);
82 /* in cmds.c (auto-generated) */
83 extern void list_commands (void);
84 extern int display_command (const char *cmd);
85 extern int run_action (const char *cmd, size_t argc, char *argv[]);
87 /* in completion.c (auto-generated) */
88 extern char **do_completion (const char *text, int start, int end);
91 extern int complete_dest_paths;
92 extern char *complete_dest_paths_generator (const char *text, int state);
95 extern int run_alloc (const char *cmd, size_t argc, char *argv[]);
96 extern int run_sparse (const char *cmd, size_t argc, char *argv[]);
97 extern int alloc_disk (const char *filename, const char *size,
99 extern int parse_size (const char *str, off_t *size_rtn);
102 extern int run_copy_in (const char *cmd, size_t argc, char *argv[]);
103 extern int run_copy_out (const char *cmd, size_t argc, char *argv[]);
106 extern int run_echo (const char *cmd, size_t argc, char *argv[]);
109 extern int run_edit (const char *cmd, size_t argc, char *argv[]);
112 extern void display_help (void);
115 extern int run_hexedit (const char *cmd, size_t argc, char *argv[]);
118 extern int run_lcd (const char *cmd, size_t argc, char *argv[]);
121 extern int run_glob (const char *cmd, size_t argc, char *argv[]);
124 extern int run_man (const char *cmd, size_t argc, char *argv[]);
127 extern int run_more (const char *cmd, size_t argc, char *argv[]);
131 const struct prep *prep;
132 const char *orig_type_string;
135 typedef struct prep_data prep_data;
136 extern void list_prepared_drives (void);
137 extern prep_data *create_prepared_file (const char *type_string,
138 const char *filename);
139 extern void prepare_drive (const char *filename, prep_data *data,
141 extern void prep_error (prep_data *data, const char *filename, const char *fs, ...) __attribute__((noreturn, format (printf,3,4)));
142 extern void free_prep_data (void *data);
145 extern int vg_lv_parse (const char *device, char **vg, char **lv);
148 extern void reset_progress_bar (void);
149 extern void progress_callback (guestfs_h *g, void *data, uint64_t event, int event_handle, int flags, const char *buf, size_t buf_len, const uint64_t *array, size_t array_len);
151 /* in rc.c (remote control) */
152 extern void rc_listen (void) __attribute__((noreturn));
153 extern int rc_remote (int pid, const char *cmd, size_t argc, char *argv[],
157 extern int run_reopen (const char *cmd, size_t argc, char *argv[]);
160 extern int run_supported (const char *cmd, size_t argc, char *argv[]);
163 extern int run_time (const char *cmd, size_t argc, char *argv[]);
166 extern char *try_tilde_expansion (char *path);
168 /* This should just list all the built-in commands so they can
169 * be added to the generated auto-completion code.
171 #define BUILTIN_COMMANDS_FOR_COMPLETION \
176 bad_cast (char const *s)