Generated code for 'set_memsize'/'get_memsize' calls.
[libguestfs.git] / fish / completion.c
1 /* libguestfs generated file
2  * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3  * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
4  *
5  * Copyright (C) 2009 Red Hat Inc.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #include <config.h>
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27
28 #ifdef HAVE_LIBREADLINE
29 #include <readline/readline.h>
30 #endif
31
32 #include "fish.h"
33
34 #ifdef HAVE_LIBREADLINE
35
36 static const char *const commands[] = {
37   BUILTIN_COMMANDS_FOR_COMPLETION,
38   "launch",
39   "run",
40   "kill-subprocess",
41   "add-drive",
42   "add",
43   "add-cdrom",
44   "cdrom",
45   "add-drive-ro",
46   "add-ro",
47   "config",
48   "set-qemu",
49   "qemu",
50   "get-qemu",
51   "set-path",
52   "path",
53   "get-path",
54   "set-append",
55   "append",
56   "get-append",
57   "set-autosync",
58   "autosync",
59   "get-autosync",
60   "set-verbose",
61   "verbose",
62   "get-verbose",
63   "is-ready",
64   "is-config",
65   "is-launching",
66   "is-busy",
67   "get-state",
68   "set-memsize",
69   "memsize",
70   "get-memsize",
71   "mount",
72   "sync",
73   "touch",
74   "cat",
75   "ll",
76   "ls",
77   "list-devices",
78   "list-partitions",
79   "pvs",
80   "vgs",
81   "lvs",
82   "pvs-full",
83   "vgs-full",
84   "lvs-full",
85   "read-lines",
86   "aug-init",
87   "aug-close",
88   "aug-defvar",
89   "aug-defnode",
90   "aug-get",
91   "aug-set",
92   "aug-insert",
93   "aug-rm",
94   "aug-mv",
95   "aug-match",
96   "aug-save",
97   "aug-load",
98   "aug-ls",
99   "rm",
100   "rmdir",
101   "rm-rf",
102   "mkdir",
103   "mkdir-p",
104   "chmod",
105   "chown",
106   "exists",
107   "is-file",
108   "is-dir",
109   "pvcreate",
110   "vgcreate",
111   "lvcreate",
112   "mkfs",
113   "sfdisk",
114   "write-file",
115   "umount",
116   "unmount",
117   "mounts",
118   "umount-all",
119   "unmount-all",
120   "lvm-remove-all",
121   "file",
122   "command",
123   "command-lines",
124   "stat",
125   "lstat",
126   "statvfs",
127   "tune2fs-l",
128   "blockdev-setro",
129   "blockdev-setrw",
130   "blockdev-getro",
131   "blockdev-getss",
132   "blockdev-getbsz",
133   "blockdev-setbsz",
134   "blockdev-getsz",
135   "blockdev-getsize64",
136   "blockdev-flushbufs",
137   "blockdev-rereadpt",
138   "upload",
139   "download",
140   "checksum",
141   "tar-in",
142   "tar-out",
143   "tgz-in",
144   "tgz-out",
145   "mount-ro",
146   "mount-options",
147   "mount-vfs",
148   "debug",
149   "lvremove",
150   "vgremove",
151   "pvremove",
152   "set-e2label",
153   "get-e2label",
154   "set-e2uuid",
155   "get-e2uuid",
156   "fsck",
157   "zero",
158   "grub-install",
159   "cp",
160   "cp-a",
161   "mv",
162   "drop-caches",
163   "dmesg",
164   "ping-daemon",
165   "equal",
166   "strings",
167   "strings-e",
168   "hexdump",
169   "zerofree",
170   "pvresize",
171   "sfdisk-N",
172   "sfdisk-l",
173   "sfdisk-kernel-geometry",
174   "sfdisk-disk-geometry",
175   "vg-activate-all",
176   "vg-activate",
177   "lvresize",
178   "resize2fs",
179   "find",
180   "e2fsck-f",
181   "sleep",
182   "ntfs-3g-probe",
183   "sh",
184   "sh-lines",
185   "glob-expand",
186   "scrub-device",
187   "scrub-file",
188   "scrub-freespace",
189   "mkdtemp",
190   "wc-l",
191   "wc-w",
192   "wc-c",
193   "head",
194   "head-n",
195   "tail",
196   "tail-n",
197   "df",
198   "df-h",
199   "du",
200   "initrd-list",
201   "mount-loop",
202   "mkswap",
203   "mkswap-L",
204   "mkswap-U",
205   NULL
206 };
207
208 static char *
209 generator (const char *text, int state)
210 {
211   static int index, len;
212   const char *name;
213
214   if (!state) {
215     index = 0;
216     len = strlen (text);
217   }
218
219   rl_attempted_completion_over = 1;
220
221   while ((name = commands[index]) != NULL) {
222     index++;
223     if (strncasecmp (name, text, len) == 0)
224       return strdup (name);
225   }
226
227   return NULL;
228 }
229
230 #endif /* HAVE_LIBREADLINE */
231
232 char **do_completion (const char *text, int start, int end)
233 {
234   char **matches = NULL;
235
236 #ifdef HAVE_LIBREADLINE
237   rl_completion_append_character = ' ';
238
239   if (start == 0)
240     matches = rl_completion_matches (text, generator);
241   else if (complete_dest_paths)
242     matches = rl_completion_matches (text, complete_dest_paths_generator);
243 #endif
244
245   return matches;
246 }