1/*
2 * tc.decls.h: Function declarations from all the tcsh modules
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_tc_decls
33#define _h_tc_decls
34
35struct blk_buf;
36struct strbuf;
37struct Strbuf;
38
39/*
40 * tc.alloc.c
41 */
42#ifndef SYSMALLOC
43#ifndef WINNT_NATIVE
44#ifndef __linux__
45extern	void		  free		(ptr_t);
46extern	memalign_t	  malloc	(size_t);
47extern	memalign_t	  realloc	(ptr_t, size_t);
48extern	memalign_t	  calloc	(size_t, size_t);
49#endif
50#endif /* !WINNT_NATIVE */
51#else /* SYSMALLOC */
52extern	void		  sfree		(ptr_t);
53extern	memalign_t	  smalloc	(size_t);
54extern	memalign_t	  srealloc	(ptr_t, size_t);
55extern	memalign_t	  scalloc	(size_t, size_t);
56#endif /* SYSMALLOC */
57extern	void		  showall	(Char **, struct command *);
58
59/*
60 * tc.bind.c
61 */
62extern	void		  dobindkey	(Char **, struct command *);
63
64/*
65 * tc.defs.c:
66 */
67extern	void		  getmachine	(void);
68
69
70/*
71 * tc.disc.c
72 */
73extern	int		  setdisc	(int);
74extern	int		  resetdisc	(int);
75
76/*
77 * tc.func.c
78 */
79extern	Char		 *expand_lex    (const struct wordent *, int, int);
80extern	Char		 *sprlex	(const struct wordent *);
81extern	Char		 *Itoa		(int, size_t, Char);
82extern	void		  dolist	(Char **, struct command *);
83extern	void		  dotermname	(Char **, struct command *);
84extern	void		  dotelltc	(Char **, struct command *);
85extern	void		  doechotc	(Char **, struct command *);
86extern	void		  dosettc	(Char **, struct command *);
87extern	int		  cmd_expand	(Char *, Char **);
88extern	void		  dowhich	(Char **, struct command *);
89extern	struct process	 *find_stop_ed	(void);
90extern	void		  fg_proc_entry	(struct process *);
91extern	void		  alrmcatch	(void);
92extern	void		  precmd	(void);
93extern	void		  postcmd	(void);
94extern	void		  cwd_cmd	(void);
95extern	void		  beep_cmd	(void);
96extern	void		  period_cmd	(void);
97extern	void		  job_cmd	(Char *);
98extern	void		  aliasrun	(int, Char *, Char *);
99extern	void		  setalarm	(int);
100extern	void		  rmstar	(struct wordent *);
101extern	void		  continue_jobs	(struct wordent *);
102extern	Char		 *gettilde	(const Char *);
103extern	Char		 *getusername	(Char **);
104#ifdef OBSOLETE
105extern	void		  doaliases	(Char **, struct command *);
106#endif /* OBSOLETE */
107extern	void		  shlvl		(int);
108extern	int		  fixio		(int, int);
109extern	int		  collate	(const Char *, const Char *);
110#ifdef HASHBANG
111extern	int		  hashbang	(int, Char ***);
112#endif /* HASHBANG */
113#ifdef REMOTEHOST
114extern	void		  remotehost	(void);
115#endif /* REMOTEHOST */
116
117
118/*
119 * tc.os.c
120 */
121#ifdef MACH
122extern	void		  dosetpath	(Char **, struct command *);
123#endif /* MACH */
124
125#ifdef TCF
126extern	void		  dogetxvers	(Char **, struct command *);
127extern	void		  dosetxvers	(Char **, struct command *);
128extern	void		  dogetspath	(Char **, struct command *);
129extern	void		  dosetspath	(Char **, struct command *);
130extern	char		 *sitename	(pid_t);
131extern	void		  domigrate	(Char **, struct command *);
132#endif /* TCF */
133
134#ifdef WARP
135extern	void 		  dowarp	(Char **, struct command *);
136#endif /* WARP */
137
138#if defined(_CRAY) && !defined(_CRAYMPP)
139extern	void 		  dodmmode	(Char **, struct command *);
140#endif /* _CRAY && !_CRAYMPP */
141
142#if defined(masscomp) || defined(hcx)
143extern	void		  douniverse	(Char **, struct command *);
144#endif /* masscomp */
145
146#if defined(_OSD_POSIX) /* BS2000 */
147extern	void		  dobs2cmd	(Char **, struct command *);
148#endif /* _OSD_POSIX */
149
150#if defined(hcx)
151extern	void		  doatt		(Char **, struct command *);
152extern	void		  doucb		(Char **, struct command *);
153#endif /* hcx */
154
155#ifdef _SEQUENT_
156extern	void	 	  pr_stat_sub	(struct process_stats *,
157					 struct process_stats *,
158					 struct process_stats *);
159#endif /* _SEQUENT_ */
160
161#ifdef NEEDtcgetpgrp
162extern	pid_t	 	  xtcgetpgrp	(int);
163extern	int		  xtcsetpgrp	(int, int);
164# undef tcgetpgrp
165# define tcgetpgrp(a) 	  xtcgetpgrp(a)
166# undef tcsetpgrp
167# define tcsetpgrp(a, b)  xtcsetpgrp((a), (b))
168#endif /* NEEDtcgetpgrp */
169
170#ifdef YPBUGS
171extern	void	 	  fix_yp_bugs	(void);
172#endif /* YPBUGS */
173#ifdef STRCOLLBUG
174extern	void	 	  fix_strcoll_bug	(void);
175#endif /* STRCOLLBUG */
176
177extern	void	 	  osinit	(void);
178
179#ifndef HAVE_MEMMOVE
180extern void 		*xmemmove	(void *, const void *, size_t);
181# define memmove(a, b, c) xmemmove(a, b, c)
182#endif /* !HAVE_MEMMOVE */
183
184#ifndef HAVE_MEMSET
185extern void 		*xmemset	(void *, int, size_t);
186# define memset(a, b, c) xmemset(a, b, c)
187#endif /* !HAVE_MEMSET */
188
189
190#ifndef HAVE_GETCWD
191extern	char		 *xgetcwd	(char *, size_t);
192# undef getcwd
193# define getcwd(a, b) xgetcwd(a, b)
194#endif /* !HAVE_GETCWD */
195
196#ifndef HAVE_GETHOSTNAME
197extern	int	 	  xgethostname	(char *, int);
198# undef gethostname
199# define gethostname(a, b) xgethostname(a, b)
200#endif /* !HAVE_GETHOSTNAME */
201
202#ifndef HAVE_NICE
203extern	int	 	  xnice	(int);
204# undef nice
205# define nice(a)	  xnice(a)
206#endif /* !HAVE_NICE */
207
208#ifndef HAVE_STRERROR
209extern	char	 	 *xstrerror	(int);
210# undef strerror
211# define strerror(a) 	  xstrerror(a)
212#endif /* !HAVE_STRERROR */
213
214#ifdef apollo
215extern	void		  doinlib	(Char **, struct command *);
216extern	void		  dover		(Char **, struct command *);
217extern	void		  dorootnode	(Char **, struct command *);
218extern	int		  getv		(Char *);
219#endif /* apollo */
220
221
222/*
223 * tc.printf.h
224 */
225#ifndef __GNUC__
226#define __attribute__(a)
227#endif
228extern	int		  xprintf	(const char *, ...)
229    __attribute__((__format__(__printf__, 1, 2)));
230extern	int		  xsnprintf	(char *, size_t, const char *, ...)
231    __attribute__((__format__(__printf__, 3, 4)));
232extern	char		 *xasprintf	(const char *, ...)
233    __attribute__((__format__(__printf__, 1, 2)));
234extern	int		  xvprintf	(const char *, va_list)
235    __attribute__((__format__(__printf__, 1, 0)));
236extern	int		  xvsnprintf	(char *, size_t, const char *, va_list)
237    __attribute__((__format__(__printf__, 3, 0)));
238extern	char		 *xvasprintf	(const char *, va_list)
239    __attribute__((__format__(__printf__, 1, 0)));
240
241/*
242 * tc.prompt.c
243 */
244extern	void		  dateinit	(void);
245extern	void		  printprompt	(int, const char *);
246extern  int 		  expdollar	(struct Strbuf *, const Char **, Char);
247extern	Char		 *tprintf	(int, const Char *, const char *,
248					 time_t, ptr_t);
249
250/*
251 * tc.sched.c
252 */
253extern	time_t		  sched_next	(void);
254extern	void		  dosched	(Char **, struct command *);
255extern	void		  sched_run	(void);
256
257/*
258 * tc.str.c:
259 */
260#ifdef WIDE_STRINGS
261extern	size_t		  one_mbtowc	(Char *, const char *, size_t);
262extern	size_t		  one_wctomb	(char *, Char);
263extern  int		  rt_mbtowc	(Char *, const char *, size_t);
264#else
265#define one_mbtowc(PWC, S, N) \
266	((void)(N), *(PWC) = (unsigned char)*(S), (size_t)1)
267#define one_wctomb(S, WCHAR) (*(S) = (char)(WCHAR), (size_t)1)
268#endif
269#ifdef SHORT_STRINGS
270extern	Char		 *s_strchr	(const Char *, int);
271extern	Char		 *s_strrchr	(const Char *, int);
272extern	Char		 *s_strcat	(Char *, const Char *);
273# ifdef NOTUSED
274extern	Char		 *s_strncat	(Char *, const Char *, size_t);
275# endif /* NOTUSED */
276extern	Char		 *s_strcpy	(Char *, const Char *);
277extern	Char		 *s_strncpy	(Char *, const Char *, size_t);
278extern	Char		 *s_strspl	(const Char *, const Char *);
279extern	size_t		  s_strlen	(const Char *);
280extern	int		  s_strcmp	(const Char *, const Char *);
281extern	int		  s_strncmp	(const Char *, const Char *, size_t);
282extern	int		  s_strcasecmp	(const Char *, const Char *);
283extern	Char		 *s_strnsave	(const Char *, size_t);
284extern	Char		 *s_strsave	(const Char *);
285extern	Char		 *s_strend	(const Char *);
286extern	Char		 *s_strstr	(const Char *, const Char *);
287extern	Char		 *str2short	(const char *);
288extern	Char		**blk2short	(char **);
289extern	char		 *short2str	(const Char *);
290extern	char		**short2blk	(Char **);
291#else /* !SHORT_STRINGS */
292extern	char		 *caching_strip	(const char *);
293#endif
294extern	char		 *short2qstr	(const Char *);
295
296extern  struct blk_buf   *bb_alloc	(void);
297extern	void		  bb_append	(struct blk_buf *, Char *);
298extern	void		  bb_cleanup	(void *);
299extern	Char		**bb_finish	(struct blk_buf *);
300extern  void 		  bb_free	(void *);
301
302extern	struct strbuf	 *strbuf_alloc(void);
303extern	void		  strbuf_terminate(struct strbuf *);
304extern  void		  strbuf_append1(struct strbuf *, char);
305extern  void		  strbuf_appendn(struct strbuf *, const char *,
306					 size_t);
307extern  void		  strbuf_append (struct strbuf *, const char *);
308extern  char		 *strbuf_finish (struct strbuf *);
309extern	void		  strbuf_cleanup(void *);
310extern	void		  strbuf_free(void *);
311extern	struct Strbuf	 *Strbuf_alloc(void);
312extern	void		  Strbuf_terminate(struct Strbuf *);
313extern  void		  Strbuf_append1(struct Strbuf *, Char);
314extern  void		  Strbuf_appendn(struct Strbuf *, const Char *,
315					 size_t);
316extern  void		  Strbuf_append (struct Strbuf *, const Char *);
317extern  Char		 *Strbuf_finish (struct Strbuf *);
318extern	void		  Strbuf_cleanup(void *);
319extern	void		  Strbuf_free(void *);
320
321
322/*
323 * tc.vers.c:
324 */
325extern	void		  fix_version	(void);
326
327/*
328 * tc.who.c
329 */
330#if defined (HAVE_UTMP_H) || defined (HAVE_UTMPX_H) || defined (WINNT_NATIVE)
331extern	void		  initwatch	(void);
332extern	void		  resetwatch	(void);
333extern	void		  watch_login	(int);
334extern	char	 	 *who_info	(ptr_t, int);
335extern	void		  dolog		(Char **, struct command *);
336# ifdef HAVE_STRUCT_UTMP_UT_HOST
337extern	char		 *utmphost	(void);
338extern	size_t		  utmphostsize	(void);
339# endif /* HAVE_STRUCT_UTMP_UT_HOST */
340#else
341# define HAVENOUTMP
342#endif
343
344#endif /* _h_tc_decls */
345