]>
Commit | Line | Data |
---|---|---|
bb70624e | 1 | /* pcomplete.h - structure definitions and other stuff for programmable |
0001803f | 2 | completion. */ |
bb70624e | 3 | |
3185942a | 4 | /* Copyright (C) 1999-2009 Free Software Foundation, Inc. |
bb70624e JA |
5 | |
6 | This file is part of GNU Bash, the Bourne Again SHell. | |
7 | ||
3185942a JA |
8 | Bash is free software: you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation, either version 3 of the License, or | |
11 | (at your option) any later version. | |
bb70624e | 12 | |
3185942a JA |
13 | Bash is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
bb70624e | 17 | |
3185942a JA |
18 | You should have received a copy of the GNU General Public License |
19 | along with Bash. If not, see <http://www.gnu.org/licenses/>. | |
20 | */ | |
bb70624e JA |
21 | |
22 | #if !defined (_PCOMPLETE_H_) | |
23 | # define _PCOMPLETE_H_ | |
24 | ||
25 | #include "stdc.h" | |
26 | #include "hashlib.h" | |
27 | ||
28 | typedef struct compspec { | |
29 | int refcount; | |
30 | unsigned long actions; | |
28ef6c31 | 31 | unsigned long options; |
bb70624e JA |
32 | char *globpat; |
33 | char *words; | |
34 | char *prefix; | |
35 | char *suffix; | |
36 | char *funcname; | |
37 | char *command; | |
495aee44 | 38 | char *lcommand; |
bb70624e JA |
39 | char *filterpat; |
40 | } COMPSPEC; | |
41 | ||
42 | /* Values for COMPSPEC actions. These are things the shell knows how to | |
43 | build internally. */ | |
44 | #define CA_ALIAS (1<<0) | |
45 | #define CA_ARRAYVAR (1<<1) | |
46 | #define CA_BINDING (1<<2) | |
47 | #define CA_BUILTIN (1<<3) | |
48 | #define CA_COMMAND (1<<4) | |
49 | #define CA_DIRECTORY (1<<5) | |
50 | #define CA_DISABLED (1<<6) | |
51 | #define CA_ENABLED (1<<7) | |
52 | #define CA_EXPORT (1<<8) | |
53 | #define CA_FILE (1<<9) | |
54 | #define CA_FUNCTION (1<<10) | |
f73dda09 JA |
55 | #define CA_GROUP (1<<11) |
56 | #define CA_HELPTOPIC (1<<12) | |
57 | #define CA_HOSTNAME (1<<13) | |
58 | #define CA_JOB (1<<14) | |
59 | #define CA_KEYWORD (1<<15) | |
60 | #define CA_RUNNING (1<<16) | |
7117c2d2 JA |
61 | #define CA_SERVICE (1<<17) |
62 | #define CA_SETOPT (1<<18) | |
63 | #define CA_SHOPT (1<<19) | |
64 | #define CA_SIGNAL (1<<20) | |
65 | #define CA_STOPPED (1<<21) | |
66 | #define CA_USER (1<<22) | |
67 | #define CA_VARIABLE (1<<23) | |
bb70624e | 68 | |
28ef6c31 JA |
69 | /* Values for COMPSPEC options field. */ |
70 | #define COPT_RESERVED (1<<0) /* reserved for other use */ | |
71 | #define COPT_DEFAULT (1<<1) | |
72 | #define COPT_FILENAMES (1<<2) | |
73 | #define COPT_DIRNAMES (1<<3) | |
ac50fbac CR |
74 | #define COPT_NOQUOTE (1<<4) |
75 | #define COPT_NOSPACE (1<<5) | |
76 | #define COPT_BASHDEFAULT (1<<6) | |
77 | #define COPT_PLUSDIRS (1<<7) | |
a0c0a00f | 78 | #define COPT_NOSORT (1<<8) |
bb70624e | 79 | |
d233b485 CR |
80 | #define COPT_LASTUSER COPT_NOSORT |
81 | ||
82 | #define PCOMP_RETRYFAIL (COPT_LASTUSER << 1) | |
83 | #define PCOMP_NOTFOUND (COPT_LASTUSER << 2) | |
84 | ||
85 | ||
bb70624e JA |
86 | /* List of items is used by the code that implements the programmable |
87 | completions. */ | |
88 | typedef struct _list_of_items { | |
89 | int flags; | |
f73dda09 | 90 | int (*list_getter) __P((struct _list_of_items *)); /* function to call to get the list */ |
bb70624e JA |
91 | |
92 | STRINGLIST *slist; | |
93 | ||
94 | /* These may or may not be used. */ | |
95 | STRINGLIST *genlist; /* for handing to the completion code one item at a time */ | |
96 | int genindex; /* index of item last handed to completion code */ | |
97 | ||
98 | } ITEMLIST; | |
99 | ||
100 | /* Values for ITEMLIST -> flags */ | |
101 | #define LIST_DYNAMIC 0x001 | |
102 | #define LIST_DIRTY 0x002 | |
103 | #define LIST_INITIALIZED 0x004 | |
104 | #define LIST_MUSTSORT 0x008 | |
105 | #define LIST_DONTFREE 0x010 | |
106 | #define LIST_DONTFREEMEMBERS 0x020 | |
107 | ||
0001803f CR |
108 | #define EMPTYCMD "_EmptycmD_" |
109 | #define DEFAULTCMD "_DefaultCmD_" | |
d233b485 | 110 | #define INITIALWORD "_InitialWorD_" |
0001803f | 111 | |
bb70624e | 112 | extern HASH_TABLE *prog_completes; |
d233b485 CR |
113 | |
114 | extern char *pcomp_line; | |
115 | extern int pcomp_ind; | |
116 | ||
bb70624e | 117 | extern int prog_completion_enabled; |
d233b485 | 118 | extern int progcomp_alias; |
bb70624e JA |
119 | |
120 | /* Not all of these are used yet. */ | |
121 | extern ITEMLIST it_aliases; | |
122 | extern ITEMLIST it_arrayvars; | |
123 | extern ITEMLIST it_bindings; | |
124 | extern ITEMLIST it_builtins; | |
125 | extern ITEMLIST it_commands; | |
126 | extern ITEMLIST it_directories; | |
127 | extern ITEMLIST it_disabled; | |
128 | extern ITEMLIST it_enabled; | |
129 | extern ITEMLIST it_exports; | |
130 | extern ITEMLIST it_files; | |
131 | extern ITEMLIST it_functions; | |
f73dda09 | 132 | extern ITEMLIST it_groups; |
ac50fbac | 133 | extern ITEMLIST it_helptopics; |
bb70624e JA |
134 | extern ITEMLIST it_hostnames; |
135 | extern ITEMLIST it_jobs; | |
136 | extern ITEMLIST it_keywords; | |
137 | extern ITEMLIST it_running; | |
7117c2d2 | 138 | extern ITEMLIST it_services; |
bb70624e JA |
139 | extern ITEMLIST it_setopts; |
140 | extern ITEMLIST it_shopts; | |
141 | extern ITEMLIST it_signals; | |
142 | extern ITEMLIST it_stopped; | |
143 | extern ITEMLIST it_users; | |
144 | extern ITEMLIST it_variables; | |
145 | ||
3185942a JA |
146 | extern COMPSPEC *pcomp_curcs; |
147 | extern const char *pcomp_curcmd; | |
148 | ||
bb70624e | 149 | /* Functions from pcomplib.c */ |
7117c2d2 JA |
150 | extern COMPSPEC *compspec_create __P((void)); |
151 | extern void compspec_dispose __P((COMPSPEC *)); | |
152 | extern COMPSPEC *compspec_copy __P((COMPSPEC *)); | |
bb70624e | 153 | |
7117c2d2 JA |
154 | extern void progcomp_create __P((void)); |
155 | extern void progcomp_flush __P((void)); | |
156 | extern void progcomp_dispose __P((void)); | |
bb70624e | 157 | |
7117c2d2 | 158 | extern int progcomp_size __P((void)); |
bb70624e | 159 | |
7117c2d2 JA |
160 | extern int progcomp_insert __P((char *, COMPSPEC *)); |
161 | extern int progcomp_remove __P((char *)); | |
bb70624e | 162 | |
7117c2d2 | 163 | extern COMPSPEC *progcomp_search __P((const char *)); |
bb70624e | 164 | |
7117c2d2 | 165 | extern void progcomp_walk __P((hash_wfunc *)); |
bb70624e JA |
166 | |
167 | /* Functions from pcomplete.c */ | |
168 | extern void set_itemlist_dirty __P((ITEMLIST *)); | |
169 | ||
f73dda09 JA |
170 | extern STRINGLIST *completions_to_stringlist __P((char **)); |
171 | ||
0001803f | 172 | extern STRINGLIST *gen_compspec_completions __P((COMPSPEC *, const char *, const char *, int, int, int *)); |
28ef6c31 | 173 | extern char **programmable_completions __P((const char *, const char *, int, int, int *)); |
bb70624e | 174 | |
3185942a JA |
175 | extern void pcomp_set_readline_variables __P((int, int)); |
176 | extern void pcomp_set_compspec_options __P((COMPSPEC *, int, int)); | |
bb70624e | 177 | #endif /* _PCOMPLETE_H_ */ |