fish: Declare run_* functions in a generated header file.
[libguestfs.git] / fish / fish.h
1 /* libguestfs - guestfish shell
2  * Copyright (C) 2009 Red Hat Inc.
3  *
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.
8  *
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.
13  *
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.
17  */
18
19 #ifndef FISH_H
20 #define FISH_H
21
22 #include <guestfs.h>
23
24 #include "fish-cmds.h"
25
26 #ifdef HAVE_GETTEXT
27 #include "gettext.h"
28 #define _(str) dgettext(PACKAGE, (str))
29 #define N_(str) dgettext(PACKAGE, (str))
30 #else
31 #define _(str) str
32 #define N_(str) str
33 #endif
34
35 #if !ENABLE_NLS
36 #undef textdomain
37 #define textdomain(Domainname) /* empty */
38 #undef bindtextdomain
39 #define bindtextdomain(Domainname, Dirname) /* empty */
40 #endif
41
42 #define STREQ(a,b) (strcmp((a),(b)) == 0)
43 #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
44 #define STRNEQ(a,b) (strcmp((a),(b)) != 0)
45 #define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0)
46 #define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
47 #define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
48 #define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
49 #define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0)
50 #define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0)
51
52 #define TMP_TEMPLATE_ON_STACK(var)                        \
53   const char *ttos_tmpdir = guestfs_tmpdir ();            \
54   char var[strlen (ttos_tmpdir) + 32];                    \
55   sprintf (var, "%s/guestfishXXXXXX", ttos_tmpdir)        \
56
57 /* in fish.c */
58 extern guestfs_h *g;
59 extern int read_only;
60 extern int quit;
61 extern int verbose;
62 extern int command_num;
63 extern int utf8_mode;
64 extern int have_terminfo;
65 extern int progress_bars;
66 extern int remote_control_csh;
67 extern const char *libvirt_uri;
68 extern int input_lineno;
69
70 extern int issue_command (const char *cmd, char *argv[], const char *pipe, int rc_exit_on_error_flag);
71 extern void list_builtin_commands (void);
72 extern int display_builtin_command (const char *cmd);
73 extern void free_strings (char **argv);
74 extern int count_strings (char *const *argv);
75 extern void print_strings (char *const *argv);
76 extern void print_table (char *const *argv);
77 extern int is_true (const char *str);
78 extern char **parse_string_list (const char *str);
79 extern int xwrite (int fd, const void *buf, size_t len);
80 extern char *win_prefix (const char *path);
81 extern char *file_in (const char *arg);
82 extern void free_file_in (char *s);
83 extern char *file_out (const char *arg);
84 extern void extended_help_message (void);
85
86 /* in cmds.c (auto-generated) */
87 extern void list_commands (void);
88 extern int display_command (const char *cmd);
89 extern int run_action (const char *cmd, size_t argc, char *argv[]);
90
91 /* in completion.c (auto-generated) */
92 extern char **do_completion (const char *text, int start, int end);
93
94 /* in destpaths.c */
95 extern int complete_dest_paths;
96 extern char *complete_dest_paths_generator (const char *text, int state);
97
98 /* in alloc.c */
99 extern int alloc_disk (const char *filename, const char *size,
100                        int add, int sparse);
101 extern int parse_size (const char *str, off_t *size_rtn);
102
103 /* in help.c */
104 extern void display_help (void);
105
106 /* in prep.c */
107 struct prep_data {
108   const struct prep *prep;
109   const char *orig_type_string;
110   char **params;
111 };
112 typedef struct prep_data prep_data;
113 extern void list_prepared_drives (void);
114 extern prep_data *create_prepared_file (const char *type_string,
115                                         const char *filename);
116 extern void prepare_drive (const char *filename, prep_data *data,
117                            const char *device);
118 extern void prep_error (prep_data *data, const char *filename, const char *fs, ...) __attribute__((noreturn, format (printf,3,4)));
119 extern void free_prep_data (void *data);
120
121 /* in prep_lv.c */
122 extern int vg_lv_parse (const char *device, char **vg, char **lv);
123
124 /* in progress.c */
125 extern void reset_progress_bar (void);
126 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);
127
128 /* in rc.c (remote control) */
129 extern void rc_listen (void) __attribute__((noreturn));
130 extern int rc_remote (int pid, const char *cmd, size_t argc, char *argv[],
131                       int exit_on_error);
132
133 /* in tilde.c */
134 extern char *try_tilde_expansion (char *path);
135
136 /* This should just list all the built-in commands so they can
137  * be added to the generated auto-completion code.
138  */
139 #define BUILTIN_COMMANDS_FOR_COMPLETION \
140   "help",                               \
141   "quit", "exit", "q"
142
143 static inline char *
144 bad_cast (char const *s)
145 {
146   return (char *) s;
147 }
148
149 #endif /* FISH_H */