Generated code for blockdev_* calls, RInt64, enhanced tests.
[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 *commands[] = {
37   "add",
38   "add-cdrom",
39   "add-drive",
40   "aug-close",
41   "aug-defnode",
42   "aug-defvar",
43   "aug-get",
44   "aug-init",
45   "aug-insert",
46   "aug-load",
47   "aug-ls",
48   "aug-match",
49   "aug-mv",
50   "aug-rm",
51   "aug-save",
52   "aug-set",
53   "autosync",
54   "blockdev-flushbufs",
55   "blockdev-getbsz",
56   "blockdev-getro",
57   "blockdev-getsize64",
58   "blockdev-getss",
59   "blockdev-getsz",
60   "blockdev-rereadpt",
61   "blockdev-setbsz",
62   "blockdev-setro",
63   "blockdev-setrw",
64   "cat",
65   "cdrom",
66   "chmod",
67   "chown",
68   "command",
69   "command-lines",
70   "config",
71   "exists",
72   "file",
73   "get-autosync",
74   "get-path",
75   "get-verbose",
76   "is-dir",
77   "is-file",
78   "kill-subprocess",
79   "launch",
80   "list-devices",
81   "list-partitions",
82   "ll",
83   "ls",
84   "lstat",
85   "lvcreate",
86   "lvm-remove-all",
87   "lvs",
88   "lvs-full",
89   "mkdir",
90   "mkdir-p",
91   "mkfs",
92   "mount",
93   "mounts",
94   "path",
95   "pvcreate",
96   "pvs",
97   "pvs-full",
98   "read-lines",
99   "rm",
100   "rm-rf",
101   "rmdir",
102   "run",
103   "set-autosync",
104   "set-path",
105   "set-verbose",
106   "sfdisk",
107   "stat",
108   "statvfs",
109   "sync",
110   "touch",
111   "tune2fs-l",
112   "umount",
113   "umount-all",
114   "unmount",
115   "unmount-all",
116   "verbose",
117   "vgcreate",
118   "vgs",
119   "vgs-full",
120   "write-file",
121   NULL
122 };
123
124 static char *
125 generator (const char *text, int state)
126 {
127   static int index, len;
128   const char *name;
129
130   if (!state) {
131     index = 0;
132     len = strlen (text);
133   }
134
135   while ((name = commands[index]) != NULL) {
136     index++;
137     if (strncasecmp (name, text, len) == 0)
138       return strdup (name);
139   }
140
141   return NULL;
142 }
143
144 #endif /* HAVE_LIBREADLINE */
145
146 char **do_completion (const char *text, int start, int end)
147 {
148   char **matches = NULL;
149
150 #ifdef HAVE_LIBREADLINE
151   if (start == 0)
152     matches = rl_completion_matches (text, generator);
153 #endif
154
155   return matches;
156 }