1 /*
2  * alias.h: header for alias.c
3  *
4  * Written by Jeremy Nelson
5  * Copyright 1997 EPIC Software Labs
6  * See the COPYRIGHT file, or do a HELP IRCII COPYRIGHT
7  */
8 
9 #ifndef __alias_h__
10 #define __alias_h__
11 
12 /*
13  * XXXX - These need to go away
14  */
15 #define COMMAND_ALIAS 		0
16 #define VAR_ALIAS 		1
17 #define VAR_ALIAS_LOCAL 	2
18 
19 /*
20  * These are the user commands.  Dont call these directly.
21  */
22 	BUILT_IN_COMMAND(aliascmd);
23 	BUILT_IN_COMMAND(assigncmd);
24 	BUILT_IN_COMMAND(localcmd);
25 	BUILT_IN_COMMAND(stubcmd);
26 	BUILT_IN_COMMAND(dumpcmd);
27 	BUILT_IN_COMMAND(unloadcmd);
28 
29 	void 	add_var_alias      	(const char *name, const char *stuff, int noisy);
30 	void 	add_local_alias    	(const char *name, const char *stuff, int noisy);
31 #if 0	/* Internal now */
32 	void 	add_cmd_alias 	   	(void);
33 #endif
34 	void 	add_var_stub_alias 	(const char *name, const char *stuff);
35 	void 	add_cmd_stub_alias 	(const char *name, const char *stuff);
36 
37 	char *	get_variable		(const char *name);
38 	char **	glob_cmd_alias		(const char *name, int *howmany, int maxret, int start, int rev);
39 	char *	get_cmd_alias   	(const char *name, int *howmany,
40 					 char **complete_name, void **args);
41 	char **	get_subarray_elements 	(const char *root, int *howmany, int type);
42 
43 
44 /* These are in expr.c */
45 /*
46  * This function is a general purpose interface to alias expansion.
47  * The second argument is the text to be expanded.
48  * The third argument are the command line expandoes $0, $1, etc.
49  * The fourth argument is a flag whether $0, $1, etc are used
50  * The fifth argument, if set, controls whether only the first "command"
51  *   will be expanded.  If set, this argument will be set to the "rest"
52  *   of the commands (after the first semicolon, or the null).  If NULL,
53  *   then the entire text will be expanded.
54  */
55 	char *	expand_alias 		(const char *, const char *, int *, ssize_t *);
56 
57 /*
58  * This is the interface to the "expression parser"
59  * The first argument is the expression to be parsed
60  * The second argument is the command line expandoes ($0, $1, etc)
61  * The third argument will be set if the command line expandoes are used.
62  */
63 	char *	parse_inline 		(char *, const char *, int *);
64 
65 /*
66  * This function is used to call a user-defined function.
67  * Noone should be calling this directly except for call_function.
68  */
69 	char *	call_user_function 	(const char *, char *);
70 	void	call_user_alias		(const char *, char *, char *, void *);
71 
72 /*
73  * This function is used to call a lambda (``anonymous'') function.
74  * You provide the lambda function name, its contents, and $*, and
75  * it returns you $FUNCTION_RETURN.
76  */
77 	char *  call_lambda_function    (const char *, const char *, const char *);
78 
79 
80 /*
81  * This function is used to save all the current aliases to a global
82  * file.  This is used by /SAVE and /ABORT.
83  */
84 	void	save_assigns		(FILE *, int);
85 	void	save_aliases 		(FILE *, int);
86 
87 /*
88  * This function is in functions.c
89  * This function allows you to execute a primitive "BUILT IN" expando.
90  * These are the $A, $B, $C, etc expandoes.
91  * The argument is the character of the expando (eg, 'A', 'B', etc)
92  *
93  * This is in functions.c
94  */
95 	char *	built_in_alias		(char, int *);
96 
97 
98 
99 /* BOGUS */
100 
101 /*
102  * This function is used to prepare the $* string before calling a user
103  * alias or function.  You should pass in the last argument from get_cmd_alias
104  * to this function, and also the $* value.  The second value may very well
105  * be modified.
106  */
107 	void	prepare_alias_call	(void *, char **);
108 	void	destroy_alias_call	(void *);
109 
110 /*
111  * This is in functions.c
112  * This is only used by next_unit and expand_alias to call built in functions.
113  * Noone should call this function directly.
114  */
115 	char *	call_function		(char *, const char *, int *);
116 
117 
118 
119 /*
120  * These are the two primitives for runtime stacks.
121  */
122 	int	make_local_stack 	(const char *);
123 	void	destroy_local_stack 	(void);
124 	void	set_current_command 	(char *);
125 	void	bless_local_stack 	(void);
126 	void	unset_current_command 	(void);
127 	void	lock_stack_frame	(void);
128 	void	unlock_stack_frame	(void);
129 	void	destroy_call_stack	(void);
130 	void	dump_call_stack		(void);
131 	void	panic_dump_call_stack 	(void);
132 
133 /*
134  * This is the alias interface to the /STACK command.
135  */
136 	void	do_stack_alias 		(int, char *, int);
137 
138 /*
139  * Truly bogus. =)
140  */
141 	char 	*canon_number (char *input);
142 
143 	char	*aliasctl (char *);
144 
145 	char *	after_expando (char *, int, int *);
146 #endif /* _ALIAS_H_ */
147