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