/* : : generated from /tmp/pkgbuild/shells/ksh93/work.sh3el/ksh-1.0.10/src/lib/libast/features/stdio by iffe version 2024-03-20 : : */
#ifndef _SFSTDIO_H
#define _SFSTDIO_H	1
#define _sys_types	1	/* #include <sys/types.h> ok */
#define __FILE_typedef	1
#define _FILE_DEFINED	1
#define _FILE_defined	1
#define _FILEDEFED	1
#define __FILE_defined  1
#define ____FILE_defined    1

#ifndef __FILE_TAG
#define __FILE_TAG	_sfio_s
#endif

#undef	FILE
#undef	_FILE
#undef	__FILE_T
#undef	fpos_t

typedef struct _sfio_s _sfio_FILE;

#define FILE		_sfio_FILE
#define _FILE		FILE

#if !defined(__FILE) && !__CYGWIN__
#undef	__FILE
#define __FILE		FILE
#endif

#if defined(_AST_H) || defined(_SFIO_H)

#define BUFSIZ		SFIO_BUFSIZE

#else

#ifndef BUFSIZ
#define BUFSIZ		8192
#endif

#ifndef EOF
#define EOF		(-1)
#endif

#ifndef SEEK_SET
#define SEEK_SET	0
#define SEEK_CUR	1
#define SEEK_END	2
#endif

#include <ast_std.h>

#include <sfio_s.h>

#define _sf_(f)		((struct _sfio_s*)(f))

#define _SFIO_EOF		0000200
#define _SFIO_ERROR	0000400

#endif

#define fpos_t		_ast_fpos_t

typedef struct _ast_fpos_s
{
	intmax_t	_sf_offset;
	unsigned char	_sf_state[64 - sizeof(intmax_t)];
} _ast_fpos_t;

#define _base		_data
#define _ptr		_next
#define _IOFBF		0
#define _IONBF		1
#define _IOLBF		2

#ifndef FILENAME_MAX
#define FILENAME_MAX	1024
#endif
#ifndef FOPEN_MAX
#define FOPEN_MAX	20
#endif
#ifndef TMP_MAX
#define TMP_MAX		308915776
#endif

#define _doprnt		_ast_doprnt
#define _doscan		_ast_doscan
#define asprintf	_ast_asprintf
#define clearerr	_ast_clearerr
#define fclose		_ast_fclose
#define fdopen		_ast_fdopen
#define fflush		_ast_fflush
#define fgetc		_ast_fgetc
#define fgetpos		_ast_fgetpos
#define fgets		_ast_fgets
#define fopen		_ast_fopen
#define fprintf		_ast_fprintf
#define fpurge		_ast_fpurge
#define fputs		_ast_fputs
#define fread		_ast_fread
#define freopen		_ast_freopen
#define fscanf		_ast_fscanf
#define fseek		_ast_fseek
#define fseeko		_ast_fseeko
#define fsetpos		_ast_fsetpos
#define ftell		_ast_ftell
#define ftello		_ast_ftello
#define fwrite		_ast_fwrite
#define gets		_ast_gets
#define getw		_ast_getw
#define pclose		_ast_pclose
#define popen		_ast_popen
#define printf		_ast_printf
#define puts		_ast_puts
#define putw		_ast_putw
#define rewind		_ast_rewind
#define scanf		_ast_scanf
#define setbuf		_ast_setbuf
#undef	setbuffer
#define setbuffer	_ast_setbuffer
#define setlinebuf	_ast_setlinebuf
#define setvbuf		_ast_setvbuf
#define snprintf	_ast_snprintf
#define sprintf		_ast_sprintf
#define sscanf		_ast_sscanf
#define tmpfile		_ast_tmpfile
#define ungetc		_ast_ungetc
#define vasprintf	_ast_vasprintf
#define vfprintf	_ast_vfprintf
#define vfscanf		_ast_vfscanf
#define vprintf		_ast_vprintf
#define vscanf		_ast_vscanf
#define vsnprintf	_ast_vsnprintf
#define vsprintf	_ast_vsprintf
#define vsscanf		_ast_vsscanf
#define fcloseall	_ast_fcloseall
#define _filbuf		_ast__filbuf
#define fmemopen	_ast_fmemopen
#define __getdelim	_ast___getdelim
#define getdelim	_ast_getdelim
#define getline		_ast_getline
#define clearerr_unlocked _ast_clearerr_unlocked
#define feof_unlocked	_ast_feof_unlocked
#define ferror_unlocked	_ast_ferror_unlocked
#define fflush_unlocked	_ast_fflush_unlocked
#define fgetc_unlocked	_ast_fgetc_unlocked
#define fgets_unlocked	_ast_fgets_unlocked
#define fileno_unlocked	_ast_fileno_unlocked
#define fputc_unlocked	_ast_fputc_unlocked
#define fputs_unlocked	_ast_fputs_unlocked
#define fread_unlocked	_ast_fread_unlocked
#define fwrite_unlocked	_ast_fwrite_unlocked
#define getc_unlocked	_ast_getc_unlocked
#define getchar_unlocked _ast_getchar_unlocked
#define putc_unlocked	_ast_putc_unlocked
#define putchar_unlocked _ast_putchar_unlocked

#ifndef P_tmpdir
#define P_tmpdir "/tmp/" /*NOCATLITERAL*/
#endif
#ifndef L_ctermid
#define L_ctermid 1024
#endif
#ifndef L_tmpnam
#define L_tmpnam 1024
#endif
extern char*	ctermid(char*);
extern char*	tmpnam(char*);
extern char*	tempnam(const char*, const char*);
extern void	perror(const char*);
#ifndef _AST_STD_H
#ifndef remove
extern int	remove(const char*);
#endif
#ifndef rename
extern int	rename(const char*, const char*);
#endif
#endif

#undef	extern

extern int	_doprnt(const char*, va_list, FILE*);
extern int	_doscan(FILE*, const char*, va_list);
extern int	asprintf(char**, const char*, ...);
extern int	clearerr(FILE*);
extern int	fclose(FILE*);
extern FILE*	fdopen(int, const char*);
extern int	feof(FILE*);
extern int	ferror(FILE*);
extern int	fflush(FILE*);
extern int	fgetc(FILE*);
extern int	fgetpos(FILE*, fpos_t*);
extern char*	fgets(char*, int, FILE*);
extern int	fileno(FILE*);
extern FILE*	fopen(const char*, const char*);
extern int	fprintf(FILE*, const char*, ...);
extern int	fpurge(FILE*);
extern int	fputc(int, FILE*);
extern int	fputs(const char*, FILE*);
extern size_t	fread(void*, size_t, size_t, FILE*);
extern FILE*	freopen(const char*, const char*, FILE*);
extern int	fscanf(FILE*, const char*, ...);
extern int	fseek(FILE*, long, int);
extern int	fseeko(FILE*, off_t, int);
extern int	fsetpos(FILE*, const fpos_t*);
extern long	ftell(FILE*);
extern off_t	ftello(FILE*);
extern size_t	fwrite(const void*, size_t, size_t, FILE*);
extern int	getc(FILE*);
extern int	getchar(void);
extern char*	gets(char*);
extern int	getw(FILE*);
extern int	pclose(FILE*);
extern FILE*	popen(const char*, const char*);
extern int	printf(const char*, ...);
extern int	putc(int, FILE*);
extern int	putchar(int);
extern int	puts(const char*);
extern int	putw(int, FILE*);
extern void	rewind(FILE*);
extern int	scanf(const char*, ...);
extern void	setbuf(FILE*, char*);
extern int	setbuffer(FILE*, char*, int);
extern int	setlinebuf(FILE*);
extern int	setvbuf(FILE*, char*, int, size_t);
extern int	snprintf(char*, int, const char*, ...);
extern int	sprintf(char*, const char*, ...);
extern int	sscanf(const char*, const char*, ...);
extern FILE*	tmpfile(void);
extern int	ungetc(int, FILE*);
extern int	vasprintf(char**, const char*, va_list);
extern int	vfprintf(FILE*, const char*, va_list);
extern int	vfscanf(FILE*, const char*, va_list);
extern int	vprintf(const char*, va_list);
extern int	vscanf(const char*, va_list);
extern int	vsnprintf(char*, int, const char*, va_list);
extern int	vsprintf(char*, const char*, va_list);
extern int	vsscanf(const char*, const char*, va_list);

extern void	clearerr_unlocked(FILE*);
extern int	feof_unlocked(FILE*);
extern int	ferror_unlocked(FILE*);
extern int	fflush_unlocked(FILE*);
extern int	fgetc_unlocked(FILE*);
extern char*	fgets_unlocked(char*, int, FILE*);
extern int	fileno_unlocked(FILE*);
extern int	fputc_unlocked(int, FILE*);
extern int	fputs_unlocked(char*, FILE*);
extern size_t	fread_unlocked(void*, size_t, size_t, FILE*);
extern size_t	fwrite_unlocked(void*, size_t, size_t, FILE*);
extern int	getc_unlocked(FILE*);
extern int	getchar_unlocked(void);
extern int	putc_unlocked(int, FILE*);
extern int	putchar_unlocked(int);

#ifdef _USE_GNU

extern int	fcloseall(void);
extern FILE*	fmemopen(void*, size_t, const char*);
extern ssize_t	__getdelim(char**, size_t*, int, FILE*);
extern ssize_t	getdelim(char**, size_t*, int, FILE*);
extern ssize_t	getline(char**, size_t*, FILE*);

#endif

#undef	extern

#if _BLD_DLL && _DLL_INDIRECT_DATA

#define stdin		((FILE*)_ast_dll->_ast_stdin)
#define stdout		((FILE*)_ast_dll->_ast_stdout)
#define stderr		((FILE*)_ast_dll->_ast_stderr)

#else

#define	stdin		(&_Sfstdin)
#define	stdout		(&_Sfstdout)
#define	stderr		(&_Sfstderr)

#endif

#if defined(_AST_H) || defined(_SFIO_H)

#define feof(f)		sfeof(f)
#define ferror(f)	sferror(f)
#define fileno(f)	sffileno(f)
#define fputc(c,f)	sfputc(f,c)
#define getc(f)		sfgetc(f)
#define getchar()	sfgetc(sfstdin)
#define putc(c,f)	sfputc(f,c)
#define putchar(c)	sfputc(sfstdout,c)

#else

extern FILE	_Sfstdin;
extern FILE	_Sfstdout;
extern FILE	_Sfstderr;

#define feof(f)		(_sf_(f)->_flags&_SFIO_EOF)
#define ferror(f)	(_sf_(f)->_flags&_SFIO_ERROR)
#define fileno(f)	(_sf_(f)->_file)
#define fputc(c,f)	(_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
#define getc(f)		(_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
#define getchar()	getc(stdin)
#define putc(c,f)	fputc(c,f)
#define putchar(c)	fputc(c,stdout)

extern int		_sffilbuf(FILE*, int);
extern int		_sfflsbuf(FILE*, int);

#endif

#endif
