sh.decls.h revision 316957
1/* $Header: /p/tcsh/cvsroot/tcsh/sh.decls.h,v 3.68 2016/08/01 16:21:09 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 */
39extern	Char	 	 *gethdir	(const Char *);
40extern	void		  dosource	(Char **, struct command *);
41extern	void		  exitstat	(void);
42extern	void		  goodbye	(Char **, struct command *);
43extern	void		  importpath	(Char *);
44extern	void		  initdesc	(void);
45extern	void		  pintr		(void);
46extern	void		  pintr1	(int);
47extern	void		  phup		(void);
48extern	void		  process	(int);
49extern	void		  untty		(void);
50#ifdef PROF
51extern	void		  done		(int) __attribute__((__noreturn__));
52#else
53extern	void		  xexit		(int) __attribute__((__noreturn__));
54#endif
55extern	int		  grabpgrp	(int, pid_t);
56
57/*
58 * sh.dir.c
59 */
60extern	void		  dinit		(Char *);
61extern	void		  dodirs	(Char **, struct command *);
62extern	Char		 *dcanon	(Char *, Char *);
63extern	void		  dtildepr	(Char *);
64extern	void		  dtilde	(void);
65extern	void		  dochngd	(Char **, struct command *);
66extern	Char		 *dnormalize	(const Char *, int);
67extern	void		  dopushd	(Char **, struct command *);
68extern	void		  dopopd	(Char **, struct command *);
69extern	void		  dfree		(struct directory *);
70extern	void		  dsetstack	(void);
71extern	const Char	 *getstakd	(int);
72extern	void		  recdirs	(Char *, int);
73extern	void		  loaddirs	(Char *);
74
75/*
76 * sh.dol.c
77 */
78extern	void		  Dfix		(struct command *);
79extern	Char		 *Dfix1		(Char *);
80extern	void		  heredoc	(Char *);
81extern  Char		 *randsuf	(void);
82
83/*
84 * sh.err.c
85 */
86extern	void		  reset		(void) __attribute__((__noreturn__));
87extern	void		  cleanup_push_internal(void *, void (*fn) (void *)
88#ifdef CLEANUP_DEBUG
89						, const char *, size_t
90#define cleanup_push(v, f) cleanup_push_internal(v, f, __FILE__, __LINE__)
91#else
92#define cleanup_push(v, f) cleanup_push_internal(v, f)
93#endif
94);
95extern	int		  cleanup_reset(void);
96extern	void		  cleanup_ignore(void *);
97extern	void		  cleanup_until(void *);
98extern	void		  cleanup_until_mark(void);
99extern	size_t		  cleanup_push_mark(void);
100extern	void		  cleanup_pop_mark(size_t);
101extern	void		  open_cleanup(void *);
102extern	void		  opendir_cleanup(void *);
103extern	void		  sigint_cleanup(void *);
104extern	void		  sigprocmask_cleanup(void *);
105extern	void		  xfree_indirect(void *);
106extern	void		  errinit	(void);
107extern	void		  seterror	(unsigned int, ...);
108extern	void		  fixerror	(void);
109extern	void		  stderror	(unsigned int, ...)
110    __attribute__((__noreturn__));
111
112/*
113 * sh.exec.c
114 */
115extern	void		  doexec	(struct command *, int);
116extern	void		  dohash	(Char **, struct command *);
117extern	void		  dounhash	(Char **, struct command *);
118extern	void		  execash	(Char **, struct command *);
119extern	void		  hashstat	(Char **, struct command *);
120extern	void		  xechoit	(Char **);
121extern	int		  executable	(const Char *, const Char *, int);
122extern	int		  tellmewhat	(struct wordent *, Char **);
123extern	void		  dowhere	(Char **, struct command *);
124extern	int		  find_cmd	(Char *, int);
125
126/*
127 * sh.exp.c
128 */
129extern  Char		 *filetest      (Char *, Char ***, int);
130extern	tcsh_number_t 	  expr		(Char ***);
131extern	tcsh_number_t	  exp0		(Char ***, int);
132
133/*
134 * sh.file.c
135 */
136#if defined(FILEC) && defined(TIOCSTI)
137extern	size_t		  tenex		(Char *, size_t);
138#endif
139
140/*
141 * sh.func.c
142 */
143extern	void		  tsetenv	(const Char *, const Char *);
144extern	void		  Unsetenv	(Char *);
145extern	void		  doalias	(Char **, struct command *);
146extern	void		  dobreak	(Char **, struct command *);
147extern	void		  docontin	(Char **, struct command *);
148extern	void		  doecho	(Char **, struct command *);
149extern	void		  doelse	(Char **, struct command *);
150extern	void		  doend		(Char **, struct command *);
151extern	void		  doeval	(Char **, struct command *);
152extern	void		  doexit	(Char **, struct command *);
153extern	void		  doforeach	(Char **, struct command *);
154extern	void		  doglob	(Char **, struct command *);
155extern	void		  dogoto	(Char **, struct command *);
156extern	void		  doif		(Char **, struct command *);
157extern	void		  dolimit	(Char **, struct command *);
158extern	void		  dologin	(Char **, struct command *);
159extern	void		  dologout	(Char **, struct command *);
160#ifdef NEWGRP
161extern	void		  donewgrp	(Char **, struct command *);
162#endif
163extern	void		  donohup	(Char **, struct command *);
164extern	void		  dohup		(Char **, struct command *);
165extern	void		  doonintr	(Char **, struct command *);
166extern	void		  doprintenv	(Char **, struct command *);
167extern	void		  dorepeat	(Char **, struct command *);
168extern	void		  dofiletest	(Char **, struct command *);
169extern	void		  dosetenv	(Char **, struct command *);
170extern	void		  dosuspend	(Char **, struct command *);
171extern	void		  doswbrk	(Char **, struct command *);
172extern	void		  doswitch	(Char **, struct command *);
173extern	void		  doumask	(Char **, struct command *);
174extern	void		  dounlimit	(Char **, struct command *);
175extern	void		  dounsetenv	(Char **, struct command *);
176extern	void		  dowhile	(Char **, struct command *);
177extern	void		  dozip		(Char **, struct command *);
178extern	void		  func		(struct command *,
179					 const struct biltins *);
180extern	void		  gotolab	(Char *);
181extern const struct biltins *isbfunc	(struct command *);
182extern	void		  prvars	(void);
183extern	int		  srchx		(Char *);
184extern	void		  unalias	(Char **, struct command *);
185extern	void		  wfree		(void);
186extern	void		  dobuiltins	(Char **, struct command *);
187extern	void		  reexecute	(struct command *);
188extern  int		  getYN		(const char *);
189
190/*
191 * sh.glob.c
192 */
193extern	Char	 	 *globequal	(Char *);
194extern	Char		**dobackp	(Char *, int);
195extern	Char		 *globone	(Char *, int);
196extern	int		  Gmatch	(const Char *, const Char *);
197extern	int		  Gnmatch	(const Char *, const Char *,
198					 const Char **);
199extern	Char		**globall	(Char **, int);
200extern	Char		**glob_all_or_error(Char **);
201extern	void		  rscan		(Char **, void (*)(Char));
202extern	int		  tglob		(Char **);
203extern	void		  trim		(Char **);
204
205#if !defined(WINNT_NATIVE) && defined(NLS_CATALOGS)
206extern	char		 *xcatgets	(nl_catd, int, int, const char *);
207#if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
208extern	char		 *iconv_catgets	(nl_catd, int, int, const char *);
209#endif
210#endif
211extern	void		  nlsinit	(void);
212extern	void	          nlsclose	(void);
213extern  int	  	  t_pmatch	(const Char *, const Char *,
214					 const Char **, int);
215
216/*
217 * sh.hist.c
218 */
219extern	void	 	  dohist	(Char **, struct command *);
220extern  struct Hist 	 *enthist	(int, struct wordent *, int, int, int);
221extern	void	 	  savehist	(struct wordent *, int);
222extern	char		 *fmthist	(int, ptr_t);
223extern	void		  rechist	(Char *, int);
224extern	void		  loadhist	(Char *, int);
225extern	void		  displayHistStats(const char *);
226extern	void		  sethistory	(int);
227
228/*
229 * sh.init.c
230 */
231extern	void		  mesginit	(void);
232
233/*
234 * sh.lex.c
235 */
236extern	void		  addla		(Char *);
237extern	void		  bseek		(struct Ain *);
238extern	void		  btell		(struct Ain *);
239extern	void		  btoeof	(void);
240extern	void		  copylex	(struct wordent *, struct wordent *);
241extern	Char		 *domod		(Char *, Char);
242extern	void		  initlex	(struct wordent *);
243extern	void		  freelex	(struct wordent *);
244extern	int		  lex		(struct wordent *);
245extern	void		  lex_cleanup	(void *);
246extern	void		  prlex		(struct wordent *);
247extern	eChar		  readc		(int);
248extern	void		  settell	(void);
249extern	void		  unreadc	(Char);
250extern	ssize_t		  wide_read	(int, Char *, size_t, int);
251
252
253/*
254 * sh.misc.c
255 */
256extern	int		  any		(const char *, Char);
257extern	Char		**blkcpy	(Char **, Char **);
258extern	void		  blkfree	(Char **);
259extern	void		  blk_cleanup	(void *);
260extern	void		  blk_indirect_cleanup(void *);
261extern	int		  blklen	(Char **);
262extern	void		  blkpr		(Char *const *);
263extern	Char		 *blkexpand	(Char *const *);
264extern	Char		**blkspl	(Char **, Char **);
265extern	void		  closem	(void);
266#ifndef CLOSE_ON_EXEC
267extern  void 		  closech	(void);
268#endif /* !CLOSE_ON_EXEC */
269extern	Char		**copyblk	(Char **);
270extern	int		  dcopy		(int, int);
271extern	int		  dmove		(int, int);
272extern	void		  donefds	(void);
273extern	Char		  lastchr	(Char *);
274extern	void		  lshift	(Char **, int);
275extern	int		  number	(Char *);
276extern	int		  prefix	(const Char *, const Char *);
277extern	Char		**saveblk	(Char **);
278extern	void		  setzero	(void *, size_t);
279extern	Char		 *strip		(Char *);
280extern	Char		 *quote		(Char *);
281extern	const Char	 *quote_meta	(struct Strbuf *, const Char *);
282#ifndef SHORT_STRINGS
283extern	char		 *strnsave	(const char *, size_t);
284#endif
285extern	char		 *strsave	(const char *);
286extern	void		  udvar		(Char *) __attribute__((__noreturn__));
287#ifndef POSIX
288extern  char   	  	 *strstr	(const char *, const char *);
289#endif /* !POSIX */
290extern	char		 *strspl	(const char *, const char *);
291extern	char		 *strend	(const char *);
292extern	char		 *areadlink	(const char *);
293extern	void		  xclose	(int);
294extern	void		  xclosedir	(DIR *);
295extern	int		  xcreat	(const char *, mode_t);
296extern	struct group	 *xgetgrgid	(gid_t);
297extern	struct passwd	 *xgetpwnam	(const char *);
298extern	struct passwd	 *xgetpwuid	(uid_t);
299extern	int		  xopen		(const char *, int, ...);
300extern	ssize_t		  xread		(int, void *, size_t);
301extern	int		  xtcsetattr	(int, int, const struct termios *);
302extern	ssize_t		  xwrite	(int, const void *, size_t);
303
304/*
305 * sh.parse.c
306 */
307extern	void		  alias		(struct wordent *);
308extern	void		  freesyn	(struct command *);
309extern struct command 	 *syntax	(const struct wordent *,
310					 const struct wordent *, int);
311extern	void		  syntax_cleanup(void *);
312
313/*
314 * sh.print.c
315 */
316extern	void		  drainoline	(void);
317extern	void		  flush		(void);
318#ifdef BSDTIMES
319extern	void		  pcsecs	(unsigned long);
320#else /* !BSDTIMES */
321# ifdef POSIX
322extern	void		  pcsecs	(clock_t);
323# else /* !POSIX */
324extern	void		  pcsecs	(time_t);
325# endif /* !POSIX */
326#endif /* BSDTIMES */
327#ifdef BSDLIMIT
328extern	void		  psecs		(unsigned long);
329#endif /* BSDLIMIT */
330extern	int		  putpure	(int);
331extern	int		  putraw	(int);
332extern	void		  xputchar	(int);
333#ifdef WIDE_STRINGS
334extern	void		  putwraw	(Char);
335extern	void		  xputwchar	(Char);
336#else
337# define putwraw(C) putraw(C)
338# define xputwchar(C) xputchar(C)
339#endif
340extern	void		  output_raw_restore(void *);
341
342
343/*
344 * sh.proc.c
345 */
346extern	void		  dobg		(Char **, struct command *);
347extern	void		  dobg1		(Char **, struct command *);
348extern	void		  dofg		(Char **, struct command *);
349extern	void		  dofg1		(Char **, struct command *);
350extern	void		  dojobs	(Char **, struct command *);
351extern	void		  dokill	(Char **, struct command *);
352extern	void		  donotify	(Char **, struct command *);
353extern	void		  dostop	(Char **, struct command *);
354extern	void		  dowait	(Char **, struct command *);
355extern	void		  palloc	(pid_t, struct command *);
356extern	void		  panystop	(int);
357extern	void		  pchild	(void);
358extern	void		  pendjob	(void);
359extern	pid_t		  pfork		(struct command *, int);
360extern	void		  pgetty	(int, pid_t);
361extern	void		  pjwait	(struct process *);
362extern	void		  pnote		(void);
363extern	void		  psavejob	(void);
364extern	void		  psavejob_cleanup(void *);
365extern	int		  pstart	(struct process *, int);
366extern	void		  pwait		(void);
367extern  struct process   *pfind		(Char *);
368
369/*
370 * sh.sem.c
371 */
372extern	void		  execute	(struct command *, volatile int, int *,
373					 int *, int);
374extern	void		  mypipe	(int *);
375
376/*
377 * sh.set.c
378 */
379extern	struct varent 	 *adrof1	(const Char *, struct varent *);
380extern	void		  doset		(Char **, struct command *);
381extern	void		  dolet		(Char **, struct command *);
382extern	Char		 *putn		(tcsh_number_t);
383extern	tcsh_number_t	  getn		(const Char *);
384extern	Char		 *value1	(Char *, struct varent *);
385extern	void		  setcopy	(const Char *, const Char *, int);
386extern	void		  setv		(const Char *, Char *, int);
387extern	void		  set1		(const Char *, Char **,
388					 struct varent *, int);
389extern	void		  setq		(const Char *, Char **,
390					 struct varent *, int);
391extern	void		  unset		(Char **, struct command *);
392extern	void		  unset1	(Char *[], struct varent *);
393extern	void		  unsetv	(Char *);
394extern	void		  setNS		(const Char *);
395extern	void		  shift		(Char **, struct command *);
396extern	void		  plist		(struct varent *, int);
397extern	Char		 *unparse	(struct command *);
398#if defined(DSPMBYTE)
399extern	void 		  update_dspmbyte_vars	(void);
400extern	void		  autoset_dspmbyte	(const Char *);
401#endif
402#if defined(AUTOSET_KANJI)
403extern	void		  autoset_kanji	(void);
404#endif
405extern	void		  update_wordchars	(void);
406
407/*
408 * sh.time.c
409 */
410extern	void		  donice	(Char **, struct command *);
411extern	void		  dotime	(Char **, struct command *);
412#ifdef BSDTIMES
413extern	void		  prusage	(struct sysrusage *,
414					 struct sysrusage *,
415					 timeval_t *, timeval_t *);
416extern	void		  ruadd		(struct sysrusage *,
417					 struct sysrusage *);
418#else /* BSDTIMES */
419# ifdef _SEQUENT_
420extern	void		  prusage	(struct process_stats *,
421					 struct process_stats *,
422					 timeval_t *, timeval_t *);
423extern	void		  ruadd		(struct process_stats *,
424					 struct process_stats *);
425# else /* !_SEQUENT_ */
426#  ifdef POSIX
427extern	void		  prusage	(struct tms *, struct tms *,
428					 clock_t, clock_t);
429#  else	/* !POSIX */
430extern	void		  prusage	(struct tms *, struct tms *,
431					 time_t, time_t);
432#  endif /* !POSIX */
433# endif	/* !_SEQUENT_ */
434#endif /* BSDTIMES */
435extern	void		  settimes	(void);
436#if defined(BSDTIMES) || defined(_SEQUENT_)
437extern	void		  tvsub		(struct timeval *,
438					 struct timeval *,
439					 struct timeval *);
440#endif /* BSDTIMES || _SEQUENT_ */
441
442/*
443 * tw.parse.c
444 */
445extern	 void		  copyn			(Char *, const Char *, size_t);
446extern	 void		  catn			(Char *, const Char *, int);
447
448#endif /* _h_sh_decls */
449