// D import file generated from '../../../../libphobos/libdruntime/core/stdc/stdio.d'
module core.stdc.stdio;
private 
{
	import core.stdc.config;
	import core.stdc.stddef;
	import core.stdc.stdarg;
	version (FreeBSD)
	{
		import core.sys.posix.sys.types;
	}
}
extern (C) @system nothrow 
{
	version (Win32)
	{
		enum 
		{
			BUFSIZ = 16384,
			EOF = -1,
			FOPEN_MAX = 20,
			FILENAME_MAX = 256,
			TMP_MAX = 32767,
			SYS_OPEN = 20,
		}
		enum int _NFILE = 60;
		enum string _P_tmpdir = "\\";
		enum wstring _wP_tmpdir = "\\";
		enum int L_tmpnam = _P_tmpdir.length + 12;
	}
	else
	{
		version (Win64)
		{
			enum 
			{
				BUFSIZ = 512,
				EOF = -1,
				FOPEN_MAX = 20,
				FILENAME_MAX = 260,
				TMP_MAX = 32767,
				_SYS_OPEN = 20,
			}
			enum int _NFILE = 512;
			enum string _P_tmpdir = "\\";
			enum wstring _wP_tmpdir = "\\";
			enum int L_tmpnam = _P_tmpdir.length + 12;
		}
		else
		{
			version (linux)
			{
				enum 
				{
					BUFSIZ = 8192,
					EOF = -1,
					FOPEN_MAX = 16,
					FILENAME_MAX = 4095,
					TMP_MAX = 238328,
					L_tmpnam = 20,
				}
			}
			else
			{
				version (OSX)
				{
					enum 
					{
						BUFSIZ = 1024,
						EOF = -1,
						FOPEN_MAX = 20,
						FILENAME_MAX = 1024,
						TMP_MAX = 308915776,
						L_tmpnam = 1024,
					}
					private 
					{
						struct __sbuf
						{
							ubyte* _base;
							int _size;
						}
						struct __sFILEX
						{
						}
					}
				}
				else
				{
					version (FreeBSD)
					{
						enum 
						{
							BUFSIZ = 1024,
							EOF = -1,
							FOPEN_MAX = 20,
							FILENAME_MAX = 1024,
							TMP_MAX = 308915776,
							L_tmpnam = 1024,
						}
						struct __sbuf
						{
							ubyte* _base;
							int _size;
						}
						alias _iobuf __sFILE;
						union __mbstate_t
						{
							char[128] _mbstate8;
							long _mbstateL;
						}
					}
					else
					{
						version (Solaris)
						{
							enum 
							{
								BUFSIZ = 1024,
								EOF = -1,
								FOPEN_MAX = _NFILE,
								FILENAME_MAX = 1024,
								TMP_MAX = 17576,
								L_tmpnam = 25,
							}
							version (X86)
							{
								enum int _NFILE = 60;
							}
							else
							{
								enum int _NFILE = 20;
							}
						}
						else
						{
							static assert(false,"Unsupported platform");
						}
					}
				}
			}
		}
	}
	enum 
	{
		SEEK_SET,
		SEEK_CUR,
		SEEK_END,
	}
	version (Win32)
	{
		struct _iobuf
		{
			char* _ptr;
			int _cnt;
			char* _base;
			int _flag;
			int _file;
			int _charbuf;
			int _bufsiz;
			char* __tmpnum;
		}
	}
	else
	{
		version (Win64)
		{
			struct _iobuf
			{
				char* _ptr;
				int _cnt;
				char* _base;
				int _flag;
				int _file;
				int _charbuf;
				int _bufsiz;
				char* _tmpfname;
			}
		}
		else
		{
			version (linux)
			{
				align (1)struct _iobuf
				{
					int _flags;
					char* _read_ptr;
					char* _read_end;
					char* _read_base;
					char* _write_base;
					char* _write_ptr;
					char* _write_end;
					char* _buf_base;
					char* _buf_end;
					char* _save_base;
					char* _backup_base;
					char* _save_end;
					void* _markers;
					_iobuf* _chain;
					int _fileno;
					int _blksize;
					int _old_offset;
					ushort _cur_column;
					byte _vtable_offset;
					char[1] _shortbuf;
					void* _lock;
				}

			}
			else
			{
				version (OSX)
				{
					align (1)struct _iobuf
					{
						ubyte* _p;
						int _r;
						int _w;
						short _flags;
						short _file;
						__sbuf _bf;
						int _lbfsize;
						int* function(void*) _close;
						int* function(void*, char*, int) _read;
						fpos_t* function(void*, fpos_t, int) _seek;
						int* function(void*, char*, int) _write;
						__sbuf _ub;
						__sFILEX* _extra;
						int _ur;
						ubyte[3] _ubuf;
						ubyte[1] _nbuf;
						__sbuf _lb;
						int _blksize;
						fpos_t _offset;
					}

				}
				else
				{
					version (FreeBSD)
					{
						align (1)struct _iobuf
						{
							ubyte* _p;
							int _r;
							int _w;
							short _flags;
							short _file;
							__sbuf _bf;
							int _lbfsize;
							void* _cookie;
							int function(void*) _close;
							int function(void*, char*, int) _read;
							fpos_t function(void*, fpos_t, int) _seek;
							int function(void*, in char*, int) _write;
							__sbuf _ub;
							ubyte* _up;
							int _ur;
							ubyte[3] _ubuf;
							ubyte[1] _nbuf;
							__sbuf _lb;
							int _blksize;
							fpos_t _offset;
							pthread_mutex_t _fl_mutex;
							pthread_t _fl_owner;
							int _fl_count;
							int _orientation;
							__mbstate_t _mbstate;
						}

					}
					else
					{
						version (Solaris)
						{
							align (1)struct _iobuf
							{
								char* _ptr;
								int _cnt;
								char* _base;
								char _flag;
								char _magic;
								ushort __flags;
							}

						}
						else
						{
							static assert(false,"Unsupported platform");
						}
					}
				}
			}
		}
	}
	alias shared(_iobuf) FILE;
	enum 
	{
		_F_RDWR = 3,
		_F_READ = 1,
		_F_WRIT = 2,
		_F_BUF = 4,
		_F_LBUF = 8,
		_F_ERR = 16,
		_F_EOF = 32,
		_F_BIN = 64,
		_F_IN = 128,
		_F_OUT = 256,
		_F_TERM = 512,
	}
	version (Win32)
	{
		enum 
		{
			_IOFBF = 0,
			_IOLBF = 64,
			_IONBF = 4,
			_IOREAD = 1,
			_IOWRT = 2,
			_IOMYBUF = 8,
			_IOEOF = 16,
			_IOERR = 32,
			_IOSTRG = 64,
			_IORW = 128,
			_IOTRAN = 256,
			_IOAPP = 512,
		}
		version (MinGW)
		{
			private extern __gshared export FILE[5] _iob;




			__gshared FILE* stdin;

			__gshared FILE* stdout;

			__gshared FILE* stderr;

			shared static this();
		}
		else
		{
			extern shared void function() _fcloseallp;

			private extern shared FILE[_NFILE] _iob;


			shared stdin = &_iob[0];
			shared stdout = &_iob[1];
			shared stderr = &_iob[2];
			shared stdaux = &_iob[3];
			shared stdprn = &_iob[4];
		}
	}
	else
	{
		version (Win64)
		{
			enum 
			{
				_IOFBF = 0,
				_IOLBF = 64,
				_IONBF = 4,
				_IOREAD = 1,
				_IOWRT = 2,
				_IOMYBUF = 8,
				_IOEOF = 16,
				_IOERR = 32,
				_IOSTRG = 64,
				_IORW = 128,
				_IOAPP = 512,
				_IOAPPEND = 512,
			}
			extern shared void function() _fcloseallp;

			private extern shared FILE[_NFILE] _iob;


			shared(FILE)* __iob_func();
			shared FILE* stdin;

			shared FILE* stdout;

			shared FILE* stderr;

		}
		else
		{
			version (linux)
			{
				enum 
				{
					_IOFBF = 0,
					_IOLBF = 1,
					_IONBF = 2,
				}
				extern shared FILE* stdin;

				extern shared FILE* stdout;

				extern shared FILE* stderr;

			}
			else
			{
				version (OSX)
				{
					enum 
					{
						_IOFBF = 0,
						_IOLBF = 1,
						_IONBF = 2,
					}
					private extern shared FILE* __stdinp;


					private extern shared FILE* __stdoutp;


					private extern shared FILE* __stderrp;


					alias __stdinp stdin;
					alias __stdoutp stdout;
					alias __stderrp stderr;
				}
				else
				{
					version (FreeBSD)
					{
						enum 
						{
							_IOFBF = 0,
							_IOLBF = 1,
							_IONBF = 2,
						}
						private extern shared FILE* __stdinp;


						private extern shared FILE* __stdoutp;


						private extern shared FILE* __stderrp;


						alias __stdinp stdin;
						alias __stdoutp stdout;
						alias __stderrp stderr;
					}
					else
					{
						version (Solaris)
						{
							enum 
							{
								_IOFBF = 0,
								_IOLBF = 64,
								_IONBF = 4,
								_IOEOF = 32,
								_IOERR = 64,
								_IOREAD = 1,
								_IOWRT = 2,
								_IORW = 128,
								_IOMYBUF = 8,
							}
							private extern shared FILE[_NFILE] __iob;


							shared stdin = &__iob[0];
							shared stdout = &__iob[1];
							shared stderr = &__iob[2];
						}
						else
						{
							version (GNU_CBridge_Stdio)
							{
								extern FILE* _d_gnu_cbridge_stdin;

								extern FILE* _d_gnu_cbridge_stdout;

								extern FILE* _d_gnu_cbridge_stderr;

								extern void _d_gnu_cbridge_init_stdio();

								shared static this();
								alias _d_gnu_cbridge_stdin stdin;
								alias _d_gnu_cbridge_stdout stdout;
								alias _d_gnu_cbridge_stderr stderr;
							}
							else
							{
								static assert(false,"Unsupported platform");
							}
						}
					}
				}
			}
		}
	}
	alias int fpos_t;
	int remove(in char* filename);
	int rename(in char* from, in char* to);
	@trusted FILE* tmpfile();

	char* tmpnam(char* s);
	int fclose(FILE* stream);
	@trusted int fflush(FILE* stream);

	FILE* fopen(in char* filename, in char* mode);
	FILE* freopen(in char* filename, in char* mode, FILE* stream);
	void setbuf(FILE* stream, char* buf);
	int setvbuf(FILE* stream, char* buf, int mode, size_t size);
	int fprintf(FILE* stream, in char* format, ...);
	int fscanf(FILE* stream, in char* format, ...);
	int sprintf(char* s, in char* format, ...);
	int sscanf(in char* s, in char* format, ...);
	int vfprintf(FILE* stream, in char* format, va_list arg);
	int vfscanf(FILE* stream, in char* format, va_list arg);
	int vsprintf(char* s, in char* format, va_list arg);
	int vsscanf(in char* s, in char* format, va_list arg);
	int vprintf(in char* format, va_list arg);
	int vscanf(in char* format, va_list arg);
	int printf(in char* format, ...);
	int scanf(in char* format, ...);
	@trusted 
	{
		int fgetc(FILE* stream);
		int fputc(int c, FILE* stream);
	}
	char* fgets(char* s, int n, FILE* stream);
	int fputs(in char* s, FILE* stream);
	char* gets(char* s);
	int puts(in char* s);
	extern (D) @trusted 
	{
		int getchar();
		int putchar(int c);
		int getc(FILE* stream);
		int putc(int c, FILE* stream);
	}

	@trusted int ungetc(int c, FILE* stream);

	size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream);
	size_t fwrite(in void* ptr, size_t size, size_t nmemb, FILE* stream);
	@trusted 
	{
		int fgetpos(FILE* stream, fpos_t* pos);
		int fsetpos(FILE* stream, in fpos_t* pos);
		int fseek(FILE* stream, c_long offset, int whence);
		c_long ftell(FILE* stream);
	}
	version (Win32)
	{
		extern (D) @trusted 
		{
			void rewind(FILE* stream);
			pure void clearerr(FILE* stream);

			pure int feof(FILE* stream);

			pure int ferror(FILE* stream);

		}

		int _snprintf(char* s, size_t n, in char* fmt, ...);
		alias _snprintf snprintf;
		int _vsnprintf(char* s, size_t n, in char* format, va_list arg);
		alias _vsnprintf vsnprintf;
	}
	else
	{
		version (Win64)
		{
			extern (D) @trusted 
			{
				void rewind(FILE* stream);
				pure void clearerr(FILE* stream);

				pure int feof(FILE* stream);

				pure int ferror(FILE* stream);

				pure int fileno(FILE* stream);

			}

			int _snprintf(char* s, size_t n, in char* fmt, ...);
			alias _snprintf snprintf;
			int _vsnprintf(char* s, size_t n, in char* format, va_list arg);
			alias _vsnprintf vsnprintf;
			int _filbuf(FILE* fp);
			int _flsbuf(int c, FILE* fp);
			int _fputc_nolock(int c, FILE* fp);
			int _fgetc_nolock(FILE* fp);
			int _lock_file(FILE* fp);
			int _unlock_file(FILE* fp);
		}
		else
		{
			version (linux)
			{
				@trusted 
				{
					void rewind(FILE* stream);
					pure void clearerr(FILE* stream);

					pure int feof(FILE* stream);

					pure int ferror(FILE* stream);

					int fileno(FILE*);
				}
				int snprintf(char* s, size_t n, in char* format, ...);
				int vsnprintf(char* s, size_t n, in char* format, va_list arg);
			}
			else
			{
				version (OSX)
				{
					@trusted 
					{
						void rewind(FILE*);
						pure void clearerr(FILE*);

						pure int feof(FILE*);

						pure int ferror(FILE*);

						int fileno(FILE*);
					}
					int snprintf(char* s, size_t n, in char* format, ...);
					int vsnprintf(char* s, size_t n, in char* format, va_list arg);
				}
				else
				{
					version (FreeBSD)
					{
						@trusted 
						{
							void rewind(FILE*);
							pure void clearerr(FILE*);

							pure int feof(FILE*);

							pure int ferror(FILE*);

							int fileno(FILE*);
						}
						int snprintf(char* s, size_t n, in char* format, ...);
						int vsnprintf(char* s, size_t n, in char* format, va_list arg);
					}
					else
					{
						version (Solaris)
						{
							@trusted 
							{
								void rewind(FILE*);
								pure void clearerr(FILE*);

								pure int feof(FILE*);

								pure int ferror(FILE*);

								int fileno(FILE*);
							}
							int snprintf(char* s, size_t n, in char* format, ...);
							int vsnprintf(char* s, size_t n, in char* format, va_list arg);
						}
						else
						{
							version (GNU)
							{
								@trusted 
								{
									void rewind(FILE*);
									pure void clearerr(FILE*);

									pure int feof(FILE*);

									pure int ferror(FILE*);

									int fileno(FILE*);
								}
								int snprintf(char* s, size_t n, in char* format, ...);
								int vsnprintf(char* s, size_t n, in char* format, va_list arg);
							}
							else
							{
								static assert(false,"Unsupported platform");
							}
						}
					}
				}
			}
		}
	}
	void perror(in char* s);
	version (DigitalMars)
	{
		version (Win32)
		{
			import core.sys.windows.windows;
			enum 
			{
				FHND_APPEND = 4,
				FHND_DEVICE = 8,
				FHND_TEXT = 16,
				FHND_BYTE = 32,
				FHND_WCHAR = 64,
			}
			private enum _MAX_SEMAPHORES = 10 + _NFILE;

			private enum _semIO = 3;

			private extern __gshared short[_MAX_SEMAPHORES] _iSemLockCtrs;


			private extern __gshared int[_MAX_SEMAPHORES] _iSemThreadIds;


			private extern __gshared int[_MAX_SEMAPHORES] _iSemNestCount;


			private extern __gshared HANDLE[_NFILE] _osfhnd;


			private extern __gshared ubyte[_NFILE] __fhnd_info;


			private void _WaitSemaphore(int iSemaphore);

			private void _ReleaseSemaphore(int iSemaphore);

			private void LockSemaphore(uint num);

			private void UnlockSemaphore(uint num);

			int _handleToFD(HANDLE h, int flags);
			HANDLE _fdToHandle(int fd);
			enum 
			{
				O_RDONLY = 0,
				O_WRONLY = 1,
				O_RDWR = 2,
				O_APPEND = 8,
				O_CREAT = 256,
				O_TRUNC = 512,
				O_EXCL = 1024,
			}
			enum 
			{
				S_IREAD = 256,
				S_IWRITE = 128,
			}
			enum 
			{
				STDIN_FILENO = 0,
				STDOUT_FILENO = 1,
				STDERR_FILENO = 2,
			}
			int open(const(char)* filename, int flags, ...);
			int close(int fd);
			FILE* fdopen(int fd, const(char)* flags);
		}
	}
}


