1 /* @(#)schily.h	1.131 19/10/16 Copyright 1985-2018 J. Schilling */
2 /*
3  *	Definitions for libschily
4  *
5  *	This file should be included past:
6  *
7  *	schily/mconfig.h / config.h
8  *	schily/standard.h
9  *	stdio.h
10  *	stdlib.h	(better use schily/stdlib.h)
11  *	unistd.h	(better use schily/unistd.h) needed f. LARGEFILE support
12  *	schily/string.h
13  *	sys/types.h
14  *
15  *	If you need stdio.h, you must include it before schily/schily.h
16  *
17  *	NOTE: If you need ctype.h and did not include stdio.h you need to
18  *	include ctype.h past schily/schily.h as OpenBSD does not follow POSIX
19  *	and defines EOF in ctype.h
20  *
21  *	Copyright (c) 1985-2018 J. Schilling
22  */
23 /*
24  * The contents of this file are subject to the terms of the
25  * Common Development and Distribution License, Version 1.0 only
26  * (the "License").  You may not use this file except in compliance
27  * with the License.
28  *
29  * See the file CDDL.Schily.txt in this distribution for details.
30  * A copy of the CDDL is also available via the Internet at
31  * http://www.opensource.org/licenses/cddl1.txt
32  *
33  * When distributing Covered Code, include this CDDL HEADER in each
34  * file and include the License file CDDL.Schily.txt from this distribution.
35  */
36 
37 #ifndef _SCHILY_SCHILY_H
38 #define	_SCHILY_SCHILY_H
39 
40 #ifndef _SCHILY_MCONFIG_H
41 #include <schily/mconfig.h>
42 #endif
43 
44 #ifndef _SCHILY_STANDARD_H
45 #include <schily/standard.h>
46 #endif
47 #ifndef _SCHILY_CCOMDEFS_H
48 #include <schily/ccomdefs.h>
49 #endif
50 
51 #ifdef	__cplusplus
52 extern "C" {
53 #endif
54 
55 #if	defined(_INCL_SYS_TYPES_H) || defined(_INCL_TYPES_H) || defined(off_t)
56 #	ifndef	FOUND_OFF_T
57 #	define	FOUND_OFF_T
58 #	endif
59 #endif
60 #if	defined(_INCL_SYS_TYPES_H) || defined(_INCL_TYPES_H) || defined(size_t)
61 #	ifndef	FOUND_SIZE_T
62 #	define	FOUND_SIZE_T
63 #	endif
64 #endif
65 #if	defined(_MSC_VER) && !defined(_SIZE_T_DEFINED)
66 #	undef	FOUND_SIZE_T
67 #endif
68 
69 #ifdef	__never_def__
70 /*
71  * It turns out that we cannot use the folloginw definition because there are
72  * some platforms that do not behave application friendly. These are mainly
73  * BSD-4.4 based systems (which #undef a definition when size_t is available.
74  * We actually removed this code because of a problem with QNX Neutrino.
75  * For this reason, it is important not to include <sys/types.h> directly but
76  * via the Schily SING include files so we know whether it has been included
77  * before we come here.
78  */
79 #if	defined(_SIZE_T)	|| defined(_T_SIZE_)	|| defined(_T_SIZE) || \
80 	defined(__SIZE_T)	|| defined(_SIZE_T_)	|| \
81 	defined(_GCC_SIZE_T)	|| defined(_SIZET_)	|| \
82 	defined(__sys_stdtypes_h) || defined(___int_size_t_h) || defined(size_t)
83 
84 #ifndef	FOUND_SIZE_T
85 #	define	FOUND_SIZE_T	/* We already included a size_t definition */
86 #endif
87 #endif
88 #endif	/* __never_def__ */
89 
90 #if	defined(HAVE_LARGEFILES)
91 #	define	_fcons		_fcons64
92 #	define	fdup		fdup64
93 #	define	fileluopen	fileluopen64
94 #	define	fileopen	fileopen64
95 #	define	filemopen	filemopen64
96 #	define	filepos		filepos64
97 #	define	filereopen	filereopen64
98 #	define	fileseek	fileseek64
99 #	define	filesize	filesize64
100 #	define	filestat	filestat64
101 #	define	_openfd		_openfd64
102 #endif
103 
104 /*
105  * The official POSIX rule is not to define "new" interfaces that
106  * are in conflict with older interfaces of the same name.
107  * Our interfaces fexec*() have been defined and published in 1982.
108  * The new POSIX interfaces define a different interface and the
109  * new POSIX interfaces even use names that are not compatible with
110  * POSIX rules. The new POSIX interfaces in question should be called
111  * fdexec*() to follow the rules of other similar POSIX functions.
112  * Simiar problems exist with getline()/fgetline().
113  */
114 #if	defined(HAVE_RAW_FEXECL) || defined(HAVE_RAW_FEXECLE) || \
115 	defined(HAVE_RAW_FEXECV) || defined(HAVE_RAW_FEXECVE)
116 #define	RENAME_FEXEC
117 #endif
118 #if	defined(HAVE_RAW_FSPAWNV) || defined(HAVE_RAW_FSPAWNL) || \
119 	defined(HAVE_RAW_FSPAWNV_NOWAIT)
120 #define	RENAME_FSPAWN
121 #endif
122 #if	defined(HAVE_RAW_GETLINE) || defined(HAVE_RAW_FGETLINE)
123 #define	RENAME_GETLINE
124 #endif
125 
126 #ifdef	__needed__
127 #define	RENAME_FEXEC
128 #define	RENAME_FSPAWN
129 #define	RENAME_GETLINE
130 #endif
131 
132 #if	defined(RENAME_FEXEC) || defined(RENAME_FSPAWN)
133 #ifndef	_SCHILY_UNISTD_H
134 #include <schily/unistd.h>	/* Need to incl. before fexec*() protoypes */
135 #endif
136 #endif
137 
138 #if	defined(RENAME_GETLINE)
139 #ifndef _SCHILY_STDIO_H
140 #include <schily/stdio.h>	/* Need to incl. before *getline() protoypes */
141 #endif
142 
143 #endif
144 
145 #ifdef	EOF	/* stdio.h has been included */
146 
147 extern	int	_cvmod __PR((const char *, int *, int *));
148 extern	FILE	*_fcons __PR((FILE *, int, int));
149 extern	FILE	*fdup __PR((FILE *));
150 #if	!defined(fdown) || defined(PROTOTYPES)
151 /*
152  * We cannot declare fdown() with K&R in case that fdown() has been #define'd
153  */
154 extern	int	fdown __PR((FILE *));
155 #endif
156 extern	int	js_fexecl __PR((const char *, FILE *, FILE *, FILE *,
157 							const char *, ...));
158 extern	int	js_fexecle __PR((const char *, FILE *, FILE *, FILE *,
159 							const char *, ...));
160 		/* 6th arg not const, fexecv forces av[ac] = NULL */
161 extern	int	js_fexecv __PR((const char *, FILE *, FILE *, FILE *, int,
162 							char **));
163 extern	int	js_fexecve __PR((const char *, FILE *, FILE *, FILE *,
164 					char * const *, char * const *));
165 extern	int	js_fspawnv __PR((FILE *, FILE *, FILE *, int, char * const *));
166 extern	int	js_fspawnl __PR((FILE *, FILE *, FILE *, const char *, ...));
167 extern	int	js_fspawnv_nowait __PR((FILE *, FILE *, FILE *,
168 					const char *, int, char *const*));
169 extern	int	js_fgetline __PR((FILE *, char *, int));
170 #ifdef	FOUND_SIZE_T
171 extern	ssize_t	fgetaline __PR((FILE *, char **, size_t *));
172 extern	ssize_t	getaline __PR((char **, size_t *));
173 #endif
174 extern	int	fgetstr __PR((FILE *, char *, int));
175 extern	int	file_getraise __PR((FILE *));
176 extern	void	file_raise __PR((FILE *, int));
177 extern	int	fileclose __PR((FILE *));
178 extern	FILE	*fileluopen __PR((int, const char *));
179 extern	FILE	*fileopen __PR((const char *, const char *));
180 #ifdef	_SCHILY_TYPES_H
181 extern	FILE	*filemopen __PR((const char *, const char *, mode_t));
182 #endif
183 #ifdef	FOUND_OFF_T
184 extern	off_t	filepos __PR((FILE *));
185 #endif
186 #ifdef	FOUND_SIZE_T
187 extern	ssize_t	fileread __PR((FILE *, void *, size_t));
188 extern	ssize_t	ffileread __PR((FILE *, void *, size_t));
189 #endif
190 extern	FILE	*filereopen __PR((const char *, const char *, FILE *));
191 #ifdef	FOUND_OFF_T
192 extern	int	fileseek __PR((FILE *, off_t));
193 extern	off_t	filesize __PR((FILE *));
194 #endif
195 #ifdef	S_IFMT
196 extern	int	filestat __PR((FILE *, struct stat *));
197 #endif
198 #ifdef	FOUND_SIZE_T
199 extern	ssize_t	filewrite __PR((FILE *, void *, size_t));
200 extern	ssize_t	ffilewrite __PR((FILE *, void *, size_t));
201 #endif
202 extern	int	flush __PR((void));
203 extern	int	fpipe __PR((FILE **));
204 #ifdef	__never__
205 extern	int	fprintf __PR((FILE *, const char *, ...)) __printflike__(2, 3);
206 #endif
207 extern	int	getbroken __PR((FILE *, char *, char, char **, int));
208 extern	int	ofindline __PR((FILE *, char, const char *, int,
209 							char **, int));
210 extern	int	peekc __PR((FILE *));
211 
212 #ifdef	__never_def__
213 /*
214  * We cannot define this or we may get into problems with DOS based systems.
215  */
216 extern	int	spawnv __PR((FILE *, FILE *, FILE *, int, char * const *));
217 extern	int	spawnl __PR((FILE *, FILE *, FILE *, const char *, ...));
218 extern	int	spawnv_nowait __PR((FILE *, FILE *, FILE *,
219 					const char *, int, char *const*));
220 #endif	/* __never_def__ */
221 #endif	/* EOF */
222 
223 /*
224  * Flags for absfpath() and resolvefpath():
225  */
226 #define	RSPF_EXIST		0x01	/* All path components must exist    */
227 #define	RSPF_NOFOLLOW_LAST	0x02	/* Don't follow link in last pathcomp */
228 
229 #ifdef	FOUND_SIZE_T
230 extern	char	*abspath __PR((const char *relp, char *absp, size_t asize));
231 extern	char	*absnpath __PR((const char *relp, char *absp, size_t asize));
232 extern	char	*absfpath __PR((const char *relp, char *absp, size_t asize,
233 				int __flags));
234 #ifndef	HAVE_RESOLVEPATH
235 extern	int	resolvepath __PR((const char *__path,
236 				char *__buf, size_t __bufsiz));
237 #endif
238 extern	int	resolvenpath __PR((const char *__path,
239 				char *__buf, size_t __bufsiz));
240 extern	int	resolvefpath __PR((const char *__path,
241 				char *__buf, size_t __bufsiz, int __flags));
242 #endif
243 
244 #ifdef	_SCHILY_TYPES_H
245 extern	int	mkdirs __PR((char *, mode_t));
246 extern	int	makedirs __PR((char *, mode_t, int __striplast));
247 #endif
248 
249 extern	int	lxchdir	__PR((char *));
250 #ifdef	HAVE_FCHDIR
251 #define	fdsetname(fd, name)	(0)
252 #define	fdclosename(fd)		(0)
253 #else
254 extern	int	fdsetname __PR((int fd, const char *name));
255 extern	int	fdclosename __PR((int fd));
256 #endif
257 extern	int	diropen __PR((const char *));
258 extern	int	dirrdopen __PR((const char *));
259 extern	int	dirclose __PR((int));
260 
261 struct save_wd {
262 	int	fd;
263 	char	*name;
264 };
265 
266 extern int	savewd	__PR((struct save_wd *sp));
267 extern void	closewd	__PR((struct save_wd *sp));
268 extern int	restorewd __PR((struct save_wd *sp));
269 
270 
271 #ifdef	_SCHILY_UTYPES_H
272 typedef struct gnmult {
273 	char	key;
274 	Llong	mult;
275 } gnmult_t;
276 
277 extern	int	getllnum __PR((char *arg, Llong *lvalp));
278 extern	int	getxnum	 __PR((char *arg, long *valp, gnmult_t *mult));
279 extern	int	getllxnum __PR((char *arg, Llong *lvalp, gnmult_t *mult));
280 
281 extern	int	getlltnum  __PR((char *arg, Llong *lvalp));
282 extern	int	getxtnum  __PR((char *arg, time_t *valp, gnmult_t *mult));
283 extern	int	getllxtnum __PR((char *arg, Llong *lvalp, gnmult_t *mult));
284 #endif
285 extern	int	getnum	__PR((char *arg, long *valp));
286 #ifdef	_SCHILY_TIME_H
287 extern	int	gettnum	__PR((char *arg, time_t *valp));
288 #endif
289 
290 #ifdef	_SCHILY_TIME_H
291 
292 extern	int		getnstimeofday	__PR((struct timespec *__tp));
293 extern	int		setnstimeofday	__PR((struct timespec *__tp));
294 
295 #ifdef	_SCHILY_UTYPES_H
296 extern	Llong		mklgmtime	__PR((struct tm *));
297 #endif
298 extern	time_t		mkgmtime	__PR((struct tm *));
299 #endif
300 
301 
302 #ifdef	EOF			/* stdio.h has been included */
303 #ifdef	_SCHILY_TYPES_H
304 /*
305  * getperm() flags:
306  */
307 #define	GP_NOX		0	/* This is not a dir and 'X' is not valid */
308 #define	GP_DOX		1	/* 'X' perm character is valid		  */
309 #define	GP_XERR		2	/* 'X' perm characters are invalid	  */
310 #define	GP_FPERM	4	/* TRUE if we implement find -perm	  */
311 #define	GP_UMASK	8	/* TRUE if we implement umask		  */
312 
313 extern	int	getperm	__PR((FILE *f, char *perm, char *opname,
314 				mode_t *modep, int smode, int flag));
315 extern	void	permtostr	__PR((mode_t mode, char *));
316 #endif
317 #endif
318 
319 #ifdef	FOUND_SIZE_T
320 extern	ssize_t	_niread __PR((int, void *, size_t));
321 extern	ssize_t	_niwrite __PR((int, void *, size_t));
322 extern	ssize_t	_nixread __PR((int, void *, size_t));
323 extern	ssize_t	_nixwrite __PR((int, void *, size_t));
324 #endif
325 extern	int	_openfd __PR((const char *, int));
326 extern	int	on_comerr __PR((void (*fun)(int, void *), void *arg));
327 /*PRINTFLIKE1*/
328 extern	void	comerr __PR((const char *, ...)) __printflike__(1, 2);
329 /*PRINTFLIKE2*/
330 extern	void	xcomerr	 __PR((int, const char *, ...)) __printflike__(2, 3);
331 /*PRINTFLIKE2*/
332 extern	void	comerrno __PR((int, const char *, ...)) __printflike__(2, 3);
333 /*PRINTFLIKE3*/
334 extern	void	xcomerrno __PR((int, int, const char *, ...)) __printflike__(3, 4);
335 /*PRINTFLIKE1*/
336 extern	int	errmsg __PR((const char *, ...)) __printflike__(1, 2);
337 /*PRINTFLIKE2*/
338 extern	int	errmsgno __PR((int, const char *, ...)) __printflike__(2, 3);
339 #ifdef	FOUND_SIZE_T
340 /*PRINTFLIKE3*/
341 extern	int	serrmsg __PR((char *, size_t, const char *, ...))
342 					__printflike__(3, 4);
343 /*PRINTFLIKE4*/
344 extern	int	serrmsgno __PR((int, char *, size_t, const char *, ...))
345 					__printflike__(4, 5);
346 #endif
347 extern	void	comexit	__PR((int));
348 extern	char	*errmsgstr __PR((int));
349 
350 /*PRINTFLIKE1*/
351 extern	void	gtcomerr __PR((const char *, ...)) __printflike__(1, 2);
352 /*PRINTFLIKE2*/
353 extern	void	gtxcomerr __PR((int, const char *, ...)) __printflike__(2, 3);
354 /*PRINTFLIKE2*/
355 extern	void	gtcomerrno __PR((int, const char *, ...)) __printflike__(2, 3);
356 /*PRINTFLIKE3*/
357 extern	void	gtxcomerrno __PR((int, int, const char *, ...)) __printflike__(3, 4);
358 /*PRINTFLIKE1*/
359 extern	int	gterrmsg __PR((const char *, ...)) __printflike__(1, 2);
360 /*PRINTFLIKE2*/
361 extern	int	gterrmsgno __PR((int, const char *, ...)) __printflike__(2, 3);
362 
363 #ifdef	GT_COMERR
364 #define	comerr		gtcomerr
365 #define	xcomerr		gtxcomerr
366 #define	comerrno	gtcomerrno
367 #define	xcomerrno	gtxcomerrno
368 #define	errmsg		gterrmsg
369 #define	errmsgno	gterrmsgno
370 #endif
371 
372 #ifdef	EOF	/* stdio.h has been included */
373 /*PRINTFLIKE2*/
374 extern	void	fcomerr		__PR((FILE *, const char *, ...))
375 					__printflike__(2, 3);
376 /*PRINTFLIKE3*/
377 extern	void	fxcomerr	__PR((FILE *, int, const char *, ...))
378 					__printflike__(3, 4);
379 /*PRINTFLIKE3*/
380 extern	void	fcomerrno	__PR((FILE *, int, const char *, ...))
381 					__printflike__(3, 4);
382 /*PRINTFLIKE4*/
383 extern	void	fxcomerrno	__PR((FILE *, int, int, const char *, ...))
384 					__printflike__(4, 5);
385 /*PRINTFLIKE2*/
386 extern	int	ferrmsg		__PR((FILE *, const char *, ...))
387 					__printflike__(2, 3);
388 /*PRINTFLIKE3*/
389 extern	int	ferrmsgno	__PR((FILE *, int, const char *, ...))
390 					__printflike__(3, 4);
391 
392 /*PRINTFLIKE2*/
393 extern	void	fgtcomerr	__PR((FILE *, const char *, ...))
394 					__printflike__(2, 3);
395 /*PRINTFLIKE3*/
396 extern	void	fgtxcomerr	__PR((FILE *, int, const char *, ...))
397 					__printflike__(3, 4);
398 /*PRINTFLIKE3*/
399 extern	void	fgtcomerrno	__PR((FILE *, int, const char *, ...))
400 					__printflike__(3, 4);
401 /*PRINTFLIKE4*/
402 extern	void	fgtxcomerrno	__PR((FILE *, int, int, const char *, ...))
403 					__printflike__(4, 5);
404 /*PRINTFLIKE2*/
405 extern	int	fgterrmsg	__PR((FILE *, const char *, ...))
406 					__printflike__(2, 3);
407 /*PRINTFLIKE3*/
408 extern	int	fgterrmsgno	__PR((FILE *, int, const char *, ...))
409 					__printflike__(3, 4);
410 
411 #ifdef	GT_COMERR
412 #define	fcomerr		fgtcomerr
413 #define	fxcomerr	fgtxcomerr
414 #define	fcomerrno	fgtcomerrno
415 #define	fxcomerrno	fgtxcomerrno
416 #define	ferrmsg		fgterrmsg
417 #define	ferrmsgno	fgterrmsgno
418 #endif
419 
420 #ifdef	_SCHILY_VARARGS_H
421 /*
422  * Definitions for the second _comerr() parameter:
423  */
424 #define	COMERR_RETURN	0	/* Do not exit, return only		*/
425 #define	COMERR_EXIT	1	/* Exit program, map (X % 256) != X to -64 */
426 #define	COMERR_EXCODE	2	/* Exit program, do not map exit codes	*/
427 /*PRINTFLIKE5*/
428 extern	int	_comerr		__PR((FILE *, int, int, int,
429 						const char *, va_list));
430 #endif	/* _SCHILY_VARARGS_H */
431 #endif	/* EOF */
432 
433 /*PRINTFLIKE1*/
434 extern	int	error __PR((const char *, ...)) __printflike__(1, 2);
435 /*PRINTFLIKE1*/
436 extern	int	gterror __PR((const char *, ...)) __printflike__(1, 2);
437 
438 #ifdef	GT_ERROR
439 #undef	error
440 #define	error		gterror
441 #endif
442 
443 #ifdef	FOUND_SIZE_T
444 extern	char	*fillbytes __PR((void *, ssize_t, char));
445 extern	char	*zerobytes __PR((void *, ssize_t));
446 extern	char	*findbytes __PR((const void *, ssize_t, char));
447 #endif
448 extern	char	*findinpath __PR((char *__name, int __mode,
449 					BOOL __plain_file, char *__path));
450 extern	int	findline __PR((const char *, char, const char *,
451 							int, char **, int));
452 extern	int	js_getline __PR((char *, int));
453 extern	int	getstr __PR((char *, int));
454 extern	int	breakline __PR((char *, char, char **, int));
455 extern	int	getallargs __PR((int *, char * const**, const char *, ...));
456 extern	int	getargs __PR((int *, char * const**, const char *, ...));
457 extern	int	getfiles __PR((int *, char * const**, const char *));
458 extern	char	*astoi __PR((const char *, int *));
459 extern	char	*astol __PR((const char *, long *));
460 extern	char	*astolb __PR((const char *, long *, int base));
461 #ifdef	_SCHILY_UTYPES_H
462 extern	char	*astoll __PR((const char *, Llong *));
463 extern	char	*astollb __PR((const char *, Llong *, int));
464 extern	char	*astoull __PR((const char *, Ullong *));
465 extern	char	*astoullb __PR((const char *, Ullong *, int));
466 #endif
467 
468 extern	int		patcompile __PR((const unsigned char *, int, int *));
469 extern	unsigned char	*patmatch __PR((const unsigned char *, const int *,
470 					const unsigned char *,
471 					int, int, int, int[]));
472 extern	unsigned char	*patlmatch __PR((const unsigned char *, const int *,
473 					const unsigned char *,
474 					int, int, int, int[]));
475 
476 #ifdef	__never__
477 extern	int	printf __PR((const char *, ...)) __printflike__(1, 2);
478 #endif
479 #ifdef	FOUND_SIZE_T
480 extern	char	*movebytes __PR((const void *, void *, ssize_t));
481 extern	char	*movecbytes __PR((const void *, void *, int, size_t));
482 #endif
483 
484 extern	void	save_args __PR((int, char **));
485 extern	int	saved_ac __PR((void));
486 extern	char	**saved_av __PR((void));
487 extern	char	*saved_av0 __PR((void));
488 extern	char	*searchfileinpath __PR((char *__name, int __mode,
489 					int __file_mode, char *__path));
490 #define	SIP_ANY_FILE	0x00	/* Search for any file type		*/
491 #define	SIP_PLAIN_FILE	0x01	/* Search for plain files - not dirs	*/
492 #define	SIP_NO_PATH	0x10	/* Do not do PATH search		*/
493 #define	SIP_ONLY_PATH	0x20	/* Do only PATH search			*/
494 #define	SIP_NO_STRIPBIN	0x40	/* Do not strip "/bin" from PATH elem.	*/
495 #define	SIP_TYPE_MASK	0x0F	/* Mask file type related bits		*/
496 
497 #ifndef	seterrno
498 extern	int	seterrno __PR((int));
499 #endif
500 extern	void	set_progname __PR((const char *));
501 extern	char	*get_progname __PR((void));
502 extern	char	*get_progpath __PR((void));
503 extern	char	*getexecpath __PR((void));
504 
505 extern	void	setfp __PR((void * const *));
506 extern	int	wait_chld __PR((int));		/* for fspawnv_nowait() */
507 extern	int	geterrno __PR((void));
508 extern	void	raisecond __PR((const char *, long));
509 #ifdef	__never__
510 /*
511  * sprintf() may be declared incorrectly somewhere else
512  * e.g. in old BSD include files
513  */
514 extern	int	sprintf __PR((char *, const char *, ...));
515 #endif
516 extern	char	*ovstrcpy __PR((char *, const char *));
517 extern	char	*strcatl __PR((char *, ...));
518 #ifdef	FOUND_SIZE_T
519 extern	size_t	strlcatl __PR((char *, size_t, ...));
520 #endif
521 extern	int	streql __PR((const char *, const char *));
522 #ifdef	_SCHILY_WCHAR_H
523 extern	wchar_t	*wcscatl __PR((wchar_t *, ...));
524 #ifdef	FOUND_SIZE_T
525 extern	size_t	wcslcatl __PR((wchar_t *, size_t, ...));
526 #endif
527 extern	int	wcseql __PR((const wchar_t *, const wchar_t *));
528 #endif
529 #ifdef	va_arg
530 extern	int	format __PR((void (*)(char, void *), void *, const char *,
531 							va_list));
532 extern	int	fprformat __PR((void *, const char *, va_list));
533 #else
534 extern	int	format __PR((void (*)(char, void *), void *, const char *, void *));
535 extern	int	fprformat __PR((void *, const char *, void *));
536 #endif
537 
538 extern	int	ftoes __PR((char *, double, int, int));
539 extern	int	ftofs __PR((char *, double, int, int));
540 #ifdef	HAVE_LONGDOUBLE
541 extern	int	qftoes __PR((char *, long double, int, int));
542 extern	int	qftofs __PR((char *, long double, int, int));
543 #endif
544 
545 /*PRINTFLIKE1*/
546 extern	int	js_error __PR((const char *, ...)) __printflike__(1, 2);
547 /*PRINTFLIKE2*/
548 extern	int	js_dprintf	__PR((int, const char *, ...))
549 							__printflike__(2, 3);
550 #ifdef	EOF	/* stdio.h has been included */
551 /*PRINTFLIKE2*/
552 extern	int	js_fprintf	__PR((FILE *, const char *, ...))
553 							__printflike__(2, 3);
554 #endif	/* EOF */
555 /*PRINTFLIKE1*/
556 extern	int	js_printf	__PR((const char *, ...)) __printflike__(1, 2);
557 #ifdef	FOUND_SIZE_T
558 /*PRINTFLIKE3*/
559 extern	int	js_snprintf	__PR((char *, size_t, const char *, ...))
560 							__printflike__(3, 4);
561 #endif
562 /*PRINTFLIKE2*/
563 extern	int	js_sprintf	__PR((char *, const char *, ...))
564 							__printflike__(2, 3);
565 
566 #ifdef	EOF	/* stdio.h has been included */
567 /*PRINTFLIKE2*/
568 extern	int	fgtprintf	__PR((FILE *, const char *, ...))
569 							__printflike__(2, 3);
570 #endif	/* EOF */
571 /*PRINTFLIKE1*/
572 extern	int	gtprintf	__PR((const char *, ...)) __printflike__(1, 2);
573 
574 #ifdef	FOUND_SIZE_T
575 extern	void	swabbytes	__PR((void *, ssize_t));
576 #endif
577 extern	char	**getmainfp	__PR((void));
578 extern	char	**getavp	__PR((void));
579 extern	char	*getav0		__PR((void));
580 extern	void	**getfp		__PR((void));
581 extern	int	flush_reg_windows __PR((int));
582 #ifdef	FOUND_SIZE_T
583 extern	ssize_t	cmpbytes	__PR((const void *, const void *, ssize_t));
584 extern	int	cmpmbytes	__PR((const void *, const void *, ssize_t));
585 extern	ssize_t	cmpnullbytes	__PR((const void *, ssize_t));
586 #endif
587 
588 #ifdef	nonono
589 #if	defined(HAVE_LARGEFILES)
590 /*
591  * To allow this, we need to figure out how to do autoconfiguration for off64_t
592  */
593 extern	FILE	*_fcons64	__PR((FILE *, int, int));
594 extern	FILE	*fdup64		__PR((FILE *));
595 extern	FILE	*fileluopen64	__PR((int, const char *));
596 extern	FILE	*fileopen64	__PR((const char *, const char *));
597 #ifdef	FOUND_OFF_T
598 extern	off64_t	filepos64	__PR((FILE *));
599 #endif
600 extern	FILE	*filereopen64	__PR((const char *, const char *, FILE *));
601 #ifdef	FOUND_OFF_T
602 extern	int	fileseek64	__PR((FILE *, off64_t));
603 extern	off64_t	filesize64	__PR((FILE *));
604 #endif
605 #ifdef	S_IFMT
606 extern	int	filestat64	__PR((FILE *, struct stat *));
607 #endif
608 extern	int	_openfd64	__PR((const char *, int));
609 #endif
610 #endif
611 
612 #ifndef	NO_SCHILY_PRINT		/* Define to disable *printf() redirects */
613 #ifdef	SCHILY_PRINT
614 #ifdef	__never__
615 #ifndef	GT_ERROR
616 #undef	error
617 #define	error		js_error
618 #endif
619 #endif	/* __never__ */
620 #undef	dprintf
621 #define	dprintf		js_dprintf
622 #undef	fprintf
623 #define	fprintf		js_fprintf
624 #undef	printf
625 #define	printf		js_printf
626 #undef	snprintf
627 #define	snprintf	js_snprintf
628 #undef	sprintf
629 #define	sprintf		js_sprintf
630 #else
631 #ifndef	HAVE_SNPRINTF
632 #undef	snprintf
633 #define	snprintf	js_snprintf
634 #endif	/* HAVE_SNPRINTF */
635 #endif	/* SCHILY_PRINT */
636 #endif	/* NO_SCHILY_PRINT */
637 
638 #ifndef	NO_SCHILY_GETLINE	/* Define to disable *getline() redirect */
639 #undef	getline
640 #define	getline		js_getline
641 #undef	fgetline
642 #define	fgetline	js_fgetline
643 #endif
644 
645 #ifndef	NO_SCHILY_FEXEC		/* Define to disable fexec*() redirect */
646 #undef	fexecl
647 #define	fexecl		js_fexecl
648 #undef	fexecle
649 #define	fexecle		js_fexecle
650 #undef	fexecv
651 #define	fexecv		js_fexecv
652 #undef	fexecve
653 #define	fexecve		js_fexecve
654 #endif
655 
656 #ifndef	NO_SCHILY_FSPAWN	/* Define to disable fspawn*() redirect */
657 #undef	fspawnv
658 #define	fspawnv		js_fspawnv
659 #undef	fspawnv_nowait
660 #define	fspawnv_nowait	js_fspawnv_nowait
661 #undef	fspawnl
662 #define	fspawnl		js_fspawnl
663 #endif
664 
665 extern	int	js_mexval	__PR((int exval));
666 #ifdef	FOUND_SIZE_T
667 extern	void	*js_malloc	__PR((size_t size, char *msg));
668 extern	void	*js_realloc	__PR((void *ptr, size_t size, char *msg));
669 #endif
670 extern	char	*js_savestr	__PR((const char *s));
671 
672 #ifdef	_SCHILY_JMPDEFS_H
673 
674 /*
675  * Special values for the "jmp" parameter.
676  *
677  * Control how the siglongjmp() should be handled:
678  */
679 #define	JM_EXIT		((sigjmps_t *)-1) /* Call comexit(errno) instead */
680 #define	JM_RETURN	((sigjmps_t *)0)  /* Return instead		 */
681 
682 extern	int	js_jmexval	__PR((int exval));
683 #ifdef	FOUND_SIZE_T
684 extern	void	*js_jmalloc	__PR((size_t size, char *msg, sigjmps_t *jmp));
685 extern	void	*js_jrealloc	__PR((void *ptr, size_t size, char *msg,
686 							sigjmps_t *jmp));
687 #endif
688 extern	char	*js_jsavestr	__PR((const char *s, sigjmps_t *jmp));
689 
690 extern	int	js_fjmexval	__PR((int exval));
691 #ifdef	EOF	/* stdio.h has been included */
692 #ifdef	FOUND_SIZE_T
693 extern	void	*js_fjmalloc	__PR((FILE *f, size_t size, char *msg,
694 						sigjmps_t *jmp));
695 extern	void	*js_fjrealloc	__PR((FILE *f, void *ptr, size_t size,
696 						char *msg, sigjmps_t *jmp));
697 #endif
698 extern	char	*js_fjsavestr	__PR((FILE *f, const char *s, sigjmps_t *jmp));
699 #endif	/* EOF */
700 #endif	/* _SCHILY_JMPDEFS_H */
701 
702 #define	___mexval	js_mexval
703 #define	___malloc	js_malloc
704 #define	___realloc	js_realloc
705 #define	___savestr	js_savestr
706 #define	__jmexval	js_jmexval
707 #define	__jmalloc	js_jmalloc
708 #define	__jrealloc	js_jrealloc
709 #define	__jsavestr	js_jsavestr
710 #define	__fjmalloc	js_fjmalloc
711 #define	__fjmexval	js_fjmexval
712 #define	__fjrealloc	js_fjrealloc
713 #define	__fjsavestr	js_fjsavestr
714 
715 #ifdef	__cplusplus
716 }
717 #endif
718 
719 #if defined(_JOS) || defined(JOS)
720 #	ifndef	_SCHILY_JOS_IO_H
721 #	include <schily/jos_io.h>
722 #	endif
723 #endif
724 
725 #if !defined(_SCHILY_LIBPORT_H) && !defined(NO_LIBPORT_H)
726 #include <schily/libport.h>
727 #endif
728 #if !defined(_SCHILY_HOSTNAME_H) && defined(USE_HOSTNAME_H)
729 #include <schily/hostname.h>
730 #endif
731 
732 #endif	/* _SCHILY_SCHILY_H */
733