blob: df303252941d96cd9474ebb6293f8e5af1a7f64f [file] [log] [blame]
Jari Aalto726f6381996-08-26 18:22:31 +00001/* common.h -- extern declarations for functions defined in common.c. */
2
Jari Aaltob80f6442004-07-27 13:29:18 +00003/* Copyright (C) 1993-2004 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
7 Bash is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with Bash; see the file COPYING. If not, write to the Free Software
Jari Aaltobb706242000-03-17 21:46:59 +000019 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
Jari Aalto726f6381996-08-26 18:22:31 +000020
21#if !defined (__COMMON_H)
22# define __COMMON_H
23
Jari Aaltobb706242000-03-17 21:46:59 +000024#include "stdc.h"
Jari Aaltoccc6cda1996-12-23 17:02:34 +000025
Jari Aalto726f6381996-08-26 18:22:31 +000026#define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c)
27
Jari Aaltod166f041997-06-05 14:59:13 +000028/* Flag values for parse_and_execute () */
Jari Aalto7117c2d2002-07-17 14:10:11 +000029#define SEVAL_NONINT 0x001
30#define SEVAL_INTERACT 0x002
31#define SEVAL_NOHIST 0x004
32#define SEVAL_NOFREE 0x008
Jari Aaltob80f6442004-07-27 13:29:18 +000033#define SEVAL_RESETLINE 0x010
Jari Aalto7117c2d2002-07-17 14:10:11 +000034
35/* Flags for describe_command, shared between type.def and command.def */
36#define CDESC_ALL 0x001 /* type -a */
37#define CDESC_SHORTDESC 0x002 /* command -V */
38#define CDESC_REUSABLE 0x004 /* command -v */
39#define CDESC_TYPE 0x008 /* type -t */
40#define CDESC_PATH_ONLY 0x010 /* type -p */
41#define CDESC_FORCE_PATH 0x020 /* type -ap or type -P */
42#define CDESC_NOFUNCS 0x040 /* type -f */
Jari Aalto95732b42005-12-07 14:08:12 +000043#define CDESC_ABSPATH 0x080 /* convert to absolute path, no ./ */
Jari Aalto7117c2d2002-07-17 14:10:11 +000044
45/* Flags for get_job_by_name */
46#define JM_PREFIX 0x01 /* prefix of job name */
47#define JM_SUBSTRING 0x02 /* substring of job name */
48#define JM_EXACT 0x04 /* match job name exactly */
49#define JM_STOPPED 0x08 /* match stopped jobs only */
50#define JM_FIRSTMATCH 0x10 /* return first matching job */
51
52/* Flags for remember_args and value of changed_dollar_vars */
53#define ARGS_NONE 0x0
54#define ARGS_INVOC 0x01
55#define ARGS_FUNC 0x02
56#define ARGS_SETBLTIN 0x04
Jari Aaltod166f041997-06-05 14:59:13 +000057
Jari Aaltocce855b1998-04-17 19:52:44 +000058/* Functions from common.c */
Jari Aaltof73dda02001-11-13 17:56:06 +000059extern void builtin_error __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
Jari Aaltocce855b1998-04-17 19:52:44 +000060extern void builtin_usage __P((void));
61extern void no_args __P((WORD_LIST *));
Jari Aaltocce855b1998-04-17 19:52:44 +000062extern int no_options __P((WORD_LIST *));
Jari Aalto726f6381996-08-26 18:22:31 +000063
Jari Aalto7117c2d2002-07-17 14:10:11 +000064/* common error message functions */
65extern void sh_needarg __P((char *));
66extern void sh_neednumarg __P((char *));
67extern void sh_notfound __P((char *));
68extern void sh_invalidopt __P((char *));
69extern void sh_invalidoptname __P((char *));
70extern void sh_invalidid __P((char *));
71extern void sh_invalidnum __P((char *));
72extern void sh_invalidsig __P((char *));
73extern void sh_erange __P((char *, char *));
74extern void sh_badpid __P((char *));
75extern void sh_badjob __P((char *));
76extern void sh_readonly __P((const char *));
77extern void sh_nojobs __P((char *));
78extern void sh_restricted __P((char *));
Jari Aaltob80f6442004-07-27 13:29:18 +000079extern void sh_notbuiltin __P((char *));
Jari Aalto95732b42005-12-07 14:08:12 +000080extern void sh_wrerror __P((void));
Jari Aalto7117c2d2002-07-17 14:10:11 +000081
Jari Aaltocce855b1998-04-17 19:52:44 +000082extern char **make_builtin_argv __P((WORD_LIST *, int *));
83extern void remember_args __P((WORD_LIST *, int));
Jari Aaltoccc6cda1996-12-23 17:02:34 +000084
Jari Aaltocce855b1998-04-17 19:52:44 +000085extern int dollar_vars_changed __P((void));
86extern void set_dollar_vars_unchanged __P((void));
87extern void set_dollar_vars_changed __P((void));
Jari Aalto726f6381996-08-26 18:22:31 +000088
Jari Aalto7117c2d2002-07-17 14:10:11 +000089extern intmax_t get_numeric_arg __P((WORD_LIST *, int));
Jari Aaltof73dda02001-11-13 17:56:06 +000090extern int get_exitstat __P((WORD_LIST *));
Jari Aaltocce855b1998-04-17 19:52:44 +000091extern int read_octal __P((char *));
Jari Aalto726f6381996-08-26 18:22:31 +000092
93/* Keeps track of the current working directory. */
94extern char *the_current_working_directory;
Jari Aaltocce855b1998-04-17 19:52:44 +000095extern char *get_working_directory __P((char *));
96extern void set_working_directory __P((char *));
Jari Aalto726f6381996-08-26 18:22:31 +000097
98#if defined (JOB_CONTROL)
Jari Aalto7117c2d2002-07-17 14:10:11 +000099extern int get_job_by_name __P((const char *, int));
Jari Aaltocce855b1998-04-17 19:52:44 +0000100extern int get_job_spec __P((WORD_LIST *));
Jari Aalto726f6381996-08-26 18:22:31 +0000101#endif
Jari Aaltocce855b1998-04-17 19:52:44 +0000102extern int display_signal_list __P((WORD_LIST *, int));
Jari Aalto726f6381996-08-26 18:22:31 +0000103
104/* It's OK to declare a function as returning a Function * without
105 providing a definition of what a `Function' is. */
Jari Aaltocce855b1998-04-17 19:52:44 +0000106extern struct builtin *builtin_address_internal __P((char *, int));
Jari Aaltof73dda02001-11-13 17:56:06 +0000107extern sh_builtin_func_t *find_shell_builtin __P((char *));
108extern sh_builtin_func_t *builtin_address __P((char *));
109extern sh_builtin_func_t *find_special_builtin __P((char *));
Jari Aaltocce855b1998-04-17 19:52:44 +0000110extern void initialize_shell_builtins __P((void));
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000111
Jari Aaltob80f6442004-07-27 13:29:18 +0000112/* Functions from exit.def */
113extern void bash_logout __P((void));
114
Jari Aaltof73dda02001-11-13 17:56:06 +0000115/* Functions from getopts.def */
116extern void getopts_reset __P((int));
117
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000118/* Functions from set.def */
Jari Aaltocce855b1998-04-17 19:52:44 +0000119extern int minus_o_option_value __P((char *));
Jari Aaltof73dda02001-11-13 17:56:06 +0000120extern void list_minus_o_opts __P((int, int));
Jari Aaltobb706242000-03-17 21:46:59 +0000121extern char **get_minus_o_opts __P((void));
Jari Aaltof73dda02001-11-13 17:56:06 +0000122extern int set_minus_o_option __P((int, char *));
123
124extern void set_shellopts __P((void));
125extern void parse_shellopts __P((char *));
126extern void initialize_shell_options __P((int));
127
128extern void reset_shell_options __P((void));
Jari Aaltod166f041997-06-05 14:59:13 +0000129
130/* Functions from shopt.def */
Jari Aaltocce855b1998-04-17 19:52:44 +0000131extern void reset_shopt_options __P((void));
Jari Aaltobb706242000-03-17 21:46:59 +0000132extern char **get_shopt_options __P((void));
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000133
Jari Aaltof73dda02001-11-13 17:56:06 +0000134extern int shopt_setopt __P((char *, int));
135extern int shopt_listopt __P((char *, int));
136
137extern int set_login_shell __P((int));
138
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000139/* Functions from type.def */
Jari Aalto7117c2d2002-07-17 14:10:11 +0000140extern int describe_command __P((char *, int));
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000141
142/* Functions from setattr.def */
Jari Aaltocce855b1998-04-17 19:52:44 +0000143extern int set_or_show_attributes __P((WORD_LIST *, int, int));
144extern int show_var_attributes __P((SHELL_VAR *, int, int));
145extern int show_name_attributes __P((char *, int));
146extern void set_var_attribute __P((char *, int, int));
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000147
148/* Functions from pushd.def */
Jari Aaltocce855b1998-04-17 19:52:44 +0000149extern char *get_dirstack_from_string __P((char *));
Jari Aalto7117c2d2002-07-17 14:10:11 +0000150extern char *get_dirstack_element __P((intmax_t, int));
151extern void set_dirstack_element __P((intmax_t, int, char *));
Jari Aaltocce855b1998-04-17 19:52:44 +0000152extern WORD_LIST *get_directory_stack __P((void));
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000153
154/* Functions from evalstring.c */
Jari Aaltof73dda02001-11-13 17:56:06 +0000155extern int parse_and_execute __P((char *, const char *, int));
Jari Aaltocce855b1998-04-17 19:52:44 +0000156extern void parse_and_execute_cleanup __P((void));
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000157
158/* Functions from evalfile.c */
Jari Aaltof73dda02001-11-13 17:56:06 +0000159extern int maybe_execute_file __P((const char *, int));
Jari Aaltob80f6442004-07-27 13:29:18 +0000160extern int source_file __P((const char *, int));
Jari Aaltof73dda02001-11-13 17:56:06 +0000161extern int fc_execute_file __P((const char *));
Jari Aalto726f6381996-08-26 18:22:31 +0000162
163#endif /* !__COMMON_H */