blob: 4d0075f85c97409271dd64074abdc5ee9fbeb235 [file] [log] [blame]
Jari Aalto726f6381996-08-26 18:22:31 +00001/* alias.h -- structure definitions. */
2
Jari Aalto31859422009-01-12 13:36:28 +00003/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
Jari Aalto726f6381996-08-26 18:22:31 +00004
5 This file is part of GNU Bash, the Bourne Again SHell.
6
Jari Aalto31859422009-01-12 13:36:28 +00007 Bash 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 3 of the License, or
10 (at your option) any later version.
Jari Aalto726f6381996-08-26 18:22:31 +000011
Jari Aalto31859422009-01-12 13:36:28 +000012 Bash 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.
Jari Aalto726f6381996-08-26 18:22:31 +000016
17 You should have received a copy of the GNU General Public License
Jari Aalto31859422009-01-12 13:36:28 +000018 along with Bash. If not, see <http://www.gnu.org/licenses/>.
19*/
Jari Aalto726f6381996-08-26 18:22:31 +000020
Jari Aaltoccc6cda1996-12-23 17:02:34 +000021#if !defined (_ALIAS_H_)
22#define _ALIAS_H_
Jari Aalto726f6381996-08-26 18:22:31 +000023
Jari Aaltof73dda02001-11-13 17:56:06 +000024#include "stdc.h"
Jari Aalto726f6381996-08-26 18:22:31 +000025
Jari Aaltof73dda02001-11-13 17:56:06 +000026#include "hashlib.h"
Jari Aalto726f6381996-08-26 18:22:31 +000027
Jari Aaltoccc6cda1996-12-23 17:02:34 +000028typedef struct alias {
Jari Aalto726f6381996-08-26 18:22:31 +000029 char *name;
30 char *value;
Jari Aaltoccc6cda1996-12-23 17:02:34 +000031 char flags;
32} alias_t;
33
34/* Values for `flags' member of struct alias. */
35#define AL_EXPANDNEXT 0x1
36#define AL_BEINGEXPANDED 0x2
Jari Aalto726f6381996-08-26 18:22:31 +000037
38/* The list of known aliases. */
39extern HASH_TABLE *aliases;
40
Jari Aaltof73dda02001-11-13 17:56:06 +000041extern void initialize_aliases __P((void));
Jari Aalto726f6381996-08-26 18:22:31 +000042
43/* Scan the list of aliases looking for one with NAME. Return NULL
Jari Aaltoccc6cda1996-12-23 17:02:34 +000044 if the alias doesn't exist, else a pointer to the alias. */
Jari Aaltof73dda02001-11-13 17:56:06 +000045extern alias_t *find_alias __P((char *));
Jari Aalto726f6381996-08-26 18:22:31 +000046
47/* Return the value of the alias for NAME, or NULL if there is none. */
Jari Aaltof73dda02001-11-13 17:56:06 +000048extern char *get_alias_value __P((char *));
Jari Aalto726f6381996-08-26 18:22:31 +000049
50/* Make a new alias from NAME and VALUE. If NAME can be found,
51 then replace its value. */
Jari Aaltof73dda02001-11-13 17:56:06 +000052extern void add_alias __P((char *, char *));
Jari Aalto726f6381996-08-26 18:22:31 +000053
54/* Remove the alias with name NAME from the alias list. Returns
55 the index of the removed alias, or -1 if the alias didn't exist. */
Jari Aaltof73dda02001-11-13 17:56:06 +000056extern int remove_alias __P((char *));
Jari Aalto726f6381996-08-26 18:22:31 +000057
Jari Aaltoccc6cda1996-12-23 17:02:34 +000058/* Remove all aliases. */
Jari Aaltof73dda02001-11-13 17:56:06 +000059extern void delete_all_aliases __P((void));
Jari Aalto726f6381996-08-26 18:22:31 +000060
61/* Return an array of all defined aliases. */
Jari Aaltof73dda02001-11-13 17:56:06 +000062extern alias_t **all_aliases __P((void));
Jari Aalto726f6381996-08-26 18:22:31 +000063
Jari Aaltoccc6cda1996-12-23 17:02:34 +000064/* Expand a single word for aliases. */
Jari Aaltof73dda02001-11-13 17:56:06 +000065extern char *alias_expand_word __P((char *));
66
67/* Return a new line, with any aliases expanded. */
68extern char *alias_expand __P((char *));
Jari Aaltoccc6cda1996-12-23 17:02:34 +000069
70#endif /* _ALIAS_H_ */