]> git.ipfire.org Git - thirdparty/bash.git/blame - pcomplete.h
Imported from ../bash-2.04.tar.gz.
[thirdparty/bash.git] / pcomplete.h
CommitLineData
bb70624e
JA
1/* pcomplete.h - structure definitions and other stuff for programmable
2 completion. */
3
4/* Copyright (C) 1999 Free Software Foundation, Inc.
5
6 This file is part of GNU Bash, the Bourne Again SHell.
7
8 Bash is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
11 version.
12
13 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with Bash; see the file COPYING. If not, write to the Free Software
20 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
21
22#if !defined (_PCOMPLETE_H_)
23# define _PCOMPLETE_H_
24
25#include "stdc.h"
26#include "hashlib.h"
27
28typedef struct compspec {
29 int refcount;
30 unsigned long actions;
31 char *globpat;
32 char *words;
33 char *prefix;
34 char *suffix;
35 char *funcname;
36 char *command;
37 char *filterpat;
38} COMPSPEC;
39
40/* Values for COMPSPEC actions. These are things the shell knows how to
41 build internally. */
42#define CA_ALIAS (1<<0)
43#define CA_ARRAYVAR (1<<1)
44#define CA_BINDING (1<<2)
45#define CA_BUILTIN (1<<3)
46#define CA_COMMAND (1<<4)
47#define CA_DIRECTORY (1<<5)
48#define CA_DISABLED (1<<6)
49#define CA_ENABLED (1<<7)
50#define CA_EXPORT (1<<8)
51#define CA_FILE (1<<9)
52#define CA_FUNCTION (1<<10)
53#define CA_HELPTOPIC (1<<11)
54#define CA_HOSTNAME (1<<12)
55#define CA_JOB (1<<13)
56#define CA_KEYWORD (1<<14)
57#define CA_RUNNING (1<<15)
58#define CA_SETOPT (1<<16)
59#define CA_SHOPT (1<<17)
60#define CA_SIGNAL (1<<18)
61#define CA_STOPPED (1<<19)
62#define CA_USER (1<<20)
63#define CA_VARIABLE (1<<21)
64
65/* This is a general-purpose argv-style array struct that should be used
66 elsewhere. */
67typedef struct _list_of_strings {
68 char **list;
69 int list_size;
70 int list_len;
71} STRINGLIST;
72
73/* List of items is used by the code that implements the programmable
74 completions. */
75typedef struct _list_of_items {
76 int flags;
77 Function *list_getter; /* function to call to get the list */
78
79 STRINGLIST *slist;
80
81 /* These may or may not be used. */
82 STRINGLIST *genlist; /* for handing to the completion code one item at a time */
83 int genindex; /* index of item last handed to completion code */
84
85} ITEMLIST;
86
87/* Values for ITEMLIST -> flags */
88#define LIST_DYNAMIC 0x001
89#define LIST_DIRTY 0x002
90#define LIST_INITIALIZED 0x004
91#define LIST_MUSTSORT 0x008
92#define LIST_DONTFREE 0x010
93#define LIST_DONTFREEMEMBERS 0x020
94
95extern HASH_TABLE *prog_completes;
96extern int prog_completion_enabled;
97
98/* Not all of these are used yet. */
99extern ITEMLIST it_aliases;
100extern ITEMLIST it_arrayvars;
101extern ITEMLIST it_bindings;
102extern ITEMLIST it_builtins;
103extern ITEMLIST it_commands;
104extern ITEMLIST it_directories;
105extern ITEMLIST it_disabled;
106extern ITEMLIST it_enabled;
107extern ITEMLIST it_exports;
108extern ITEMLIST it_files;
109extern ITEMLIST it_functions;
110extern ITEMLIST it_hostnames;
111extern ITEMLIST it_jobs;
112extern ITEMLIST it_keywords;
113extern ITEMLIST it_running;
114extern ITEMLIST it_setopts;
115extern ITEMLIST it_shopts;
116extern ITEMLIST it_signals;
117extern ITEMLIST it_stopped;
118extern ITEMLIST it_users;
119extern ITEMLIST it_variables;
120
121/* Functions from pcomplib.c */
122
123extern COMPSPEC *alloc_compspec __P((void));
124extern void free_compspec __P((COMPSPEC *));
125
126extern COMPSPEC *copy_compspec __P((COMPSPEC *));
127
128extern void initialize_progcomp __P((void));
129extern void clear_progcomps __P((void));
130
131extern int remove_progcomp __P((char *));
132extern int add_progcomp __P((char *, COMPSPEC *));
133
134extern int num_progcomps __P((void));
135
136extern COMPSPEC *find_compspec __P((char *));
137
138extern void print_all_compspecs __P((VFunction *));
139
140/* Functions from pcomplete.c */
141extern void set_itemlist_dirty __P((ITEMLIST *));
142
143extern STRINGLIST *gen_compspec_completions __P((COMPSPEC *, char *, char *, int, int));
144extern char **programmable_completions __P((char *, char *, int, int, int *));
145
146#endif /* _PCOMPLETE_H_ */