Generated code for tune2fs-l command and RHashtable return type.
[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   "cat",
55   "cdrom",
56   "chmod",
57   "chown",
58   "command",
59   "command-lines",
60   "config",
61   "exists",
62   "file",
63   "get-autosync",
64   "get-path",
65   "get-verbose",
66   "is-dir",
67   "is-file",
68   "kill-subprocess",
69   "launch",
70   "list-devices",
71   "list-partitions",
72   "ll",
73   "ls",
74   "lstat",
75   "lvcreate",
76   "lvm-remove-all",
77   "lvs",
78   "lvs-full",
79   "mkdir",
80   "mkdir-p",
81   "mkfs",
82   "mount",
83   "mounts",
84   "path",
85   "pvcreate",
86   "pvs",
87   "pvs-full",
88   "read-lines",
89   "rm",
90   "rm-rf",
91   "rmdir",
92   "run",
93   "set-autosync",
94   "set-path",
95   "set-verbose",
96   "sfdisk",
97   "stat",
98   "statvfs",
99   "sync",
100   "touch",
101   "tune2fs-l",
102   "umount",
103   "umount-all",
104   "unmount",
105   "unmount-all",
106   "verbose",
107   "vgcreate",
108   "vgs",
109   "vgs-full",
110   "write-file",
111   NULL
112 };
113
114 static char *
115 generator (const char *text, int state)
116 {
117   static int index, len;
118   const char *name;
119
120   if (!state) {
121     index = 0;
122     len = strlen (text);
123   }
124
125   while ((name = commands[index]) != NULL) {
126     index++;
127     if (strncasecmp (name, text, len) == 0)
128       return strdup (name);
129   }
130
131   return NULL;
132 }
133
134 #endif /* HAVE_LIBREADLINE */
135
136 char **do_completion (const char *text, int start, int end)
137 {
138   char **matches = NULL;
139
140 #ifdef HAVE_LIBREADLINE
141   if (start == 0)
142     matches = rl_completion_matches (text, generator);
143 #endif
144
145   return matches;
146 }