| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 1 | /* pcomplete.h - structure definitions and other stuff for programmable |
| Chet Ramey | 0001803 | 2011-11-21 20:51:19 -0500 | [diff] [blame] | 2 | completion. */ |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 3 | |
| Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 4 | /* Copyright (C) 1999-2009 Free Software Foundation, Inc. |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 5 | |
| 6 | This file is part of GNU Bash, the Bourne Again SHell. |
| 7 | |
| Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 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. |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 12 | |
| Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 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. |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 17 | |
| Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 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 | */ |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 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; |
| Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 31 | unsigned long options; |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 32 | char *globpat; |
| 33 | char *words; |
| 34 | char *prefix; |
| 35 | char *suffix; |
| 36 | char *funcname; |
| 37 | char *command; |
| Chet Ramey | 495aee4 | 2011-11-22 19:11:26 -0500 | [diff] [blame] | 38 | char *lcommand; |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 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) |
| Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 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) |
| Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 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) |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 68 | |
| Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 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) |
| Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame] | 74 | #define COPT_NOQUOTE (1<<4) |
| 75 | #define COPT_NOSPACE (1<<5) |
| 76 | #define COPT_BASHDEFAULT (1<<6) |
| 77 | #define COPT_PLUSDIRS (1<<7) |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 78 | |
| 79 | /* List of items is used by the code that implements the programmable |
| 80 | completions. */ |
| 81 | typedef struct _list_of_items { |
| 82 | int flags; |
| Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 83 | int (*list_getter) __P((struct _list_of_items *)); /* function to call to get the list */ |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 84 | |
| 85 | STRINGLIST *slist; |
| 86 | |
| 87 | /* These may or may not be used. */ |
| 88 | STRINGLIST *genlist; /* for handing to the completion code one item at a time */ |
| 89 | int genindex; /* index of item last handed to completion code */ |
| 90 | |
| 91 | } ITEMLIST; |
| 92 | |
| 93 | /* Values for ITEMLIST -> flags */ |
| 94 | #define LIST_DYNAMIC 0x001 |
| 95 | #define LIST_DIRTY 0x002 |
| 96 | #define LIST_INITIALIZED 0x004 |
| 97 | #define LIST_MUSTSORT 0x008 |
| 98 | #define LIST_DONTFREE 0x010 |
| 99 | #define LIST_DONTFREEMEMBERS 0x020 |
| 100 | |
| Chet Ramey | 0001803 | 2011-11-21 20:51:19 -0500 | [diff] [blame] | 101 | #define EMPTYCMD "_EmptycmD_" |
| 102 | #define DEFAULTCMD "_DefaultCmD_" |
| 103 | |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 104 | extern HASH_TABLE *prog_completes; |
| 105 | extern int prog_completion_enabled; |
| 106 | |
| 107 | /* Not all of these are used yet. */ |
| 108 | extern ITEMLIST it_aliases; |
| 109 | extern ITEMLIST it_arrayvars; |
| 110 | extern ITEMLIST it_bindings; |
| 111 | extern ITEMLIST it_builtins; |
| 112 | extern ITEMLIST it_commands; |
| 113 | extern ITEMLIST it_directories; |
| 114 | extern ITEMLIST it_disabled; |
| 115 | extern ITEMLIST it_enabled; |
| 116 | extern ITEMLIST it_exports; |
| 117 | extern ITEMLIST it_files; |
| 118 | extern ITEMLIST it_functions; |
| Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 119 | extern ITEMLIST it_groups; |
| Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame] | 120 | extern ITEMLIST it_helptopics; |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 121 | extern ITEMLIST it_hostnames; |
| 122 | extern ITEMLIST it_jobs; |
| 123 | extern ITEMLIST it_keywords; |
| 124 | extern ITEMLIST it_running; |
| Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 125 | extern ITEMLIST it_services; |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 126 | extern ITEMLIST it_setopts; |
| 127 | extern ITEMLIST it_shopts; |
| 128 | extern ITEMLIST it_signals; |
| 129 | extern ITEMLIST it_stopped; |
| 130 | extern ITEMLIST it_users; |
| 131 | extern ITEMLIST it_variables; |
| 132 | |
| Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 133 | extern COMPSPEC *pcomp_curcs; |
| 134 | extern const char *pcomp_curcmd; |
| 135 | |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 136 | /* Functions from pcomplib.c */ |
| Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 137 | extern COMPSPEC *compspec_create __P((void)); |
| 138 | extern void compspec_dispose __P((COMPSPEC *)); |
| 139 | extern COMPSPEC *compspec_copy __P((COMPSPEC *)); |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 140 | |
| Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 141 | extern void progcomp_create __P((void)); |
| 142 | extern void progcomp_flush __P((void)); |
| 143 | extern void progcomp_dispose __P((void)); |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 144 | |
| Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 145 | extern int progcomp_size __P((void)); |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 146 | |
| Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 147 | extern int progcomp_insert __P((char *, COMPSPEC *)); |
| 148 | extern int progcomp_remove __P((char *)); |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 149 | |
| Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 150 | extern COMPSPEC *progcomp_search __P((const char *)); |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 151 | |
| Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 152 | extern void progcomp_walk __P((hash_wfunc *)); |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 153 | |
| 154 | /* Functions from pcomplete.c */ |
| 155 | extern void set_itemlist_dirty __P((ITEMLIST *)); |
| 156 | |
| Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 157 | extern STRINGLIST *completions_to_stringlist __P((char **)); |
| 158 | |
| Chet Ramey | 0001803 | 2011-11-21 20:51:19 -0500 | [diff] [blame] | 159 | extern STRINGLIST *gen_compspec_completions __P((COMPSPEC *, const char *, const char *, int, int, int *)); |
| Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 160 | extern char **programmable_completions __P((const char *, const char *, int, int, int *)); |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 161 | |
| Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 162 | extern void pcomp_set_readline_variables __P((int, int)); |
| 163 | extern void pcomp_set_compspec_options __P((COMPSPEC *, int, int)); |
| Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 164 | #endif /* _PCOMPLETE_H_ */ |