xref: /freebsd/contrib/tcsh/sh.decls.h (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
1 /* $Header: /p/tcsh/cvsroot/tcsh/sh.decls.h,v 3.53 2006/08/24 20:56:31 christos Exp $ */
2 /*
3  * sh.decls.h	 External declarations from sh*.c
4  */
5 /*-
6  * Copyright (c) 1980, 1991 The Regents of the University of California.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33 #ifndef _h_sh_decls
34 #define _h_sh_decls
35 
36 /*
37  * sh.c
38  */
39 extern	Char	 	 *gethdir	(const Char *);
40 extern	void		  dosource	(Char **, struct command *);
41 extern	void		  exitstat	(void);
42 extern	void		  goodbye	(Char **, struct command *);
43 extern	void		  importpath	(Char *);
44 extern	void		  initdesc	(void);
45 extern	void		  pintr		(void);
46 extern	void		  pintr1	(int);
47 extern	void		  phup		(void);
48 extern	void		  process	(int);
49 extern	void		  untty		(void);
50 #ifdef PROF
51 extern	void		  done		(int);
52 #else
53 extern	void		  xexit		(int);
54 #endif
55 
56 /*
57  * sh.dir.c
58  */
59 extern	void		  dinit		(Char *);
60 extern	void		  dodirs	(Char **, struct command *);
61 extern	Char		 *dcanon	(Char *, Char *);
62 extern	void		  dtildepr	(Char *);
63 extern	void		  dtilde	(void);
64 extern	void		  dochngd	(Char **, struct command *);
65 extern	Char		 *dnormalize	(const Char *, int);
66 extern	void		  dopushd	(Char **, struct command *);
67 extern	void		  dopopd	(Char **, struct command *);
68 extern	void		  dfree		(struct directory *);
69 extern	void		  dsetstack	(void);
70 extern	const Char	 *getstakd	(int);
71 extern	void		  recdirs	(Char *, int);
72 extern	void		  loaddirs	(Char *);
73 
74 /*
75  * sh.dol.c
76  */
77 extern	void		  Dfix		(struct command *);
78 extern	Char		 *Dfix1		(Char *);
79 extern	void		  heredoc	(Char *);
80 
81 /*
82  * sh.err.c
83  */
84 extern	void		  reset		(void);
85 extern	void		  cleanup_push_internal(void *, void (*fn) (void *)
86 #ifdef CLEANUP_DEBUG
87 						, const char *, size_t
88 #define cleanup_push(v, f) cleanup_push_internal(v, f, __FILE__, __LINE__)
89 #else
90 #define cleanup_push(v, f) cleanup_push_internal(v, f)
91 #endif
92 );
93 extern	void		  cleanup_ignore(void *);
94 extern	void		  cleanup_until	(void *);
95 extern	void		  cleanup_until_mark(void);
96 extern	size_t		  cleanup_push_mark(void);
97 extern	void		  cleanup_pop_mark(size_t);
98 extern	void		  open_cleanup(void *);
99 extern	void		  opendir_cleanup(void *);
100 extern	void		  sigint_cleanup(void *);
101 extern	void		  sigprocmask_cleanup(void *);
102 extern	void		  xfree_indirect(void *);
103 extern	void		  errinit	(void);
104 extern	void		  seterror	(unsigned int, ...);
105 extern	void		  stderror	(unsigned int, ...);
106 
107 /*
108  * sh.exec.c
109  */
110 extern	void		  doexec	(struct command *, int);
111 extern	void		  dohash	(Char **, struct command *);
112 extern	void		  dounhash	(Char **, struct command *);
113 extern	void		  execash	(Char **, struct command *);
114 extern	void		  hashstat	(Char **, struct command *);
115 extern	void		  xechoit	(Char **);
116 extern	int		  executable	(const Char *, const Char *, int);
117 extern	int		  tellmewhat	(struct wordent *, Char **);
118 extern	void		  dowhere	(Char **, struct command *);
119 extern	int		  find_cmd	(Char *, int);
120 
121 /*
122  * sh.exp.c
123  */
124 extern  Char     *filetest       (Char *, Char ***, int);
125 extern	int	 	  expr		(Char ***);
126 extern	int		  exp0		(Char ***, int);
127 
128 /*
129  * sh.file.c
130  */
131 #if defined(FILEC) && defined(TIOCSTI)
132 extern	size_t		  tenex		(Char *, size_t);
133 #endif
134 
135 /*
136  * sh.func.c
137  */
138 extern	void		  tsetenv	(const Char *, const Char *);
139 extern	void		  Unsetenv	(Char *);
140 extern	void		  doalias	(Char **, struct command *);
141 extern	void		  dobreak	(Char **, struct command *);
142 extern	void		  docontin	(Char **, struct command *);
143 extern	void		  doecho	(Char **, struct command *);
144 extern	void		  doelse	(Char **, struct command *);
145 extern	void		  doend		(Char **, struct command *);
146 extern	void		  doeval	(Char **, struct command *);
147 extern	void		  doexit	(Char **, struct command *);
148 extern	void		  doforeach	(Char **, struct command *);
149 extern	void		  doglob	(Char **, struct command *);
150 extern	void		  dogoto	(Char **, struct command *);
151 extern	void		  doif		(Char **, struct command *);
152 extern	void		  dolimit	(Char **, struct command *);
153 extern	void		  dologin	(Char **, struct command *);
154 extern	void		  dologout	(Char **, struct command *);
155 #ifdef NEWGRP
156 extern	void		  donewgrp	(Char **, struct command *);
157 #endif
158 extern	void		  donohup	(Char **, struct command *);
159 extern	void		  dohup		(Char **, struct command *);
160 extern	void		  doonintr	(Char **, struct command *);
161 extern	void		  doprintenv	(Char **, struct command *);
162 extern	void		  dorepeat	(Char **, struct command *);
163 extern	void		  dofiletest	(Char **, struct command *);
164 extern	void		  dosetenv	(Char **, struct command *);
165 extern	void		  dosuspend	(Char **, struct command *);
166 extern	void		  doswbrk	(Char **, struct command *);
167 extern	void		  doswitch	(Char **, struct command *);
168 extern	void		  doumask	(Char **, struct command *);
169 extern	void		  dounlimit	(Char **, struct command *);
170 extern	void		  dounsetenv	(Char **, struct command *);
171 extern	void		  dowhile	(Char **, struct command *);
172 extern	void		  dozip		(Char **, struct command *);
173 extern	void		  func		(struct command *,
174 					 const struct biltins *);
175 extern	void		  gotolab	(Char *);
176 extern const struct biltins *isbfunc	(struct command *);
177 extern	void		  prvars	(void);
178 extern	int		  srchx		(Char *);
179 extern	void		  unalias	(Char **, struct command *);
180 extern	void		  wfree		(void);
181 extern	void		  dobuiltins	(Char **, struct command *);
182 extern	void		  reexecute	(struct command *);
183 
184 /*
185  * sh.glob.c
186  */
187 extern	Char	 	 *globequal	(Char *);
188 extern	Char		**dobackp	(Char *, int);
189 extern	Char		 *globone	(Char *, int);
190 extern	int		  Gmatch	(const Char *, const Char *);
191 extern	int		  Gnmatch	(const Char *, const Char *,
192 					 const Char **);
193 extern	Char		**globall	(Char **, int);
194 extern	Char		**glob_all_or_error(Char **);
195 extern	void		  rscan		(Char **, void (*)(Char));
196 extern	int		  tglob		(Char **);
197 extern	void		  trim		(Char **);
198 
199 #if !defined(WINNT_NATIVE) && defined(NLS_CATALOGS)
200 extern	char		 *xcatgets	(nl_catd, int, int, const char *);
201 #if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
202 extern	char		 *iconv_catgets	(nl_catd, int, int, const char *);
203 #endif
204 #endif
205 extern	void		  nlsinit	(void);
206 extern	void	          nlsclose	(void);
207 extern  int	  	  t_pmatch	(const Char *, const Char *,
208 					 const Char **, int);
209 
210 /*
211  * sh.hist.c
212  */
213 extern	void	 	  dohist	(Char **, struct command *);
214 extern  struct Hist 	 *enthist	(int, struct wordent *, int, int);
215 extern	void	 	  savehist	(struct wordent *, int);
216 extern	char		 *fmthist	(int, ptr_t);
217 extern	void		  rechist	(Char *, int);
218 extern	void		  loadhist	(Char *, int);
219 
220 /*
221  * sh.init.c
222  */
223 extern	void		  mesginit	(void);
224 
225 /*
226  * sh.lex.c
227  */
228 extern	void		  addla		(Char *);
229 extern	void		  bseek		(struct Ain *);
230 extern	void		  btell		(struct Ain *);
231 extern	void		  btoeof	(void);
232 extern	void		  copylex	(struct wordent *, struct wordent *);
233 extern	Char		 *domod		(Char *, Char);
234 extern	void		  freelex	(struct wordent *);
235 extern	int		  lex		(struct wordent *);
236 extern	void		  lex_cleanup	(void *);
237 extern	void		  prlex		(struct wordent *);
238 extern	eChar		  readc		(int);
239 extern	void		  settell	(void);
240 extern	void		  unreadc	(Char);
241 
242 
243 /*
244  * sh.misc.c
245  */
246 extern	int		  any		(const char *, Char);
247 extern	Char		**blkcpy	(Char **, Char **);
248 extern	void		  blkfree	(Char **);
249 extern	void		  blk_cleanup	(void *);
250 extern	void		  blk_indirect_cleanup(void *);
251 extern	int		  blklen	(Char **);
252 extern	void		  blkpr		(Char *const *);
253 extern	Char		 *blkexpand	(Char *const *);
254 extern	Char		**blkspl	(Char **, Char **);
255 extern	void		  closem	(void);
256 #ifndef CLOSE_ON_EXEC
257 extern  void 		  closech	(void);
258 #endif /* !CLOSE_ON_EXEC */
259 extern	Char		**copyblk	(Char **);
260 extern	int		  dcopy		(int, int);
261 extern	int		  dmove		(int, int);
262 extern	void		  donefds	(void);
263 extern	Char		  lastchr	(Char *);
264 extern	void		  lshift	(Char **, int);
265 extern	int		  number	(Char *);
266 extern	int		  prefix	(const Char *, const Char *);
267 extern	Char		**saveblk	(Char **);
268 extern	void		  setzero	(void *, size_t);
269 extern	Char		 *strip		(Char *);
270 extern	Char		 *quote		(Char *);
271 extern	const Char	 *quote_meta	(struct Strbuf *, const Char *);
272 extern	char		 *strnsave	(const char *, size_t);
273 extern	char		 *strsave	(const char *);
274 extern	void		  udvar		(Char *);
275 #ifndef POSIX
276 extern  char   	  	 *strstr	(const char *, const char *);
277 #endif /* !POSIX */
278 extern	char		 *strspl	(const char *, const char *);
279 extern	char		 *strend	(const char *);
280 extern	char		 *areadlink	(const char *);
281 extern	void		  xclose	(int);
282 extern	void		  xclosedir	(DIR *);
283 extern	int		  xcreat	(const char *, mode_t);
284 extern	struct group	 *xgetgrgid	(gid_t);
285 extern	struct passwd	 *xgetpwnam	(const char *);
286 extern	struct passwd	 *xgetpwuid	(uid_t);
287 extern	int		  xopen		(const char *, int, ...);
288 extern	ssize_t		  xread		(int, void *, size_t);
289 extern	int		  xtcsetattr	(int, int, const struct termios *);
290 extern	ssize_t		  xwrite	(int, const void *, size_t);
291 
292 /*
293  * sh.parse.c
294  */
295 extern	void		  alias		(struct wordent *);
296 extern	void		  freesyn	(struct command *);
297 extern struct command 	 *syntax	(const struct wordent *,
298 					 const struct wordent *, int);
299 extern	void		  syntax_cleanup(void *);
300 
301 /*
302  * sh.print.c
303  */
304 extern	void		  drainoline	(void);
305 extern	void		  flush		(void);
306 #ifdef BSDTIMES
307 extern	void		  pcsecs	(unsigned long);
308 #else /* !BSDTIMES */
309 # ifdef POSIX
310 extern	void		  pcsecs	(clock_t);
311 # else /* !POSIX */
312 extern	void		  pcsecs	(time_t);
313 # endif /* !POSIX */
314 #endif /* BSDTIMES */
315 #ifdef BSDLIMIT
316 extern	void		  psecs		(unsigned long);
317 #endif /* BSDLIMIT */
318 extern	int		  putpure	(int);
319 extern	int		  putraw	(int);
320 extern	void		  xputchar	(int);
321 #ifdef WIDE_STRINGS
322 extern	void		  putwraw	(Char);
323 extern	void		  xputwchar	(Char);
324 #else
325 # define putwraw(C) putraw(C)
326 # define xputwchar(C) xputchar(C)
327 #endif
328 extern	void		  output_raw_restore(void *);
329 
330 
331 /*
332  * sh.proc.c
333  */
334 extern	void		  dobg		(Char **, struct command *);
335 extern	void		  dobg1		(Char **, struct command *);
336 extern	void		  dofg		(Char **, struct command *);
337 extern	void		  dofg1		(Char **, struct command *);
338 extern	void		  dojobs	(Char **, struct command *);
339 extern	void		  dokill	(Char **, struct command *);
340 extern	void		  donotify	(Char **, struct command *);
341 extern	void		  dostop	(Char **, struct command *);
342 extern	void		  dowait	(Char **, struct command *);
343 extern	void		  palloc	(pid_t, struct command *);
344 extern	void		  panystop	(int);
345 extern	void		  pchild	(void);
346 extern	void		  pendjob	(void);
347 extern	pid_t		  pfork		(struct command *, int);
348 extern	void		  pgetty	(int, pid_t);
349 extern	void		  pjwait	(struct process *);
350 extern	void		  pnote		(void);
351 extern	void		  psavejob	(void);
352 extern	void		  psavejob_cleanup(void *);
353 extern	int		  pstart	(struct process *, int);
354 extern	void		  pwait		(void);
355 extern  struct process   *pfind		(Char *);
356 
357 /*
358  * sh.sem.c
359  */
360 extern	void		  execute	(struct command *, int, int *,
361 					 int *, int);
362 extern	void		  mypipe	(int *);
363 
364 /*
365  * sh.set.c
366  */
367 extern	struct varent 	 *adrof1	(const Char *, struct varent *);
368 extern	void		  doset		(Char **, struct command *);
369 extern	void		  dolet		(Char **, struct command *);
370 extern	Char		 *putn		(int);
371 extern	int		  getn		(Char *);
372 extern	Char		 *value1	(Char *, struct varent *);
373 extern	void		  setcopy	(const Char *, const Char *, int);
374 extern	void		  setv		(const Char *, Char *, int);
375 extern	void		  set1		(const Char *, Char **,
376 					 struct varent *, int);
377 extern	void		  setq		(const Char *, Char **,
378 					 struct varent *, int);
379 extern	void		  unset		(Char **, struct command *);
380 extern	void		  unset1	(Char *[], struct varent *);
381 extern	void		  unsetv	(Char *);
382 extern	void		  setNS		(Char *);
383 extern	void		  shift		(Char **, struct command *);
384 extern	void		  plist		(struct varent *, int);
385 extern	Char		 *unparse	(struct command *);
386 #if defined(DSPMBYTE)
387 extern	void 		  update_dspmbyte_vars	(void);
388 extern	void		  autoset_dspmbyte	(const Char *);
389 #endif
390 
391 /*
392  * sh.time.c
393  */
394 extern	void		  donice	(Char **, struct command *);
395 extern	void		  dotime	(Char **, struct command *);
396 #ifdef BSDTIMES
397 extern	void		  prusage	(struct sysrusage *,
398 					 struct sysrusage *,
399 					 timeval_t *, timeval_t *);
400 extern	void		  ruadd		(struct sysrusage *,
401 					 struct sysrusage *);
402 #else /* BSDTIMES */
403 # ifdef _SEQUENT_
404 extern	void		  prusage	(struct process_stats *,
405 					 struct process_stats *,
406 					 timeval_t *, timeval_t *);
407 extern	void		  ruadd		(struct process_stats *,
408 					 struct process_stats *);
409 # else /* !_SEQUENT_ */
410 #  ifdef POSIX
411 extern	void		  prusage	(struct tms *, struct tms *,
412 					 clock_t, clock_t);
413 #  else	/* !POSIX */
414 extern	void		  prusage	(struct tms *, struct tms *,
415 					 time_t, time_t);
416 #  endif /* !POSIX */
417 # endif	/* !_SEQUENT_ */
418 #endif /* BSDTIMES */
419 extern	void		  settimes	(void);
420 #if defined(BSDTIMES) || defined(_SEQUENT_)
421 extern	void		  tvsub		(struct timeval *,
422 					 struct timeval *,
423 					 struct timeval *);
424 #endif /* BSDTIMES || _SEQUENT_ */
425 
426 /*
427  * tw.parse.c
428  */
429 extern	 void		  copyn			(Char *, const Char *, size_t);
430 extern	 void		  catn			(Char *, const Char *, int);
431 
432 #endif /* _h_sh_decls */
433