1*56bb7041Schristos /* tilde.h: Externally available variables and function in libtilde.a. */
2*56bb7041Schristos 
3*56bb7041Schristos /* Copyright (C) 1992-2009 Free Software Foundation, Inc.
4*56bb7041Schristos 
5*56bb7041Schristos    This file contains the Readline Library (Readline), a set of
6*56bb7041Schristos    routines for providing Emacs style line input to programs that ask
7*56bb7041Schristos    for it.
8*56bb7041Schristos 
9*56bb7041Schristos    Readline is free software: you can redistribute it and/or modify
10*56bb7041Schristos    it under the terms of the GNU General Public License as published by
11*56bb7041Schristos    the Free Software Foundation, either version 3 of the License, or
12*56bb7041Schristos    (at your option) any later version.
13*56bb7041Schristos 
14*56bb7041Schristos    Readline is distributed in the hope that it will be useful,
15*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
16*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*56bb7041Schristos    GNU General Public License for more details.
18*56bb7041Schristos 
19*56bb7041Schristos    You should have received a copy of the GNU General Public License
20*56bb7041Schristos    along with Readline.  If not, see <http://www.gnu.org/licenses/>.
21*56bb7041Schristos */
22*56bb7041Schristos 
23*56bb7041Schristos #if !defined (_TILDE_H_)
24*56bb7041Schristos #  define _TILDE_H_
25*56bb7041Schristos 
26*56bb7041Schristos #ifdef __cplusplus
27*56bb7041Schristos extern "C" {
28*56bb7041Schristos #endif
29*56bb7041Schristos 
30*56bb7041Schristos /* A function can be defined using prototypes and compile on both ANSI C
31*56bb7041Schristos    and traditional C compilers with something like this:
32*56bb7041Schristos 	extern char *func PARAMS((char *, char *, int)); */
33*56bb7041Schristos 
34*56bb7041Schristos #if !defined (PARAMS)
35*56bb7041Schristos #  if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
36*56bb7041Schristos #    define PARAMS(protos) protos
37*56bb7041Schristos #  else
38*56bb7041Schristos #    define PARAMS(protos) ()
39*56bb7041Schristos #  endif
40*56bb7041Schristos #endif
41*56bb7041Schristos 
42*56bb7041Schristos typedef char *tilde_hook_func_t PARAMS((char *));
43*56bb7041Schristos 
44*56bb7041Schristos /* If non-null, this contains the address of a function that the application
45*56bb7041Schristos    wants called before trying the standard tilde expansions.  The function
46*56bb7041Schristos    is called with the text sans tilde, and returns a malloc()'ed string
47*56bb7041Schristos    which is the expansion, or a NULL pointer if the expansion fails. */
48*56bb7041Schristos extern tilde_hook_func_t *tilde_expansion_preexpansion_hook;
49*56bb7041Schristos 
50*56bb7041Schristos /* If non-null, this contains the address of a function to call if the
51*56bb7041Schristos    standard meaning for expanding a tilde fails.  The function is called
52*56bb7041Schristos    with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
53*56bb7041Schristos    which is the expansion, or a NULL pointer if there is no expansion. */
54*56bb7041Schristos extern tilde_hook_func_t *tilde_expansion_failure_hook;
55*56bb7041Schristos 
56*56bb7041Schristos /* When non-null, this is a NULL terminated array of strings which
57*56bb7041Schristos    are duplicates for a tilde prefix.  Bash uses this to expand
58*56bb7041Schristos    `=~' and `:~'. */
59*56bb7041Schristos extern char **tilde_additional_prefixes;
60*56bb7041Schristos 
61*56bb7041Schristos /* When non-null, this is a NULL terminated array of strings which match
62*56bb7041Schristos    the end of a username, instead of just "/".  Bash sets this to
63*56bb7041Schristos    `:' and `=~'. */
64*56bb7041Schristos extern char **tilde_additional_suffixes;
65*56bb7041Schristos 
66*56bb7041Schristos /* Return a new string which is the result of tilde expanding STRING. */
67*56bb7041Schristos extern char *tilde_expand PARAMS((const char *));
68*56bb7041Schristos 
69*56bb7041Schristos /* Do the work of tilde expansion on FILENAME.  FILENAME starts with a
70*56bb7041Schristos    tilde.  If there is no expansion, call tilde_expansion_failure_hook. */
71*56bb7041Schristos extern char *tilde_expand_word PARAMS((const char *));
72*56bb7041Schristos 
73*56bb7041Schristos /* Find the portion of the string beginning with ~ that should be expanded. */
74*56bb7041Schristos extern char *tilde_find_word PARAMS((const char *, int, int *));
75*56bb7041Schristos 
76*56bb7041Schristos #ifdef __cplusplus
77*56bb7041Schristos }
78*56bb7041Schristos #endif
79*56bb7041Schristos 
80*56bb7041Schristos #endif /* _TILDE_H_ */
81